- 36 files move into the module whose AGENTS.md already claimed them: Engine/, Synth/, Modulation/, Params/, Plugin/, GUI/, EffectUnits/, Resources/ - Source/engine, modulation, params, plugin and synth become Engine, Modulation, Params, Plugin and Synth, matching the directories that already hold code - ExactCompare.h stays at the Source/ root as the one shared header - SERUMALT_INCLUDE_DIRS adds one include directory per module, so the 31 parent-relative includes become plain names with no path prefix - the module AGENTS.md files list owned files instead of describing a move that had not happened, and README.md and AGENTS.md describe the real tree Verified: the harness passes CTest, the Linux VST3 and Standalone link, the Windows cross-build passes its module checks, each configure exposes only its own targets, no first-party warning line appears, and the generated Windows manifest is unchanged.
56 lines
1.9 KiB
Markdown
56 lines
1.9 KiB
Markdown
# synth module
|
|
|
|
## Owned files
|
|
|
|
- Wavetable.h, Wavetable.cpp
|
|
- Oscillator.h, Oscillator.cpp
|
|
- SubOscillator.h, SubOscillator.cpp
|
|
- NoiseOscillator.h, NoiseOscillator.cpp
|
|
- Envelope.h, Envelope.cpp
|
|
- LFO.h, LFO.cpp
|
|
- Filter.h, Filter.cpp
|
|
- FilterBank.h, FilterBank.cpp
|
|
- SynthVoice.h, SynthVoice.cpp
|
|
|
|
## Rules
|
|
|
|
- Use `noexcept` on every per-sample DSP path and cheap getter.
|
|
- Use `std::array` for fixed-size state and `std::vector<float>` for delay lines and table buffers.
|
|
- Size every buffer and delay line in `prepare()`, never in `process` or `render`.
|
|
- Clamp filter and envelope state so extreme settings cannot produce NaN or inf.
|
|
- Use `juce::MathConstants<T>::pi` and `twoPi` instead of raw pi literals.
|
|
- Use `(size_t)` casts when indexing containers with int loop variables.
|
|
- Pass global per-block state into voices as a `const RenderContext&`.
|
|
- Never allocate memory in the audio path.
|
|
- Keep oscillator phase when changing held-note parameters. LFO phase offsets are separate from the running phase.
|
|
|
|
## IF-THEN
|
|
|
|
- Wavetables are prebuilt during Engine construction. Audio and GUI code read them without triggering generation.
|
|
- IF a parameter is read every block THEN snapshot it into a struct (`OscParams`, `RenderContext`) instead of reading the APVTS per sample.
|
|
|
|
## Examples
|
|
|
|
```cpp
|
|
// BAD: lazy table build reached from the render path allocates on the audio thread
|
|
const Wavetable& wt = library.getTable (wave);
|
|
```
|
|
|
|
```cpp
|
|
// GOOD: build once in the Engine constructor, then only read const references
|
|
library.prebuild(); // in the Engine constructor
|
|
const Wavetable& wt = library.getTable (wave); // lookup, no allocation
|
|
```
|
|
|
|
```cpp
|
|
// BAD: raw pi literal duplicated across files
|
|
const double step = 6.28318530717958647692 * freq / sr;
|
|
```
|
|
|
|
```cpp
|
|
// GOOD: single source
|
|
const double step = juce::MathConstants<double>::twoPi * freq / sr;
|
|
```
|
|
|
|
This file overrides /AGENTS.md where they conflict.
|