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:
1 parent
7c873f2bd0
commit
adfb2c0287
66 files changed
+2246
-261
No files matched your search
@@ -1,4 +1,4 @@
|
||||
use anvil_core::{Engine, Monitor, Settings, Source};
|
||||
use anvil_core::{Engine, Mode, Monitor, Settings, Source};
|
||||
use common_dsp::Saw;
|
||||
|
||||
const RATE: f32 = 48000.;
|
||||
@@ -488,3 +488,73 @@ fn the_audition_finds_where_kick_and_sub_sum() {
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn unsure_tracking_brings_back_the_original_sub() {
|
||||
let (mut e, l) = engine(Settings::default());
|
||||
// A clear note, then low noise the tracker cannot read.
|
||||
let mut x = notes(&[(0.1, 0.6, 55., 0.5)], 0.6);
|
||||
let mut seed = 3u32;
|
||||
let mut lp = 0f32;
|
||||
for _ in 0..seconds(1.5) {
|
||||
seed ^= seed << 13;
|
||||
seed ^= seed >> 17;
|
||||
seed ^= seed << 5;
|
||||
lp += 0.05 * ((seed as f32 / u32::MAX as f32 - 0.5) - lp);
|
||||
x.push(4. * lp);
|
||||
}
|
||||
let solo = render(&mut e, &x, true);
|
||||
let sine = rms(&solo[seconds(0.3) + l..seconds(0.5) + l]);
|
||||
let unsure = rms(&solo[seconds(1.5) + l..seconds(2.0) + l]);
|
||||
assert!(
|
||||
db(unsure) < db(sine) - 40.,
|
||||
"{} vs {}",
|
||||
db(unsure),
|
||||
db(sine)
|
||||
);
|
||||
// The full output carries the original low band again.
|
||||
let (mut e, l) = engine(Settings::default());
|
||||
let y = render(&mut e, &x, false);
|
||||
let a = rms(&x[seconds(1.5)..seconds(2.0)]);
|
||||
let b = rms(&y[seconds(1.5) + l..seconds(2.0) + l]);
|
||||
assert!((db(a) - db(b)).abs() < 1., "{} vs {}", db(a), db(b));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn enhance_keeps_the_original_and_adds_the_sine() {
|
||||
let x = tones(&[(55., 0.3)], 1.2);
|
||||
for (mode, keeps) in [(Mode::Replace, false), (Mode::Enhance, true)] {
|
||||
let (mut e, l) = engine(Settings {
|
||||
mode,
|
||||
octave: -1,
|
||||
..Settings::default()
|
||||
});
|
||||
let y = render(&mut e, &x, false);
|
||||
// Whole cycles of 27.5 Hz: 0.4 s.
|
||||
let w = &y[seconds(0.5) + l..seconds(0.9) + l];
|
||||
let original = amplitude(w, 55.);
|
||||
let added = amplitude(w, 27.5);
|
||||
assert!((db(added) + 9.).abs() < 1., "{mode:?}: {}", db(added));
|
||||
if keeps {
|
||||
assert!((db(original) - db(0.3)).abs() < 1., "{}", db(original));
|
||||
} else {
|
||||
assert!(db(original) < db(0.3) - 12., "{}", db(original));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn note_mode_plays_the_set_note_whatever_the_audio() {
|
||||
let (mut e, l) = engine(Settings {
|
||||
source: Source::Note,
|
||||
pitch: common_dsp::tracker::Pitch {
|
||||
note: 29,
|
||||
..Default::default()
|
||||
},
|
||||
..Settings::default()
|
||||
});
|
||||
let x = notes(&[(0.1, 1.1, 61.74, 0.5)], 1.3);
|
||||
let y = render(&mut e, &x, true);
|
||||
let f = frequency(&y[seconds(0.3) + l..seconds(1.0) + l]);
|
||||
assert!((f / 43.654 - 1.).abs() < 0.005, "{f}");
|
||||
}
|
||||
Reference in new issue
Block a user