# Amp values .tick off from an array?

**URL:** <https://in-thread.sonic-pi.net/t/amp-values-tick-off-from-an-array/3666>\
**Category:** Support, Help & Resources\
**Created:** [April 18, 2020, 7:11pm UTC](https://in-thread.sonic-pi.net/t/amp-values-tick-off-from-an-array/3666 "2020-04-18T19:11:58Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![ee33](https://dub1.discourse-cdn.com/flex017/user_avatar/in-thread.sonic-pi.net/ee33/32/1033_2.png) [@ee33](https://in-thread.sonic-pi.net/u/ee33)\
**Post date:** [April 18, 2020, 7:11pm UTC](https://in-thread.sonic-pi.net/t/amp-values-tick-off-from-an-array/3666/1 "2020-04-18T19:11:58Z")

</div>

I’m trying to make some generative music that’ll only generate a new pattern every 8 bars. My solution was working until I tried to add the ability to generate whether a note played or not by using an array to give amp values.

For some reason, while the code didn’t totally cease to function when I added the amp array, it now only repeats the first 4 notes in the loop. Any idea what happened or how to fix it?

(also I’m guessing my solution is a bit clumsy with the 64.times do and all that but I wasn’t getting any kind of set/get system to work, so lemme know if you’ve solved this whole thing in a different way)

> use\_bpm 400
> 
> define :basslineMaker do  
> #note chooser  
> a = [24,26,28,29,31,33,35,  
> 36,38,40,41,43,45,47,  
> 48,50,52,53,55,57,59]  
> b=a.choose  
> c=a.choose  
> d=a.choose  
> e=a.choose  
> f=a.choose  
> g=a.choose  
> h=a.choose  
> i=a.choose  
> bassline=[b,c,d,e,f,g,h,i]
> 
> #note on or off  
> j=[1,1,1,0,0].choose  
> k=[1,1,1,0,0].choose  
> l=[1,1,1,0,0].choose  
> m=[1,1,1,0,0].choose  
> n=[1,1,1,0,0].choose  
> o=[1,1,1,0,0].choose  
> p=[1,1,1,0,0].choose  
> q=[1,1,1,0,0].choose  
> amperage=[j,k,l,m,n,o,p,q]
> 
> 64.times do  
> x=bassline.tick  
> y=amperage.tick  
> use\_synth :blade  
> play x, amp:y  
> use\_synth :beep  
> play x, amp: y  
> sleep 1  
> end  
> end
> 
> live\_loop :bassPlayer do  
> basslineMaker  
> end

Thanks! Thanks! Thanks!

---

<div class="post-metadata">

**Author:** ![ee33](https://dub1.discourse-cdn.com/flex017/user_avatar/in-thread.sonic-pi.net/ee33/32/1033_2.png) [@ee33](https://in-thread.sonic-pi.net/u/ee33)\
**Post date:** [April 18, 2020, 7:33pm UTC](https://in-thread.sonic-pi.net/t/amp-values-tick-off-from-an-array/3666/2 "2020-04-18T19:33:58Z")

</div>

whoops, I just had to name my ticks, like so, replacing lines 33 and 34:

> ```
> x=bassline.tick(:ticka)
> y=amperage.tick(:tickb)
> 
> ```

well I’m gonna leave this thread up just in case someone has a similar problem or if anyone reads this and has ideas for making my looping system more elegant or flexible.

---

<div class="post-metadata">

**Author:** ![Eli](https://dub1.discourse-cdn.com/flex017/user_avatar/in-thread.sonic-pi.net/eli/32/116_2.png) [@Eli](https://in-thread.sonic-pi.net/u/Eli)\
**Post date:** [April 18, 2020, 8:29pm UTC](https://in-thread.sonic-pi.net/t/amp-values-tick-off-from-an-array/3666/3 "2020-04-18T20:29:31Z")

</div>

Hi Matey,

Forgive me, my coding is not the greatest, but… ?

Eli…

```ruby
use_bpm 400

live_loop :blah do
  
  baseline = [24,26,28,29,31,33,35,
              36,38,40,41,43,45,47,
              48,50,52,53,55,57,59].pick(64)
  
  volume = [1,1,1,0,0].pick(64)
  
  64.times do
    use_synth :blade
    play baseline.tick, amp: volume.look
    use_synth :beep
    play baseline.look, amp: volume.look
    sleep 1
  end
end

```

If I was making a bassline for myself, I’d prefer  
the :fm synth… far more funky! 🙂

```ruby
use_bpm 400

live_loop :blah do
  
  baseline = [24,26,28,29,31,33,35,
              36,38,40,41,43,45,47,
              48,50,52,53,55,57,59].pick(64)
  
  volume = [1,1,1,0,0].pick(64)
  
  64.times do
    use_synth :fm
    play baseline.tick, amp: volume.look
    sleep 1
  end
end

```

---

<div class="post-metadata">

**Author:** ![ee33](https://dub1.discourse-cdn.com/flex017/user_avatar/in-thread.sonic-pi.net/ee33/32/1033_2.png) [@ee33](https://in-thread.sonic-pi.net/u/ee33)\
**Post date:** [April 18, 2020, 8:45pm UTC](https://in-thread.sonic-pi.net/t/amp-values-tick-off-from-an-array/3666/4 "2020-04-18T20:45:50Z")

</div>

I didn’t know about .pick, which definitely might come in handy, but If you play my code, you’ll hear that it plays an 8 beat loop 8 times and then generates another 8 beat loop and plays that 8 times, and on and on, which is what I wanted. Yours doesn’t do that.

---

<div class="post-metadata">

**Author:** ![Eli](https://dub1.discourse-cdn.com/flex017/user_avatar/in-thread.sonic-pi.net/eli/32/116_2.png) [@Eli](https://in-thread.sonic-pi.net/u/Eli)\
**Post date:** [April 18, 2020, 8:48pm UTC](https://in-thread.sonic-pi.net/t/amp-values-tick-off-from-an-array/3666/5 "2020-04-18T20:48:44Z")

</div>

Thats okay… rewrite it to suit your own needs, it’s only an example.

Eli…
