DSPark 1.8.0
Header-only C++20 DSP for real-time and offline audio
Loading...
Searching...
No Matches
ProcessorTraits.h
1// DSPark -- Professional Audio DSP Framework
2// Copyright (c) 2026 Cristian Moresi -- MIT License
3
4#pragma once
5
49#include "AudioSpec.h"
50#include "AudioBuffer.h"
51
52#include <concepts>
53
54namespace dspark {
55
81template <typename P, typename T>
82concept AudioProcessor = requires(P p, const AudioSpec& spec, AudioBufferView<T> buf) {
83 { p.prepare(spec) }; // Can throw/allocate (offline phase)
84 { p.processBlock(buf) } noexcept; // Real-time hot path
85 { p.reset() } noexcept; // Must be safe to call from audio thread
86} && !requires(P p, AudioBufferView<const T> c) {
87 p.processBlock(c); // In-place: a const view must NOT bind
88};
89
101template <typename P, typename T>
103 requires(P p, T sample, int channel) {
104 { p.processSample(sample, channel) } noexcept -> std::same_as<T>;
105 };
106
120template <typename P, typename T>
121concept GeneratorProcessor = requires(P p, const AudioSpec& spec, AudioBufferView<T> buf) {
122 { p.prepare(spec) };
123 { p.reset() } noexcept;
124 { p.generateBlock(buf) } noexcept; // Mandatory for SIMD/Cache optimization
125 { p.getSample() } noexcept -> std::same_as<T>; // Strict type matching
126} && !requires(P p, AudioBufferView<const T> c) {
127 p.generateBlock(c); // Writes: a const view must NOT bind
128};
129
130} // namespace dspark
Non-owning view over audio channel data.
Definition AudioBuffer.h:50
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.