/** * Digital Signal Processing utilities * FFT, windowing functions, and spectral analysis */ /** * Complex number representation */ export interface Complex { real: number; imag: number; } /** * Window function types */ export type WindowType = 'hann' | 'hamming' | 'blackman' | 'rectangular' | 'bartlett'; /** * FFT result with magnitude and phase */ export interface FFTResult { magnitude: Float32Array; phase: Float32Array; frequencies: Float32Array; } /** * Fast Fourier Transform (Cooley-Tukey radix-2 decimation-in-time) */ export declare class FFT { private size; private reversedBits; private cosTable; private sinTable; constructor(size: number); /** * Forward FFT (time domain to frequency domain) */ forward(input: Float32Array): Complex[]; /** * Get magnitude spectrum */ getMagnitude(complex: Complex[]): Float32Array; /** * Get phase spectrum */ getPhase(complex: Complex[]): Float32Array; /** * Get power spectrum (magnitude squared) */ getPowerSpectrum(complex: Complex[]): Float32Array; /** * Compute FFT and return magnitude, phase, and frequencies */ compute(input: Float32Array, sampleRate: number): FFTResult; /** * Get frequency bins */ getFrequencies(sampleRate: number): Float32Array; private isPowerOfTwo; private reverseBits; } /** * Window functions for reducing spectral leakage */ export declare class WindowFunction { /** * Create a window function of specified type and size */ static create(size: number, type?: WindowType): Float32Array; /** * Hann window (raised cosine) */ static hann(size: number): Float32Array; /** * Hamming window */ static hamming(size: number): Float32Array; /** * Blackman window */ static blackman(size: number): Float32Array; /** * Bartlett window (triangular) */ static bartlett(size: number): Float32Array; /** * Rectangular window (no windowing) */ static rectangular(size: number): Float32Array; /** * Apply window to signal */ static apply(signal: Float32Array, window: Float32Array): Float32Array; } /** * Spectral analysis utilities */ export declare class SpectralAnalysis { /** * Find spectral peaks */ static findPeaks(spectrum: Float32Array, threshold?: number, minDistance?: number): number[]; /** * Parabolic interpolation for more accurate peak frequency */ static parabolicInterpolation(spectrum: Float32Array, peakIndex: number): number; /** * Convert bin index to frequency */ static binToFrequency(bin: number, sampleRate: number, fftSize: number): number; /** * Convert frequency to bin index */ static frequencyToBin(frequency: number, sampleRate: number, fftSize: number): number; /** * Compute spectral centroid (center of mass of spectrum) */ static spectralCentroid(magnitude: Float32Array, frequencies: Float32Array): number; /** * Compute spectral flux (change in spectrum over time) */ static spectralFlux(currentSpectrum: Float32Array, previousSpectrum: Float32Array): number; /** * Zero-pad signal to next power of 2 */ static zeroPad(signal: Float32Array, targetSize?: number): Float32Array; /** * Compute Harmonic Product Spectrum (for pitch detection) */ static harmonicProductSpectrum(spectrum: Float32Array, harmonics?: number): Float32Array; /** * Autocorrelation using FFT (faster for large signals) */ static autocorrelation(signal: Float32Array): Float32Array; /** * Direct autocorrelation (simpler but slower) */ private static directAutocorrelation; } /** * Helper: Get next power of 2 */ export declare function nextPowerOfTwo(n: number): number; /** * Helper: Check if number is power of 2 */ export declare function isPowerOfTwo(n: number): boolean;