agentleFS
CassetteTapeCrackleCassetteTapeCrackle/claude-starters/skills/clean-code-audio/SKILL.md

clean-code-audio

Skill1 starsChanged 3 months agoMITView on GitHub

Use when writing JUCE/audio DSP code — real-time-safety and DSP-specific idioms (parameter smoothing, block processing, branch-free loops, denormals, message↔audio-thread model). Complements clean-code-cpp.

The file

We split this skill into the rules it gives an agent

4 rules. About 0 are common, 0 are distinctive, and 4 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈0

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 4

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Never apply a raw parameter jump in the audio path — zipper noise.

    line 15
  2. Very specific:

    Prefer branch-free math in the hot loop (select/min/max over if).

    line 19
  3. Very specific:

    Prefer float unless precision demands double.

    line 20
  4. Very specific:

    Keep DSP as pure functions/classes over buffers in Source/dsp/, decoupled from JUCE UI, so it's unit-testable with signal fixtures and …

    line 23

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Clean-code audio / DSP (depth)

Apply on top of the audio-plugin base rules (RT-audio non-negotiables, DSP-is-sacred, golden-buffer tests, pluginval). Also use clean-code-cpp.

The two-thread model

  • The audio thread (processBlock) and the message thread (UI, params) never share mutable state via locks.
  • Pass parameters across with std::atomic or a lock-free FIFO; the audio thread only reads smoothed snapshots.

Parameter smoothing

  • Never apply a raw parameter jump in the audio path — zipper noise. Smooth it (juce::SmoothedValue or a one-pole) and read per-sample or per-block.

The inner loop

  • Process in blocks; hoist invariants out of the per-sample loop.
  • Prefer branch-free math in the hot loop (select/min/max over if); branches stall the pipeline and hurt determinism.
  • Prefer float unless precision demands double. Flush denormals (ScopedNoDenormals), and design filters/feedback so denormals don't accumulate.

Testability & sacredness

  • Keep DSP as pure functions/classes over buffers in Source/dsp/, decoupled from JUCE UI, so it's unit-testable with signal fixtures and golden buffers (impulse, sine sweep).
  • processBlock stays a thin dispatcher: read the smoothed parameters, then call DSP functions that take the buffer and their state as arguments.
  • Randomness (noise, dither, humanize) comes from a preallocated RNG the caller passes in and seeds. Tests use a fixed seed, so golden buffers stay reproducible.
  • DSP is sacred: a golden-buffer test failing on a non-DSP change means something leaked into the algorithm — stop and fix the boundary, don't update the golden file.

Signals it's going wrong

  • Allocation/lock/log inside processBlock → move it to the message thread or preallocate.
  • A parameter read directly in the loop without smoothing → audible artifacts.
  • DSP logic reaching into UI/JUCE component state → break the coupling.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.