plugin-architecture-patterns
Clean architecture patterns for JUCE plugins including separation of concerns, APVTS patterns, state management, preset systems, MIDI handling, and modulation routing. Use when designing plugin architecture, refactoring code structure, implementing parameter systems, building preset managers, or scaling complex audio plugins.
What this skill does
# Plugin Architecture Patterns
Master architectural patterns for building maintainable, testable, and scalable audio plugins using clean architecture, separation of concerns, and JUCE best practices.
## Overview
This skill provides comprehensive guidance on structuring JUCE audio plugins using proven architectural patterns. It covers separation of DSP from UI, state management, preset systems, parameter handling, MIDI routing, and modulation architectures.
## When to Use This Skill
- Designing a new plugin architecture from scratch
- Refactoring an existing plugin for better maintainability
- Implementing complex state management or modulation routing
- Planning multi-format plugin support (VST3/AU/AAX)
- Building plugins that need to scale (many parameters, voices, effects)
## Core Architectural Principles
### 1. Separation of Concerns
Audio plugins have distinct responsibilities that should be isolated:
```
┌─────────────────────────────────────────────────┐
│ Plugin Host │
└─────────────────────┬───────────────────────────┘
│
┌───────────┴───────────┐
│ │
┌─────▼──────┐ ┌─────▼──────┐
│ Processor │ │ Editor │
│ (Audio) │◄────────┤ (UI) │
└─────┬──────┘ └────────────┘
│
┌─────▼──────┐
│ DSP Engine │
└─────┬──────┘
│
┌─────▼──────┬──────────┬───────────┐
│ Filter │ Envelope │ Oscillator│
└────────────┴──────────┴───────────┘
```
**Key Separations:**
- **DSP Logic** - Pure audio processing, realtime-safe
- **Parameter Management** - Value storage, automation, presets
- **UI Layer** - Rendering, user interaction (not realtime-safe)
- **State Management** - Serialization, preset loading/saving
---
## Architecture Pattern 1: Clean Architecture
### Layer Structure
```
┌──────────────────────────────────────────┐
│ Presentation Layer (UI) │ ← JUCE Components, Graphics
├──────────────────────────────────────────┤
│ Application Layer (Processor) │ ← AudioProcessor, parameter handling
├──────────────────────────────────────────┤
│ Domain Layer (DSP Core) │ ← Pure audio algorithms
├──────────────────────────────────────────┤
│ Infrastructure (JUCE Framework) │ ← JUCE modules, OS/DAW interface
└──────────────────────────────────────────┘
```
**Dependency Rule:** Outer layers depend on inner layers, never the reverse.
### Example: Clean Architecture in JUCE
```cpp
// ============================================================================
// Domain Layer - Pure DSP (no JUCE dependencies except juce::dsp)
// ============================================================================
// Source/DSP/FilterCore.h
class FilterCore {
public:
void setFrequency(float hz, float sampleRate) {
// Pure calculation, no allocations
coefficients = calculateCoefficients(hz, sampleRate);
}
float processSample(float input) noexcept {
// Realtime-safe processing
return filter.processSample(input, coefficients);
}
void reset() noexcept {
filter.reset();
}
private:
struct Coefficients { float b0, b1, b2, a1, a2; };
Coefficients coefficients;
BiquadFilter filter;
static Coefficients calculateCoefficients(float hz, float sampleRate);
};
// ============================================================================
// Application Layer - Parameter Management
// ============================================================================
// Source/PluginProcessor.h
class MyPluginProcessor : public juce::AudioProcessor {
public:
MyPluginProcessor()
: parameters(*this, nullptr, "Parameters", createParameterLayout())
{
// Connect parameters to DSP
cutoffParam = parameters.getRawParameterValue("cutoff");
}
void prepareToPlay(double sampleRate, int samplesPerBlock) override {
filterCore.reset();
currentSampleRate = sampleRate;
}
void processBlock(juce::AudioBuffer<float>& buffer, juce::MidiBuffer&) override {
// Update DSP from parameters (thread-safe)
float cutoff = cutoffParam->load();
filterCore.setFrequency(cutoff, currentSampleRate);
// Process audio
for (int ch = 0; ch < buffer.getNumChannels(); ++ch) {
auto* data = buffer.getWritePointer(ch);
for (int i = 0; i < buffer.getNumSamples(); ++i) {
data[i] = filterCore.processSample(data[i]);
}
}
}
void getStateInformation(juce::MemoryBlock& destData) override {
auto state = parameters.copyState();
std::unique_ptr<juce::XmlElement> xml(state.createXml());
copyXmlToBinary(*xml, destData);
}
void setStateInformation(const void* data, int sizeInBytes) override {
std::unique_ptr<juce::XmlElement> xml(getXmlFromBinary(data, sizeInBytes));
if (xml && xml->hasTagName(parameters.state.getType()))
parameters.replaceState(juce::ValueTree::fromXml(*xml));
}
private:
juce::AudioProcessorValueTreeState parameters;
std::atomic<float>* cutoffParam;
FilterCore filterCore; // Domain layer object
double currentSampleRate = 44100.0;
static juce::AudioProcessorValueTreeState::ParameterLayout createParameterLayout();
};
// ============================================================================
// Presentation Layer - UI
// ============================================================================
// Source/PluginEditor.h
class MyPluginEditor : public juce::AudioProcessorEditor {
public:
MyPluginEditor(MyPluginProcessor& p)
: AudioProcessorEditor(&p), processor(p)
{
// Attach UI to parameters (APVTS handles thread-safety)
cutoffAttachment = std::make_unique<SliderAttachment>(
processor.getParameters(), "cutoff", cutoffSlider
);
addAndMakeVisible(cutoffSlider);
}
private:
using SliderAttachment = juce::AudioProcessorValueTreeState::SliderAttachment;
MyPluginProcessor& processor;
juce::Slider cutoffSlider;
std::unique_ptr<SliderAttachment> cutoffAttachment;
};
```
**Benefits:**
- ✅ DSP is testable without JUCE (can unit test `FilterCore` standalone)
- ✅ UI changes don't affect DSP
- ✅ Easy to swap DSP implementations
- ✅ Clear separation of realtime-safe vs non-realtime code
---
## Architecture Pattern 2: Parameter-Centric Architecture
### Using AudioProcessorValueTreeState (APVTS)
JUCE's APVTS is the recommended way to manage parameters:
```cpp
// Parameters.h - Centralized parameter definitions
namespace Parameters {
inline const juce::ParameterID cutoff { "cutoff", 1 };
inline const juce::ParameterID resonance { "resonance", 1 };
inline const juce::ParameterID gain { "gain", 1 };
inline juce::AudioProcessorValueTreeState::ParameterLayout createLayout() {
std::vector<std::unique_ptr<juce::RangedAudioParameter>> params;
params.push_back(std::make_unique<juce::AudioParameterFloat>(
cutoff,
"Cutoff",
juce::NormalisableRange<float>(20.0f, 20000.0f, 0.01f, 0.3f), // Skew for log
1000.0f
));
params.push_back(std::make_unique<juce::AudioParameterFloat>(
resonance,
"Resonance",
juce::NormalisableRange<float>(0.1f, 10.0f),
1.0f
));
params.push_back(std::make_unique<juce::AudioParameterFloat>(
gain,
"Gain",
juce::NormalisableRange<float>(-24.0f, 24.0f),
0.0f
));
return { params.begin(), params.end() };
}
}
// PluginProcessor.h
class MyPluginProcessor : public juce::AudioProcessor {
public:
MyPluginProcessor()
: apvts(*this, nullptr, "Parameters", Parameters::createLayout())
{
// Get raw parameterRelated in Image & Video
watch
IncludedWatch a video (URL or local path). Downloads with yt-dlp, extracts auto-scaled frames with ffmpeg, pulls the transcript from captions (or Whisper API fallback), and hands the result to Claude so it can answer questions about what's in the video.
physical-ai-defect-image-generation
IncludedUse when the user wants to orchestrate defect image generation, run associated setup, or handle outputs on OSMO. The Day 0 path handles cold-start with USD-to-ROI, image-edit augmentation, and AnomalyGen to create initial PCBA datasets. The Day 1 path performs inference and labeling on real images. This skill helps with first-time asset setup, creation of finetuning checkpoints, and configuring deployment. Trigger keywords: defect image generation, dig workflow, dig pipeline, defect image detection workflow, aoi pipeline, aoi anomalygen, usd2roi anomalygen, day 0 pcba, day 1 pcba, day 1 real-photo alignment, day 1 manual roi, metal surface anomaly, glass defect, anomalygen finetune, setup_pcb, setup_metal, setup_glass, setup_pretrained, dig setup, dig datasets, dig pretrained checkpoint, dig image-edit endpoint.
accelint-react-best-practices
IncludedReact performance optimization and best practices. ALWAYS use this skill when working with any React code - writing components, hooks, JSX; refactoring; optimizing re-renders, memoization, state management; reviewing for performance; fixing hydration mismatches; debugging infinite re-renders, stale closures, input focus loss, animations restarting; preventing remounting; implementing transitions, lazy initialization, effect dependencies. Even simple React tasks benefit from these patterns. Covers React 19+ (useEffectEvent, Activity, ref props). Triggers - useEffect, useState, useMemo, useCallback, memo, inline components, nested components, components inside components, re-render, performance, hydration, SSR, Next.js, useDeferredValue, combined hooks.
elevenlabs-agents
IncludedBuild conversational AI voice agents with ElevenLabs Platform using React, JavaScript, React Native, or Swift SDKs. Configure agents, tools (client/server/MCP), RAG knowledge bases, multi-voice, and Scribe real-time STT. Use when: building voice chat interfaces, implementing AI phone agents with Twilio, configuring agent workflows or tools, adding RAG knowledge bases, testing with CLI "agents as code", or troubleshooting deprecated @11labs packages, Android audio cutoff, CSP violations, dynamic variables, or WebRTC config. Keywords: ElevenLabs Agents, ElevenLabs voice agents, AI voice agents, conversational AI, @elevenlabs/react, @elevenlabs/client, @elevenlabs/react-native, @elevenlabs/elevenlabs-js, @elevenlabs/agents-cli, elevenlabs SDK, voice AI, TTS, text-to-speech, ASR, speech recognition, turn-taking model, WebRTC voice, WebSocket voice, ElevenLabs conversation, agent system prompt, agent tools, agent knowledge base, RAG voice agents, multi-voice agents, pronunciation dictionary, voice speed control, elevenlabs scribe, @11labs deprecated, Android audio cutoff, CSP violation elevenlabs, dynamic variables elevenlabs, case-sensitive tool names, webhook authentication
humanizer
IncludedHumanize AI-generated text by detecting and removing patterns typical of LLM output. Rewrites text to sound natural, specific, and human. Uses 28 pattern detectors, 560+ AI vocabulary terms across 3 tiers, and statistical analysis (burstiness, type-token ratio, readability) for comprehensive detection. Use when asked to humanize text, de-AI writing, make content sound more natural/human, review writing for AI patterns, score text for AI detection, or improve AI-generated drafts. Covers content, language, style, communication, and filler categories.
generating-mermaid-diagrams
IncludedSalesforce architecture diagrams using Mermaid with ASCII fallback. Use this skill when generating text-based diagrams for Salesforce architecture, OAuth flows, ERDs, integration sequences, or Agentforce structure. TRIGGER when: user says "diagram", "visualize", "ERD", or asks for sequence diagrams, flowcharts, class diagrams, or architecture visualizations in Mermaid. DO NOT TRIGGER when: user wants PNG/SVG image output (use generating-visual-diagrams), or asks about non-Salesforce systems.