Correct ramp instruction syntax

Hello everyone!
Can someone explain me what is the correct syntax for using the “ramp” function?
I couldn’t find it in the tutorial.
Many thanks
Giovanni

Hi @verbgio,

one way to use:

  kick_volume = (line 0, 1.0, inclusive: true, steps: 20).ramp
  master = 1

  live_loop :kick do
    sample :bd_tek, amp: kick_volume.tick * master
    puts kick_volume.look * master
    sleep 1
  end

Basically I see it as: How to change a ring into a a one directional structure (because here it is supposed to blend in)

2 Likes

Each function has its own documentation separate from the tutorial. If you open up the doc system, click on the Lang tab and you’ll see a full list of functions. Alternatively, hit C-i when the cursor is over a function name and the documentation will appear.

For ramp we have the following docs:

Create a ramp vector

ramp list (array)

Create a new immutable ramp vector from args. Indexes always return first or last value if out of bounds.
Introduced in v2.6

Examples:

Example 1

(ramp 1, 2, 3)[0]

#=> 1

Example 2

(ramp 1, 2, 3)[1]

#=> 2

Example 3

(ramp 1, 2, 3)[2]

#=> 3

Example 4

(ramp 1, 2, 3)[3]

#=> 3

## Example 5
(ramp 1, 2, 3)[1000]

#=> 3

Example 6

(ramp 1, 2, 3)[-1]

#=> 1

Example 7

(ramp 1, 2, 3)[-1000]

#=> 1

1 Like

Thanks a lot Sam and Martin

@samaaron: I had to read more carefully the help section. Thanks a lot. Maybe I have chosen the wrong instruction,though. I was looking for a function to increase the value of something from one point to another in a determinate period of time. I.e: I want to increase the volume of a note from 0.1 to 0.9 in 2 seconds.
Then: “play 60, amp: (ramp 0.1, 0.9)[2]” would be correct? Or have I to use different code?

@Martin: that code is linked to external periphery? I would like to increase the volume without manual intervention.

Thank you both again

Sorry, I am not entirely clear about, what you are saying/asking.

The example should work on its own and automatically without any manual action or reference to some other code. The speed of the blend depends on the runtime resp. length of the live loop. So in this case: 20 beats (resp. steps) from 0 to 1. The master is only to be meant as a multiplier (e. g. to raise the volume in 20 steps from 0 to 2 or whatever). You can remove it if you don’t need it.

Of course you can blend/manipulate not only the volume but e. g. some filter value.

Did that anser your question?

1 Like

Yes, absolutely. Sorry but I am not very good at programming (not still at least), then I am quite slow at understaning how things work. Thanks a lot for the clear explanation. Now I think I am able to use it in my music. :wink:

Two examples

    #Example one

    2.times do
      v= 0.1
      p=play 60, release: 2,amp: v
      sleep 0.4
      8.times do
        control p, amp: v+=0.1
        sleep 0.2
      end
    end

    sleep 4
    #Example two
    2.times do
      v= 0.1
      p=play 60, release: 4,amp: v
      sleep 2
       control p, amp: 0.9
      sleep 2
    end
2 Likes

Well, then there are already two of us :wink: With respect to programming usually my brain is resisting everything beyond the obvious. So it always takes some time until I digested and then can use things.

stumbled upon this thread, looking for a way of making a ramp value…

I’ve been using “range(start, end, increments).to_a (OR .ring OR .ramp OR .mirror” as a way of generating arrays
but, I just tried

r = range(0,1,0.05).ramp

live_loop :rangeCheck do
  tick
  puts "r = #{r.look}"
  sleep 0.1
end

and that works perfectly… counts up, then stay on the final value of the ramp.

1 Like