Pulp 1.88.0
Cross-platform audio plugin framework
Loading...
Searching...
No Matches
pulp::signal::MaterialChangeDetector Class Reference

Detects a genuine change of material from the gap between the make-up the fast and the slow estimates give the current shape. More...

#include <loudness_compensation.hpp>

Public Types

enum class  Event { none , run_started , run_broken , confirmed }

Public Member Functions

void reset () noexcept
int run () const noexcept
double level_drop_db () const noexcept
 The fast level's fall below the slow one, dB (>= 0 while quieter).
bool last_was_drop () const noexcept
 Whether the last confirmation came through the quieter-after-louder path.
Event observe (float fast_db, float slow_db, double frame_lufs=kNoLevel) noexcept
 One audible frame: the make-up the fast and slow shapes give, and (optional) the frame's loudness, for the quieter-after-louder path.
void hold_off () noexcept

Public Attributes

double threshold_db = 4.0
int frames = 12
double huge_db = 12.0
int huge_frames = 6
int holdoff_frames = 6
double drop_threshold_db = 0.0
 Quieter after louder.
double drop_level_db = 3.0
double max_decay_db_per_frame = 0.0
int drop_min_loud_frames = 0
 ... and only after louder material that lasted: the level must have stayed within half of drop_level_db of (or above) its slow average for this many frames before it fell, so a short loud burst in a fast alternation is left to the alternation memory.
double level_fast_alpha = 0.3
 Per-frame coefficients of the fast and slow level averages (power).
double level_slow_alpha = 0.03

Static Public Attributes

static constexpr double kNoLevel = -1.0e300

Detailed Description

Detects a genuine change of material from the gap between the make-up the fast and the slow estimates give the current shape.

The gap must persist: a leaky count – up one for each audible frame above threshold_db, down two for each below – must reach frames (huge_frames while the gap is above huge_db, for a change nobody could miss). So material that is itself uneven (a groove: a kick frame, then a hat frame) still confirms, and a passing moment – a hit, a fill, part of a decay – drains away and is forgotten. Pure bookkeeping; deterministic.

Member Enumeration Documentation

◆ Event

Enumerator
none 
run_started 
run_broken 
confirmed 

Member Function Documentation

◆ hold_off()

void pulp::signal::MaterialChangeDetector::hold_off ( )
inlinenoexcept

◆ last_was_drop()

bool pulp::signal::MaterialChangeDetector::last_was_drop ( ) const
inlinenodiscardnoexcept

Whether the last confirmation came through the quieter-after-louder path.

◆ level_drop_db()

double pulp::signal::MaterialChangeDetector::level_drop_db ( ) const
inlinenodiscardnoexcept

The fast level's fall below the slow one, dB (>= 0 while quieter).

◆ observe()

Event pulp::signal::MaterialChangeDetector::observe ( float fast_db,
float slow_db,
double frame_lufs = kNoLevel )
inlinenoexcept

One audible frame: the make-up the fast and slow shapes give, and (optional) the frame's loudness, for the quieter-after-louder path.

◆ reset()

void pulp::signal::MaterialChangeDetector::reset ( )
inlinenoexcept

◆ run()

int pulp::signal::MaterialChangeDetector::run ( ) const
inlinenodiscardnoexcept

Member Data Documentation

◆ drop_level_db

double pulp::signal::MaterialChangeDetector::drop_level_db = 3.0

◆ drop_min_loud_frames

int pulp::signal::MaterialChangeDetector::drop_min_loud_frames = 0

... and only after louder material that lasted: the level must have stayed within half of drop_level_db of (or above) its slow average for this many frames before it fell, so a short loud burst in a fast alternation is left to the alternation memory.

◆ drop_threshold_db

double pulp::signal::MaterialChangeDetector::drop_threshold_db = 0.0

Quieter after louder.

When the frames' level has fallen at least drop_level_db below its slow average, a smaller gap – drop_threshold_db – counts as a change too: a quieter section after a loud one is a new part, and the energy-weighted estimate is slowest to give the louder past up exactly then. A decay (a hit's tail, a fade) also falls in level, so this path confirms only material whose level is steady over the run: its fitted slope must not fall faster than max_decay_db_per_frame. drop_threshold_db <= 0 turns the path off.

◆ frames

int pulp::signal::MaterialChangeDetector::frames = 12

◆ holdoff_frames

int pulp::signal::MaterialChangeDetector::holdoff_frames = 6

◆ huge_db

double pulp::signal::MaterialChangeDetector::huge_db = 12.0

◆ huge_frames

int pulp::signal::MaterialChangeDetector::huge_frames = 6

◆ kNoLevel

double pulp::signal::MaterialChangeDetector::kNoLevel = -1.0e300
staticconstexpr

◆ level_fast_alpha

double pulp::signal::MaterialChangeDetector::level_fast_alpha = 0.3

Per-frame coefficients of the fast and slow level averages (power).

◆ level_slow_alpha

double pulp::signal::MaterialChangeDetector::level_slow_alpha = 0.03

◆ max_decay_db_per_frame

double pulp::signal::MaterialChangeDetector::max_decay_db_per_frame = 0.0

◆ threshold_db

double pulp::signal::MaterialChangeDetector::threshold_db = 4.0

The documentation for this class was generated from the following file: