/** * Detail object emitted with the 'play' event. * Contains playback time, formatted time, and percentage played. */ export interface PlayEventDetail { /** Seconds played so far. */ timePlayed: number; /** Formatted time string (mm:ss). */ formattedTimePlayed: string; /** Percentage of buffer played (0-100). */ percentagePlayed: number; } /** * Listener for custom playback events. */ interface EventListener { /** Event name (e.g. 'play'). */ name: string; /** Callback for event detail. */ cb: (detail: PlayEventDetail) => void; } /** * High-level wrapper for real-time pitch shifting using ScriptProcessorNode. * Handles buffering, playback tracking, and parameter control. * * @remarks * Provides pitch, rate, and tempo control for an AudioBuffer source. * Emits 'play' events for playback progress. */ export default class PitchShifter { /** Internal SoundTouch processor. */ private _soundtouch; /** Internal filter for sample processing. */ private _filter; /** Internal ScriptProcessorNode for audio output. */ _node: ScriptProcessorNode; /** Seconds played so far. */ timePlayed: number; /** Current sample position in buffer. */ sourcePosition: number; /** Duration of the source buffer (seconds). */ duration: number; /** Sample rate of the audio context. */ sampleRate: number; /** Registered event listeners. */ listeners: EventListener[]; /** * Creates a PitchShifter instance for an AudioBuffer. * @param context AudioContext or OfflineAudioContext * @param buffer Source AudioBuffer * @param bufferSize Size of ScriptProcessorNode buffer * @param onEnd Callback when playback ends */ constructor(context: BaseAudioContext, buffer: AudioBuffer, bufferSize: number, onEnd?: () => void); /** * Returns formatted duration string (mm:ss). */ get formattedDuration(): string; /** * Returns formatted time played string (mm:ss). */ get formattedTimePlayed(): string; /** * Returns percentage of buffer played (0-100). */ get percentagePlayed(): number; /** * Sets playback position by percentage. * @param perc Percentage (0-100). */ set percentagePlayed(perc: number); /** * Returns the ScriptProcessorNode for audio output. */ get node(): ScriptProcessorNode; /** * Sets pitch factor. * @param pitch Pitch factor. */ set pitch(pitch: number); /** * Sets pitch in semitones. * @param semitone Pitch semitones. */ set pitchSemitones(semitone: number); /** * Sets playback rate. * @param rate Rate factor. */ set rate(rate: number); /** * Sets playback tempo. * @param tempo Tempo factor. */ set tempo(tempo: number); /** * Connects the ScriptProcessorNode to another AudioNode. * @param toNode Destination AudioNode. */ connect(toNode: AudioNode): void; /** * Disconnects the ScriptProcessorNode from its destination. */ disconnect(): void; /** * Registers an event listener for custom playback events. * @param eventName Event name (e.g. 'play'). * @param cb Callback for event detail. */ on(eventName: string, cb: (detail: PlayEventDetail) => void): void; /** * Removes event listeners for custom playback events. * @param eventName Event name to remove (or all if null). */ off(eventName?: string | null): void; } export {}; //# sourceMappingURL=PitchShifter.d.ts.map