Learn creative coding writing simple programs

131. plot, free and rrand

In this episodes we discover how we can play several sounds and stop them one by one, without resorting to stopping all sounds at once. We achieve this by storing synths in different variables, and then calling .free on those variables. That means that if we have synths a and b playing, we can call a.free and b.free independently to stop one or the other.
Then we find out that we can replace calls to the .play method with calls to .plot. What this does is to show us a graphical representation of the sound, instead of playing it through the speakers. This can help us understand the sound properties. When the plot windo is visible there are different key shortcuts we can use, the most interesting ones are +, - and n. Pressing n normalizes the height of the graph, which is useful when comparing different plots.
Finally we take a look at .rand and .rrand, methods that let us to generate random numbers. 10.rand gives us integer numbers between 0 and 10, 10.0.rand returns numbers with decimals in the same range, and 10.rrand(20) provides random numbers between 10 and 20. These methods let us generate sounds with random frequencies and volumes.

Tags: supercollider, plot, free, rrand, rand

Code editor

You can make changes to the code below. Then

Questions and comments

Try to stay close to the topic of this episode. Use the Processing forums for help with unrelated Processing projects (or hire me for help ;-)

To indicate that a word in your comment is code, use the `backtick`. Example
Do `float` and `int` smell similar?
To highlight code blocks, surround it with ``` code-fences ``` like this:
``` void setup() { size(600, 600); } ```