Hey @ChaSiuBao!
Nlb shows one way that should work.
As for the issues that you were having originally - if I take your second example, substitute the sample paths for some on my own system and run it:
a = "C:/Program Files/Sonic Pi/etc/samples/ambi_choir.flac"
b = "C:/Program Files/Sonic Pi/etc/samples/ambi_drone.flac"
s= (ring a, b).tick #=> :a
puts "this is a ring",s
sa = s.to_a
puts "this is an array",sa
Then I get this in the log panel:
└─ "this is a ring" "C:/Program Files/Sonic Pi/etc/samples/ambi_choir.flac"
and then the script stops with this error:
Runtime Error: [buffer 7, line 5] - NoMethodError
Thread death!
undefined method `to_a' for "C:/Program Files/Sonic Pi/etc/samples/ambi_choir.flac":String
...
For me, this error is happening because by the time the s.to_a
is executed, s
is a string, the path to a sample - and Sonic Pi doesn’t know how to convert a string into an array.
Why is s
a string by that point? this is because further above, when we call tick
on the ring, it returns the next item in the ring - a string
Does that match with what you were observing?
Also, regarding your first example - if I run it:
puts (ring "/Users/username/folder/track01.wav", "/Users/username/folder/track02.wav").tick
Then it prints out this in the log panel:
└─ "/Users/username/folder/track01.wav"
Do you get the same?
When you say “tried adding the external samples to a ring array and iterate with .tick but nothing happened” - there must have been more code to that, can you share it?