Strange behaviour iterating samples with .each

#1

I was writing some lines of code to iterate thru available samples & play them, just to hear them all in a row.
I’m facing a strange behaviour: even if “all_samples” variable contains the reference to all samples, the iteration seem to stop after the 4th sample. I’m running this on sonic pi portable, not sure if this matters or not.

use_debug false
all_samples = all_sample_names
puts all_samples

all_samples.each {
|key|
s = sample_duration(key)
puts key, s
sample key
sleep s
}

0 Likes

#2

I’m not sure what’s causing that to go wrong, but I think it must be something with your Sonic Pi installation as there’s nothing wrong with the code itself; I just pasted it into Sonic Pi and it ran fine for me all the way through until the end.

0 Likes

#3

Yes, you’re right. I’ve run the same code on a “proper” installation and it works fine.
Il looks related to the portable version and/or the fact it was put straight on the desktop (maybe creating excessive long paths)

0 Likes