Best practice for alternating values

Howdy, folks!

I learned a neat trick the other day for sound design. If you have a series of high hats or even kicks, you can alternate the velocity (or amp works) to give a subtle rolling effect.

Compare the sounds between

live_loop :cymbal do
    sample :drum_cymbal_closed, amp: amp_level
    sleep 0.25
end 

and

live_loop :cymbal do
    amp_level = (ring 0.5, 1).tick
    sample :drum_cymbal_closed, amp: amp_level
    sleep 0.25
end 

My main question here though is the structure of that live_loop with the ring.

Is that the way you would recommend structuring it?

Thanks!

1 Like

Welcome back @gregeporter!
Seems pretty reasonable to me :slight_smile:
You could even do away with the variable and just place the ring directly after the amp: opt - it all depends on personal preference and your particular use case really!

2 Likes

Thanks for the quick reply, @ethancrawford :slight_smile:

So like this?

live_loop :cymbal do
  sample :drum_cymbal_closed, amp: (ring 0.5, 1).tick
  sleep 0.25
end
1 Like

Yes, just like that :slight_smile:

Awesome, yeah, that’s really good to know.

If I added another ring to that value, are they evaluated left to right?

live_loop :ring_test do
  play 60, cutoff: (ring 30,60).tick, amp: (ring 0.5, 1).look
  sleep 0.25
end

So the cutoff would modify the entry for the ring, the amp would not.

Correct. tick advances the counter, look merely reads the current value :+1:

1 Like

Cool beans, thanks @ethancrawford !

1 Like