# Northnote

> Pitch correction for voices and single-note lines: pulls every note to the nearest note of your key and scale (chromatic, major, minor, pentatonics or your own 12-note set) at a speed from natural to a hard snap at 0 ms, with humanise to leave held notes and vibrato alone.

- Engine id: `org.sournd.pitch.northnote`
- Category: Pitch
- 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: 1024 samples
- Tail: 0.1 s
- Sidechain input: no
- Channels: mono or stereo
- Audio demo: https://sournd.com/static/preview/demos/northnote.mp3 (plucked chords, 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 | `key` | Key | 0 | 11 | 0 | - | linear |
| 1 | `scale` | Scale | 0 | 5 | 0 | - | linear |
| 2 | `note_c` | C | 0 | 1 | 1 | - | linear |
| 3 | `note_cs` | C# | 0 | 1 | 1 | - | linear |
| 4 | `note_d` | D | 0 | 1 | 1 | - | linear |
| 5 | `note_ds` | D# | 0 | 1 | 1 | - | linear |
| 6 | `note_e` | E | 0 | 1 | 1 | - | linear |
| 7 | `note_f` | F | 0 | 1 | 1 | - | linear |
| 8 | `note_fs` | F# | 0 | 1 | 1 | - | linear |
| 9 | `note_g` | G | 0 | 1 | 1 | - | linear |
| 10 | `note_gs` | G# | 0 | 1 | 1 | - | linear |
| 11 | `note_a` | A | 0 | 1 | 1 | - | linear |
| 12 | `note_as` | A# | 0 | 1 | 1 | - | linear |
| 13 | `note_b` | B | 0 | 1 | 1 | - | linear |
| 14 | `retune_ms` | Retune | 0 | 400 | 40 | ms | linear |
| 15 | `humanise` | Humanise | 0 | 100 | 0 | % | linear |
| 16 | `reference_hz` | Reference | 415 | 466 | 440 | Hz | linear |
| 17 | `amount` | Amount | 0 | 100 | 100 | % | linear |
| 18 | `formant` | Formant keep | 0 | 1 | 1 | - | linear |
| 19 | `mix` | Mix | 0 | 100 | 100 | % | linear |
| 20 | `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.pitch.northnote" };
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.pitch.northnote", &e) == SOURND_OK) {
    sournd_engine_prepare(e, 48000.0, 512);
    sournd_engine_set_param(e, 0, 0); /* Key */
    sournd_engine_process(e, in, out, 2, frames);
    sournd_engine_destroy(e);
}
```

## How it is made

Original sOURnd design blending general techniques: a YIN pitch tracker with full-rate refinement, nearest-allowed-note quantisation against a 12-note mask and a reference pitch, one-pole retune smoothing lengthened on held notes (humanise), and pitch-synchronous overlap-add grains that keep the formants.

## Ask your AI

Paste this into your coding assistant:

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