/** * Preload & Cache System * * Prevents stuttering when seeking by pre-loading and caching: * - MIDI events in range * - Soundfont samples for instruments * - Lyrics in range * - Audio buffers */ export interface PreloadRange { startTime: number; endTime: number; } export interface CacheStats { midiEventsCached: number; instrumentsCached: number; lyricsCached: number; cacheHits: number; cacheMisses: number; } /** * MIDI Event Cache * Pre-cache MIDI events for smooth seeking */ export declare class MIDIEventCache { private cache; private stats; /** * Pre-cache MIDI events in time range */ preloadRange(midiData: any, range: PreloadRange): void; /** * Get cached events for time */ getEventsAt(time: number, lookAhead?: number): any[]; /** * Find cache key containing time */ private findCacheKey; /** * Clear cache */ clear(): void; /** * Get cache stats */ getStats(): CacheStats; } /** * Instrument Cache * Pre-warm soundfont instruments */ export declare class InstrumentCache { private warmedInstruments; private synthesizer; setSynthesizer(synth: any): void; /** * Pre-warm instruments used in MIDI */ warmupInstruments(midiData: any): Promise; /** * Check if instrument is warmed up */ isWarmed(program: number): boolean; /** * Clear cache */ clear(): void; /** * Get warmed instruments count */ getWarmCount(): number; } /** * Lyric Cache * Pre-render lyrics for smooth display */ export declare class LyricCache { private cache; private preRenderRange; /** * Pre-render lyrics around time */ preloadAround(lyrics: any[], currentTime: number, renderFn: (lyric: any) => string): void; /** * Get cached lyric */ get(index: number): string | null; /** * Check if lyric is cached */ has(index: number): boolean; /** * Set pre-render range */ setPreRenderRange(seconds: number): void; /** * Clear cache */ clear(): void; /** * Get cache size */ size(): number; } /** * Seek Optimizer * Smooth seeking with pre-buffering */ export declare class SeekOptimizer { private midiCache; private instrumentCache; private lyricCache; private isPreloading; private preloadPromise; constructor(); /** * Initialize with MIDI and synthesizer */ initialize(midiData: any, synthesizer: any): Promise; /** * Pre-load range before seeking */ preloadRange(midiData: any, lyrics: any[], range: PreloadRange, lyricRenderFn: (lyric: any) => string): Promise; private _doPreload; /** * Optimized seek with pre-buffering */ seek(targetTime: number, midiData: any, lyrics: any[], lyricRenderFn: (lyric: any) => string, seekFn: (time: number) => void): Promise; /** * Get MIDI cache */ getMIDICache(): MIDIEventCache; /** * Get instrument cache */ getInstrumentCache(): InstrumentCache; /** * Get lyric cache */ getLyricCache(): LyricCache; /** * Get cache stats */ getStats(): CacheStats; /** * Clear all caches */ clear(): void; } /** * Progressive Preloader * Progressively preload entire song in background */ export declare class ProgressivePreloader { private optimizer; private chunkSize; private isPreloading; private currentChunk; constructor(optimizer: SeekOptimizer); /** * Start progressive preloading */ startPreloading(midiData: any, lyrics: any[], duration: number, lyricRenderFn: (lyric: any) => string): Promise; /** * Stop preloading */ stop(): void; /** * Get preload progress (0-1) */ getProgress(duration: number): number; /** * Set chunk size */ setChunkSize(seconds: number): void; }