Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision | Last revisionBoth sides next revision | ||
p5js-sound1 [2024/03/19 23:23] – renick | p5js-sound1 [2024/03/19 23:25] – renick | ||
---|---|---|---|
Line 2: | Line 2: | ||
===== making a sound play and loop ===== | ===== making a sound play and loop ===== | ||
+ | < | ||
+ | <iframe src=" | ||
+ | </ | ||
- | https:// | ||
===== making a sound play only when the mouse is clicked ===== | ===== making a sound play only when the mouse is clicked ===== | ||
Line 10: | Line 12: | ||
Also, can you figure out why it sounds like two different sound files even though it only uses one? What's been done in the second call to loop that makes it different? | Also, can you figure out why it sounds like two different sound files even though it only uses one? What's been done in the second call to loop that makes it different? | ||
+ | < | ||
+ | <iframe src=" | ||
+ | </ | ||
- | https:// | ||
- | ==== the problem: clicking ==== | + | ===== the problem: clicking |
Notice the terrible clicking that happens when you stop pressing the mouse button. There' | Notice the terrible clicking that happens when you stop pressing the mouse button. There' | ||
In this version, we use setVolume and give pause an argument to tell it to pause AFTER the fade-out. | In this version, we use setVolume and give pause an argument to tell it to pause AFTER the fade-out. | ||
+ | < | ||
+ | <iframe src=" | ||
+ | </ | ||
- | https:// | ||
- | ==== stopping a loop ==== | + | ===== stopping a loop ===== |
This version is a little nicer in some ways; it loops while you press the box, but the looping stops once you stop pressing the mouse. We accomplish that by passing false to setLoop. | This version is a little nicer in some ways; it loops while you press the box, but the looping stops once you stop pressing the mouse. We accomplish that by passing false to setLoop. | ||
- | + | < | |
- | https:// | + | <iframe src="https:// |
+ | </ | ||
===== notes ===== | ===== notes ===== |