Skip to content

AudioBands

Source: AudioBands.h

BandConditioner

struct BandConditioner
src/core/AudioBands.h:181

Per-band conditioning in the dB domain: the tier of the audio roadmap's design that learns the RIG rather than chasing the music.

Every band carries two learned numbers. Its floor, the level it reads with no program material (mic self-noise, mains hum, the room), followed as a running MINIMUM that drifts up slowly so a room that gets noisier is re-learned. Its peak, followed with an instant attack and a release of seconds, so it settles to the band's typical loudest level rather than tracking every beat. Between the two is the band's own dynamic range, and the correction maps that range onto the display window instead of leaving the treble at a fourteenth of the bass under spectrally balanced material (measured: a peak-per-band reading of pink noise falls as 1/sqrt(f) across the sixteen bands).

The correction is applied with a compressor's ratio: N:1 removes (1 - 1/N) of a band's deviation from the window, so 1:1 is off and the music's balance is untouched, 2:1 halves the rig's coloration, and a high ratio flattens it. Slow on purpose: a fast per-band gain is what causes cross-spectral pumping, and every source on multiband dynamics says not to (the audio roadmap, ยง two tiers). maxGain caps the lift so a silent band is never amplified into its own noise. learning off freezes both tables, which is the deterministic mode a show wants.

State is 32 floats; the work is 16 logs and a handful of multiplies per block, on the audio block path and never per light.

Public Attributes

float floorDb

float peakDb

bool primed = false

Public Methods

inline BandConditioner()

inline void process(const float db, float out, uint32_t dtMs, float windowFloor, float windowSpan, uint8_t ratioN, float maxGainDb, bool learning, float gateDb, float floorRiseDbPerS = 1.0f, float peakReleaseDbPerS = 3.0f) : Condition one block.

Public Static Attributes

constexpr float kMinRangeDb = : The narrowest dynamic range a band is credited with: the shared follower minimum, so the band and level paths cannot drift apart (kConditionerMinRangeDb, [AudioLevel.h]).

OnsetDetector

struct OnsetDetector
src/core/AudioBands.h:139

Turns a flux stream into onsets: one per hit, none for a swell.

The decision is the textbook one, flux against its own recent MEAN (Dixon 2006) rather than an absolute threshold, so a loud room and a quiet one fire on the same kind of event; a refractory window then makes one hit one onset however many blocks it spans. The mean is an EMA in 8.8 fixed point, advanced AFTER the decision so a hit does not raise the bar it is being judged against.

Public Attributes

uint16_t mean_ = 0 : EMA of the flux, 8.8 fixed point.

uint32_t lastMs_ = 0 : when the last onset fired

bool fired_ = false : whether one has fired yet (lastMs_ of 0 is a valid time)

Public Methods

inline bool feed(uint8_t flux, uint32_t nowMs, uint8_t num = 3, uint8_t den = 2, uint8_t margin = 20, uint16_t refractoryMs = 100) : Feed one block's flux at time nowMs.