Just a simple project to get familiar with SuperCollider’s sample-playing facilities. Audio data is stored in a Buffer object. You can create a buffer using, which takes a path to an audio file as its argument. Buffers can be played using the PlayBuf UGen. Note that you will need to create separate SynthDefs for playing mono and stereo samples. You can get the number of frames in a buffer using In addition, gives the ratio of the buffer sample rate to the server sample rate. Note that these are UGens designed to be used within a SynthDef.

The code below has two parts: a simple SynthDef that plays samples is sequenced by a Pbind which randomly selects the sample to play, the starting position, the duration, the amplitude, and the panning. The code assumes that your samples are in a directory called "samples" and that they all end in .wav.

Samples courtesy of the Madison, Alabama Police Department, Deutsche Bahn, and Freesound user dobroide