DSPark 1.6.1
Header-only audio DSP framework in pure C++20 — zero dependencies
Loading...
Searching...
No Matches
ProcessorTraits.h
Go to the documentation of this file.
1// DSPark -- Professional Audio DSP Framework
2// Copyright (c) 2026 Cristian Moresi -- MIT License
3
4#pragma once
5
36#include "AudioSpec.h"
37#include "AudioBuffer.h"
38
39#include <concepts>
40
41namespace dspark {
42
54template <typename P, typename T>
55concept AudioProcessor = requires(P p, const AudioSpec& spec, AudioBufferView<T> buf) {
56 { p.prepare(spec) }; // Can throw/allocate (offline phase)
57 { p.processBlock(buf) } noexcept; // Real-time hot path
58 { p.reset() } noexcept; // Must be safe to call from audio thread
59};
60
72template <typename P, typename T>
74 requires(P p, T sample, int channel) {
75 { p.processSample(sample, channel) } noexcept -> std::same_as<T>;
76 };
77
88template <typename P, typename T>
89concept GeneratorProcessor = requires(P p, const AudioSpec& spec, AudioBufferView<T> buf) {
90 { p.prepare(spec) };
91 { p.reset() } noexcept;
92 { p.generateBlock(buf) } noexcept; // Mandatory for SIMD/Cache optimization
93 { p.getSample() } noexcept -> std::same_as<T>; // Strict type matching
94};
95
96} // namespace dspark
Owning audio buffer and non-owning view for real-time DSP processing.
Describes the audio processing environment (sample rate, block size, channels).
A type that can prepare, process audio blocks, and reset state.
A real-time safe source processor (oscillators, noise, LFOs).
An AudioProcessor that additionally supports scalar per-sample processing.
Main namespace for the DSPark framework.