# Correct ramp instruction syntax

**URL:** <https://in-thread.sonic-pi.net/t/correct-ramp-instruction-syntax/462>\
**Category:** \[P\] Patreon Support\
**Created:** [November 26, 2017, 5:19pm UTC](https://in-thread.sonic-pi.net/t/correct-ramp-instruction-syntax/462 "2017-11-26T17:19:33Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![verbgio](https://avatars.discourse-cdn.com/v4/letter/v/bc8723/32.png) [@verbgio](https://in-thread.sonic-pi.net/u/verbgio)\
**Post date:** [November 26, 2017, 5:19pm UTC](https://in-thread.sonic-pi.net/t/correct-ramp-instruction-syntax/462/1 "2017-11-26T17:19:33Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Martin](https://dub1.discourse-cdn.com/flex017/user_avatar/in-thread.sonic-pi.net/martin/32/157_2.png) [@Martin](https://in-thread.sonic-pi.net/u/Martin)\
**Post date:** [November 26, 2017, 6:10pm UTC](https://in-thread.sonic-pi.net/t/correct-ramp-instruction-syntax/462/2 "2017-11-26T18:10:47Z")

</div>

Hi @verbgio,

one way to use:

```ruby
  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)

---

<div class="post-metadata">

**Author:** ![samaaron](https://dub1.discourse-cdn.com/flex017/user_avatar/in-thread.sonic-pi.net/samaaron/32/7_2.png) [@samaaron](https://in-thread.sonic-pi.net/u/samaaron)\
**Post date:** [November 27, 2017, 7:41am UTC](https://in-thread.sonic-pi.net/t/correct-ramp-instruction-syntax/462/3 "2017-11-27T07:41:21Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![verbgio](https://avatars.discourse-cdn.com/v4/letter/v/bc8723/32.png) [@verbgio](https://in-thread.sonic-pi.net/u/verbgio)\
**Post date:** [November 27, 2017, 2:33pm UTC](https://in-thread.sonic-pi.net/t/correct-ramp-instruction-syntax/462/4 "2017-11-27T14:33:42Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Martin](https://dub1.discourse-cdn.com/flex017/user_avatar/in-thread.sonic-pi.net/martin/32/157_2.png) [@Martin](https://in-thread.sonic-pi.net/u/Martin)\
**Post date:** [November 27, 2017, 2:44pm UTC](https://in-thread.sonic-pi.net/t/correct-ramp-instruction-syntax/462/5 "2017-11-27T14:44:49Z")

</div>

> [@verbgio](#):
>
> that code is linked to external periphery? I would like to increase the volume without manual intervention.

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?

---

<div class="post-metadata">

**Author:** ![verbgio](https://avatars.discourse-cdn.com/v4/letter/v/bc8723/32.png) [@verbgio](https://in-thread.sonic-pi.net/u/verbgio)\
**Post date:** [November 27, 2017, 2:50pm UTC](https://in-thread.sonic-pi.net/t/correct-ramp-instruction-syntax/462/6 "2017-11-27T14:50:22Z")

</div>

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. 😉

---

<div class="post-metadata">

**Author:** ![Raul](https://dub1.discourse-cdn.com/flex017/user_avatar/in-thread.sonic-pi.net/raul/32/265_2.png) [@Raul](https://in-thread.sonic-pi.net/u/Raul)\
**Post date:** [November 27, 2017, 4:43pm UTC](https://in-thread.sonic-pi.net/t/correct-ramp-instruction-syntax/462/7 "2017-11-27T16:43:25Z")

</div>

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
```

---

<div class="post-metadata">

**Author:** ![Martin](https://dub1.discourse-cdn.com/flex017/user_avatar/in-thread.sonic-pi.net/martin/32/157_2.png) [@Martin](https://in-thread.sonic-pi.net/u/Martin)\
**Post date:** [November 27, 2017, 7:03pm UTC](https://in-thread.sonic-pi.net/t/correct-ramp-instruction-syntax/462/8 "2017-11-27T19:03:21Z")

</div>

Well, then there are already two of us 😉 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.

---

<div class="post-metadata">

**Author:** ![philAwesomeTech](https://dub1.discourse-cdn.com/flex017/user_avatar/in-thread.sonic-pi.net/philawesometech/32/1152_2.png) [@philAwesomeTech](https://in-thread.sonic-pi.net/u/philAwesomeTech)\
**Post date:** [September 14, 2021, 1:16pm UTC](https://in-thread.sonic-pi.net/t/correct-ramp-instruction-syntax/462/9 "2021-09-14T13:16:51Z")

</div>

> [@Martin](#):
>
> `(line 0, 1.0, inclusive: true, steps: 20).ramp`

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

```ruby
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.
