At this point, you may get tired of hearing the same repetitive beeps. The good news is we can easily change these up by adding options to our beeps. Options, or opts, come in many different flavors but we will start by talking about what they are and introducing the two most simple ones.
An opt is made up of two parts: the name and the value. The best way to explain this is to give you an example:
play 60, amp: 2
As you can see, I have added an extra bit of code to my regular play command. This code changes the amplitude, or loudness, of our note. Amp is the name of the opt and 2 is the value. This value can be anything from 0 to 5, including decimals! A value between 0 and 1 will cause the note to play quieter! Feel free to play around with this new opt and get a feel for how it works.
Want to change the loudness of your notes? Use amplify!
play :C4, amp: 2 makes this note twice as loud play :C4, amp: 0.5 makes this note softer and plays half as loudly
Another popular opt, is the pan opt. This opt allows you to pick which side of your device plays out of using a value from -1 to 1. Numbers closer to -1 play out of the left side while numbers closed to 1 play out of the right side. Try out this example code:
play 60, pan: -1 sleep 1 play 60, pan: 0 sleep 1 play 60, pan: 1
You should hear three different notes play. One out of the left side, one out of both, and one out of the right side. This opt will allow you to add completely new dimensions to your music! Play around and see what you can create with this opt!
Want to give your sounds some direction? Use pan!
play :C4, pan: -1 to make sounds come from the left play :C4, pan: 1 to make sounds come from the right play :C4, pan: 0.5 to make sounds come from the right but closer play :C4, pan: 0 to make sounds come from the center
It is also important know that you can use multiple opts on a single note. This means that we could combine our amp and pan opts to create a whole new texture for our music! The only rules are that each opt has to be a different name and they must be separated by commas.
Now it’s your turn! Play a note and give it different amp and pan effects. You can even use both at the same time! How do these notes change with these effects?
play 47 play 47, pan: -1, amp: 3 play 47, pan: 1, amp: 0.5