# Messed up repeats?

**URL:** <https://in-thread.sonic-pi.net/t/messed-up-repeats/6440>\
**Category:** Support, Help & Resources\
**Created:** [January 26, 2022, 5:31am UTC](https://in-thread.sonic-pi.net/t/messed-up-repeats/6440 "2022-01-26T05:31:56Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![minetestist](https://dub1.discourse-cdn.com/flex017/user_avatar/in-thread.sonic-pi.net/minetestist/32/2194_2.png) [@minetestist](https://in-thread.sonic-pi.net/u/minetestist)\
**Post date:** [January 26, 2022, 5:31am UTC](https://in-thread.sonic-pi.net/t/messed-up-repeats/6440/1 "2022-01-26T05:31:56Z")

</div>

Hey there!  
The following code is is giving me some trouble…  
The first _times_ block represents the number of times the entire riff (is that the right word, riff?) should be repeated in a sequence, and the second _times_ block captures the number of notes that should be played inside said riff… Nothing out of the ordinary, even for a noob like me… 🙂  
And it works… But only if the “sentence” is played once…  
As soon as I increase the number of repeats, the melody is messed up… 😕  
I’m guessing it has to do with that rest at the beginning… But it has to be there, because in the track I’m trying to cover, that instrument starts with a slight delay of 1.5 beats after the leading bass, on the start of a new bar… So I can’t just get rid of it…  
This must be very basic I’m sure, but I’d appreciate some pointers on how to make this riff loop the way it should, with the slight delay at the beginning…  
Cheers! 🙂  
PS: Also, the cutoff option doesn’t seem to affect certain synths like here… Is this normal?

```ruby
guit_01_note = (ring :r, 56, 61, 63, 56, 61, 49, 56, 61)
guit_01_rel = (ring 1, 0.75, 0.75, 0.75, 0.75, 1, 1, 1)
guit_01_slp = (ring 1.5, 0.5, 0.5, 0.25, 0.25, 0.5, 0.25, 0.25)

##| ---

define :guit_01 do
  ##| stop
  with_fx :reverb, mix: 0.7, room: 0.5 do
    use_synth :chiplead
    use_transpose 3
    1.times do
      9.times do
        tick
        play guit_01_note.look, release: guit_01_rel.look, amp: 1,
          pan: -0.8, cutoff: 75
        sleep guit_01_slp.look
      end
    end
  end
end

##| ---

guit_01

```

---

<div class="post-metadata">

**Author:** ![ethancrawford](https://avatars.discourse-cdn.com/v4/letter/e/a88e4f/32.png) [@ethancrawford](https://in-thread.sonic-pi.net/u/ethancrawford)\
**Post date:** [January 26, 2022, 5:54am UTC](https://in-thread.sonic-pi.net/t/messed-up-repeats/6440/2 "2022-01-26T05:54:59Z")

</div>

Notice that you while you have rings of ‘notes’, ‘releases’ and ‘sleeps’, there are nine notes and only eight releases and sleeps. This causes the releases and sleeps to wrap around more quickly than the notes, and so unexpected values are used together. (You can place a dummy release value in the releases and an extra sleep in the sleeps, adjusting as necessary to account for the rest note too, and that should solve that 🙂 ).

Regarding the cutoff: it’s worth keeping in mind that opts that you pass to `play` or use with a `synth` etc will only affect the synth if they are part of that synth’s specific list of usable opts. Here, the `:chiplead` synth does not have a `cutoff:` opt, does not understand it, and it gets silently ignored. You could potentially wrap the melody with a filter fx instead if you like, as you have done with the `:reverb`.

---

<div class="post-metadata">

**Author:** ![minetestist](https://dub1.discourse-cdn.com/flex017/user_avatar/in-thread.sonic-pi.net/minetestist/32/2194_2.png) [@minetestist](https://in-thread.sonic-pi.net/u/minetestist)\
**Post date:** [January 26, 2022, 7:08pm UTC](https://in-thread.sonic-pi.net/t/messed-up-repeats/6440/3 "2022-01-26T19:08:36Z")

</div>

Thanks Ethan!  
Hope this works when I try it later on…  
Although I’m pretty sure, there was a moment when I didn’t mess the number of items in my lists, and it still didn’t work at that time…  
I’m always tripping over trivial stuff, but hey… This is my first week as a “coder”!  
I’ll fix it this evening, and I’ll come back here to tell you if I managed to make it work…  
As for the cutoff option, OK I’ll replace it with a proper effect then…  
Thanks again! 🙂

---

<div class="post-metadata">

**Author:** ![minetestist](https://dub1.discourse-cdn.com/flex017/user_avatar/in-thread.sonic-pi.net/minetestist/32/2194_2.png) [@minetestist](https://in-thread.sonic-pi.net/u/minetestist)\
**Post date:** [January 29, 2022, 6:25pm UTC](https://in-thread.sonic-pi.net/t/messed-up-repeats/6440/4 "2022-01-29T18:25:10Z")

</div>

Hey… Sorry I couldn’t make the test sooner, but yes you’re right, it does work now…  
The actual timings are still hard to figure out, but that’s not a Sonic Pi issue!  
Merci amigo! 🙂
