Search guides and the APICtrl K
  1. API reference
  2. Files and codecs

thumbnail.h

AudioThumbnail: the peak envelope a waveform display is drawn from.

#include <sonore/thumbnail.h>
  • 2types
On this page

Design notes

Why a waveform is not just "the samples, smaller"

A display is a few hundred pixels wide and a sample is a few million frames long, so every pixel stands for thousands of frames. Taking one of them -- nearest-neighbour, which is what naive downsampling does -- shows whichever frame happened to land on the tick, and a snare hit one frame wide either appears at full height or vanishes entirely depending on where it fell.

So each bucket keeps the MINIMUM and MAXIMUM of everything inside it. That is what makes a drawn waveform look like the sound: a transient is a tall thin spike because something in that bucket really was that loud, and silence is a flat line because nothing in it was.

RMS is kept alongside, because peak alone makes quiet dense material and quiet sparse material look identical, and a page that wants to shade the body of the waveform differently from its outline needs both.

Where it runs

Never on the audio thread. This is a UI structure, built when a file loads and handed to the page as numbers; the audio thread never reads it.

Types 2

One bucket: what the loudest and quietest samples in it were, and how much energy it carried.

A peak envelope over one or more channels.

Built once per file. Rebuilding at a different width is cheap enough to do on a window resize, but a page that redraws from the same buckets at a different scale will look right too -- the envelope is the sound, not the pixels.

↑↓ to move↵ to openEvery public name in the headers, and every guide