# Patinor

> Lo-fi character: makes anything sound played back from a worn record or tape, with drifting pitch, flutter, crackle and dust pops, hiss, a narrow bandwidth, gentle age saturation and optional bit and sample-rate crush. The surface noise rides under the playing and fades out with it.

- Engine id: `org.sournd.distortion.patinor`
- Category: Distortion
- 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: 256 samples
- Tail: 2 s
- Sidechain input: no
- Channels: mono or stereo
- Audio demo: https://sournd.com/static/preview/demos/patinor.mp3 (a bass line, 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 | `wow` | Wow | 0 | 100 | 20 | % | linear |
| 1 | `flutter` | Flutter | 0 | 100 | 15 | % | linear |
| 2 | `crackle` | Crackle | 0 | 100 | 20 | % | linear |
| 3 | `dust` | Dust | 0 | 100 | 10 | % | linear |
| 4 | `hiss` | Hiss | 0 | 100 | 10 | % | linear |
| 5 | `low_cut_hz` | Low cut | 20 | 1000 | 60 | Hz | log |
| 6 | `high_cut_hz` | High cut | 1000 | 20000 | 9000 | Hz | log |
| 7 | `bits` | Bits | 4 | 16 | 16 | bits | linear |
| 8 | `rate_hz` | Rate | 2000 | 48000 | 48000 | Hz | log |
| 9 | `age` | Age | 0 | 100 | 30 | % | linear |
| 10 | `mix` | Mix | 0 | 100 | 100 | % | linear |
| 11 | `output_db` | Output | -24 | 12 | 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.distortion.patinor" };
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.distortion.patinor", &e) == SOURND_OK) {
    sournd_engine_prepare(e, 48000.0, 512);
    sournd_engine_set_param(e, 0, 20); /* Wow */
    sournd_engine_process(e, in, out, 2, frames);
    sournd_engine_destroy(e);
}
```

## How it is made

Original sOURnd design blending general techniques: a sine-plus-random-drift and two-sine modulated fractional delay for wow and flutter with a fixed centre delay reported as latency, band-limiting biquads, tanh saturation, sample-and-hold rate reduction with mid-tread quantisation, and probabilistic impulse noise through resonant filters gated by an input envelope follower.

## Ask your AI

Paste this into your coding assistant:

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