/** * CREPE-NMF Integration for Polyphonic Pitch Detection * * This module combines CREPE neural network validation with NMF source separation * to provide accurate polyphonic pitch detection with validation. */ import { CREPEConfig, CREPEPrediction } from './crepe'; import { NMFResult, NMFComponent } from './nmf'; /** * Configuration for CREPE-NMF integration */ export interface CREPENMFConfig { crepeConfig?: CREPEConfig; nmfConfig?: { rank?: number; maxIterations?: number; tolerance?: number; sparsity?: number; smoothness?: number; }; validationThreshold?: number; maxPitches?: number; useValidation?: boolean; useNMF?: boolean; sampleRate?: number; frameSize?: number; } /** * Result of CREPE-NMF polyphonic detection */ export interface CREPENMFResult { pitches: CREPENMFPitch[]; nmfResult?: NMFResult; crepeResults?: CREPEPrediction[]; validationScores: number[]; processingTime: number; method: 'crepe-only' | 'nmf-only' | 'crepe-nmf-hybrid'; } /** * Individual pitch detection with validation */ export interface CREPENMFPitch { frequency: number; midi: number; note: string; confidence: number; clarity: number; timestamp: number; source: 'crepe' | 'nmf' | 'validated'; validationScore: number; nmfComponent?: NMFComponent; crepePrediction?: CREPEPrediction; } /** * CREPE-NMF hybrid detector */ export declare class CREPENMFDetector { private crepeModel; private nmfAlgorithm; private config; constructor(config?: CREPENMFConfig); /** * Initialize the detector */ initialize(): Promise; /** * Detect polyphonic pitches using CREPE-NMF hybrid approach */ detectPolyphonicPitches(samples: Float32Array): Promise; /** * Perform NMF-based detection */ private performNMFDetection; /** * Extract pitches from NMF result */ private extractNMFPitches; /** * Perform CREPE-based detection */ private performCREPEDetection; /** * Extract pitches from CREPE results */ private extractCREPEPitches; /** * Combine and validate pitches from both methods */ private combineAndValidatePitches; /** * Find best CREPE match for NMF pitch */ private findBestCREPEMatch; /** * Calculate validation scores for all pitches */ private calculateValidationScores; /** * Fallback detection when hybrid approach fails */ private fallbackDetection; /** * Create spectrogram from samples */ private createSpectrogram; /** * Apply window function */ private applyWindow; /** * Compute FFT magnitude (simplified) */ private computeFFTMagnitude; /** * Resample to 16kHz for CREPE */ private resampleTo16kHz; /** * Convert MIDI to note name */ private midiToNoteName; /** * Get current configuration */ getConfig(): Readonly>; /** * Update configuration */ updateConfig(newConfig: Partial): void; /** * Dispose resources */ dispose(): void; } /** * Quick utility function for CREPE-NMF detection */ export declare function detectPolyphonicPitches(samples: Float32Array, config?: CREPENMFConfig): Promise;