Rings as parameters?

Hey there…
Can I use the content of a ring as a parameter for a function?
Being new to programming in general, I thought I’d try something inspired by the Bizet tutorial, but it didn’t work…
My (naïve) hope was that the following two pieces of code would produce the same effect, but they don’t…
The first one works (obviously), but the second one doesn’t…
Is there a way I can tell Sonic Pi to pick these numbers in sequence?..
Sorry if this is a stupid question, but this is my second day trying to code…


First piece:

use_bpm 120
live_loop :bass do
  use_synth :fm
  play 45, release: 1.6
  sleep 1.5
  play 52, release: 1.6, attack: 0.01
  sleep 1.5
  play 50, release: 0.55
  sleep 0.5
  play 48, release: 0.55
  sleep 0.5
end

Second piece:

note_ring = (ring 45, 52, 50, 48)
sleep_ring = (ring 1.5, 1.5, 0.5 0.5)
release_ring = (ring 1.6, 1.6, 0.55, 0.55)

use_bpm 120

define :bass_seq do
  live_loop :bass_seq_loop do
    tick
    play note_ring.look, release: release_ring.look
    sleep sleep_ring.look
  end
end

##

bass_seq  #plays the loop as a function when run

Hi @minetestist the short answer is yes.
Your second piece is missing a comma in the sleep_ring.

Hope that helps.

2 Likes

Oh snap!
I didn’t see that comma missing there!
Thanks a million, it works now! :slight_smile:

2 Likes