Skip to content

Latest commit

 

History

History
232 lines (180 loc) · 3.53 KB

markdown.md

File metadata and controls

232 lines (180 loc) · 3.53 KB

class: center, middle

Sonic Pi Jam Session

CleRb

February 2, 2017


What's Sonic Pi?

  • A way to make sound with ruby code
  • An IDE
  • Runs on many platforms
    • Mac
    • Windows
    • Linux
    • Raspberry Pi (Raspbian)

Why does it exist?

  • Engaging education resource
  • Sits at the intersection between three core domains
    • Art - express yourself
    • Technology - time / concurrency
    • Education - open play rather than rigid structures

Example #1

Play a single note, a C

play 60

Example #2

Now lets try 3 notes: C, G, A

play 60
play 67
play 69

Example #2

Now lets try 3 notes: C, G, A

play 60
play 67
play 69

Notice how they all sound at the same time, is that what you expected?


Example #3

Same as #2 but with a pause in between each note, so you can hear them separately

play 60
sleep 1
play 67
sleep 1
play 69

Example #4

With a loop to repeat a few notes

2.times do
  play 60
  sleep 1
  play 67
  sleep 1
  play 69
  sleep 1
end

Example #4

With a loop to repeat a few notes

2.times do
  play 60
  sleep 1
  play 67
  sleep 1
  play 69
  sleep 1
end

Right, its just Ruby! :)


Notes

Notes can be expressed in numbers, but you might find it easier to use the note letter instead. Sonic Pi provides a nice set of symbos for this purpose

2.times do
  play :c4
  sleep 1
  play :g4
  sleep 1
  play :a4
  sleep 1
end

Notes

Notes can be expressed in numbers, but you might find it easier to use the note letter instead. Sonic Pi provides a nice set of symbos for this purpose

2.times do
  play :c4
  sleep 1
  play :g4
  sleep 1
  play :a4
  sleep 1
end

I'm not a musician, but I think the two characters denote the "Note" and "Octave" of each tone generated by Sonic Pi

Music

Very often, this is one of the first songs a child will learn to play on an instrument. Can you tell which song this is?

play :b4; sleep 0.25
play :a4; sleep 0.25
play :g4; sleep 0.25
play :a4; sleep 0.25
play :b4; sleep 0.25
play :b4; sleep 0.25
play :b4; sleep 0.5
play :a4; sleep 0.25
play :a4; sleep 0.25
play :a4; sleep 0.5
play :b4; sleep 0.25
play :d5; sleep 0.25
play :d5; sleep 0.5

#Mary Had Little Lamb

.center[Center-aligned image]

Sample

A portion (or sample) of one sound recording so that it can be reused

2.times do
  sample :loop_amen
  sleep 1.753
end

Backing Tracks

Some times you'll find that its good to play multiple threads of music which overlap one another. This is done using the in_thread method, as shown below

in_thread do
  loop do
    sample :loop_amen
    sleep 1.75
  end
end
in_thread do
  16.times do
    play :b4; sleep 0.25
    play :a4; sleep 0.25
    play :g4; sleep 0.25
    play :a4; sleep 0.25
    play :b4; sleep 0.25
    play :b4; sleep 0.25
    play :b4; sleep 0.5
  end
end

Effects

Just like many guitarists will have an effects pedal at their feet when they play, we can add effects to our sound as well. They can even be layered on top of one another like shown below

with_fx :reverb do
  with_fx :distortion do
    play :b4; sleep 0.25
    play :a4; sleep 0.25
    play :g4; sleep 0.25
    play :a4; sleep 0.25
    play :b4; sleep 0.25
    play :b4; sleep 0.25
    play :b4; sleep 0.5
  end
end

class: center, middle

Thank you!

Slides available at https://github.com/clerb/soinic_pi_hacknight