|
DSPark 1.6.1
Header-only audio DSP framework in pure C++20 — zero dependencies
|
Monophonic-buffer chord recognition with confidence gating. More...
#include <ChordDetector.h>
Classes | |
| struct | Result |
| One detection result. More... | |
Public Types | |
| enum class | ChordType : uint8_t { None = 0 , Major , Minor , Diminished , Augmented , Sus2 , Sus4 , Dominant7 , Major7 , Minor7 , HalfDim7 } |
| Recognized chord families. More... | |
Public Member Functions | |
| void | prepare (const AudioSpec &spec, int windowSize=4096) |
| Prepares the analysis pipeline. | |
| void | reset () noexcept |
| Clears the analysis ring and forgets the held chord. | |
| void | setConfidenceThreshold (float threshold) noexcept |
| Confidence below which the previous chord is held (default 0.55). | |
| float | getConfidenceThreshold () const noexcept |
| void | processBlock (AudioBufferView< const T > buffer) noexcept |
| Feeds a block (channels averaged to mono). | |
| void | pushSamples (std::span< const T > samples) noexcept |
| Feeds mono samples directly. | |
| Result | getChord () const noexcept |
Static Public Member Functions | |
| static int | getChordName (const Result &result, char *dest, int size) noexcept |
| Writes a human-readable chord name ("C", "F#m7", "Bbsus4"...). | |
Monophonic-buffer chord recognition with confidence gating.
| T | Sample type (float or double). |
Definition at line 59 of file ChordDetector.h.
|
strong |
Recognized chord families.
| Enumerator | |
|---|---|
| None | |
| Major | |
| Minor | |
| Diminished | |
| Augmented | |
| Sus2 | |
| Sus4 | |
| Dominant7 | |
| Major7 | |
| Minor7 | |
| HalfDim7 | |
Definition at line 63 of file ChordDetector.h.
|
inlinenoexcept |
Definition at line 176 of file ChordDetector.h.
|
inlinestaticnoexcept |
Writes a human-readable chord name ("C", "F#m7", "Bbsus4"...).
| result | Chord to name. |
| dest | Destination buffer. |
| size | Capacity of dest (8+ recommended). |
Definition at line 188 of file ChordDetector.h.
|
inlinenoexcept |
Definition at line 140 of file ChordDetector.h.
|
inline |
Prepares the analysis pipeline.
| spec | Audio environment specification. |
| windowSize | Analysis window (default 4096: ~85 ms at 48 kHz). |
Definition at line 84 of file ChordDetector.h.
|
inlinenoexcept |
Feeds a block (channels averaged to mono).
Definition at line 148 of file ChordDetector.h.
|
inlinenoexcept |
Feeds mono samples directly.
Definition at line 166 of file ChordDetector.h.
|
inlinenoexcept |
Clears the analysis ring and forgets the held chord.
Allocation-free, but it rewrites the stream state: call it from the thread that owns the stream (or while processing is stopped), not concurrently with processBlock()/pushSamples().
Definition at line 118 of file ChordDetector.h.
|
inlinenoexcept |
Confidence below which the previous chord is held (default 0.55).
Callable from any thread. Non-finite values are ignored (a NaN would make every comparison false and freeze the detector on the held chord forever).
Definition at line 133 of file ChordDetector.h.