gfx/audio_display.h
Two ways to look at audio: a scope that scrolls, and a waveform that sits still.
#include <sonore/gfx/audio_display.h>- 2types
- Guides: The native editor
On this page
Design notes
Why these are separate
AudioVisualiser shows what is happening NOW, fed continuously from the audio thread. WaveformView shows a fixed thing already loaded -- a sample, a recorded take -- from an AudioThumbnail built once. They have almost nothing in common: one is a ring buffer with a real-time constraint, the other is a lookup with a playhead.
Neither of them owns its data
AudioVisualiser points at an AudioScopeBuffer and WaveformView points at an AudioThumbnail, and both are fed by something that outlives the editor. A scope that owned its buffer would start blank every time a window was opened instead of showing the last second of audio; a waveform that owned its thumbnail would copy megabytes the plugin already has.
The real-time side lives in scope_buffer.h, with no UI anywhere near it.
Types 2
class AudioVisualiser : public Widget
A scrolling oscilloscope: a view onto an AudioScopeBuffer.
Each column is one BUCKET -- the minimum and maximum of however many samples fell into it -- rather than one sample. A scope that plotted individual samples at a pixel apart would alias badly: a 10 kHz tone at 48 kHz is under five samples a cycle, and picking every Nth one draws a slow wobble that is not in the audio. Min and max over the group draws the envelope, which is what an analogue scope shows and what people expect.
The buffer is NOT owned, and that is the whole point of the split: it is fed by the audio thread and has to exist whether or not an editor is open, so a scope shows the last second of audio the moment somebody opens the window rather than starting blank. Same arrangement as WaveformView and its thumbnail.
class WaveformView : public Widget
A waveform, drawn from an AudioThumbnail.
The thumbnail has existed in this SDK since before the native UI did, and nothing drew it: a sampler that shows no waveform gives a user nothing to aim at when setting a start point.
The thumbnail is NOT owned. It is usually built by the DSP from a file it loaded, and a display that owned it would either copy megabytes or decide the lifetime of something the plugin already holds.