PR(\basicBufferPlayer)

A generic shell for a process that plays fragments of one or more buffers (loaded from sound files).

Initialization

Buffers are loaded based on the same chuck parameters as in bufPerc. This process does little apart from automatically load the buffers. It includes a generic pattern (described below), but it's expected that you will customize this process pretty heavily in musical use.

bufPaths: One or more samples are permitted (for example, a high hat process might need open and closed samples). Here, give an array listing paths to the soundfile(s). If you're using only one sample, you still have to wrap the path in an array: ["sounds/a11wlk01.wav"].

bufCoords: By default, the whole of each sound file will be loaded. You can override this array to load portions of each file: [ [startFrame, numFrames], [startFrame, numFrames] ... ] where each array item matches up to the corresponding path.

chan: Optional -- if you have a specific mixer channel already created that you want the process to use for output, specify it here in the parameter dictionary. If you omit this parameter, the following parameters will be used to create a mixer channel for you.

inChannels: The number of input channels for the mixer channel.

outChannels: The number of output channels.

master: The target of this process mixer channel -- may be a global mixer, or it could also be a drum submix.

postMCCreation: A user specified function that executes after creating the mixer channel for the process. Here, you may initialize other resources, create effects etc. This takes place before loading the sound files. (If you manually supply a mixer channel as chan, this function still executes.)

free: If you created any extra resources in postMCCreation, you should supply a function here to release those resources.

Default pattern

The default pattern uses several BPStream objects. You should supplying patterns for each of these, by assigning the pattern to the corresponding key. Constant values are also okay. Only def, attack and decay have a default value; you must specify all the rest or the process will terminate immediately.

If these parameters are not suitable for a particular use, you can write your own function into ~asPattern and use an entirely different pattern.

def: Returns a symbol or string with the name of the synthdef to play the buffer fragment. These are recommended, but you can write your own.

\bufGrain: Mono sound file, outputs one channel.

\bufGrain2: Stereo sound file, outputs two channels.

\bufGrainPan: Mono sound file, outputs two channels, pans output using Pan2.

\bufGrainPan2: Stereo sound file, outputs two channels, pans output using Balance2.

\bufGrainRLPF: Like \bufGrain, but adds a resonant lowpass filter.

\bufGrainRLPF2: Like \bufGrain2, but adds a resonant lowpass filter.

\bufGrainRLPFPan: Like \bufGrainPan, but adds a resonant lowpass filter.

bufIndex: The index into the ~buffers array.

time: How many beats the sound should play. Automatically converted into seconds before sending the synth message. You can do additional processing on the time by overriding the function in ~timeConversion, which takes the result of the time pattern and the partially constructed event as arguments.

rate: Playback rate. 1.0 is normal speed.

start: The starting position for playback within the buffer, in frames.

amp: Volume for this event.

attack: Duration in seconds of the attack portion of the envelope. (Default = 0.005s.)

decay: Duration in seconds of the release portion of the envelope. (Default = 0.02s.)

delta: How long until the next event.

You can also add additional synth arguments using ~argPairs, as in the drum machine processes.

Example

s.boot;

TempoClock.default.tempo = 1;

(

PR(\basicBufferPlayer).chuck(BP(\ex1), parms: (

inChannels: 2,

bufPaths: ["sounds/a11wlk01.wav", "sounds/a11wlk01-44_1.aiff"],

def: \bufGrainPan,

bufIndex: Prand(#[0, 1], inf),

time: Pwhite(1, 3, inf) * 0.25,

rate: Pwhite(0.9, 1.5, inf),

start: Pfunc({ |ev| rrand(0.0, ~buffers[ev[\bufIndex]].duration - (ev[\time] * ev[\rate]))

* ~buffers[ev[\bufIndex]].sampleRate }),

amp: Pexprand(0.1, 0.9, inf),

delta: Pkey(\time),

argPairs: [pan: Pwhite(-1.0, 1.0, inf)]

));

)

BP(\ex1).play;

BP(\ex1).stop;

BP(\ex1).free;