Skip to main content

Inspecting Buffers

An essential part of writing code is being able to debug unwanted or unexpected behaviors. This is particularly necessary when dealing with audio data — i.e., buffers. In bellplay~, we can use the inspect function to check the contents of any buffer we create. This function opens a pop-up window displaying useful information about the inspected buffers, once the code finished evaluation.

This tutorial shows a simple example where every buffer that is not rendered can still be visualized through the buffer inspector.

inspecting_buffers.bell
## import audio sample
$buff = importaudio('trumpet.wav');
## queue original sample for inspection
inspect($buff @label 'pre-processing buffer');
## create envelope buffer, based on audio file duration
$env = envelope(
[0 4 0] [1 100 0.25] @duration $buff.getkey('duration')
);
## queue envelope for inspection (label is optional)
inspect($env, @label 'frequency envelope');
## create oscillator using envelope as frequency
$osc = cycle($env).process(plus(1));
## queue oscillator for inspection
inspect($osc @label 'frequency oscillator');
## process and transcribe buffer
$buff.process(
## use oscillator for amplitude modulation
multiply($osc)
).transcribe();
## trigger rendering
render(@play 1)