@@ -19,18 +19,18 @@ making has taken is the Algorave (http://algorave.com) - events where
1919artists code music for people to dance to. However, you don't need to be
2020in a nightclub to Live Code - with Sonic Pi version 2.0 you can do it
2121anywhere you can take your Raspberry Pi and a pair of headphones or some
22- speakers. Once you reach the end of this articla , you'll be programming
22+ speakers. Once you reach the end of this article , you'll be programming
2323your own beats and modifying them live. Where you go afterwards will
2424only be constrained by your imagination.
2525
2626## Getting Sonic Pi v2.0
2727
28- Firstly, you'll need the latest version of Sonic Pi: version 2+.
28+ Firstly, you'll need the latest version of Sonic Pi: version 2+.
2929
3030At the time of writing, this hasn't been released yet. However, by the
3131time you read this, it should be available as part of the latest
3232Raspbian OS. If you have an older image on your SD cards, running the
33- following should get you up to date:
33+ following should get you up to date:
3434
3535 sudo apt-get update
3636 sudo apt-get upgrade
@@ -63,14 +63,14 @@ started. In the main code editor window of Sonic Pi, type the following
6363and then hit the Run button:
6464
6565 sample :loop_amen
66-
66+
6767Boom! Instant drums! Go on, press it a few times. Have fun. I'll still
6868be here when you've finished...
6969
7070But that's not all. We can mess around with the sample. Try this:
7171
7272 sample :loop_amen, rate: 0.5
73-
73+
7474Oooh, half speed. Go on, try changing the rate. Try lower and higher
7575numbers. What happens if you use a negative number?
7676
@@ -90,27 +90,27 @@ times. So we have a nice way of saying that with code:
9090 sample :loop_amen
9191 sleep 1.753
9292 end
93-
93+
9494Of course, we can change the 10 to whatever number we want. Go on, try
9595it! What if we want to loop forever? We simply say loop instead of
969610.times. Also, I'm sure you're asking what the magic 1.753 represents
9797and how I got it. Well, it's the length of the sample in seconds and I
9898got it because I asked Sonic Pi:
9999
100- puts sample_duration :loop_amen
100+ puts sample_duration :loop_amen
101101
102102And it told me 1.753310657596372 - I just shortended it to 1.753 to make
103103it easier for you to type in. Now, the cool thing is, we can combine
104104this code and add a variable for fun:
105105
106106 sample_to_loop = :loop_amen
107107 sample_rate = 0.5
108-
108+
109109 loop do
110110 sample sample_to_loop, rate: sample_rate
111111 sleep sample_duration sample_to_loop, rate: sample_rate
112112 end
113-
113+
114114Now, you can change the : loop_amen to any of the other loop samples (use
115115the auto-complete to discover them). Change the rate too. Have fun!
116116
@@ -123,29 +123,29 @@ support for studio effects such as reverb and echo and distortion. These
123123are really easy to use. For example take the following sample trigger code:
124124
125125 sample :guit_e_fifths
126-
126+
127127To add some reverb to this, we simply need to wrap it with a with_fx block:
128128
129129 with_fx :reverb do
130130 sample :guit_e_fifths
131131 end
132-
132+
133133To add some distortion too, we can add more fx:
134134
135135 with_fx :reverb do
136136 with_fx :disortion do
137137 sample :guit_e_fifths
138138 end
139139 end
140-
140+
141141Just like synths and samples, FX also support parameters to allow you to
142142tinker with their settings:
143143
144144 with_fx :reverb, mix: 0.8 do
145145 with_fx :distortion, distort: 0.8 do
146146 sample :guit_e_fifths
147147 end
148- end
148+ end
149149
150150Of course, you can wrap FX blocks around any code. For example here's
151151how you'd combine the : ixi_techno FX and our drum loop:
@@ -164,13 +164,13 @@ For a complete list of FX and their parameters click the help button.
164164Now we've mastered the basics of triggering samples, sleeping and
165165looping, let's do the same with some synths and then jump head first
166166into live coding territory:
167-
167+
168168 loop do
169169 use_synth :tb303
170170 play 30, attack: 0, release: 0.2
171171 sleep 0.5
172172 end
173-
173+
174174So, what do the numbers mean in this example? Well, you could stop it
175175playing, change a number, then start it and see if you can hear the
176176difference. However all that stopping and starting gets quite
@@ -182,11 +182,11 @@ changes. We need to put our code into a named function which we loop:
182182 play 42, attack: 0, release: 0.2
183183 sleep 0.5
184184 end
185-
186- loop do
185+
186+ loop do
187187 play_my_synth
188188 end
189-
189+
190190Now when you run this it will sound exactly the same as the simpler loop
191191above. However, now we have given our code a name (in this case,
192192play_my_synth) we can change the definition of our code whilst things
@@ -209,11 +209,11 @@ should look like this:
209209 play 45, attack: 0, release: 0.2, cutoff: 70
210210 sleep 0.5
211211 end
212-
212+
213213 # loop do
214214 # play_my_synth
215215 # end
216-
216+
217217Then hit the run button again. You should hear the note go higher. Try
218218changing the attack and release and cutoff parameters. Listen to the
219219effect they have. Notice that attack and release change the length of
@@ -232,7 +232,7 @@ value from a list of numbers. Try changing 45 to chord(:a3,
232232: minor ).choose. Your play line should look like this:
233233
234234 play chord(:a2, :minor).choose, attack: 0, release: 0.3, cutoff: rrand(30, 100)
235-
235+
236236Now you can start experimenting with different chords and range values
237237for cutoff. You can do something similar with the pan value too:
238238
0 commit comments