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.