Intro to SoundCipher


Many programs use sounds or music, whether it be a click when you press a button or a soundtrack to a video game music and sound is everywhere. SoundCipher is a library which allows programmers to implement sounds and music into their Processing scripts. It provides users with a multitude of instruments and ways to use them.

You can see the demonstration that we will be recreating down below or at:

Starting out with SoundCipher is simple. To begin you must declare a SoundCipher object as demonstrated below:

Next, to play a sound the “playNote” function will be added into the “mousePressed” function so a sound is played every click.

After, to make the sound based off of the position of our mouse as in the example we must add a note and dynamic variable and map the note variable to our mouse’s y-position and the dynamic to our mouse’s x-position. Lastly we must substitute the values in our “playNote” function to the variables.

Once you’ve completed the following it’s time to add the visual effects as seen in the demo. First you’ll need to change your setup function slightly to recreate the exact look. You’ll then a “lastMouseX” and “lastMouseY” variable and set it to the mouseX and mouseY at the end of the mousePressed function to store values for creating the lines. Once this is complete you can add the lines from the last mouse coordinates to the current mouse coordinates and the ellipse at the current mouse position. To top it off add the fill line seen down below to make the color dependent on the mouse position.

Finally, to customize the sound a little more we’ll change the instrument to one from the following list.

In this case we’ll go with the xylophone. You can see how to add/cahange instruments down below.

Now that you’re able to use SoundCipher try remaking this program but with your own twist. It could be anything from making the instrument a different one every time or having it play a series of notes every time you click.

Leave a Reply

Your email address will not be published. Required fields are marked *