/** BPMDetector.ts * BPMDetector - Framework-agnostic BPM detection module * * Provides pure functions for detecting beats per minute in audio using * autocorrelation and onset detection algorithms. Works with any Web Audio * AudioBuffer and can be used in any framework (Astro, React, Vue, vanilla JS). * * @module BPMDetector * @author PlecoXA Audio Analysis */ /** * Configuration options for BPM detection * @typedef {Object} BPMDetectionOptions * @property {number} [minBPM=60] - Minimum BPM to detect * @property {number} [maxBPM=180] - Maximum BPM to detect * @property {number} [hopLength=512] - Hop length for analysis frames * @property {number} [windowSize=1024] - Window size for analysis * @property {boolean} [useOnsetStrength=true] - Use onset strength calculation * @property {number} [threshold=0.1] - Minimum correlation threshold */ /** * BPM detection result * @typedef {Object} BPMResult * @property {number} bpm - Detected beats per minute * @property {number} confidence - Confidence score (0-1) * @property {number[]} onsets - Array of onset times in seconds * @property {number[]} beats - Array of beat times in seconds * @property {Object} analysis - Additional analysis data */ /** * Detects BPM from an AudioBuffer using autocorrelation and onset detection * * @param {AudioBuffer} audioBuffer - Web Audio API AudioBuffer * @param {BPMDetectionOptions} [options={}] - Detection options * @param {number} [startSample=0] - Start sample index for windowed analysis * @param {number} [endSample=null] - End sample index for windowed analysis * @returns {Promise} Promise resolving to BPM detection result * * @example * ```javascript * import { detectBPM } from './analysis/BPMDetector.ts'; * * const audioContext = new AudioContext(); * const response = await fetch('audio.wav'); * const arrayBuffer = await response.arrayBuffer(); * const audioBuffer = await audioContext.decodeAudioData(arrayBuffer); * * const result = await detectBPM(audioBuffer, { * minBPM: 80, * maxBPM: 160 * }); * * console.log(`Detected BPM: ${result.bpm}`); * console.log(`Confidence: ${result.confidence}`); * ``` */ export declare function detectBPM(audioBuffer: any, options?: {}, startSample?: number, endSample?: any): Promise<{ bpm: number; confidence: number; onsets: any[]; beats: any[]; analysis: { onsetStrength: any; autocorrelation: Float32Array; sampleRate: any; }; }>; /** * Detects BPM from a sliding window of audio data for live updates * * @param {AudioBuffer} audioBuffer - Web Audio API AudioBuffer * @param {number} centerSample - Center sample index for the window * @param {number} windowDuration - Duration of the window in seconds * @param {BPMDetectionOptions} [options={}] - Detection options * @returns {Promise} Promise resolving to BPM detection result */ export declare function detectBPMWindow(audioBuffer: any, centerSample: any, windowDuration: any, options?: {}): Promise<{ bpm: number; confidence: number; onsets: any[]; beats: any[]; analysis: { onsetStrength: any; autocorrelation: Float32Array; sampleRate: any; }; }>; /** * Fast BPM detection with simplified algorithm for real-time use * * @param {AudioBuffer} audioBuffer - Web Audio API AudioBuffer * @param {Object} [options={}] - Detection options * @returns {number} Detected BPM value * * @example * ```javascript * import { fastBPMDetect } from './analysis/BPMDetector.ts'; * * const bpm = fastBPMDetect(audioBuffer); * console.log(`Quick BPM: ${bpm}`); * ``` */ export declare function fastBPMDetect(audioBuffer: any, options?: {}): number; /** * BPMDetector class for object-oriented usage */ export declare class BPMDetector { constructor(options?: {}); analyze(audioBuffer: any): Promise<{ bpm: number; confidence: number; onsets: any[]; beats: any[]; analysis: { onsetStrength: any; autocorrelation: Float32Array; sampleRate: any; }; }>; detectFast(audioBuffer: any): number; } /** * Analyze tempo variations over time * * @param {AudioBuffer} audioBuffer - Web Audio API AudioBuffer * @param {Object} [options={}] - Analysis options * @returns {Promise} Tempo analysis with time-varying BPM * * @example * ```javascript * import { analyzeTempoVariations } from './analysis/BPMDetector.ts'; * * const analysis = await analyzeTempoVariations(audioBuffer, { * windowDuration: 4.0, // 4 second windows * hopDuration: 1.0 // 1 second hop * }); * * console.log('BPM over time:', analysis.bpmOverTime); * ``` */ export declare function analyzeTempoVariations(audioBuffer: any, options?: {}): Promise<{ bpmOverTime: any[]; timePoints: any[]; averageBPM: number; bpmVariance: number; }>;