DSPark 1.6.1
Header-only audio DSP framework in pure C++20 — zero dependencies
Loading...
Searching...
No Matches
dspark::AudioSpec Struct Reference

Describes the audio environment for a DSP processor. More...

#include <AudioSpec.h>

Public Member Functions

constexpr bool isValid () const noexcept
 Checks if the specification contains valid, processable parameters.
 
constexpr bool operator== (const AudioSpec &) const noexcept=default
 Default member-wise equality (C++20).
 

Public Attributes

double sampleRate = 0.0
 Sample rate in Hz.
 
int maxBlockSize = 0
 Maximum number of samples per processing block.
 
int numChannels = 0
 Number of audio channels (e.g., 1 = mono, 2 = stereo).
 

Detailed Description

Describes the audio environment for a DSP processor.

Passed to prepare() before processing begins.

Processors should typically check if (newSpec == currentSpec) to avoid redundant allocations or state resets when the host triggers multiple prepare calls.

Definition at line 34 of file AudioSpec.h.

Member Function Documentation

◆ isValid()

constexpr bool dspark::AudioSpec::isValid ( ) const
inlineconstexprnoexcept

Checks if the specification contains valid, processable parameters.

Use this in assertions at the start of your processor's prepare() method. A NaN sample rate fails the check (every comparison against NaN is false), so corrupted specs are rejected too.

Returns
true if all parameters are strictly positive (> 0), false otherwise.

Definition at line 67 of file AudioSpec.h.

◆ operator==()

constexpr bool dspark::AudioSpec::operator== ( const AudioSpec ) const
constexprdefaultnoexcept

Default member-wise equality (C++20).

Allows processors to diff the incoming specification against their cached one to skip unnecessary re-allocations or coefficient recalculations. The comparison is exact on purpose: hosts hand over literal configuration values, not computed ones.

Member Data Documentation

◆ maxBlockSize

int dspark::AudioSpec::maxBlockSize = 0

Maximum number of samples per processing block.

Processors use this to pre-allocate internal buffers. The actual block size passed to process() may vary but will never exceed this value.

Definition at line 51 of file AudioSpec.h.

◆ numChannels

int dspark::AudioSpec::numChannels = 0

Number of audio channels (e.g., 1 = mono, 2 = stereo).

Definition at line 56 of file AudioSpec.h.

◆ sampleRate

double dspark::AudioSpec::sampleRate = 0.0

Sample rate in Hz.

Initialized to 0.0 by default to enforce explicit initialization. Processing with an uninitialized sample rate will cause immediate, observable failures (NaNs) instead of silent tuning bugs.

Definition at line 43 of file AudioSpec.h.


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