# Glacine

> Sustainer: turn Hold on and the current sound is captured and held indefinitely as a smooth, evolving texture, blended under or over the live signal. While held, the trigger decides when it crossfades to a fresh capture: 0 = manual (only when Hold is switched on), 1 = new note (a stable pitch change larger than Pitch change), 2 = transient, 3 = every N beats, 4 = every N bars (host grid, or the Tempo control without one). Switching Hold off lets the held sound die away over Release.

- Engine id: `org.sournd.performance.glacine`
- Category: Performance
- Licence: paid: £2.99 an effect or £4.99 a synth, once (owned for good, with updates), or included in the Everything plan (£14.99 a month)
- Version: 1.0.0
- Latency: 0 samples
- Tail: 10.5 s
- Sidechain input: no
- Channels: mono or stereo
- Audio demo: https://sournd.com/static/preview/demos/glacine.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 | `trigger` | Trigger | 0 | 4 | 0 | - | linear |
| 1 | `hold` | Hold | 0 | 1 | 0 | - | linear |
| 2 | `sensitivity` | Sensitivity | 0 | 100 | 50 | % | linear |
| 3 | `pitch_cents` | Pitch change | 10 | 200 | 50 | cents | linear |
| 4 | `every` | Every | 1 | 16 | 1 | - | linear |
| 5 | `fade` | Fade | 5 | 2000 | 150 | ms | log |
| 6 | `release` | Release | 10 | 10000 | 1500 | ms | log |
| 7 | `texture` | Texture | 0 | 100 | 40 | % | linear |
| 8 | `low_cut` | Low cut | 20 | 2000 | 20 | Hz | log |
| 9 | `high_cut` | High cut | 1000 | 20000 | 20000 | Hz | log |
| 10 | `tempo` | Tempo | 40 | 300 | 120 | bpm | linear |
| 11 | `mix` | Mix | 0 | 100 | 50 | % | 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.performance.glacine" };
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.performance.glacine", &e) == SOURND_OK) {
    sournd_engine_prepare(e, 48000.0, 512);
    sournd_engine_set_param(e, 0, 0); /* Trigger */
    sournd_engine_process(e, in, out, 2, frames);
    sournd_engine_destroy(e);
}
```

## How it is made

Original sOURnd design: a continuously recorded input history, post-attack captures that are level-evened when they decay, and an overlapped cloud of Hann-windowed grains at randomised positions with power normalisation, so the hold has no loop to hear. Triggers come from a relative-level transient detector, a YIN-style pitch tracker and the transport grid. Inspired by our own earlier hardware sustain block; no third-party code or audio.

## Ask your AI

Paste this into your coding assistant:

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