Messed up repeats?

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… :slight_smile:
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… :confused:
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! :slight_smile:
PS: Also, the cutoff option doesn’t seem to affect certain synths like here… Is this normal?

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

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 :slight_smile: ).

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.

1 Like

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! :slight_smile:

1 Like

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! :slight_smile:

1 Like