# Merlon

> Adaptive loudness limiter: an optional soft clipper shaves the sharpest peaks, a soft knee eases into the ceiling, and the release recovers fast after isolated peaks but slows while the limiter works continuously, so dense material does not pump.

- Engine id: `org.sournd.dynamics.merlon`
- Category: Dynamics
- Licence: free: a closed library, free to use in your plugins, downloaded with no account or email
- Download (no account or email): https://sournd.com/download/free/macos (macOS universal), https://sournd.com/download/free/linux (Linux x86_64 and aarch64) or https://sournd.com/download/free/windows (Windows x64). One archive with every free engine: static library, C headers, README.
- Version: 1.0.0
- Latency: 143 samples
- Tail: 0.05 s
- Sidechain input: no
- Channels: mono or stereo
- Audio demo: https://sournd.com/static/preview/demos/merlon.mp3 (a drum loop, default settings)

## Parameters

The id is the C ABI parameter id and the JUCE parameter id (as a decimal string).

| Id | Key | Name | Min | Max | Default | Unit | Taper |
|---|---|---|---|---|---|---|---|
| 0 | `input_db` | Input | 0 | 24 | 0 | dB | linear |
| 1 | `ceiling_db` | Ceiling | -24 | 0 | -1 | dB | linear |
| 2 | `release_ms` | Release | 10 | 1000 | 150 | ms | log |
| 3 | `adapt_pct` | Adaptive release | 0 | 100 | 60 | % | linear |
| 4 | `knee_db` | Knee | 0 | 6 | 1 | dB | linear |
| 5 | `clip_db` | Clip stage | 0 | 6 | 0 | dB | linear |

## Use it in JUCE

CMake ([quick start](/docs/juce/index.md)):

```cmake
juce_add_module(path/to/sournd_engine)
target_include_directories(MyPlugin PRIVATE path/to/include)
target_link_libraries(MyPlugin PRIVATE sournd_engine path/to/libsournd_cabi.a)
```

C++:

```cpp
#include <sournd_engine/sournd_engine.h>

sournd::SourndEngine engine { "org.sournd.dynamics.merlon" };
juce::AudioProcessorValueTreeState parameters { *this, nullptr, "Parameters",
    sournd::SourndEngineParameters::createLayout (engine) };
sournd::SourndEngineParameters bridge { engine, parameters };

// prepareToPlay
engine.prepare ({ sampleRate, (juce::uint32) maximumBlock, 2 });
bridge.prepare (sampleRate);
setLatencySamples ((int) engine.latency());

// processBlock
bridge.apply ((uint32_t) buffer.getNumSamples());
juce::dsp::AudioBlock<float> block { buffer };
engine.process (juce::dsp::ProcessContextReplacing<float> { block });

// get/setStateInformation: hold getCallbackLock() around saveState / loadState,
// so state work never overlaps processBlock (full example: /docs/juce/)
```

Plain C:

```c
sournd_engine *e = NULL;
if (sournd_engine_create("org.sournd.dynamics.merlon", &e) == SOURND_OK) {
    sournd_engine_prepare(e, 48000.0, 512);
    sournd_engine_set_param(e, 0, 0); /* Input */
    sournd_engine_process(e, in, out, 2, frames);
    sournd_engine_destroy(e);
}
```

## How it is made

Original sOURnd design blending general techniques: 2x oversampled soft clipping, stereo-linked peak detection with a quadratic soft knee, sliding-window minimum and box-filter lookahead ramp, and a programme-dependent release driven by how long gain reduction has been sustained.

## Ask your AI

Paste this into your coding assistant:

```text
Add the sournd engine org.sournd.dynamics.merlon to my JUCE plugin. Follow https://sournd.com/docs/juce/index.md
and the engine reference at https://sournd.com/engines/merlon/index.md. Expose every parameter through APVTS.
```

## Related engines

Other [dynamics engines](https://sournd.com/engines/category/dynamics/index.md):

- [Clampa](https://sournd.com/engines/clampa/index.md): Free. Punchy peak compressor: fast peak sensing with a firm knee, a punch control that lets transients through ahead of the gain reduction, and a parallel mix.
- [Attaq](https://sournd.com/engines/attaq/index.md): Free. Transient shaper: boost or soften the attack of each hit and lift or tuck its sustain, independent of level, with a speed control for tight or loose envelopes and a clip-safe output.
- [Ceilwall](https://sournd.com/engines/ceilwall/index.md): Paid. Transparent lookahead brickwall limiter: the gain ramps down before each peak arrives so the output never passes the ceiling, then recovers with a smooth release.
- [Hushel](https://sournd.com/engines/hushel/index.md): Paid. Dynamic EQ band: a bell that cuts only while its own band is louder than the threshold. Set it high and narrow-ish for de-essing; the wide control moves the cut from the band to the whole signal.
- [Levella](https://sournd.com/engines/levella/index.md): Paid. Slow, smooth leveller: long-window RMS sensing, a wide knee and a two-stage release that recovers quickly from short peaks and slowly after sustained loud passages.
- [Sluice](https://sournd.com/engines/sluice/index.md): Paid. Gate and downward expander: opens above the threshold, closes below it minus the hysteresis after the hold time, and expands at the chosen ratio down to the range floor.
- [Unisill](https://sournd.com/engines/unisill/index.md): Paid. Glue compressor: RMS sensing that blends feed-forward and feedback detection, a soft knee and a release that speeds up on transient material and relaxes on sustained material.
