DSPark 1.9.0
Header-only C++20 DSP for real-time and offline audio
Loading...
Searching...
No Matches
dspark::detail::OnsetNovelty< T > Class Template Referencefinal

Shared whitening, spectral/complex flux and SuperFlux feature history. More...

#include <OnsetFeatures.h>

Classes

struct  Frame
 

Public Types

enum class  Method { SpectralFlux , ComplexDomain , SuperFlux , BothFlux }
 

Public Member Functions

void prepare (double sampleRate, int fftSize, bool boundedWorkspace=false, int pickLag=1, int persistLag=0, int persistSpan=1, int contentBack=0, int contentAhead=0, int contentHold=0, int contentSpan=1)
 Allocates histories and the canonical quarter-tone filterbank.
 
void reset () noexcept
 Clears feature history without allocation or changing the filterbank.
 
int getNumBands () const noexcept
 
T contentShare () noexcept
 New-content share of the frame contentHold back from the last processed one (prepare()); zero when no content hold is configured. Computed on request, allocation free.
 
void setLinearFlux (bool on) noexcept
 Computes Frame::linear alongside SuperFlux. Allocation free.
 
Frame process (std::span< T > mag, std::span< const T > phase, Method method, bool whiten=false) noexcept
 Advances one frame; optional whitening modifies the supplied magnitudes. Phase-less frames support SpectralFlux, SuperFlux and BothFlux. ComplexDomain requires phases on every frame since reset; missing/incompatible data returns valid=false without changing history. No source clock is inferred here.
 

Static Public Member Functions

static std::size_t preparationBytes (int fftSize) noexcept
 Setup payload allowance when prepare() reserves the bounded filterbank.
 

Static Public Attributes

static constexpr int kNumRegisters = 4
 

Detailed Description

template<FloatType T>
class dspark::detail::OnsetNovelty< T >

Shared whitening, spectral/complex flux and SuperFlux feature history.

Definition at line 221 of file OnsetFeatures.h.

Member Enumeration Documentation

◆ Method

template<FloatType T>
enum class dspark::detail::OnsetNovelty::Method
strong
Enumerator
SpectralFlux 
ComplexDomain 
SuperFlux 
BothFlux 

Definition at line 224 of file OnsetFeatures.h.

Member Function Documentation

◆ contentShare()

template<FloatType T>
T dspark::detail::OnsetNovelty< T >::contentShare ( )
inlinenoexcept

New-content share of the frame contentHold back from the last processed one (prepare()); zero when no content hold is configured. Computed on request, allocation free.

A band counts when its energy contentAhead after that frame is more than kContentGain times the largest energy it, or either neighbour, held over the contentSpan frames ending contentBack before it; it then contributes the smaller of its energies contentAhead and contentHold after the frame. The share is their sum over all band energy contentAhead after the frame. A note that starts while a louder one ends raises its own bands and holds them; the spectral spread of a note-off raises bands that are silent again a few frames later, and the neighbours and the span keep a vibrato or a tremolo from reading as new. Frames of the functions that compute no bands read as silence.

Definition at line 359 of file OnsetFeatures.h.

◆ getNumBands()

template<FloatType T>
int dspark::detail::OnsetNovelty< T >::getNumBands ( ) const
inlinenoexcept

Definition at line 339 of file OnsetFeatures.h.

◆ preparationBytes()

template<FloatType T>
static std::size_t dspark::detail::OnsetNovelty< T >::preparationBytes ( int  fftSize)
inlinestaticnoexcept

Setup payload allowance when prepare() reserves the bounded filterbank.

Definition at line 252 of file OnsetFeatures.h.

◆ prepare()

template<FloatType T>
void dspark::detail::OnsetNovelty< T >::prepare ( double  sampleRate,
int  fftSize,
bool  boundedWorkspace = false,
int  pickLag = 1,
int  persistLag = 0,
int  persistSpan = 1,
int  contentBack = 0,
int  contentAhead = 0,
int  contentHold = 0,
int  contentSpan = 1 
)
inline

Allocates histories and the canonical quarter-tone filterbank.

Parameters
sampleRateSample rate in Hz.
fftSizePower-of-two frame size.
boundedWorkspaceReserve the filterbank's worst-case size up front.
pickLagFrames back the SuperFlux pick value compares with (1, the default, is the value itself and keeps no extra history).
persistLagFrames back the persistence value compares with (0, the default, disables it). Lags above 1 keep a ring of max-filtered band frames, allocated here.
persistSpanFrames, ending persistLag back, whose band-wise maximum the persistence value compares with: a partial whose level oscillates within the span does not read as a rise.
contentBackFrames before the content candidate its band energies are compared from.
contentAheadFrames after the candidate they are compared at.
contentHoldFrames after the candidate the grown bands must still hold their energy at; 0 (the default) disables contentShare(), and it must exceed contentAhead otherwise. A ring of band energies is allocated here.
contentSpanFrames, ending contentBack before the candidate, whose band-wise maximum the energies are compared from: a sound whose level or pitch oscillates within the span does not read as new content.

Definition at line 285 of file OnsetFeatures.h.

◆ process()

template<FloatType T>
Frame dspark::detail::OnsetNovelty< T >::process ( std::span< T >  mag,
std::span< const T >  phase,
Method  method,
bool  whiten = false 
)
inlinenoexcept

Advances one frame; optional whitening modifies the supplied magnitudes. Phase-less frames support SpectralFlux, SuperFlux and BothFlux. ComplexDomain requires phases on every frame since reset; missing/incompatible data returns valid=false without changing history. No source clock is inferred here.

Definition at line 405 of file OnsetFeatures.h.

◆ reset()

template<FloatType T>
void dspark::detail::OnsetNovelty< T >::reset ( )
inlinenoexcept

Clears feature history without allocation or changing the filterbank.

Definition at line 322 of file OnsetFeatures.h.

◆ setLinearFlux()

template<FloatType T>
void dspark::detail::OnsetNovelty< T >::setLinearFlux ( bool  on)
inlinenoexcept

Computes Frame::linear alongside SuperFlux. Allocation free.

Parameters
onTrue to compute it.

Definition at line 394 of file OnsetFeatures.h.

Member Data Documentation

◆ kNumRegisters

template<FloatType T>
constexpr int dspark::detail::OnsetNovelty< T >::kNumRegisters = 4
staticconstexpr

Definition at line 231 of file OnsetFeatures.h.


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