This repo contains some code to practice with SonicPi.
Drum beats samples taken from the following references:
play 60
4.times do
play rrand_i(60, 90)
sleep 0.5
end
play chord(60, :M)
play chord(60, :m)
loop do
play chord(60, :M7).tick
sleep 0.5
end
loop do
play chord(60, :M7), release: 3
16.times do # 16*0.25 = 4 beats
play chord(60, :M7).choose
sleep 0.25
end
end
start_notes = ring(60, 62, 63, 62)
loop do
my_chord = chord(start_notes.tick, :M7)
play my_chord, release: 2
16.times do # 16*0.125 = 2 beats
play my_chord.choose, release: 0.25
sleep 0.125
end
end
notes = ring(:c5, :g4, :a4, :f4)
chord_type = ring(:M, :M, :m, :M)
loop do
my_chord = chord(notes.tick, chord_type.look)
play my_chord, release: 2
16.times do # 16*0.125 = 2 beats
play my_chord.choose, release: 0.2
sleep 0.125
end
end
notes = ring(:c5, :g4, :a4, :f4)
chord_type = ring(:M, :M, :m, :M)
loop do
my_chord = chord(notes.tick, chord_type.look)
duration = 4.0
play my_chord, release: duration
num_arp_notes = 16
num_arp_notes.times do
play my_chord.choose, release: 0.2
sleep duration/num_arp_notes
end
end
notes = ring(:c5, :g4, :a4, :f4)
chord_type = ring(:M, :M, :m, :M)
loop do
my_chord = chord(notes.tick, chord_type.look)
duration = 4.0
num_rep = 4
play my_chord, release: duration
num_rep.times do
play_pattern_timed(my_chord.reflect,duration/(my_chord.length*num_rep))
end
end
notes = ring(:c5, :g4, :a4, :f4)
chord_type = ring(:M, :M, :m, :M)
loop do
my_chord = chord(notes.tick, chord_type.look)
duration = 4.0
play my_chord, release: duration
pattern = chord(notes.look, chord_type.look, num_octaves: 2).take(4).reflect.butlast.repeat(4)
play_pattern_timed(pattern,duration/pattern.length)
end
Play a shifting minor/major chord with a guitar style arpeggio (using play_pattern_timed and chord_degree)
loop do
duration = 4.0
my_chord = chord_degree([8,5,6,4].tick, :c4, :major, 3)
play my_chord, release: duration
pattern = (my_chord+my_chord.map{|n| n+12}).take(4).reflect.butlast.repeat(4)
play_pattern_timed(pattern,duration/pattern.length)
end
play 60, amp: 1
sleep 1
play 60, amp: 4
sleep 1
play 60, amp: 6
sleep 1
play 60, pan: 0
sleep 1
play 60, pan: -1
sleep 1
play 60, pan:1
sleep 1
in_thread do
play 60, attack: 2,sustain: 2,release: 0
sleep 6
play 60, attack: 2, sustain: 2,release: 2
sleep 6
play 60, attack: 0,sustain: 2,release: 2
sleep 6
end
loop do
sample :drum_bass_soft
sleep 2
end
sample :drum_bass_hard
loop do
sample :bd_haus
sleep 0.5
end
loop do
if tick.even?
sample :bd_haus
else
sample :sn_dolf
end
sleep 0.5
end
loop do
sample :drum_cymbal_closed
if tick.even?
sample :bd_haus
else
sample :sn_dolf
end
sleep 0.25
sample :drum_cymbal_closed
sleep 0.25
end
sample :loop_amen
loop do
sample :loop_amen
sleep sample_duration(:loop_amen)
end
loop do
start_note = ring(60, 62, 63, 62).tick
my_chord = chord(start_note, :M7)
play my_chord, release: 2
16.times do
play my_chord.choose, release: 0.25, amp: [0.75, 0.5, 0.25].choose
sleep 0.125
end
end
loop do
sample :loop_amen
sleep sample_duration(:loop_amen)
end
in_thread do
loop do
start_note = ring(60, 62, 63, 62).tick
my_chord = chord(start_note, :M7)
play my_chord, release: 2
16.times do
play my_chord.choose, release: 0.25, amp: [0.75, 0.5, 0.25].choose
sleep 0.125
end
end
end
loop do
sample :loop_amen
sleep sample_duration(:loop_amen)
end
in_thread do
loop do
start_note = ring(60, 62, 63, 62).tick
my_chord = chord(start_note, :M7)
play my_chord, release: 2
16.times do
play my_chord.choose, release: 0.25, amp: [0.75, 0.5, 0.25].choose
sleep 0.125
end
end
end
loop do
sample :loop_amen, beat_stretch: 2
sleep 2
end
live_loop :beeps do
start_note = ring(60, 62, 63, 62).tick
my_chord = chord(start_note, :M7)
play my_chord, release: 2
16.times do
play my_chord.choose, release: 0.25, amp: [0.75, 0.5, 0.25].choose
sleep 0.125
end
end
live_loop :drums do
sample :loop_amen, beat_stretch: 2
sleep 2
end
use_synth :saw
loop do
play scale(60, :major).choose
sleep 0.25
end
play 50
sleep 0.5
sample :elec_plip
sleep 0.5
play 62
with_fx :reverb do
play 50
sleep 0.5
sample :elec_plip
sleep 0.5
play 62
end
with_fx :echo do
play 50
sleep 0.5
sample :elec_plip
sleep 0.5
play 62
end
with_fx :echo do
with_fx :reverb do
play 50
sleep 0.5
sample :elec_plip
sleep 0.5
play 62
end
end