Ramp usage examples


i discover today the ramp function.

live_loop :testRamp do
  n = (ramp 1,2,5,15).tick
  puts n
  sleep 0.125
  n2 = (line 0,10, steps: 21, inclusive: true).ramp.tick("gloups")
  puts n2
  sleep 0.25

A drunk pianist finally finding the right notes to play

use_bpm 120
live_loop :rampTune do
  v = (range 0,1, step: 0.1, inclusive: true).ramp.tick("volume")
  c = (line 50,120, steps: 31, inclusive: true).ramp.tick("cutoff")
  puts c
  tune = (ring :c1, :c3, :f2, :f4, :g1, :g3, :f3, :f2)
  use_synth :prophet
  play tune.look, cutoff: c, amp: v
  use_synth :piano
  play tune.look + (line -12, 12, steps: 30, inclusive: true).ramp.tick("tok"),
    amp: v,
    sustain: 1  
  sleep 0.5

live_loop :drums do
  sample :drum_bass_hard
  sleep 1
  sample :drum_bass_hard
  sample :drum_roll, amp: 0.5, finish: 0.1
  sleep 1

Note that it crashes quickly if i decrease the sleep value. Why ?

Hope it helps

If I understand it correctly, (and @samaaron or others may correct me otherwise) that would be because a loop that has a total duration that is very short will begin to cause problems when Sonic Pi tries to keep up. I think it is related to how events are scheduled on SuperCollider - the more closely together things are scheduled, the more chance there is that SuperCollider will end up not being able to play the sounds on time, or something like that.

By the way, is there a reason why the inclusive: true is not the default behaviour ?

No idea personally…

IMHO it should be true as default behaviour.