feat: stable note tracking, NOTE pitch source and unsure fallback

Producers found the tracked plugins jumpy: the shared tracker switched notes
after 10 ms and retuned every 5 ms, so growls and formant basses flickered
and every tracked plugin acted on wrong notes.

Shared tracker (common-dsp):
- A new note needs a steady read for 40 ms; an octave down 80 ms, an octave
  up 200 ms (an octave-up read still fits the note's period and counts as
  agreeing). Inside a note the tuning only moves past a 0.25 semitone
  deadband. Follow bends keeps the old fast behaviour as an option.
- A trust score turns the note unsure while reads disagree; Tracker::active
  and NoteState report it, and Fallback latches "step back" across note ends.
- Notes end when the window start stays below the gate's release level for
  20 ms, so short gaps between notes are seen without waiting for the gate.
- PitchSource replaces the old (midi, gate, glide) arguments: Audio, MIDI or
  Note mode (a set note, no detection), plus a key lock (minor, major, root
  only) that snaps reads to the key.
- stems.rs: synthetic stems (growls, wobble, reese, formant, 808 slide,
  layered drop, noise riser) and a score; examples/tracker_report scores the
  corpus or real WAV stems. On the corpus the old behaviour makes up to 28
  extra note starts per second; the stable default makes none.

Plugins:
- Anvil, Lathe, Temper, Knurl, Planish, Braze and Forge gain the NOTE pitch
  source, the key lock and Follow bends (shared common-params crate and a
  shared header switch in common-ui).
- Unsure tracking: Anvil brings the original sub back in place of the sine,
  Lathe passes the audio through, Knurl fades its texture out; Temper,
  Planish and Braze hold their last sure tuning. Readouts show the note only
  when it is sure.
- Anvil gains Mode: Replace or Enhance (keeps the original sub and adds the
  sine under it).
- Planish slides its band edges over 6 ms on a new note instead of snapping.
- Ballast defaults to Grid parts, which need no tracking.
This commit is contained in:
nvrl committed 2026-11-06 21:02:52 +01:00
1 parent 7c873f2bd0
commit adfb2c0287
66 files changed
+2246 -261

No files matched your search

+6 -4
View File
@@ -8,7 +8,7 @@
//! after `new`; mono-safe (both channels get the same treatment).
mod settings;
use common_dsp::svf::{Svf, SvfCoef};
use common_dsp::tracker::{Lookahead, NoteEvent, PitchFollower, Tracked, TrackerConfig};
use common_dsp::tracker::{Lookahead, NoteEvent, NoteState, PitchFollower, Tracked, TrackerConfig};
use common_dsp::{coefficient, db_to_gain, hz_to_midi};
pub use settings::{Seed, Settings, Source, GRIT_OFF, PATTERNS, STEPS, STEP_MIN};
@@ -402,8 +402,10 @@ impl Tracked for Module {
};
self.pitch.event(self.settings.snap, e);
}
fn process(&mut self, x: [f32; 2], sounding: bool) -> [f32; 2] {
self.run(x, sounding)
fn process(&mut self, x: [f32; 2], note: NoteState) -> [f32; 2] {
// The texture needs a trusted cycle clock: it fades out while tracking is unsure, as
// it does between notes.
self.run(x, note.sure)
}
}
@@ -444,7 +446,7 @@ impl Engine {
fn set_tracker(&mut self, s: &Settings) {
self.lookahead
.tracker
.set(s.source == Source::Midi, s.gate, false);
.set(s.pitch.source(s.source.mode(), s.gate, false));
}
pub fn reset(&mut self) {
self.lookahead.reset();
+24
View File
@@ -1,4 +1,5 @@
//! Host-independent controls. Gains in dB; amounts relative to one cycle in percent.
use common_dsp::tracker::{Pitch, PitchMode};
use serde::{Deserialize, Serialize};
/// Pattern steps: one per cycle, repeating.
@@ -14,6 +15,24 @@ pub enum Source {
Audio,
/// Notes come from MIDI note input.
Midi,
/// Note starts are detected, the pitch is the set note: nothing is guessed.
Note,
}
impl Source {
pub fn mode(self) -> PitchMode {
match self {
Source::Audio => PitchMode::Audio,
Source::Midi => PitchMode::Midi,
Source::Note => PitchMode::Note,
}
}
pub fn from_mode(mode: PitchMode) -> Self {
match mode {
PitchMode::Audio => Source::Audio,
PitchMode::Midi => Source::Midi,
PitchMode::Note => Source::Note,
}
}
}
#[derive(Debug, Clone, Copy, Serialize, Deserialize, PartialEq, Eq, Default)]
@@ -29,6 +48,9 @@ pub enum Seed {
#[serde(deny_unknown_fields)]
pub struct Settings {
pub source: Source,
/// Note mode's note, the key lock and Follow bends.
#[serde(default)]
pub pitch: Pitch,
/// Gain per pattern step, 0 down to `STEP_MIN`.
pub pattern: [f32; STEPS],
/// Steps that get a grit burst.
@@ -104,6 +126,7 @@ impl Default for Settings {
fn default() -> Self {
let mut s = Self {
source: Source::Audio,
pitch: Pitch::default(),
pattern: [0.; STEPS],
grit_steps: [true; STEPS],
steps: 1,
@@ -127,6 +150,7 @@ impl Default for Settings {
}
impl Settings {
pub fn validate(&self) -> Result<(), &'static str> {
self.pitch.validate()?;
let finite = [
self.edge,
self.level_jitter,
+13
View File
@@ -309,11 +309,23 @@ dependencies = [
[[package]]
name = "common-dsp"
version = "0.1.0"
dependencies = [
"serde",
]
[[package]]
name = "common-params"
version = "0.1.0"
dependencies = [
"common-dsp",
"nih_plug",
]
[[package]]
name = "common-ui"
version = "0.1.0"
dependencies = [
"common-dsp",
"egui",
]
@@ -864,6 +876,7 @@ name = "knurl"
version = "0.2.0"
dependencies = [
"clap-sys",
"common-params",
"crossbeam-queue",
"knurl-core",
"knurl-ui",
+1
View File
@@ -13,6 +13,7 @@ crate-type = ["cdylib", "rlib"]
nih_plug = { git = "https://github.com/robbert-vdh/nih-plug.git", rev = "de421011f41a6d10fc8c7a6084e4f4dee0143683", default-features = false }
nih_plug_egui = { git = "https://github.com/robbert-vdh/nih-plug.git", rev = "de421011f41a6d10fc8c7a6084e4f4dee0143683" }
knurl-core = { path = "../core" }
common-params = { path = "../../common/params" }
knurl-ui = { path = "../ui" }
crossbeam-queue = "0.3"
serde = { version = "1", features = ["derive"] }
+28 -9
View File
@@ -1,3 +1,4 @@
use common_params::PitchParams;
use knurl_core::{Seed, Settings, Source, GRIT_OFF, STEPS, STEP_MIN};
use nih_plug::prelude::*;
use nih_plug_egui::EguiState;
@@ -10,6 +11,26 @@ pub enum SourceParam {
#[id = "midi"]
#[name = "MIDI"]
Midi,
#[id = "note"]
Note,
}
impl From<SourceParam> for Source {
fn from(s: SourceParam) -> Self {
match s {
SourceParam::Audio => Source::Audio,
SourceParam::Midi => Source::Midi,
SourceParam::Note => Source::Note,
}
}
}
impl From<Source> for SourceParam {
fn from(s: Source) -> Self {
match s {
Source::Audio => SourceParam::Audio,
Source::Midi => SourceParam::Midi,
Source::Note => SourceParam::Note,
}
}
}
#[derive(Enum, Debug, PartialEq, Eq, Clone, Copy)]
pub enum SeedParam {
@@ -50,6 +71,8 @@ pub struct KnurlParams {
pub pattern: RwLock<Pattern>,
#[id = "source"]
pub source: EnumParam<SourceParam>,
#[nested(group = "Pitch")]
pub pitch: PitchParams,
#[id = "seed"]
pub seed: EnumParam<SeedParam>,
#[id = "steps"]
@@ -86,6 +109,7 @@ impl Default for KnurlParams {
editor: EguiState::from_size(knurl_ui::WIDTH, knurl_ui::HEIGHT),
pattern: RwLock::new(Pattern::default()),
source: EnumParam::new("Pitch source", SourceParam::Audio),
pitch: PitchParams::default(),
seed: EnumParam::new("Random", SeedParam::Same),
steps: IntParam::new(
"Steps",
@@ -131,10 +155,8 @@ impl KnurlParams {
pub fn settings(&self, last: &Pattern) -> Settings {
let pattern = self.pattern.try_read().map(|p| *p).unwrap_or(*last);
Settings {
source: match self.source.value() {
SourceParam::Audio => Source::Audio,
SourceParam::Midi => Source::Midi,
},
source: self.source.value().into(),
pitch: self.pitch.pitch(),
pattern: pattern.gains.map(|g| {
if g.is_finite() {
g.clamp(STEP_MIN, 0.)
@@ -238,12 +260,9 @@ impl KnurlParams {
switch(setter, &self.bypass, new.bypass);
}
if new.source != old.source {
let v = match new.source {
Source::Audio => SourceParam::Audio,
Source::Midi => SourceParam::Midi,
};
switch(setter, &self.source, v);
switch(setter, &self.source, new.source.into());
}
self.pitch.apply(setter, &old.pitch, &new.pitch);
if new.seed != old.seed {
let v = match new.seed {
Seed::Same => SeedParam::Same,
+3 -7
View File
@@ -78,13 +78,9 @@ pub fn show(ui: &mut egui::Ui, settings: &mut Settings, state: &mut State) {
settings.bypass = !settings.bypass;
}
ui.separator();
for (source, label) in [(Source::Midi, "MIDI"), (Source::Audio, "AUDIO")] {
let r = ui.selectable_label(settings.source == source, RichText::new(label).size(13.));
if r.clicked() {
settings.source = source;
}
}
caption(ui, "PITCH FROM");
let mut mode = settings.source.mode();
pitch_from(ui, &mut mode, &mut settings.pitch);
settings.source = Source::from_mode(mode);
});
body(ui, settings, state);
ui.separator();