Hey, im new to sonic pi and im trying to recreating a piece called “Summer-Joe Hisaishi” but i need to be able to cut the loop in the middle of one and go to a different code. is there any way to do it? (I need to play code lines 3~149 twice but on the second loop cut to a different code at line 121)
use_synth :piano
use_bpm 155
3.times do
#1
play 47, release: 1.5
sleep 1
play 54, release: 1
sleep 1
play 59, release: 1
sleep 1
play 54, release: 1
sleep 1
#2
play 43, release: 1.5
sleep 1
play 50, release: 1
sleep 1
play 55, release: 1
sleep 1
play 50, release: 1
sleep 1
#3
play 45, release: 1.5
sleep 1
play 52, release: 1
sleep 1
play 57, release: 1
sleep 1
play 52, release: 1
sleep 1
#4
play 50, release: 1.5
sleep 1
play 57, release: 1
sleep 1
play 62, release: 1
sleep 1
play 57, release: 1
sleep 1
end
#13
play 47, release: 1.5
sleep 1
play 54, release: 1
sleep 1
play 59, release: 1
sleep 1
play 54, release: 1
sleep 1
#14
play 43, release: 1.5
sleep 1
play 50, release: 1
sleep 1
play 55, release: 1
sleep 1
play 50, release: 1
sleep 1
#15
play 45, release: 1.5
sleep 1
play 52, release: 1
sleep 1
play 57, release: 1
sleep 1
play 52, release: 1
sleep 1
#16
play 50, release: 1.5
sleep 1
play 57, release: 1.5
sleep 1
play 62, release: 1.5
sleep 1
play 57, release: 1.5
sleep 1
#17
play 45, release: 1.5
sleep 1
play 52, release: 1.5
sleep 1
play 57, release: 1.5
sleep 1
play 52, release: 1.5
sleep 1
#18
play 43, release: 1.5
sleep 1
play 50, release: 1.5
sleep 1
play 55, release: 1.5
sleep 1
play 50, release: 1.5
sleep 1
#19
play 42, release: 1.5
sleep 1
play 49, release: 1.5
sleep 1
play 57, release: 1.5
sleep 1
play 49, release: 1.5
sleep 1
#20
play 47, release: 1.5
sleep 1
play 54, release: 1.5
sleep 1
play 59, release: 1.5
sleep 1
play 54, release: 1.5
sleep 1
#21
play 40, release: 1.5
sleep 1
play 47, release: 1.5
sleep 1
play 52, release: 1.5
sleep 1
play 47, release: 1.5
sleep 1
#LOOPX2
#22
play 43, release: 1.5
sleep 1
play 50, release: 1.5
sleep 1
play 55, release: 1.5
sleep 1
play 50, release: 1.5
sleep 1
#23
play 45, release: 1.5
sleep 1
play 52, release: 1.5
sleep 1
play 57, release: 1.5
sleep 1
play 52, release: 1.5
sleep 1
#24
play 45, release: 1.5
sleep 1
play 52, release: 1.5
sleep 1
play 57, release: 1.5
sleep 1
play 52, release: 1.5
sleep 1
i guess i can just copy and paste the code twice but it wouldnt really look nice;;
line 121 is the line before #LOOPX2, 149 is the end sleep 1 code
and if there is something to be improved for efficiancy sake, please inform me! Thank you very much
(Reference: https://www.youtube.com/watch?v=w9NOnS1-COs)
Hi there
One thing you could try is putting the bassline through a function rather than rewriting the code each time. For example, this is how you could approach the beginning:
use_synth :piano
use_bpm 155
define :play_bass do | notes, style = :staccato |
rel = (knit 1.5, 4)
if style == :staccato
rel = (knit 1.5, 1, 1.0, 3)
end
4.times do
play notes[ring(0, 1, 2, 1).tick], release: rel.look
sleep 1
end
end
# intro
3.times do
play_bass([47, 54, 59])
play_bass([43, 50, 55])
play_bass([45, 52, 57])
play_bass([50, 57, 62])
end
# this time it's legato at the end
play_bass([47, 54, 59])
play_bass([43, 50, 55])
play_bass([45, 52, 57])
play_bass([50, 57, 62], style: :legato)
# etc
This takes advantage of the fact that each bar of the bassline seems to be just three different notes following the same pattern. I’ve not looked at the piece in detail, so it’s possible you could simplify it even further. However, I hope this helps you get started!
Yes, writing your own methods/functions is a great way to encapsulate complexity, so the top-line code is easier to read & troubleshoot.
Here’s another refinement, which simply allows you to pass in the rootnote of each chord you want to play:
use_synth :piano
use_bpm 155
define :play_bass do | rootnote, style = :staccato |
notes = ring(rootnote, rootnote + 7, rootnote + 12, rootnote + 7)
rel = (knit 1.5, 4)
if style == :staccato
rel = (knit 1.5, 1, 1.0, 3)
end
4.times do
play notes[ring(0, 1, 2, 1).tick], release: rel.look
sleep 1
end
end
# intro
3.times do
play_bass :b2
play_bass :g2
play_bass :a2
play_bass :d3
end
# this time it's legato at the end
play_bass :b2
play_bass :g2
play_bass :a2
play_bass :d3, style: :legato
# etc
(btw, to get the code in its own little window, you precede and follow it with three back-quotes, which on my keyboard is right below the escape key.)
Note also my use of note names, rather than numbers. For me, this is easier to understand. :c4 is the same as 60.
My first thought to simplify this approach was to use the built-in “chord” command, which has a zillion chord types built-in, but to my surprise there wasn’t a chord that was just root, fifth and octave. “5” is root and fifth, and I suppose I could have spread it across 2 octaves and then deleted the last item from the ring, but I thought that might be confusing.
Anyway, definitely worth exploring the chord command, which returns a ring of the notes in the chord.
Have fun exploring sonic pi! It’s so much fun! And welcome!
Thank you so much! I didnt even realise you could style it and everything XD
Woah this code is really cool, cant understand much of it rn but wow… Thank you very much for the tips!!!
Can’t tell you how much I’ve learned about sonic pi by looking at code from other people.
It’s a fun tool, and a very welcoming community. Have fun!
I’ve just finished coding what you and @ nairobiny told me and it shrunk the code from 700 to 300 thank you so much >.<
However I’ve finished making the melody and is there a way to shrink it? I’ve tried to combine the melody with the bassline and it doesnt seem to play even though there are no errors in the code;; here is the full code. I’ve seperated the melody with the bassline with live_loops
live_loop :Melody do
play :a4, release: 0.7
sleep 0.5
play :d5, release: 0.7
sleep 0.5
play :e5, release: 0.7
sleep 0.5
play :fs5, release: 0.7
sleep 0.5
play :e5, release: 1.2
sleep 1
play :d5, release: 0.7
sleep 0.5
play :d5, sustain: 2, release: 2.7
sleep 2.5
sleep 2
play :a4, release: 0.7
sleep 0.5
play :d5, release: 0.7
sleep 0.5
play :e5, release: 0.7
sleep 0.5
play :fs5, release: 0.7
sleep 0.5
play :e5, release: 1.2
sleep 1
play :d5, release: 0.7
sleep 0.5
play :e5, release: 1.2
sleep 1
play :fs5, release: 1.2
sleep 1
play :fs5, release: 2.7
sleep 0.5
sleep 2
play :a4, release: 0.7
sleep 0.5
play :d5, release: 0.7
sleep 0.5
play :e5, release: 0.7
sleep 0.5
play :fs5, release: 0.7
sleep 0.5
play :e5, release: 1.2
sleep 1
play :d5, release: 0.7
sleep 0.5
play :d5, sustain: 2, release: 2.7
sleep 2.5
sleep 2
play :a4, release: 0.7
sleep 0.5
play :d5, release: 0.7
sleep 0.5
play :e5, release: 0.7
sleep 0.5
play :fs5, release: 0.7
sleep 0.5
play :e5, release: 1.2
sleep 1
play :d5, release: 0.7
sleep 0.5
play :e5, release: 1.2
sleep 1
play :a5, release: 1.2
sleep 1
play :fs5, release: 2.7
sleep 2.5
play_chord [:a4,:fs5], attack: 0.05, amp: 2, release: 1.2
sleep 1
play_chord [:b4,:g5], attack: 0.05, amp: 2, release: 1.2
sleep 1
#legato from here
play_chord [:cs5,:a5], attack: 0.05, amp: 2, release: 1.2
sleep 1
play_chord [:cs5,:a5], attack: 0.05, amp: 2, release: 0.7
sleep 0.5
play_chord [:cs5,:a5], attack: 0.05, amp: 2, release: 1.7
sleep 1.5
play_chord [:cs5,:a5], attack: 0.05, amp: 2, release: 1.2
sleep 1
play_chord [:cs5,:a5], attack: 0.05, amp: 2, release: 1.2
sleep 1
play :fs5, release: 0.7
sleep 0.5
play :d5, release: 1.7
sleep 1.5
play :fs5, release: 0.7
sleep 0.5
play :g5, release: 0.7
sleep 0.5
play_chord [:cs5,:a5], attack: 0.05, amp: 2, release: 1.2
sleep 1
play_chord [:cs5,:a5], attack: 0.05, amp: 2, release: 0.7
sleep 0.5
play_chord [:cs5,:a5], attack: 0.05, amp: 2, release: 1.7
sleep 1.5
play_chord [:cs5,:a5], attack: 0.05, amp: 2, release: 1.2
sleep 1
play_chord [:cs5,:a5], attack: 0.05, amp: 2, release: 1.2
sleep 1
play :fs5, release: 0.7
sleep 0.5
play :d5, release: 1.7
sleep 1.5
play :d5, release: 0.7
sleep 0.5
play :e5, release: 0.7
sleep 0.5
play_chord [:fs5,:b4,:gs4], attack: 0.05, amp: 2, release: 1.2
sleep 1
play :fs5, release: 0.7
sleep 0.5
play :fs5, release: 1.7
sleep 1.5
play :fs5, release: 1.2
sleep 1
play_chord [:fs5,:b4,:g4], attack: 0.05, amp: 2, release: 1.2
sleep 1
play :b5, release: 1.2
sleep 1
play_chord [:b5,:e5], release: 0.5
sleep 0.3
play :fs5, release: 0.5
sleep 0.3
play :e5, release: 0.6
sleep 0.4
play :d5, release: 1.2
sleep 1
play :e5, release: 2.2
sleep 2
play_chord [:e5,:b4,:g4], attack: 0.05, amp: 2, release: 1.2
sleep 1
play :b4, release: 0.7
sleep 0.5
play :b4, release: 0.7
sleep 0.5
play_chord [:e5,:g4], attack: 0.05, amp: 2, release: 1.2
sleep 1
play :cs5, release: 1.2
sleep 1
play :a4, release: 0.7
sleep 0.5
play :d5, release: 0.7
sleep 0.5
play :e5, release: 0.7
sleep 0.5
play :fs5, release: 0.7
sleep 0.5
play :e5, release: 1.2
sleep 1
play :d5, release: 0.7
sleep 0.5
play :d5, sustain: 2, release: 2.7
sleep 2.5
sleep 2
play :a4, release: 0.7
sleep 0.5
play :d5, release: 0.7
sleep 0.5
play :e5, release: 0.7
sleep 0.5
play :fs5, release: 0.7
sleep 0.5
play :e5, release: 1.2
sleep 1
play :d5, release: 0.7
sleep 0.5
play :e5, release: 1.2
sleep 1
play :fs5, release: 1.2
sleep 1
play :fs5, release: 2.7
sleep 0.5
sleep 2
play :a4, release: 0.7
sleep 0.5
play :d5, release: 0.7
sleep 0.5
play :e5, release: 0.7
sleep 0.5
play :fs5, release: 0.7
sleep 0.5
play :e5, release: 1.2
sleep 1
play :d5, release: 0.7
sleep 0.5
play :d5, sustain: 2, release: 2.7
sleep 2.5
sleep 2
play :a4, release: 0.7
sleep 0.5
play :d5, release: 0.7
sleep 0.5
play :e5, release: 0.7
sleep 0.5
play :fs5, release: 0.7
sleep 0.5
play :e5, release: 1.2
sleep 1
play :d5, release: 0.7
sleep 0.5
play :e5, release: 1.2
sleep 1
play :a5, release: 1.2
sleep 1
play :fs5, release: 2.7
sleep 2.5
play_chord [:a4,:fs5], attack: 0.05, amp: 2, release: 1.2
sleep 1
play_chord [:b4,:g5], attack: 0.05, amp: 2, release: 1.2
sleep 1
#legato from here
play_chord [:cs5,:a5], attack: 0.05, amp: 2, release: 1.2
sleep 1
play_chord [:cs5,:a5], attack: 0.05, amp: 2, release: 0.7
sleep 0.5
play_chord [:cs5,:a5], attack: 0.05, amp: 2, release: 1.7
sleep 1.5
play_chord [:cs5,:a5], attack: 0.05, amp: 2, release: 1.2
sleep 1
play_chord [:cs5,:a5], attack: 0.05, amp: 2, release: 1.2
sleep 1
play :fs5, release: 0.7
sleep 0.5
play :d5, release: 1.7
sleep 1.5
play :fs5, release: 0.7
sleep 0.5
play :g5, release: 0.7
sleep 0.5
play_chord [:cs5,:a5], attack: 0.05, amp: 2, release: 1.2
sleep 1
play_chord [:cs5,:a5], attack: 0.05, amp: 2, release: 0.7
sleep 0.5
play_chord [:cs5,:a5], attack: 0.05, amp: 2, release: 1.7
sleep 1.5
play_chord [:cs5,:a5], attack: 0.05, amp: 2, release: 1.2
sleep 1
play_chord [:cs5,:a5], attack: 0.05, amp: 2, release: 1.2
sleep 1
play :fs5, release: 0.7
sleep 0.5
play :d5, release: 1.7
sleep 1.5
play :d5, release: 0.7
sleep 0.5
play :e5, release: 0.7
sleep 0.5
play_chord [:fs5,:b4,:gs4], attack: 0.05, amp: 2, release: 1.2
sleep 1
play :fs5, release: 0.7
sleep 0.5
play :fs5, release: 1.7
sleep 1.5
play :fs5, release: 1.2
sleep 1
play_chord [:fs5,:b4,:g4], attack: 0.05, amp: 2, release: 2.2
sleep 2
play_chord [:e5,:b5], release: 0.5
sleep 0.3
play :fs5, release: 0.5
sleep 0.3
play :e5, release: 0.6
sleep 0.4
play :d5, release: 0.7
sleep 0.5
play :b4, release: 0.7
sleep 0.5
play :d5, release: 2.2
sleep 2
play :d5, release: 1.2
sleep 1
play :a4, release: 1.2
sleep 1
play :fs4, sustain: 4, release: 4.2
sleep 4
play :d4, release: 0.2
play :d4, sustain: 2, release: 2
sleep 0.2
play :fs4, release: 0.1
play :fs4, sustain: 1.9, release: 2
sleep 1.8
play_chord [:b3,:d], amp: 2, release: 1.2
sleep 1
play :fs4, release: 1.2
sleep 1
play_chord [:c4,:e4], sustain: 4, release: 4.2
sleep 4
3.times do
play :d4, release: 2.2
sleep 0.1
play :e4, release: 2
sleep 0.15
play :fs4, release: 1.8
sleep 0.15
play :a4, release: 1.6
sleep 1.6
play_chord [:d4,:fs4,:a4], amp: 2, release: 1.2
sleep 1
play :e, release: 0.7
sleep 0.5
play :d, release: 0.7
sleep 0.5
end
play_chord [:cs4,:e4], amp: 2, sustain: 4, release: 4.2
sleep 4
8.times do
play :a5, release: 0.7
sleep 0.5
play :a4, release: 0.7
sleep 0.5
play :d5, release: 0.7
sleep 0.5
play :e5, release: 0.7
sleep 0.5
play :a5, release: 0.7
sleep 0.5
play :e5, release: 0.7
sleep 0.5
play :d5, release: 0.7
sleep 0.5
play :a4, release: 0.7
sleep 0.5
end
8.times do
play :d6, release: 0.7
sleep 0.5
play :d5, release: 0.7
sleep 0.5
play :g5, release: 0.7
sleep 0.5
play :a5, release: 0.7
sleep 0.5
play :d6, release: 0.7
sleep 0.5
play :a5, release: 0.7
sleep 0.5
play :g5, release: 0.7
sleep 0.5
play :d5, release: 0.7
sleep 0.5
end
8.times do
play :a5, release: 0.7
sleep 0.5
play :a4, release: 0.7
sleep 0.5
play :d5, release: 0.7
sleep 0.5
play :e5, release: 0.7
sleep 0.5
play :a5, release: 0.7
sleep 0.5
play :e5, release: 0.7
sleep 0.5
play :d5, release: 0.7
sleep 0.5
play :a4, release: 0.7
sleep 0.5
end
play_chord [:a4,:cs5,:a5], attack: 0.05, amp: 2, release: 1.2
sleep 1
play_chord [:cs5,:a5], attack: 0.05, amp: 2, release: 0.7
sleep 0.5
play_chord [:cs5,:a5], attack: 0.05, amp: 2, release: 1.7
sleep 1.5
play_chord [:cs5,:a5], attack: 0.05, amp: 2, release: 1.2
sleep 1
play_chord [:cs5,:a5], attack: 0.05, amp: 2, release: 1.2
sleep 1
play :fs5, release: 0.7
sleep 0.5
play :d5, release: 1.7
sleep 1.5
play :fs5, release: 0.7
sleep 0.5
play :g5, release: 0.7
sleep 0.5
play_chord [:a4,:cs5,:a5], attack: 0.05, amp: 2, release: 1.2
sleep 1
play_chord [:cs5,:a5], attack: 0.05, amp: 2, release: 0.7
sleep 0.5
play_chord [:cs5,:a5], attack: 0.05, amp: 2, release: 1.7
sleep 1.5
play_chord [:cs5,:a5], attack: 0.05, amp: 2, release: 1.2
sleep 1
play_chord [:cs5,:a5], attack: 0.05, amp: 2, release: 1.2
sleep 1
play :fs5, release: 0.7
sleep 0.5
play :d5, release: 1.7
sleep 1.5
play :d5, release: 0.7
sleep 0.5
play :e5, release: 0.7
sleep 0.5
play_chord [:fs5,:b4,:gs4], attack: 0.05, amp: 2, release: 1.2
sleep 1
play :fs5, release: 0.7
sleep 0.5
play :fs5, release: 1.7
sleep 1.5
play :fs5, release: 1.2
sleep 1
play_chord [:fs5,:b4,:g4], attack: 0.05, amp: 2, release: 2.2
sleep 2
play_chord [:e5,:b5], release: 0.5
sleep 0.3
play :fs5, release: 0.5
sleep 0.3
play :e5, release: 0.6
sleep 0.4
play :d5, release: 0.7
sleep 0.5
play :b4, release: 0.7
sleep 0.5
play :e5, release: 2.2
sleep 2
play_chord [:g4,:b4,:e5], attack: 0.05, amp: 3 , release: 1.2
sleep 1
play :b4, release: 0.7, amp: 2
sleep 0.5
play :b4, release: 0.7, amp: 2
sleep 0.5
play_chord [:g4,:b4,:e5], attack: 0.05, amp: 4, release: 1.2
sleep 1
play :cs5, release: 1.2, amp: 2.2
sleep 1
play :a4, release: 0.7
sleep 0.5
play :d5, release: 0.7
sleep 0.5
play :e5, release: 0.7
sleep 0.5
play :fs5, release: 0.7
sleep 0.5
play :e5, release: 1.2
sleep 1
play :d5, release: 0.7
sleep 0.5
play :d5, sustain: 2, release: 2.7
sleep 2.5
sleep 2
play :a4, release: 0.7
sleep 0.5
play :d5, release: 0.7
sleep 0.5
play :e5, release: 0.7
sleep 0.5
play :fs5, release: 0.7
sleep 0.5
play :e5, release: 1.2
sleep 1
play :d5, release: 0.7
sleep 0.5
play :e5, release: 1.2
sleep 1
play :fs5, release: 1.2
sleep 1
play :fs5, release: 2.7
sleep 0.5
sleep 2
play :a4, release: 0.7
sleep 0.5
play :d5, release: 0.7
sleep 0.5
play :e5, release: 0.7
sleep 0.5
play :fs5, release: 0.7
sleep 0.5
play :e5, release: 1.2
sleep 1
play :d5, release: 0.7
sleep 0.5
play :d5, sustain: 2, release: 2.7
sleep 2.5
sleep 2
play :a4, release: 0.7
sleep 0.5
play :d5, release: 0.7
sleep 0.5
play :e5, release: 0.7
sleep 0.5
play :fs5, release: 0.7
sleep 0.5
play :e5, release: 1.2
sleep 1
play :d5, release: 0.7
sleep 0.5
play :e5, release: 1.2
sleep 1
play :a5, release: 1.2
sleep 1
play :fs5, release: 2.7
sleep 2.5
play_chord [:a4,:fs5], attack: 0.05, amp: 2, release: 1.2
sleep 1
play_chord [:b4,:g5], attack: 0.05, amp: 2, release: 1.2
sleep 1
#legato from here
play_chord [:cs5,:a5], attack: 0.05, amp: 2, release: 1.2
sleep 1
play_chord [:cs5,:a5], attack: 0.05, amp: 2, release: 0.7
sleep 0.5
play_chord [:cs5,:a5], attack: 0.05, amp: 2, release: 1.7
sleep 1.5
play_chord [:cs5,:a5], attack: 0.05, amp: 2, release: 1.2
sleep 1
play_chord [:cs5,:a5], attack: 0.05, amp: 2, release: 1.2
sleep 1
play :fs5, release: 0.7
sleep 0.5
play :d5, release: 1.7
sleep 1.5
play :fs5, release: 0.7
sleep 0.5
play :g5, release: 0.7
sleep 0.5
play_chord [:cs5,:a5], attack: 0.05, amp: 2, release: 1.2
sleep 1
play_chord [:cs5,:a5], attack: 0.05, amp: 2, release: 0.7
sleep 0.5
play_chord [:cs5,:a5], attack: 0.05, amp: 2, release: 1.7
sleep 1.5
play_chord [:cs5,:a5], attack: 0.05, amp: 2, release: 1.2
sleep 1
play_chord [:cs5,:a5], attack: 0.05, amp: 2, release: 1.2
sleep 1
play :fs5, release: 0.7
sleep 0.5
play :d5, release: 1.7
sleep 1.5
play :d5, release: 0.7
sleep 0.5
play :e5, release: 0.7
sleep 0.5
play_chord [:fs5,:b4,:gs4], attack: 0.05, amp: 2, release: 1.2
sleep 1
play :fs5, release: 0.7
sleep 0.5
play :fs5, release: 1.7
sleep 1.5
play :fs5, release: 1.2
sleep 1
play_chord [:fs5,:b4,:g4], attack: 0.05, amp: 2, release: 2.2
sleep 2
play_chord [:b5,:e5], release: 0.5
sleep 0.3
play :fs5, release: 0.5
sleep 0.3
play :e5, release: 0.6
sleep 0.4
play :d5, release: 1.2
sleep 0.5
play :b4, release: 1.2
sleep 0.5
play :d5, sustain: 2, release: 2.2
sleep 2
play :d6, sustain: 2,release: 2.2
sleep 2
play :cs5, sustain: 3, release: 3
sleep 0.3
play :cs6, sustain: 3, release: 3.1
sleep 2.8
play_chord [:a4,:a5], amp: 2, release: 1.2
sleep 1
play_chord [:fs4,:fs5], amp: 2, release: 2.2
sleep 2
play_chord [:b3,:d4], amp: 2, release: 1.2
sleep 1
play :fs4, release: 1.2
sleep 1
play_chord [:cs4,:e4], amp: 2, release: 2.2
sleep 2
play :a4, release: 0.7
sleep 0.5
play :d5, release: 0.7
sleep 0.5
play :e5, release: 0.7
sleep 0.5
play :fs5, release: 0.7
sleep 0.5
play :e5, release: 1.2
sleep 1
play :d5, release: 1.2
sleep 1
play :d5, sustain: 2, release: 2
sleep 0.2
play :d6, sustain: 2, release: 2
sleep 1.8
play :cs5, sustain: 3, release: 3.2
sleep 0.2
play :cs6, sustain: 3, release: 3.2
sleep 2.8
play_chord [:a4,:a5], amp: 2, release: 1.2
sleep 1
play :d5, sustain: 2, release: 2.2
sleep 0.2
play :fs5, sustain: 2, release: 2.2
sleep 0.1
play :b5, sustain: 2, release: 2.2
sleep 2
play :b3, release: 0.7
sleep 0.5
play :cs4, release: 0.7
sleep 0.5
play :d4, release: 0.7
sleep 0.5
play :e4, release: 0.7
sleep 0.5
play :fs4, release: 0.7
sleep 0.5
play :g4, release: 0.7
sleep 0.5
play :e4, release: 1.2
sleep 1
play :a4, release: 0.7
sleep 0.5
play :d5, release: 0.7
sleep 0.5
play :e5, release: 0.7
sleep 0.5
play :fs5, release: 0.7
sleep 0.5
play :d5, release: 2.2
sleep 2
play :d6, release: 2.2
sleep 2
play :cs5, sustain: 3, release: 3
sleep 0.3
play :cs6, sustain: 3, release: 3.1
sleep 2.8
play_chord [:a4,:a5], amp: 2, release: 1.2
sleep 1
play_chord [:fs4,:fs5], amp: 2, release: 2.2
sleep 2
play_chord [:b3,:d4], amp: 2, release: 1.2
sleep 1
play :fs4, release: 1.2
sleep 1
play_chord [:cs4,:e4], amp: 2, release: 2.2
sleep 2
play :a4, release: 0.7
sleep 0.5
play :d5, release: 0.7
sleep 0.5
play :e5, release: 0.7
sleep 0.5
play :fs5, release: 0.7
sleep 0.5
play :e5, release: 1.2
sleep 1
play :d5, release: 0.7
sleep 0.5
play :d5, release: 1.5
sleep 1.5
play_chord [:d4,:g4,:b4], amp: 3, release: 2.2
sleep 1.8
play_chord [:d4,:a4], amp: 3, release: 2.2
sleep 1.8
play_chord [:d4,:g4], amp: 3, release: 3.5
sleep 3.3
play_chord [:d,:e,:fs4], amp: 3, release: 4
sleep 100
end
#_________________________________________________________________________
live_loop :Bass do
define :play_bass do | rootnote, style = :staccato |
notes = ring(rootnote, rootnote + 7, rootnote + 12, rootnote + 7)
rel = (knit 1.5, 4)
if style == :staccato
rel = (knit 1.5, 1, 1, 3)
end
4.times do
play notes[ring(0, 1, 2, 1).tick], release: rel.look
sleep 1
end
end
3.times do
play_bass :b2
play_bass :g2
play_bass :a2
play_bass :d3
end
play_bass :b2
play_bass :g2
play_bass :a2
play_bass :d3, style: :legato
play_bass :g2, style: :legato
play_bass :fs2, style: :legato
play_bass :b2, style: :legato
play_bass :e2, style: :legato
play_bass :g2, style: :legato
play_bass :a2, style: :legato
play_bass :a2, style: :legato
play_bass :b2, style: :legato
play_bass :g2
play_bass :a2
play_bass :d3
play_bass :b2
play_bass :g2
play_bass :a2
play_bass :d3, style: :legato
play_bass :a2, style: :legato
play_bass :g2, style: :legato
play :fs2, release: 1.5
sleep 1
play :cs3, release: 1.5
sleep 1
play :a3, release: 1.5
sleep 1
play :cs3, release: 1.5
sleep 1
play_bass :b2, style: :legato
play_bass :e2, style: :legato
play e2, release: 4
sleep 4
play :d3, release: 1.5
sleep 1
play :a3, release: 1.5
sleep 1
play :e4, release: 1.5
sleep 1
play :a3, release: 1.5
sleep 1
play_bass :b2, style: :legato
play_bass :g2, style: :legato
play_bass :a2, style: :legato
play_bass :d3, style: :legato
play_bass :b2, style: :legato
play_bass :g2, style: :legato
play_bass :a2, style: :legato
play_chord [50, 54, 57], attack: 0.05, amp: 2, release: 2.2
sleep 2
play_chord [50, 54, 57], attack: 0.05, amp: 2, release: 2.2
sleep 2
play_chord [52, 55, 57], attack: 0.05, amp: 2, release: 2.2
sleep 2
play_chord [52, 55, 57], attack: 0.05, amp: 2, release: 2.2
sleep 2
play_chord [54, 57], attack: 0.05, amp: 2, release: 2.2
sleep 2
play_chord [54, 57], attack: 0.05, amp: 2, release: 2.2
sleep 2
play_chord [55, 57], attack: 0.05, amp: 2, release: 1.7
sleep 1.5
play_chord [54, 57], attack: 0.05, amp: 2, release: 2.2
sleep 1.5
play_chord [52, 57], attack: 0.05, amp: 2, release: 2.2
sleep 1
4.times do
play_chord [50, 54, 57], attack: 0.05, amp: 2, release: 1.2
sleep 1
end
4.times do
play_chord [52, 55, 57], attack: 0.05, amp: 2, release: 1.2
sleep 1
end
4.times do
play_chord [54, 57], attack: 0.05, amp: 2, release: 1.2
sleep 1
end
play_chord [55, 57], attack: 0.05, amp: 2, release: 1.7
sleep 1.5
play_chord [54, 57], attack: 0.05, amp: 2, release: 2.2
sleep 1.5
play_chord [52, 57], attack: 0.05, amp: 2, release: 2.2
sleep 1
play_chord [55, 59, 62], attack: 0.05, amp: 2, release: 2.2
sleep 2
play_chord [55, 59, 62], attack: 0.05, amp: 2, release: 2.2
sleep 2
play_chord [57, 60, 62], attack: 0.05, amp: 2, release: 2.2
sleep 2
play_chord [57, 60, 62], attack: 0.05, amp: 2, release: 2.2
sleep 2
play_chord [59, 62], attack: 0.05, amp: 2, release: 2.2
sleep 2
play_chord [59, 62], attack: 0.05, amp: 2, release: 2.2
sleep 2
play_chord [60, 62], attack: 0.05, amp: 1.7, release: 1.7
sleep 1.5
play_chord [59, 62], attack: 0.05, amp: 1.3, release: 1.5
sleep 1.5
play_chord [57, 62], attack: 0.05, amp: 1, release: 1.2
sleep 1
4.times do
play_chord [55, 59, 62], attack: 0.05, amp: 2, release: 1.2
sleep 1
end
4.times do
play_chord [57, 60, 62], attack: 0.05, amp: 2.3, release: 1.2
sleep 1
end
4.times do
play_chord [59, 62], attack: 0.05, amp: 2.5, release: 1.2
sleep 1
end
play_chord [60, 62], attack: 0.05, amp: 1.7, release: 1.7
sleep 1.5
play_chord [59, 62], attack: 0.05, amp: 1.3, release: 1.5
sleep 1.5
play_chord [57, 62], attack: 0.05, amp: 1, release: 1.2
sleep 1
2.times do
play 38, release: 1.5
sleep 1
play 45, release: 1.5
sleep 1
play 50, release: 1.5
sleep 1
play 52, release: 1.5
sleep 1
play 40, release: 1.5
sleep 1
play 47, release: 1.5
sleep 1
play 52, release: 1.5
sleep 1
play 55, release: 1.5
sleep 1
play 42, release: 1.5
sleep 1
play 50, release: 1.5
sleep 1
play 54, release: 1.5
sleep 1
play 57, release: 1.5
sleep 1
play_chord [43,55], amp: 2.5, release: 1.7
sleep 1.5
play_chord [42,54], amp: 2.5, release: 1.5
sleep 1.5
play_chord [40,52], amp: 2.5, release: 1.2
sleep 1
end
play_chord [33,45], attack: 0.05, amp: 3, release: 2.2
sleep 2
play_chord [52,57,61], attack: 0.05, amp: 3, release: 2.2
sleep 2
play_chord [31,43], attack: 0.05, amp: 3, release: 2.2
sleep 2
play_chord [55,58,62], attack: 0.05, amp: 3, release: 2.2
sleep 2
play_chord [30,42], attack: 0.05, amp: 3, release: 2.2
sleep 2
play_chord [54,61,64], attack: 0.05, amp: 3, release: 2.2
sleep 2
play_chord [35,47], attack: 0.05, amp: 3, release: 2.2
sleep 2
play_chord [54,59,62], attack: 0.05, amp: 3, release: 2.2
sleep 2
play_chord [28,40], attack: 0.05, amp: 3, release: 2.2
sleep 2
play_chord [56,59,62], attack: 0.05, amp: 3, release: 2.2
sleep 2
play_chord [31,43], attack: 0.05, amp: 3, release: 2.2
sleep 2
play_chord [55,58,62], attack: 0.05, amp: 3, release: 2.2
sleep 2
play_chord [33,45], attack: 0.05, amp: 3, release: 2.2
sleep 2
play_chord [55,59,64], attack: 0.05, amp: 3, release: 2.2
sleep 2
play_chord [33,45], attack: 0.05, amp: 3, release: 2.2
sleep 2
play_chord [55,57,66], attack: 0.05, amp: 3, release: 2.2
sleep 2
play_bass :b2
play_bass :g2
play_bass :a2
play_bass :d3
play_bass :b2
play_bass :g2
play_bass :a2
play_bass :d3, style: :legato
play_bass :a2, style: :legato
play_bass :g2, style: :legato
play :fs2, release: 1.5
sleep 1
play :cs3, release: 1.5
sleep 1
play :a3, release: 1.5
sleep 1
play :cs3, release: 1.5
sleep 1
play_bass :b2, style: :legato
play_bass :e2, style: :legato
play 45, release: 4
sleep 4
play_bass :d3, style: :legato
play_bass :b2, style: :legato
play_bass :g2, style: :legato
play_bass :a2, style: :legato
play_bass :d3, style: :legato
play_bass :b2, style: :legato
play_bass :g2, style: :legato
play_bass :a2, style: :legato
play_bass :d3, style: :legato
play_bass :b2, style: :legato
play_bass :g2, style: :legato
play_bass :a2, style: :legato
play 50, release: 1.5
sleep 1
play 57, release: 1.5
sleep 1
play 62, release: 2
sleep 2
play_chord [31,43], amp: 2.5, sustain: 1.5, release: 2
sleep 1.8
play_chord [30,42], amp: 2.5, sustain: 1.5, release: 2
sleep 1.8
play_chord [28,40], amp: 2.5, sustain: 1.5, release: 3.5
sleep 3.3
play_chord [26,38], amp: 2.5, sustain: 2, release: 4
sleep 100
end
You might want to explore the commands play_pattern and play_pattern_timed. I haven’t used them yet, but they might help you organize the chunks. The downside (I think) is that you can’t control individual articulations as much.
From the docs, it looks like this one line is equivalent to the lines that follow:
play_pattern_timed [47, 54, 59, 54], [1.5, 1, 1, 1]
play 47, release: 1.5
sleep 1
play 54, release: 1
sleep 1
play 59, release: 1
sleep 1
play 54, release: 1
sleep 1
Another useful command to get to know is use_synth_defaults (and use_sample_defaults).