/** * Polyphonic Pitch Detection Package * Uses CREPE-inspired neural networks with NMF source separation */ import { AudioProcessor } from './audio'; /** * Configuration options for the pitch detector */ export interface PitchDetectionOptions { sampleRate?: number; frameSize?: number; hopSize?: number; maxPolyphony?: number; confidenceThreshold?: number; useNMF?: boolean; useCrepe?: boolean; useWorklet?: boolean; useHarmonicAnalysis?: boolean; usePitchTracking?: boolean; nmfRank?: number; useCREPENMF?: boolean; crepeNMFConfig?: { validationThreshold?: number; maxPitches?: number; useValidation?: boolean; useNMF?: boolean; }; modelPath?: string; workletPath?: string; } /** * Represents a detected pitch with metadata */ export interface DetectedPitch { frequency: number; midi: number; note: string; confidence: number; clarity: number; timestamp: number; } /** * Main pitch detection class */ export declare class PitchDetector { private options; private initialized; private audioProcessor; private harmonicAnalyzer; private pitchTracker; private nmfAlgorithm; private crepeNMFDetector; constructor(options?: PitchDetectionOptions); /** * Initialize the pitch detector (load models, setup processing) */ initialize(): Promise; /** * Detect pitches from an AudioBuffer */ detectFromAudioBuffer(buffer: AudioBuffer): Promise; /** * Detect pitches from a MediaStream (real-time) */ detectFromStream(stream: MediaStream): AsyncGenerator; /** * Process a single audio frame */ processFrame(samples: Float32Array): Promise; /** * Clean up resources */ dispose(): void; /** * Get the audio processor instance */ getAudioProcessor(): AudioProcessor; /** * Get current configuration */ getOptions(): Readonly>; /** * Get pitch tracking state */ getPitchTrackingState(): Readonly; /** * Reset pitch tracking state */ resetPitchTracking(): void; /** * Detect polyphonic pitches using NMF */ private detectPolyphonicPitches; /** * Create spectrogram from time-domain signal */ private createSpectrogram; /** * Apply window function to frame */ private applyWindow; /** * Create Hann window */ private createHannWindow; /** * Compute FFT magnitude (simplified implementation) */ private computeFFTMagnitude; } /** * Utility function to convert frequency to MIDI note number */ export declare function frequencyToMidi(frequency: number): number; /** * Utility function to convert MIDI note number to frequency */ export declare function midiToFrequency(midi: number): number; /** * Utility function to convert MIDI note number to note name */ export declare function midiToNoteName(midi: number): string; export { AudioProcessor, mixToMono, calculateRMS, normalizeAudio, applyPreEmphasis, type AudioProcessorOptions } from './audio'; export { PitchWorklet, createPitchWorklet, type WorkletFrameEvent, type WorkletConfigMessage } from './worklet'; export { FFT, WindowFunction, SpectralAnalysis, nextPowerOfTwo, isPowerOfTwo, type Complex, type WindowType, type FFTResult } from './dsp'; export { PeakDetector, findFundamental, type Peak, type PeakDetectionConfig } from './peak-detection'; export { TFJSModelManager, TensorUtils, createModelManager, tf, type ModelLoadOptions, type InferenceResult } from './tfjs'; export { CREPEModel, detectPitchCREPE, CREPEUtils, type CREPEConfig, type CREPEPrediction } from './crepe'; export { AutocorrelationDetector, detectPitchAutocorrelation, AutocorrelationUtils, type AutocorrelationConfig, type AutocorrelationResult } from './autocorrelation'; export { HarmonicAnalyzer, analyzeHarmonics, HarmonicMatching, HarmonicUtils, type HarmonicAnalysisConfig, type HarmonicResult } from './harmonic-analysis'; export { PitchTracker, PitchTrackingUtils, trackPitch, type PitchTrackingConfig, type TrackedPitch, type PitchTrackingState } from './pitch-tracking'; export { NMFAlgorithm, SpectralDictionary, NMFUtils, decomposeNMF, type NMFConfig, type NMFResult, type NMFComponent, type SpectralDictionary as SpectralDictionaryType } from './nmf'; export { CREPENMFDetector, detectPolyphonicPitches, type CREPENMFConfig, type CREPENMFResult, type CREPENMFPitch } from './crepe-nmf';