feat: implemented v1 audio-to-midi conversion (polyphonic only, algorithm-based)
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
import {
|
||||
detectMonophonicNotesFromAudio,
|
||||
type AudioToMidiDetectedNote,
|
||||
type AudioToMidiDetectionRequest,
|
||||
} from '../util/audioToMidiCore';
|
||||
|
||||
export interface AudioToMidiWorkerResult {
|
||||
type: 'result';
|
||||
notes: AudioToMidiDetectedNote[];
|
||||
}
|
||||
|
||||
type WorkerScopeLike = typeof globalThis & {
|
||||
onmessage: ((event: MessageEvent<AudioToMidiDetectionRequest>) => void) | null;
|
||||
postMessage: (message: AudioToMidiWorkerResult) => void;
|
||||
};
|
||||
|
||||
const workerScope = self as WorkerScopeLike;
|
||||
|
||||
workerScope.onmessage = (event: MessageEvent<AudioToMidiDetectionRequest>) => {
|
||||
const notes = detectMonophonicNotesFromAudio(event.data);
|
||||
workerScope.postMessage({ type: 'result', notes });
|
||||
};
|
||||
Reference in New Issue
Block a user