Listen to the samples in a folder

This simple code serves to listen to all the samples of a folder, a practical way to listen to them one by one, in its total duration, not only a fragment of them, it is useful if for example you have downloaded folders from freesound and want to hear them, to Know what you can use at one time or another.

The code

dirsamples = 'the address where the samples are located’
In range the second parameter is the amount of samples that the folder contains, you can also do a limited listening by the parameters
example (range 4,15), samples 5 to 14

dirsamples ='/home/raul/Sonic Pi/Samples/90s Ambient_2/SoundFX/' #/home/usuario/sonic pi/samples

for i in (range 0,40) do
    puts i
    puts sample_duration dirsamples,i
    sample dirsamples, i
    sleep sample_duration dirsamples, I
end
2 Likes