Phrase mode: audio engine (groups, clicks, blanking), raw frame bus, trainer hook

This commit is contained in:
2026-09-14 00:50:47 +02:00
parent 7c5632fab6
commit c7f1fa170b
5 changed files with 700 additions and 12 deletions

View File

@@ -1,6 +1,7 @@
import { useEffect, useRef, useState } from 'react';
import { PitchAnalyzer, type MicrophoneDebugInfo } from '../audio/PitchAnalyzer';
import { frequencyToMidi, getNoteDetails, getCentDifference } from '../music/NoteUtils';
import { emitRawFrame } from './rawFrameBus';
import {
MIC_DEFAULT_SENSITIVITY,
PITCH_READING_HOLD_MS,
@@ -91,6 +92,11 @@ export function usePitchDetector(
const freq = analyzer.getPitch();
const now = performance.now();
// RAW frame for sequence matching (phrase mode): one per tick,
// silence included. Not batched through React state — matching
// must see nulls immediately and must not depend on render rate.
emitRawFrame({ midi: freq ? frequencyToMidi(freq) : null, at: now });
if (freq) {
lastPitchAt = now;
const midi = frequencyToMidi(freq);