Samples in Sonic Pi

I got this from the official tutorial: https://sonic-pi.net/tutorial#section-3

Triggering Samples

This is straightforward, type

sample :ambi_lunar_land

Setting the amplitude and the pan

Just like the synths, we can control these parameters in samples

sample :ambi_lunar_land, amp:0.8, pan: -0.3

Stretching

samples can be squashed and stretched, even played backwards. Or better yet, squashed or stretched and played backwards.

sample :ambi_lunar_land, rate: 0.5

Explanation:

“Typically a waveform like this will have 44100 points of data per second (this is due to the Nyquist-Shannon sampling theorem). So, if the sample lasts for 2 seconds, the waveform will be represented by 88200 numbers which we would feed to the speaker at a rate of 44100 points per second. Of course, we could feed it at double rate which would be 88200 points per second. This would therefore take only 1 second to play back. We could also play it back at half rate which would be 22050 points per second taking 4 seconds to play back.”

Sonic Pi Official website

Envelopes

Here we should note the difference with synth ADSR envelopes. It lies in the sustain value.

“In the standard synth envelope, the sustain defaulted to 0 unless you set it manually. With samples, the sustain value defaults to an automagical value – the time left to play the rest of the sample.”

This is the reason why we hear the full length of the samples.

In short: attack times are used for fade ins and release times are used for fade outs.

envelopes can be used with samples to get nice effects on our samples.

More possibilities with the samples can be explored on the website

External samples

Sonic Pi can work with samples stored on the computer.’

for me, I can load a sample by typing

sample /Users/chadiabifadel/Downloads/Fun-Programming-master/processing/04/e100_rhythm/data/2.wav 

If you are interested in more information on samples in Sonic Pi, Go to https://sonic-pi.net/tutorial#section-3-1

Leave a comment

Design a site like this with WordPress.com
Get started