@amplib/music-detection

GitHub ↗

DetectTone

DetectTone detects notes and possible chords in real time.

DetectTone({ audioContext: AudioContext }): { async initialize({ source: AudioBufferSourceNode | MediaElementAudioSourceNode | MediaStreamAudioSourceNode }): void; tick(): { change: boolean; label: string; guess: { chord: Chord; key: string; presence: number; }; notes: DetectToneChordTracking[]; } }

const detector = new DetectTone({ audioContext });
detector.initialize({ source });
loop();

function loop() {
  requestAnimationFrame(loop);
  detector.tick();
}