# Rippet

> Grid stutter: once per interval, at the offset, it rolls the dice and may grab a short slice and stutter it for the gate length, each repeat optionally dropping in pitch and level. Locks to the host grid; without one it runs on its own Tempo. Interval: 0 = 1 beat, 1 = 2 beats, 2 = 1 bar, 3 = 2 bars, 4 = 4 bars. Offset and Gate count sixteenth notes. Repeat: 0 = 1/32, 1 = 1/16, 2 = 1/8, 3 = 1/4, 4 = 1/2. The same seed and song position always make the same decision.

- Engine id: `org.sournd.performance.rippet`
- 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: 25 s
- Sidechain input: no
- Channels: mono or stereo
- Audio demo: https://sournd.com/static/preview/demos/rippet.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 | `interval` | Interval | 0 | 4 | 2 | - | linear |
| 1 | `offset` | Offset | 0 | 15 | 8 | 1/16 | linear |
| 2 | `repeat` | Repeat | 0 | 4 | 1 | - | linear |
| 3 | `gate` | Gate | 1 | 64 | 4 | 1/16 | linear |
| 4 | `chance` | Chance | 0 | 100 | 50 | % | linear |
| 5 | `pitch_decay` | Pitch decay | 0 | 12 | 0 | st | linear |
| 6 | `fade_db` | Fade | 0 | 6 | 0 | dB | linear |
| 7 | `seed` | Seed | 1 | 64 | 1 | - | linear |
| 8 | `tempo` | Tempo | 40 | 300 | 120 | bpm | linear |
| 9 | `mix` | Mix | 0 | 100 | 100 | % | 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.rippet" };
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.rippet", &e) == SOURND_OK) {
    sournd_engine_prepare(e, 48000.0, 512);
    sournd_engine_set_param(e, 0, 2); /* Interval */
    sournd_engine_process(e, in, out, 2, frames);
    sournd_engine_destroy(e);
}
```

## How it is made

Original sOURnd design: grid events from the bar-relative musical clock, a seeded hash of the event index against the chance, capture of one slice into preallocated memory while the live signal passes, then looped replay with per-repeat resampling ratio and gain, raised-sine edges and a live-path crossfade.

## Ask your AI

Paste this into your coding assistant:

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