import { type PersistedViewerState, type ViewerMode } from "./viewer-state"; export type SoundFontSource = { url: string; label: string; custom: boolean; }; export type AudioExportWriter = { write(chunk: Uint8Array): Promise; /** Resolves with the saved file name once the export is durable. */ finish(): Promise; abort(message: string): void; }; /** Everything the player needs from its surroundings (VS Code, a web page, ...). */ export type PlayerHost = { loadState?(): unknown; saveState?(state: PersistedViewerState): void; persistViewMode?(viewMode: ViewerMode): void; /** Ask the host for another bank; the host answers with player.setSoundFont(). */ requestSoundFont?(kind: "default" | "custom"): void; /** Resolves undefined when the user cancels. Omit to hide WAV export. */ beginAudioExport?(suggestedName: string): Promise; fetchSoundBank?(url: string): Promise; onPlaybackChange?(playing: boolean): void; }; /** A recording that plays in step with the MIDI, e.g. the source mix or a stem. */ export type AudioTrackSource = { url: string; label: string; /** Seconds into the MIDI where the recording starts (negative trims its start). */ offset?: number; /** Display before this MIDI track (1-based). Omit to display above all MIDI. */ beforeMidiTrack?: number; }; export type PlayerConfig = { /** Element the player renders into. */ app: HTMLElement; /** Receives global shortcuts (Space, Escape, menu arrows). */ keyboardTarget: EventTarget; /** Receives outside clicks that close the SoundFont menu. */ pointerTarget: EventTarget; midi: string | ArrayBuffer; fileName: string; workletUrl: string; soundFont?: SoundFontSource; /** Load the bank immediately instead of on first play or export. */ preloadSoundFont?: boolean; /** Explicit starting state; its view mode overrides a remembered one. */ viewerState?: unknown; /** View used when neither viewerState nor saved state names one. */ defaultViewMode?: ViewerMode; audioTracks?: readonly AudioTrackSource[]; host: PlayerHost; }; export type MidiRealPlayer = { readonly duration: number; /** MIDI tracks plus audio tracks, once ready has resolved. */ readonly trackCount: number; readonly currentTime: number; readonly playing: boolean; readonly ready: Promise; play(): Promise; pause(): void; stop(): void; seek(seconds: number): void; /** Repaint the canvas, e.g. after the theme changed; colors are read from CSS. */ redraw(): void; setSoundFont(source: SoundFontSource): void; destroy(): void; }; export declare function createMidiRealPlayer(config: PlayerConfig): MidiRealPlayer;