|
| 1 | +declare module 'waveform-data' { |
| 2 | + |
| 3 | + type Options = { |
| 4 | + /* optional props to override defaults */ |
| 5 | + scale?: number, |
| 6 | + amplitude_scale?: number, |
| 7 | + split_channels?: boolean |
| 8 | + } |
| 9 | + |
| 10 | + export type WaveformAudioContextOptions = { |
| 11 | + audio_context: AudioContext |
| 12 | + array_buffer: ArrayBuffer |
| 13 | + } & Options; |
| 14 | + |
| 15 | + export type WaveformAudioBufferOptions = { |
| 16 | + audio_buffer: AudioBuffer |
| 17 | + } & Options |
| 18 | + |
| 19 | + export type WaveformFromAudioCallback = (error: null | DOMException, instance?: WaveformData, audioBuffer?: AudioBuffer) => void |
| 20 | + |
| 21 | + export type JsonWaveformData = { |
| 22 | + version: number |
| 23 | + channels: number |
| 24 | + sample_rate: number |
| 25 | + samples_per_pixel: number |
| 26 | + bits: number |
| 27 | + length: number |
| 28 | + data: Array<number> |
| 29 | + } |
| 30 | + |
| 31 | + export type WaveformDataChannel = { |
| 32 | + min_sample: (index: number) => number |
| 33 | + max_sample: (index: number) => number |
| 34 | + min_array: () => Array<number> |
| 35 | + max_array: () => Array<number> |
| 36 | + } |
| 37 | + |
| 38 | + declare class WaveformData { |
| 39 | + resample: (options: number | { width: number, scale: number }) => WaveformData; |
| 40 | + concat: (...args: Array<WaveformData>) => WaveformData; |
| 41 | + readonly length: number; |
| 42 | + readonly bits: number; |
| 43 | + readonly duration: number; |
| 44 | + readonly pixels_per_second: number; |
| 45 | + readonly seconds_per_pixel: number; |
| 46 | + readonly channels: number; |
| 47 | + channel: (index: number) => WaveformDataChannel; |
| 48 | + readonly sample_rate: number; |
| 49 | + readonly scale: number; |
| 50 | + at_time: (time: number) => number; |
| 51 | + time: (time: number) => number; |
| 52 | + |
| 53 | + static create: (data: ArrayBuffer | JsonWaveformData) => WaveformData; |
| 54 | + static createFromAudio: (options: WaveformAudioContextOptions | WaveformAudioBufferOptions, callback: WaveformFromAudioCallback) => void; |
| 55 | + } |
| 56 | + |
| 57 | + export = WaveformData; |
| 58 | +} |
0 commit comments