Trigger list of samples

I’m new to Sonic Pi. I want to trigger multiple samples at once, but I find it daunting to write out “sample” for every sample. Then I tried feeding it a list, like this:
sample [:sample1, :sample2, :sample3]
But it doesn’t seem to work. Is there a way to trigger multiple samples at once, in a compact way?

take your list of samples and use a loop like this to play them all together.

slist = [:sample1, :sample2, :sample3]
slist.each do |x|
  sample x
end

Here is an example which plays all the :loop samples together, all adjusted to sound for 4 beats

slist = sample_names :loop # get a list (or ring) of all the samples in the :loop category
puts slist #printout the list
slist.each do |s|
  sample s,beat_stretch: 4
end
1 Like

Could you also make a function to shorten the name?

define :s do |x|
  sample x
end

s :ambi_dark_woosh 

Granted, you still have to type s but it’s shorter than sample :stuck_out_tongue:

Oh, maybe you could combine those ideas to make a function that takes 1 or more samples

define :s do |x|
  x.each do |y|
    sample y
 end
end

s [:ambi_dark_woosh]
sleep 1
s [:ambi_choir, :ambi_piano]