# Lesson 17 # Effects Lesson. In this lesson, # you will learn how manipulate # synthesizer and sample sounds, # and add special effects to the # sounds # General Instructions: # # This lesson contains three examples and # three exercises (A, B, C). # # To listen to an example, change "comment" # to "uncomment" on the "comment do" line, # then click the "Run" menu command at the # top of the Sonic Pi editor window. # When you are done with the example, turn # it off by changing "uncomment" back to # "comment," and move on to the next section # of the lesson. # # Example 1: Manipulating synthesizer sounds. # Sonic Pi contains a number of synthesizers, # each one having an arrange of options that # you can change in your code. In this example, # we use the Mod_fm synth to create a sliding, # siren like sound. You can find descriptions # of the various options in the help section # for each synthesizer. comment do use_bpm 50 use_synth :mod_fm amplitude = 1 center = -1 up = true loop do play 60, duration: 4, mod_wave: 3, mod_phase: 4, mod_range: 12, amp: amplitude, pan:center sleep 2 if (amplitude < 2 && up == true) amplitude += 0.25 center = -1 elsif (amplitude >= 2 && up == true) amplitude -= 0.25 center = 0 up = false elsif (amplitude > 0.25 && up == false) amplitude -= 0.2 center = -1 else amplitude += 0.25 center = 1 up = true end end end # Exercise A: # Find the following synths in the help # section and try experimenting with the # parameters described. Alter the code # in Example 1 accordingly. # Dark Ambience (:dark_ambience) # Growl (:growl) # Mod Pulse (:mod_pulse) # Example 2: Manipulating sample sounds. comment do amplitude = 2 center = 0 width = 0.1 cutoff = 70 lpf_change = 7 s_rate = 1.25 s_rate_change = 0.1 up = true loop do sample :ambi_piano, amp: amplitude, pan:center, lpf: cutoff, rate:s_rate sleep 1 if (amplitude < 3 && up == true) amplitude += 0.25 width += 0.1 cutoff += lpf_change center = -1 s_rate += s_rate_change elsif (amplitude >= 3 && up == true) amplitude -= 0.25 center = 0 width -= 0.1 cutoff -= lpf_change s_rate -= s_rate_change up = false elsif (amplitude > 1.0 && up == false) amplitude -= 0.2 width -= 0.1 center = -1 cutoff -= lpf_change s_rate -= s_rate_change else amplitude += 0.25 center = 1 width += 1 cutoff += lpf_change s_rate += s_rate_change up = true end end end # Exercise B: Experiment with the various # parameters in Example 2. Look up the # reference for the :ambi_piano sample # in the Samples section of the help menu. # Try adding and changing other parameters # for that sample. Note the places where # parameter values might go out of bounds # (the Output window on the top right of # Sonic Pi can be helpful). Try using # other samples and their parameters. # Experiment with negative rate values, # result in backward-playing samples. # # Example 3: Adding effects. comment do amplitude = 1 amp_change = 0.2 phase = 3.0 phase_change = 0.5 use_synth :prophet up = true note = 60 loop do with_fx :flanger do play note, amp: amplitude, duration: 1.75, phase: phase sleep 2 if (amplitude < 3 && up == true) amplitude += amp_change phase += phase_change note += 1 elsif (amplitude >= 3 && up == true) amplitude -= amp_change phase -= phase_change note -= 1 up = false elsif (amplitude > 1.0 && up == false) amplitude -= amp_change phase -= phase_change note -= 1 else amplitude += amp_change phase += phase_change note += 1 up = true end end end end # Exercise C: # Experiment by changing the parameters in # Example 3. Look up other types of effects # in the Fx menu and experiment with them # in Example 3. #