UNPKG

wave-roll

Version:

JavaScript Library for Comparative MIDI Piano-Roll Visualization

79 lines 3.18 kB
import { MidiInput } from "@/lib/midi/types"; import { MidiExportOptions } from "@/lib/components/player/wave-roll/types"; /** * Generate a filename for the exported MIDI file. * * @param originalName - Original filename (optional) * @param newTempo - The new tempo in BPM * @returns Generated filename */ export declare function generateExportFilename(originalName: string | undefined, newTempo: number): string; /** * Get the original filename from a MidiInput. * * @param input - MidiInput (File or URL string) * @returns Original filename or undefined */ export declare function getOriginalFilename(input: MidiInput): string | undefined; /** * Export a MIDI file with a modified tempo. * * This function loads the original MIDI file, updates only the tempo metadata * (preserving all note ticks/times), and triggers a download of the modified file. * * Note: Only tempo metadata is modified. Note events keep their original tick * positions, so the musical content remains unchanged - it will simply play * at a different speed in DAWs and MIDI players. * * @param originalInput - The original MIDI file (File object or URL string) * @param newTempo - The new tempo in BPM to set * @param filename - Optional custom filename for the download * @throws Error if the MIDI file cannot be loaded or processed * * @example * ```typescript * // Export with tempo changed to 144 BPM * await exportMidiWithTempo(midiFile, 144); * * // Export with custom filename * await exportMidiWithTempo(midiFile, 144, "my_song_fast.mid"); * ``` */ export declare function exportMidiWithTempo(originalInput: MidiInput, newTempo: number, filename?: string): Promise<void>; /** * Export a MIDI file with options for different export modes. * * @param originalInput - The original MIDI file (File object or URL string) * @param newTempo - The new tempo in BPM to set * @param options - Export options (mode and custom handler) * @param filename - Optional custom filename override * @throws Error if the MIDI file cannot be loaded or processed * * @example * ```typescript * // Default download mode * await performMidiExport(midiFile, 144, { mode: 'download' }); * * // Let user choose save location * await performMidiExport(midiFile, 144, { mode: 'saveAs' }); * * // Custom handler (e.g., for VS Code extension) * await performMidiExport(midiFile, 144, { * mode: 'custom', * onExport: async (blob, filename) => { * // Handle the blob as needed * } * }); * ``` */ export declare function performMidiExport(originalInput: MidiInput, newTempo: number, options?: MidiExportOptions, filename?: string): Promise<void>; /** * Export a MIDI file with tempo metadata, returning the Blob instead of triggering download. * Useful for programmatic use cases where the caller handles the file. * * @param originalInput - The original MIDI file (File object or URL string) * @param newTempo - The new tempo in BPM to set * @returns Promise resolving to Blob of the modified MIDI file */ export declare function exportMidiWithTempoAsBlob(originalInput: MidiInput, newTempo: number): Promise<Blob>; //# sourceMappingURL=midi-export.d.ts.map