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

+8 -7
View File
@@ -7,7 +7,7 @@
//! its audio by its own latency, so the strip's latency never changes. Allocation-free after
//! `new`.
mod settings;
use common_dsp::tracker::{NoteEvent, Tracked, Tracker, TrackerConfig};
use common_dsp::tracker::{NoteEvent, NoteState, Tracked, Tracker, TrackerConfig};
use common_dsp::{coefficient, hz_to_midi};
pub use settings::{Settings, Source, Stage, ORDERS, STAGES};
@@ -44,7 +44,7 @@ impl Default for AnalyzerFrame {
struct Slot {
events: [NoteEvent; EVENTS],
len: usize,
sounding: bool,
note: NoteState,
/// The undelayed input, one lookahead ahead of the audio this slot belongs to.
ahead: f32,
}
@@ -53,7 +53,7 @@ impl Default for Slot {
Self {
events: [NoteEvent::Stop; EVENTS],
len: 0,
sounding: false,
note: NoteState::default(),
ahead: 0.,
}
}
@@ -155,7 +155,8 @@ impl Engine {
/// Tracker settings and how far back each position reads the note events.
fn route(&mut self, s: &Settings) {
// Each module decides itself whether a legato note slides.
self.tracker.set(s.source == Source::Midi, s.gate, true);
self.tracker
.set(s.pitch.source(s.source.mode(), s.gate, true));
let mut at = 0;
for (i, stage) in s.order.into_iter().enumerate() {
self.offsets[i] = at;
@@ -198,7 +199,7 @@ impl Engine {
..Slot::default()
};
self.tracker.process(mono, |e| slot.push(e));
slot.sounding = self.tracker.sounding();
slot.note = self.tracker.state();
let len = self.line.len();
self.line_at = (self.line_at + 1) % len;
self.line[self.line_at] = slot;
@@ -221,7 +222,7 @@ impl Engine {
for &e in &slot.events[..slot.len] {
m.event(e);
}
v = m.process(v, slot.sounding);
v = m.process(v, slot.note);
}
// The pitch at the output: the oldest slot is the last module's input time minus its
@@ -231,7 +232,7 @@ impl Engine {
self.pitch.event(false, e);
}
self.pitch.step(1.);
self.sounding = last.sounding;
self.sounding = last.note.sure;
let len = self.dry.len();
self.dry_at = (self.dry_at + 1) % len;
+32 -17
View File
@@ -1,4 +1,5 @@
//! Host-independent controls of the strip and its modules.
use common_dsp::tracker::{Pitch, PitchMode};
use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, Copy, Serialize, Deserialize, PartialEq, Eq, Default)]
@@ -8,6 +9,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,
}
}
}
/// One module of the strip.
@@ -45,6 +64,9 @@ pub const ORDERS: [[Stage; STAGES]; 6] = [
pub struct Settings {
/// Pitch source of the one tracker every module follows.
pub source: Source,
/// Note mode's note, the key lock and Follow bends.
#[serde(default)]
pub pitch: Pitch,
/// Detection threshold in dBFS for note starts (Audio source).
pub gate: f32,
/// Modules in processing order.
@@ -60,6 +82,7 @@ impl Default for Settings {
fn default() -> Self {
Self {
source: Source::Audio,
pitch: Pitch::default(),
gate: lathe_core::Settings::default().gate,
order: ORDERS[0],
lathe: lathe_core::Settings::default(),
@@ -71,6 +94,7 @@ impl Default for Settings {
}
impl Settings {
pub fn validate(&self) -> Result<(), &'static str> {
self.pitch.validate()?;
let ok = (-60.0..=-20.).contains(&self.gate) && ORDERS.contains(&self.order);
if !ok {
return Err("invalid settings");
@@ -94,26 +118,17 @@ impl Settings {
Stage::Knurl => self.knurl.bypass = !on,
}
}
/// Copies the strip's pitch source and gate into every module.
/// Copies the strip's pitch source, pitch details and gate into every module.
pub fn share(&mut self) {
let midi = self.source == Source::Midi;
let mode = self.source.mode();
self.lathe.gate = self.gate;
self.temper.gate = self.gate;
self.knurl.gate = self.gate;
self.lathe.source = if midi {
lathe_core::Source::Midi
} else {
lathe_core::Source::Audio
};
self.temper.source = if midi {
temper_core::Source::Midi
} else {
temper_core::Source::Audio
};
self.knurl.source = if midi {
knurl_core::Source::Midi
} else {
knurl_core::Source::Audio
};
self.lathe.pitch = self.pitch;
self.temper.pitch = self.pitch;
self.knurl.pitch = self.pitch;
self.lathe.source = lathe_core::Source::from_mode(mode);
self.temper.source = temper_core::Source::from_mode(mode);
self.knurl.source = knurl_core::Source::from_mode(mode);
}
}
+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",
]
@@ -646,6 +658,7 @@ name = "forge"
version = "0.1.0"
dependencies = [
"clap-sys",
"common-params",
"crossbeam-queue",
"forge-core",
"forge-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" }
forge-core = { path = "../core" }
common-params = { path = "../../common/params" }
lathe-core = { path = "../../lathe/core" }
temper-core = { path = "../../temper/core" }
knurl-core = { path = "../../knurl/core" }
+33 -9
View File
@@ -1,3 +1,4 @@
use common_params::PitchParams;
use forge_core::{Settings, Source, ORDERS};
use knurl_core::{Seed, GRIT_OFF, STEPS, STEP_MIN};
use lathe_core::HARMONICS;
@@ -13,6 +14,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,
}
}
}
/// The six orders of `ORDERS`, in the same order.
#[derive(Enum, Debug, PartialEq, Eq, Clone, Copy)]
@@ -281,6 +302,8 @@ pub struct ForgeParams {
pub editor: Arc<EguiState>,
#[id = "source"]
pub source: EnumParam<SourceParam>,
#[nested(group = "Pitch")]
pub pitch: PitchParams,
#[id = "gate"]
pub gate: FloatParam,
#[id = "order"]
@@ -300,6 +323,7 @@ impl Default for ForgeParams {
Self {
editor: EguiState::from_size(forge_ui::WIDTH, forge_ui::HEIGHT),
source: EnumParam::new("Pitch source", SourceParam::Audio),
pitch: PitchParams::default(),
gate: linear("Gate", d.gate, -60., -20., " dB"),
order: EnumParam::new("Order", OrderParam::LatheTemperKnurl),
bypass: BoolParam::new("Bypass", false).make_bypass(),
@@ -401,10 +425,8 @@ impl ForgeParams {
.unwrap_or(0);
let curve = self.temper.curve.value();
let mut s = Settings {
source: match self.source.value() {
SourceParam::Audio => Source::Audio,
SourceParam::Midi => Source::Midi,
},
source: self.source.value().into(),
pitch: self.pitch.pitch(),
gate: self.gate.value(),
order: ORDERS[order],
lathe: lathe_core::Settings {
@@ -576,11 +598,13 @@ impl ForgeParams {
old.knurl.steps as i32,
new.knurl.steps as i32,
);
let source = |s: Source| match s {
Source::Audio => SourceParam::Audio,
Source::Midi => SourceParam::Midi,
};
switch(setter, &self.source, source(old.source), source(new.source));
switch(
setter,
&self.source,
SourceParam::from(old.source),
SourceParam::from(new.source),
);
self.pitch.apply(setter, &old.pitch, &new.pitch);
let order =
|s: &Settings| ORDER_PARAMS[ORDERS.iter().position(|o| *o == s.order).unwrap_or(0)];
switch(setter, &self.order, order(old), order(new));
+3 -7
View File
@@ -129,13 +129,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);
});
ui.add_space(6.);
panel(ui, |ui| {