Skip to main content

Transcription

For the buffers we create to show up on the timeline, we need to transcribe them via the transcribe function. This tells bellplay~ that we want the current version of the buffer to be assembled together with other transcribed buffers once we call the render function. At this stage, we get to specify essential information about how each buffer fits within the final output or timeline. For instance, specifying the time onset position (i.e., start time), gain, panning, and even resampling-based detuning amount in cents.

## generate buffers
$sound1 = importaudio('guitar.wav');
$sound2 = importaudio('flute.wav');
## transcribe buffers
transcribe($sound1, 1000); ## start 1000 ms later
transcribe($sound2, 2000); ## start 2000 ms later
transcribe($sound2);
render()
tip

The order in which buffers are transcribed in the script does not determine the order (i.e., onset position) in which they appear on the timeline. This is solely determined by the @onset argument in the transcribe function.

Crucially, transcribing the buffer means taking a snapshot of the current version of the buffer and, therefore, further modifications done to the buffer will not affect the transcribed version. Think of this in the same way you think about sending an email—once an email is been sent, it cannot be unsent not modify its content.

The code below shows how a single buffer is transcribed multiple times, each time with different settings, to generate a simple melodic gesture.

transcription.bell
## generate a triangle wave oscillator as a buffer
$buff = tri();
## number of notes (i.e., buffers)
$numnotes = 25;
$N = $numnotes - 1;
## total output duration
$totaldur = 1500;
## iterate for each note
for $i in 0...$N do (
## compute normalize value of temporal position within output (i.e., 0 = start, 1 = end)
$progress = $i / $N;
## make onsets equally spaced within the total duration
$onset = $progress * $totaldur;
## panning goes from 0 (left) to 1 (right) with each iteration
$pan = $progress;
## make gain exponentially softer
$gain = (1 - $progress) ** 2;
## detuning amount from 0 to 1200 (octave) midicents with each iteration
$detune = 1200 * $progress;
## transcribe the same buffer, with different values for onset, gain, detuning amount, and panning.
$buff.transcribe(
@onset $onset
@gain $gain
@detune $detune
@pan $pan
)
);
## render transcribed buffers
render()
danger

Calling render before transcribing any buffers will raise an error.

Result