/ Examples / Instruments / SoundBuf


Projects .. AudioIO .. Control
NoteStreams .. Instruments
Filters .. Effects .. LiCK Effects
Plot .. Utility .. Pure ChucK


Wherein we present the SoundBuf Node for playing audio files.

Right-click to copy examples to your workspace

SoundBuf

In ChucK, sampled audio data is imported from .wav and .aif files into a ChucK session's soundbuffers and performed with its SndBuf ugens.

The SoundBuf node allows you to trigger the playing of a soundbuf with a NoteStream. SoundBuf supports a number of modes all related to the interpretation of incoming note frequencies. In this example we interpret the note frequency to represent the soundbuf playback rate.

Here's our graph:

When performed, this graph causes a scale of notes that result in playing the buffer backwards at decreasing rates. Here's we'll reveal the important knobs that make it work.

SoundBuf Node

SoundFile specifies the name of the soundbuffer file. .wav and some .aif files are supported. Clicking on the viewfile button will open the file in the Sound Player.

Mode controls the interpetation of note frequency when receiving MIDI notes. When set to Ignore, we play the soundbuf at the Rate value below. Otherwise, the incoming note frequency affects either the Rate control or its Phase. In either case, you should consider establishing a mapping between frequency (in terms of MIDI notes, 0-127) and rate or phase (as a pct of the file) by connecting a Remapping node.

Rate controls the playback rate when Rate Control is not the current Mode. A value of 1 signifies that the file should be played at its natural rate. Negative values cause it to play backwards. In either forward or reverse play the values of Loop and Phase play an important role. Note that if you want to resample a sound buffer to play at a different pitch without affecting its timing, the Rate parameter will disappoint. For this purpose, other nodes, like PitShift may be more appropriate.

Loop controls whether to loop around to the opposite side of the buffer when the end (or beginning in reverse mode) is reached.

Phase controls the initial phase of playback when not in Phase Control mode. A phase of 0 represents the start of the file and 1 represents the end. If you would like to playback the buffer in reverse and Loop is disabled set this value to 1 so that playback starts at the end of the buffer and works its way forward.

Here we set Phase to 1 because we are playing the buffer backwards.

Interpolation kicks in when you play back at slow or fast rates. Usually the effect is subtle. Options include None, Linear, Sinc ordered from cheap to expensive.

MidiNote is only present for use in conjunction with SoundBufBank. In the case where you opt to wire individual SoundBuf nodes into SoundBufBank, this tells SoundBufBank which MIDI note we're interested in.

Remapper Node

In this context the job of the remapper is to convert incoming MIDI note numbers into outgoing file rates.

Notes 60 to 70 correspond to the first 11 semitones starting at Middle C. The value 60 is converted to -2 which represents playing the sound buffer at twice its natural rate, in reverse. When notes 70 is encountered, we produce a rate or -1. Notes between 60 and 70 produce rates between -2 and -1. And the rest is history.





Scale Node

The Scale node produces the triggers for our SoundBuf node. The notes generated by Scale are remapped (by Remapper) into the rate values that drive this example.

Here are the relevant parameters for this example:

Base the value 60 represents Middle C in MIDI note space. This value is the same as Remapper's InputMin parameter.

Octaves we only produce one octave of notes of of the Base note so we produce values from 60 to 71.

Beats the number of beats for each note in our scale. The value 4 means that we produce one note per measure assuming our Time Signature is 4/4.

home .. topics .. interface .. reference .. examples .. tipjar