Files
serumalt/Source/synth/AGENTS.md
T
biggy e4cea300db chore: land janitor round 1 and graft integration
Round 1 findings and fixes, all previously uncommitted:
- FXProcessor per-slot DSP history repair (HEAD does not compile without it)
- SynthVoice::getModulationValue, editor control-lock guard
- ExactCompare.h naming the deliberate exact float comparisons
- KnobLookAndFeel replacing the never-installed SerumLookAndFeel
- 55 first-party compiler warnings to 0
- AGENT.md renamed to AGENTS.md across Source/
- graft repository context graph and its hooks
- JANITOR_TASKS.md and UI_UX_AUDIT.md records
2026-10-06 08:50:45 +02:00

2.0 KiB

synth module

This directory contains guidance. All files listed below remain in the parent Source/ directory.

  • 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

// BAD: lazy table build reached from the render path allocates on the audio thread
const Wavetable& wt = library.getTable (wave);
// 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
// BAD: raw pi literal duplicated across files
const double step = 6.28318530717958647692 * freq / sr;
// GOOD: single source
const double step = juce::MathConstants<double>::twoPi * freq / sr;

This file overrides /AGENTS.md where they conflict.