First little diddy


#1

Greetings,

I have been playing around with sonic-pi for a month or so, and here is my first little diddy. I’m still just taking things from the tutorial and editing/altering. The plan is to keep do this until I come up with something new and actually my own. Looking forward to creating more and interacting with this community. The timing of the :pad loop isn’t exactly what I intended and I am not sure I am understanding the math on the “sleep” command. Any help would be great.

live_loop :euclid_beat do
  sample :elec_bong, amp: 1.5 if (spread 4, 7).tick
  sample :vinyl_rewind, onset: pick, sustain: 0, release: 0.5,
    amp: 0.8 if (spread 2, 5).look
  sample :bd_haus, amp: 2 if (spread 1, 4).look
  with_fx :echo, phase: 0.275, decay: 1.7 do
    sample :perc_bell, onset: pick, sustain: 0, release: 0.55,
      amp: 2 if (spread 1, 8, rotate: 1).look
    sleep 0.125
  end
end

live_loop :pad do
  use_synth :prophet
  play [:c4, :f4, :g4, :bb4], amp: 3, attack: 0.2, release: 2
  sleep 4
  play [:c4, :e4, :f4, :a4], amp: 3, attack: 0.1, release: 1.5
  sleep 2
  play [:g3, :d4, :f4, :b4], amp: 3, attack: 0.1, release: 1.5
  sleep 2
  play [:db3, :e4, :a4, :d5], amp: 3, attack: 0.2, release: 4.5
  sleep 4
  play [:c4, :e4, :g4, :b4], amp: 3, attack: 0.2, release: 4
  sleep 6
end

#2

What don’t you understand about “sleep”?


#3

So, in the example I posted, I wanted the last chord to last four beats than the loop to start over. Well I noticed when I ran the program that it was only lasting a little over 2 beats. So, I changed the sleep command to 6 beats to compensate. Oh, and I tried the code on different machines and had the same problem.

Jason


#4

Sleep will never make a chord (or any other sound) “last longer”. Sleep is the time (pause) until the loop or whichever part proceeds to the next line, thus your last sleep in :pad is the time to wait until it starts the :pad loop over again at the first chord.

To make a chord last longer, you can stretch its envelop by increasing attack, delay, sustain and release. The time a chord “lasts” is the sum of those.

play [:c4, :e4, :g4, :b4], amp: 3, attack: 0.2, release: 4
sleep 4
play [:c4, :e4, :g4, :b4], amp: 3, attack: 0.2, sustain: 8, release: 4

#5

Greetings,

Thanks, @GooDump that was helpful. So now the opposite seems to be happening, In the code below for some reason, there is an extra beat before the loop starts up again. Sleep is set to 4, but from the moment the last chord plays, it is five beats until the loop plays again. Is there is always a pause between one run of a loop and the next? Do I need to just factor that in when calculating the final Sleep time of a loop?

> live_loop :bd do
>   sample :bd_haus
>   sleep 1
> end
> 
> live_loop :pad do
>   sync :bd
>   use_synth :prophet
>   play [:c4, :f4, :g4, :bb4], amp: 3, attack: 0.2, release: 2
>   sleep 4
>   play [:c4, :e4, :f4, :a4], amp: 3, attack: 0.1, release: 1.5
>   sleep 2
>   play [:g3, :d4, :f4, :b4], amp: 3, attack: 0.1, release: 1.5
>   sleep 2
>   play [:db3, :e4, :a4, :d5], amp: 3, attack: 0.2, release: 4.5
>   sleep 4
>   play [:c4, :e4, :g4, :b4], amp: 3, attack: 0.2, delay: 0, sustain: 0, release: 3.8
>   sleep 4
>   tick
> end

#6

Hi @barefootpriest.

There is a (long-ish) discussion around that particular issue: See Live loops Sync questions :-). [Edit - Ha. Just realised that’s one of the Patreon specific topics. Sorry :no_mouth:]
In short though, it is because the sync :bd inside the :pad live_loop will block that live_loop and make it wait until the next time the :bd live_loop loops around before continuing.
The live_loop command has a sync: parameter that you will want to investigate as an alternative - See the Lang help section for details.


#7

Hi,

here is the help image from the thread that @ethancrawford mentioned. Maybe that clarifies additionally:


Sync loops in sequencer
#8

Excellent! Thanks, everyone. This gives me stuff to practice.

J