# Trigger list of samples

**URL:** <https://in-thread.sonic-pi.net/t/trigger-list-of-samples/5483>\
**Category:** Support, Help & Resources\
**Created:** [April 30, 2021, 6:33pm UTC](https://in-thread.sonic-pi.net/t/trigger-list-of-samples/5483 "2021-04-30T18:33:01Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![burgerkalif](https://avatars.discourse-cdn.com/v4/letter/b/eada6e/32.png) [@burgerkalif](https://in-thread.sonic-pi.net/u/burgerkalif)\
**Post date:** [April 30, 2021, 6:33pm UTC](https://in-thread.sonic-pi.net/t/trigger-list-of-samples/5483/1 "2021-04-30T18:33:01Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![robin.newman](https://avatars.discourse-cdn.com/v4/letter/r/76d3ee/32.png) [@robin.newman](https://in-thread.sonic-pi.net/u/robin.newman)\
**Post date:** [April 30, 2021, 8:13pm UTC](https://in-thread.sonic-pi.net/t/trigger-list-of-samples/5483/2 "2021-04-30T20:13:09Z")

</div>

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

```ruby
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

```ruby
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

```

---

<div class="post-metadata">

**Author:** ![gregeporter](https://dub1.discourse-cdn.com/flex017/user_avatar/in-thread.sonic-pi.net/gregeporter/32/1277_2.png) [@gregeporter](https://in-thread.sonic-pi.net/u/gregeporter)\
**Post date:** [May 2, 2021, 2:51pm UTC](https://in-thread.sonic-pi.net/t/trigger-list-of-samples/5483/3 "2021-05-02T14:51:15Z")

</div>

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 😛

---

<div class="post-metadata">

**Author:** ![gregeporter](https://dub1.discourse-cdn.com/flex017/user_avatar/in-thread.sonic-pi.net/gregeporter/32/1277_2.png) [@gregeporter](https://in-thread.sonic-pi.net/u/gregeporter)\
**Post date:** [May 2, 2021, 2:53pm UTC](https://in-thread.sonic-pi.net/t/trigger-list-of-samples/5483/4 "2021-05-02T14:53:32Z")

</div>

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]
```
