Ticking a list of notes progressively

Hi!
I’m trying to perform a list of notes using the function tick (and looping it). But I need to play only the first note at the first time; then the first and the second note; then the 1st, the 2nd and the third; so and so forth.
I need it because I’m interested in perform Les Moutons de Panurge, by Frederic Rzewski. Here you can read the score. Maybe thus you can understand what I need.
Thank you in advance.

My first attempt:
live_loop :moutons do play_pattern_timed [:f4, :ab4, :bb4, :ab4, :bb4, :c5, :e5, :c5, :bb4, :ab4, :f4, :d4, :f4, :ab4, :bb4, :ab4, :bb4, :c5, :ab4, :c5, :f4, :ab4, :bb4, :ab4, :f4, :e5, :c5, :d5, :c5, :d5, :c5, :d5, :g4, :bb4, :c5, :ab4, :g4, :c5, :d5, :e5, :c5, :g4, :c5, :d5, :g4, :a4, :c5, :bb4, :a4, :f4, :f5, :c5, :bb4, :a4, :f4, :c5, :a4, :f4, :c4, :f4, :d5, :g4, :f4, :bb4, :c5], [0.5, 0.5, 1, 0.5, 0.5, 0.5, 1, 1, 1, 0.5, 1, 0.5, 1, 0.5, 1, 0.5, 0.5, 1, 0.5, 1, 0.5, 0.5, 0.5, 0.5, 1, 1, 0.5, 0.5, 0.5, 0.5, 0.5, 1, 0.5, 0.5, 1, 0.5, 1, 1, 1, 1, 0.5, 1, 0.5, 0.5, 1, 1, 0.5, 0.5, 0.5, 1, 1, 1, 0.5, 0.5, 1, 1, 1, 0.5, 0.5, 1, 1, 1, 0.5, 0.5, 1], release: 0.3 end

1 Like

Hello with this you have the sequence 1, 1 2, 1 2 3, until 1 2 3…65
An array for the notes and another for the sleeps

notas =[:f4, :ab4, :bb4, :ab4, :bb4, :c5, :e5, :c5, :bb4, :ab4, :f4, :d4, :f4, :ab4,
       :bb4, :ab4, :bb4, :c5, :ab4, :c5, :f4, :ab4, :bb4, :ab4, :f4, :e5, :c5, :d5,
       :c5, :d5, :c5, :d5, :g4, :bb4, :c5, :ab4, :g4, :c5, :d5, :e5, :c5, :g4, :c5,
       :d5, :g4, :a4, :c5, :bb4, :a4, :f4, :f5, :c5, :bb4, :a4, :f4, :c5, :a4, :f4,
       :c4, :f4, :d5, :g4, :f4, :bb4, :c5]

tiempos = [0.5, 0.5, 1, 0.5, 0.5, 0.5, 1, 1, 1, 0.5, 1, 0.5, 1, 0.5, 1, 0.5, 0.5, 1,
          0.5, 1, 0.5, 0.5, 0.5, 0.5, 1, 1, 0.5, 0.5, 0.5, 0.5, 0.5, 1, 0.5, 0.5, 1,
          0.5, 1, 1, 1, 1, 0.5, 1, 0.5, 0.5, 1, 1, 0.5, 0.5, 0.5, 1, 1, 1, 0.5, 0.5,
          1, 1, 1, 0.5, 0.5, 1, 1, 1, 0.5, 0.5, 1]

for i in 0..64
 for j in  0..i
   puts j
   play notas[j], release: 0.30
   sleep tiempos[j]
 end
end

4 Likes

While ‘for’ works, borrowed from Ruby, is it part of the official Sonic Pi API?

I had a quick look through the tutorials, and couldn’t find it.

The above can be written without for loops, but I wonder what the best strategy is. I’ve been trying to stay documentation compliant. Not sure if that’s a good thing or not.

notas =[:f4, :ab4, :bb4, :ab4, :bb4, :c5, :e5, :c5, :bb4, :ab4, :f4, :d4, :f4, :ab4,
        :bb4, :ab4, :bb4, :c5, :ab4, :c5, :f4, :ab4, :bb4, :ab4, :f4, :e5, :c5, :d5,
        :c5, :d5, :c5, :d5, :g4, :bb4, :c5, :ab4, :g4, :c5, :d5, :e5, :c5, :g4, :c5,
        :d5, :g4, :a4, :c5, :bb4, :a4, :f4, :f5, :c5, :bb4, :a4, :f4, :c5, :a4, :f4,
        :c4, :f4, :d5, :g4, :f4, :bb4, :c5]

tiempos = [0.5, 0.5, 1, 0.5, 0.5, 0.5, 1, 1, 1, 0.5, 1, 0.5, 1, 0.5, 1, 0.5, 0.5, 1,
           0.5, 1, 0.5, 0.5, 0.5, 0.5, 1, 1, 0.5, 0.5, 0.5, 0.5, 0.5, 1, 0.5, 0.5, 1,
           0.5, 1, 1, 1, 1, 0.5, 1, 0.5, 0.5, 1, 1, 0.5, 0.5, 0.5, 1, 1, 1, 0.5, 0.5,
           1, 1, 1, 0.5, 0.5, 1, 1, 1, 0.5, 0.5, 1]

64.times do |i|
  (i+1).times do |j|
    puts j
    play notas[j], release: 0.30
    sleep tiempos[j]
  end
end
1 Like

Thank you very much! This option is more understandable than @Raul’s, since I’m a newbie and I haven’t almost had any contact with coding before Sonic Pi.

1 Like

Thank you very much!

1 Like

I hope I’ve got it right. should it be i.times do or (I+1).times do

1 Like

Both options work properly :slight_smile:

1 Like