UNPKG

wave-roll

Version:

JavaScript Library for Comparative MIDI Piano-Roll Visualization

64 lines 2.75 kB
import { ParsedMidi, NoteData, TempoEvent } from "@/lib/midi/types"; /** * Convert a list of `NoteData` into parallel arrays of intervals and pitches. * @param notes Array of `NoteData` objects * @returns Tuple of intervals [[onset, offset], …] and pitches (MIDI numbers) */ export declare function notesToIntervalsAndPitches(notes: NoteData[]): { intervals: [number, number][]; pitches: number[]; }; /** * Convenience wrapper to extract intervals and pitches directly from `ParsedMidi`. */ export declare function parsedMidiToIntervalsAndPitches(parsed: ParsedMidi): { intervals: [number, number][]; pitches: number[]; }; /** * Validate inputs akin to mir_eval.transcription.validate * Ensures array lengths match and intervals are well-formed. * Throws an Error when validation fails. */ export declare function validateTranscriptionInputs(reference_intervals: [number, number][], reference_pitches: number[], estimated_intervals: [number, number][], estimated_pitches: number[]): void; /** * Convert MIDI pitches to chroma (pitch class in [0, 12)). */ export declare function toChromaPitches(pitches: number[]): number[]; /** * Compute intersection-over-union (IoU) for two intervals [a0,a1], [b0,b1]. */ export declare function intervalIoU(a: [number, number], b: [number, number]): number; /** * Extract the initial BPM from a MIDI file's tempo events. * Uses the tempo event at or closest to time=0. * Falls back to DEFAULT_BPM (120) if no tempo events are present. * * @param tempos - Array of tempo events from ParsedMidi.header.tempos * @returns The initial BPM value (clamped between 20 and 300) */ export declare function getInitialBpm(tempos: TempoEvent[] | undefined): number; /** * Scale time intervals from one BPM to another. * This is used to align estimated MIDI notes to the reference BPM * when the two files have different tempos. * * Formula: scaledTime = originalTime * (targetBpm / sourceBpm) * * @param intervals - Array of [onset, offset] time intervals in seconds * @param sourceBpm - The original BPM of the intervals * @param targetBpm - The target BPM to scale to * @returns Scaled intervals with times adjusted for the target BPM */ export declare function scaleIntervalsForBpm(intervals: [number, number][], sourceBpm: number, targetBpm: number): [number, number][]; /** * Extract intervals, pitches, and BPM from a ParsedMidi object. * This is an extended version of parsedMidiToIntervalsAndPitches that * also extracts BPM information for tempo-aware matching. */ export declare function parsedMidiToIntervalsAndPitchesWithBpm(parsed: ParsedMidi): { intervals: [number, number][]; pitches: number[]; bpm: number; }; //# sourceMappingURL=utils.d.ts.map