Towards the end of our coding class at school today, one of the children asked me how they would choose a random synth in their code. I couldn’t give them the answer off of the top of my head so I came home and have placed two different solutions below:
# Choosing a Random Synth in Sonic Pi # Solution 1 10.times do use_synth [:beep, :blade, :cnoise, :dpulse].choose play :C3 sleep 1 end # Solution 2 10.times do use_synth choose([:beep, :blade, :cnoise, :dpulse]) play :C3 sleep 1 end