Adding special effects to music on your Raspberry Pi
You can play a sample and add effects to it, including distortion, echo, and reverb. There is a full list of effects (also known as Fx) in the Help pane, and you can also find them using the autocomplete feature. This is how you add distortion to one of the guitar samples:with_fx :distortion do
sample :guit_e_fifths
end
You can adjust how the effect is applied to the sound using options. There are several options for distortion, including distort
, which controls how much the sound is distorted, and mix
, which controls the balance between the original sound and the distorted version. In both cases, the value should be between 0
and 1
. Here's how you use them:
with_fx :distortion, distort: 0.9, mix: 0.5 do
sample :guit_e_fifths
end
Try using different values for those options and running the code to see how the sound changes. Experiment with other effects too.
To see the full options for this or any other effect, click Fx in the Help pane, or click the effect name in your code and then use Ctrl+I to jump to its entry (if available) in the Help. You can also use Ctrl+I to get help on commands in your code.
Synchronizing with your drumbeat
You now know how to play a repeating rhythm, and how to play other samples and synth melodies. You can play multiple live loops at the same time. One of the challenges is to synchronize all the different parts of the music so they play in time. To do that, you can provide an option to synchronize the start of a live loop with the name of anotherlive_loop
. Here's an example that synchronizes a cymbal beat with the main drum loop:live_loop :drums do/code>
sample :loop_industrial, beat_stretch: 2/code>
sleep 2/code>
end/code>
live_loop :cymbals, sync: :drums do/code>
4.times do/code>
sample :elec_cymbal/code>
sleep 1/code>
end/code>
sleep 8/code>
end/code>
When you play that example, you'll hear that the cymbal plays four times, in perfect sync with the main drumbeat. It then rests for 8 beats before playing again.
Take care with the colons when setting the sync option for your live loop; otherwise, the program won't work. The first colon (after sync
) goes between the option and its parameter and touches the option name, and the second colon (before drums) marks the start of the loop name you want to synchronize with.