# Torpora

> Tape stop: the sound slows down and drops in pitch to a halt over the stop time, then spins back up over the start time (0 = cut straight back in). Curve bends the slowdown from a sudden drag (negative) to a long coast (positive). Trigger: 0 = the Stop control (on above half), 1 = the host transport stopping and starting, 2 = either.

- Engine id: `org.sournd.performance.torpora`
- Category: Performance
- Licence: free (Apache-2.0, in the open framework)
- 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: 0 samples
- Tail: 4.5 s
- Sidechain input: no
- Channels: mono or stereo
- Audio demo: https://sournd.com/static/preview/demos/torpora.mp3 (a drum loop, default settings)
- Live preview: https://sournd.com/engines/torpora/ (runs the real engine in the browser; test sounds or the user's own file)

## 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 | `stop` | Stop | 0 | 1 | 0 | - | linear |
| 1 | `trigger` | Trigger | 0 | 2 | 0 | - | linear |
| 2 | `stop_ms` | Stop time | 50 | 4000 | 800 | ms | log |
| 3 | `start_ms` | Start time | 0 | 4000 | 300 | ms | linear |
| 4 | `curve` | Curve | -1 | 1 | 0 | - | linear |
| 5 | `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.torpora" };
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.torpora", &e) == SOURND_OK) {
    sournd_engine_prepare(e, 48000.0, 512);
    sournd_engine_set_param(e, 0, 0); /* Stop */
    sournd_engine_process(e, in, out, 2, frames);
    sournd_engine_destroy(e);
}
```

## How it is made

Original sOURnd design: a stereo ring buffer read behind the write point at a variable speed following a power-curve ramp (the read lag grows by one minus the speed each sample), linear-interpolated reads, a level fade over the last quarter of the speed range, and an equal-power hand-back to the live signal after spin-up; triggered by control or transport edges.

## Ask your AI

Paste this into your coding assistant:

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