Squash of 54 work commits (Sep 1–12):6251f7cai-hub: body domain — live pose packets ride the realtime sessionea50c77chat_ui: the feed's session gets its profile brief backf51b5f3ai-body: the crate for the native SAM 3D Body port, with its weights reader8211ae6ai-body: the MHR rig and the pose head's parameter decoding, oracle-exact9e343a8ai-body: the DINOv3 ViT-H+/16 backbone, crop and ray conditioning; Metal gains rope-half and affine layer norm69d842cai-body: the promptable pose decoder and its refinement loop, oracle-matched on Metal66e5e2fai-hub: SAM 3D Body runs natively — `sam3dbody` on the body domain, oracle-matched end to enda634198ai-hub: the body-native commit carried a peer's in-flight hub hunks; put them back where they were9ff44e8ai-hub: the body-native wiring, this time only the lane's hunks6a1c16bai-body: third-party notices — what the port is implemented after, and what it is notd78411aai-body: the per-step work moves to the GPUb22259bai-body: the context stays on the GPU; only the pose token leaves the loop346f31fai-body: flash attention for the head-dim-64 blocks45b5b98ai-body: the crop size is a runtime knob, and the loop reports where its time goes4be6d19ai-body: the test modules import the grid constants they still use7598346ai-body: tensor-core GEMMs for the backbone, and the rig's correctives only where they counta9ce596ai-body: the crop warp runs across cores8964ba6ai-body: an FP8 backbone mode, off by default, measured against the oraclea2aaa8fai-body: the FP8 bias rides a column-broadcast add on the deviced53c77dmetal: a device-resident ViT stack, and the body backbone rides itd006d0ametal: resident f32 linears keep their weight on the device525ba1cmetal: a device-resident two-way decoder layer, and the body decoder rides itc9e6d88ai-body: the hands pass — hand crops, the hand decoder, the hand-mode rig and the wrist fusion62dff26ai-body: the mask prompt — a person's segmentation mask conditions the body passa648cf8ai-hub: body session options — hands, detect, persons=N8c568dfai-hub: drop the SAM 3D Body reference worker backend7ff875aai-hub: keep a peer's in-flight beats/notes/local work out of the body commits31e5faaai-hub: local model runner, licence acknowledgements, a shared install panel; Beat This!, Basic Pitch and the Salamander drum-kit entriesb94bc58ai-services: the wire, the app port and the panel state — one conversation, many apps2acb798ai-services: wire v2 — endpoints, receiver-side caps, result disposition8ae0ffbai-services: the engine core — registry, router and conversation, tested against a scripted model2308736ai-services: the real models behind the engine feature — local through the hub, Claude, and nonec3f631dlivepipe: one reusable pipe from a camera to a fleet node and backff62db3ai libs: the runtime env-var cleanup — precision is a per-caller policy, not an environment side channel04a94efrealtime: one service-log line when a live session opens and one when it closes0ecb81cai models: the model-crates env-var cleanup — 172 research knobs gone, the unset default is the code4ca36c1ai hub + services: the assistant's model comes from wherever it is resident — the fleet chat box, with tools, then the local weights432121eaichat engine + wm: launch, then use — the assistant continues in the same turn once the app it started is on the bus7a5bf69ai-hub registry: the Salamander drumkit samples come from the makepad.nl mirror — the GitHub repo only carries the .sfz files102ffc5ai-services: messages on the bus — a manifest declares topics, the engine subscribes on a tool's behalf or by ToolResult.subscribe, a service publishes Message frames, an idle conversation wakes on a message as an event turn under rate laws; the WM bus forwards the new frames; every app that matches the wire gets its arma837792hub + flow: a whitespace-only chat completion is retried once and then fails instead of passing as an answer; a flow's model is a fleet model id unless it names a weight file on disk; chat models show under the text domain in /v1/modelsbc6c620hub + flow: what the chat review found — the in-process route retries an empty completion too, a node says whether its prefill opened thinking so a brief-mode answer is never discarded, a preferred model falls back to normal election when no node has it, discovery keeps looking for the preferred model until patience runs out75c3441hub: the PRO 6000 serves image as well as chat and textad5e98bhub registry: flux2-dev's VRAM estimate is its measured peak, 30 GBc7241e0hub: a node that evicted every resident releases its cached allocator pool before refusing a load or publishing usable VRAM30575f0flow: route generation by request workload1be1e21ai-hub: gate downloads by disk capacity and recover fleet admission df6b394 filesystem_watcher, bounded_http, ai services: live and tool prerequisites 79ebdb9 ai-hub: add a native Pixal3D image-to-3D backend 0ba0d74 ai-hub: propagate typed refusals under reject queue policy cc6c872 Speed up H3 conditioning and video decoding e512059 Fix Qwen vision residency and generated material colors 2864f68 ai-hub http client: bound every plain TCP connect to 3 s per address 3d93229 ai: CUDA is a Linux/Windows-only dependency; the hub library defaults to llm + stt Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
121 lines
4.3 KiB
Rust
121 lines
4.3 KiB
Rust
use makepad_ai_notes::config::{AUDIO_N_SAMPLES, SAMPLE_RATE};
|
|
use makepad_ai_notes::{NotesModel, MODEL_FILE};
|
|
use std::path::{Path, PathBuf};
|
|
|
|
fn checkpoint() -> PathBuf {
|
|
Path::new(env!("CARGO_MANIFEST_DIR"))
|
|
.join("../../../../local/models/weights/basic_pitch/nmp.onnx")
|
|
}
|
|
|
|
fn frequency(midi: f64) -> f64 {
|
|
440.0 * 2.0f64.powf((midi - 69.0) / 12.0)
|
|
}
|
|
|
|
fn attacked_sine(midi: f64, seconds: f64) -> Vec<f32> {
|
|
let samples = (seconds * SAMPLE_RATE as f64).round() as usize;
|
|
(0..samples)
|
|
.map(|index| {
|
|
let time = index as f64 / SAMPLE_RATE as f64;
|
|
let attack = (time / 0.008).min(1.0);
|
|
let release = ((seconds - time) / 0.015).clamp(0.0, 1.0);
|
|
(0.75 * attack * release
|
|
* (std::f64::consts::TAU * frequency(midi) * time).sin()) as f32
|
|
})
|
|
.collect()
|
|
}
|
|
|
|
fn has_note_near(notes: &[makepad_ai_notes::NoteEvent], midi: u8, start: f64) -> bool {
|
|
notes
|
|
.iter()
|
|
.any(|note| note.midi == midi && (note.start_secs - start).abs() <= 0.040)
|
|
}
|
|
|
|
#[test]
|
|
fn silence_produces_no_notes() {
|
|
let mut model = NotesModel::load(checkpoint()).unwrap();
|
|
let result = model.transcribe(&vec![0.0; AUDIO_N_SAMPLES]).unwrap();
|
|
assert!(result.notes.is_empty());
|
|
}
|
|
|
|
#[test]
|
|
fn four_note_bass_line_has_expected_pitches_and_onsets() {
|
|
let mut audio = Vec::new();
|
|
for midi in [28.0, 33.0, 38.0, 43.0] {
|
|
audio.extend(attacked_sine(midi, 0.5));
|
|
}
|
|
let mut model = NotesModel::load(checkpoint()).unwrap();
|
|
let result = model.transcribe(&audio).unwrap();
|
|
assert_eq!(result.notes.len(), 4, "unexpected bass notes: {:?}", result.notes);
|
|
for (midi, start) in [(28, 0.0), (33, 0.5), (38, 1.0), (43, 1.5)] {
|
|
assert!(
|
|
has_note_near(&result.notes, midi, start),
|
|
"missing MIDI {midi} near {start:.2}s; got {:?}",
|
|
result.notes
|
|
);
|
|
}
|
|
}
|
|
|
|
#[test]
|
|
fn c_major_triad_is_simultaneous() {
|
|
let voices = [attacked_sine(60.0, 0.7), attacked_sine(64.0, 0.7), attacked_sine(67.0, 0.7)];
|
|
let mut audio = vec![0.0f32; voices[0].len()];
|
|
for voice in voices {
|
|
for (sample, value) in audio.iter_mut().zip(voice) {
|
|
*sample += value / 3.0;
|
|
}
|
|
}
|
|
let mut model = NotesModel::load(checkpoint()).unwrap();
|
|
let result = model.transcribe(&audio).unwrap();
|
|
assert_eq!(result.notes.len(), 3, "unexpected triad notes: {:?}", result.notes);
|
|
for midi in [60, 64, 67] {
|
|
assert!(
|
|
has_note_near(&result.notes, midi, 0.0),
|
|
"missing triad MIDI {midi}; got {:?}",
|
|
result.notes
|
|
);
|
|
}
|
|
}
|
|
|
|
#[test]
|
|
fn one_semitone_glide_has_rising_bends() {
|
|
let seconds = 0.8;
|
|
let samples = (seconds * SAMPLE_RATE as f64) as usize;
|
|
let mut phase = 0.0f64;
|
|
let mut audio = Vec::with_capacity(samples);
|
|
for index in 0..samples {
|
|
let time = index as f64 / SAMPLE_RATE as f64;
|
|
let midi = 45.0 + time / seconds;
|
|
phase += std::f64::consts::TAU * frequency(midi) / SAMPLE_RATE as f64;
|
|
let envelope = (time / 0.008).min(1.0) * ((seconds - time) / 0.015).clamp(0.0, 1.0);
|
|
audio.push((0.75 * envelope * phase.sin()) as f32);
|
|
}
|
|
let mut model = NotesModel::load(checkpoint()).unwrap();
|
|
let result = model.transcribe(&audio).unwrap();
|
|
let note = result
|
|
.notes
|
|
.iter()
|
|
.filter(|note| note.midi == 45 || note.midi == 46)
|
|
.max_by(|a, b| a.end_secs.total_cmp(&b.end_secs))
|
|
.unwrap_or_else(|| panic!("missing gliding A; got {:?}", result.notes));
|
|
let reversals = note.bends.windows(2).filter(|pair| pair[1] < pair[0]).count();
|
|
assert!(reversals <= 1, "non-rising bend trend: {:?}", note.bends);
|
|
assert!(note.bends.last().unwrap_or(&0.0) > note.bends.first().unwrap_or(&0.0));
|
|
}
|
|
|
|
#[test]
|
|
fn overlap_seam_does_not_duplicate_a_sustained_note() {
|
|
let audio = attacked_sine(45.0, 2.4);
|
|
let mut model = NotesModel::load(checkpoint()).unwrap();
|
|
let result = model.transcribe(&audio).unwrap();
|
|
let long_a_notes = result
|
|
.notes
|
|
.iter()
|
|
.filter(|note| note.midi == 45 && note.end_secs - note.start_secs > 0.4)
|
|
.count();
|
|
assert_eq!(long_a_notes, 1, "seam duplicated A2: {:?}", result.notes);
|
|
}
|
|
|
|
#[test]
|
|
fn model_file_constant_matches_registry_cache_name() {
|
|
assert_eq!(MODEL_FILE, "basic_pitch_nmp.onnx");
|
|
}
|