# Pairo

> Correlation and balance meter: phase correlation from -1 (inverted) to +1 (mono), left/right balance and mid and side levels. Audio passes untouched.

- Engine id: `org.sournd.analysis.pairo`
- Category: Analysis
- 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: 0 s
- Sidechain input: no
- Channels: mono or stereo
- Audio demo: https://sournd.com/static/preview/demos/pairo.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 | `response_ms` | Response | 10 | 3000 | 300 | ms | log |

## Readouts

Read with `sournd_engine_readout_value` on the audio thread.

| Index | Key | Name | Kind | Min | Max | Unit |
|---|---|---|---|---|---|---|
| 0 | `correlation` | Correlation | meter | -1 | 1 | - |
| 1 | `balance` | Balance | meter | -1 | 1 | - |
| 2 | `mid_db` | Mid | level | -120 | 30 | dBFS |
| 3 | `side_db` | Side | level | -120 | 30 | dBFS |

## 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.analysis.pairo" };
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.analysis.pairo", &e) == SOURND_OK) {
    sournd_engine_prepare(e, 48000.0, 512);
    sournd_engine_set_param(e, 0, 300); /* Response */
    sournd_engine_process(e, in, out, 2, frames);
    sournd_engine_destroy(e);
}
```

## How it is made

Original sOURnd meter blending general techniques: a normalised cross-correlation of the two channels, an energy balance and mid/side RMS, all over one exponential window.

## Ask your AI

Paste this into your coding assistant:

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

## Related engines

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

- [Plumb](https://sournd.com/engines/plumb/index.md): Free. Level meter: per-channel sample peak with a falling needle, RMS and a peak hold. Audio passes untouched.
- [Metrin](https://sournd.com/engines/metrin/index.md): Free. Tempo detector: estimates beats per minute from the onsets in the last eight seconds, within a chosen range, with a confidence. Audio passes untouched.
- [Tunra](https://sournd.com/engines/tunra/index.md): Free. Chromatic tuner: the nearest note, how many cents sharp or flat, the frequency and how sure it is, against an adjustable A4. Audio passes untouched.
- [Heft](https://sournd.com/engines/heft/index.md): Paid. Loudness meter: momentary (400 ms), short-term (3 s) and gated integrated loudness in LUFS, loudness range and 4x-oversampled true peak, against a target. Audio passes untouched.
- [Huescope](https://sournd.com/engines/huescope/index.md): Paid. Spectrum meter: 31 third-octave band levels from 20 Hz to 20 kHz with an optional display tilt, plus peak and RMS. Audio passes untouched.
