Add root AGENT.md with project conventions, build verification steps, source layout, style rules, and real-time/concurrency requirements. Add per-module AGENT.md files for each existing and proposed source subdirectory. Add AUDIT_REPORT.md as a historical Phase 1 snapshot documenting memory management, error handling, concurrency model, naming conventions, and anti-pattern catalog.
1.4 KiB
1.4 KiB
engine module
Related source files
This directory contains guidance; the implementation remains in ../Engine.h
and ../Engine.cpp. The preparation rules below are requirements for changes;
current buffer resizing and lazy wavetable issues are recorded in the root AGENT.md.
Rules
- Own the voice pool, LFOs, wavetable library, FX rack, matrix and macros by value.
- Read every APVTS value through the null-guarding
v()helper. - Build the
RenderContextonce per block and pass it to voices asconst&. - Size
mixBufferonce inprepare()and onlyclear()it per block. - Prebuild wavetables in
prepare()before the first render. - Clamp the final output with the soft limiter.
- Never call
setSizeon any buffer insideprocessBlock.
IF-THEN
- IF a per-block buffer is needed THEN allocate it in
prepare()and clear it per block. - IF a module needs the matrix, macros or wavetables THEN go through Engine accessors rather than reaching into another module.
Examples
// BAD: per-callback buffer reconfiguration on the audio thread
void processBlock (...)
{
mixBuffer.setSize (2, n, false, false, true);
...
}
// GOOD: size once, clear per block
void prepare (double sr, int blockSize)
{
mixBuffer.setSize (2, blockSize, false, false, true);
}
void processBlock (...)
{
mixBuffer.clear();
...
}
This file overrides /AGENT.md where they conflict.