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

Reusable periodic-Hann real spectrum, without feature history. More...

#include <OnsetFeatures.h>

Public Member Functions

void prepare (int fftSize)
 Allocates a valid power-of-two frame; the caller owns frame timing.
 
void compute (const T *input, bool withPhase=true) noexcept
 Evaluates one contiguous frame, optionally including bin phases. Input is finite and scaled by the caller to avoid overflow in the FFT and squared magnitudes. Suppressing phases avoids unnecessary atan2 work for a pooled magnitude spectrum, which has no unique complex-domain phase.
 
bool computePooled (AudioBufferView< const T > frame) noexcept
 Pools mono/stereo spectral energy without a phase-cancelling downmix. The view must contain exactly one prepared frame. Invalid shape returns false; callers must not consume old magnitudes after failure. Two channels share one FFT instance and scratch, with one transform per channel. Equal magnitudes (including dual mono and antiphase) retain their exact value.
 
std::span< T > magnitudes () noexcept
 Borrowed scratch, valid until the next compute/prepare or destruction.
 
std::span< const T > phases () const noexcept
 Empty when the last frame did not compute phases. Same scratch lifetime.
 

Static Public Member Functions

static int defaultFrameSize (double sampleRate) noexcept
 
static std::size_t preparationBytes (int fftSize) noexcept
 Conservative setup payload allowance for a fresh power-of-two instance.
 

Detailed Description

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

Reusable periodic-Hann real spectrum, without feature history.

Definition at line 80 of file OnsetFeatures.h.

Member Function Documentation

◆ compute()

template<FloatType T>
void dspark::detail::OnsetSpectrum< T >::compute ( const T *  input,
bool  withPhase = true 
)
inlinenoexcept

Evaluates one contiguous frame, optionally including bin phases. Input is finite and scaled by the caller to avoid overflow in the FFT and squared magnitudes. Suppressing phases avoids unnecessary atan2 work for a pooled magnitude spectrum, which has no unique complex-domain phase.

Definition at line 122 of file OnsetFeatures.h.

◆ computePooled()

template<FloatType T>
bool dspark::detail::OnsetSpectrum< T >::computePooled ( AudioBufferView< const T >  frame)
inlinenoexcept

Pools mono/stereo spectral energy without a phase-cancelling downmix. The view must contain exactly one prepared frame. Invalid shape returns false; callers must not consume old magnitudes after failure. Two channels share one FFT instance and scratch, with one transform per channel. Equal magnitudes (including dual mono and antiphase) retain their exact value.

Definition at line 144 of file OnsetFeatures.h.

◆ defaultFrameSize()

template<FloatType T>
static int dspark::detail::OnsetSpectrum< T >::defaultFrameSize ( double  sampleRate)
inlinestaticnoexcept

Definition at line 83 of file OnsetFeatures.h.

◆ magnitudes()

template<FloatType T>
std::span< T > dspark::detail::OnsetSpectrum< T >::magnitudes ( )
inlinenoexcept

Borrowed scratch, valid until the next compute/prepare or destruction.

Definition at line 168 of file OnsetFeatures.h.

◆ phases()

template<FloatType T>
std::span< const T > dspark::detail::OnsetSpectrum< T >::phases ( ) const
inlinenoexcept

Empty when the last frame did not compute phases. Same scratch lifetime.

Definition at line 174 of file OnsetFeatures.h.

◆ preparationBytes()

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

Conservative setup payload allowance for a fresh power-of-two instance.

Definition at line 93 of file OnsetFeatures.h.

◆ prepare()

template<FloatType T>
void dspark::detail::OnsetSpectrum< T >::prepare ( int  fftSize)
inline

Allocates a valid power-of-two frame; the caller owns frame timing.

Definition at line 103 of file OnsetFeatures.h.


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