/** * Local autocorrelation tempogram of the onset strength envelope. * * Legacy positional signature preserved. * * @param {Float32Array|Array|null} y - audio time series (optional if * onset_envelope provided) * @param {number} sr - sample rate * @param {Float32Array|Array|null} onset_envelope - pre-computed * onset strength envelope * @param {number} hop_length - hop length used for the onset envelope * @param {number} win_length - autocorrelation window in frames * @param {boolean} center - center the analysis windows (linear_ramp pad) * @param {string} window - window function ('hann' only) * @param {number|null} norm - Infinity for per-column max-normalization * (default), null for raw autocorrelation * @returns {Array} tempogram [win_length][n_frames] — row k is * lag k; convert with convert.tempo_frequencies(win_length, hop_length, sr) * @throws {Error} on invalid parameters or an envelope shorter than one * analysis window — never returns a fabricated result */ export function tempogram(y?: Float32Array | any[] | null, sr?: number, onset_envelope?: Float32Array | any[] | null, hop_length?: number, win_length?: number, center?: boolean, window?: string, norm?: number | null): Array; /** * Fourier tempogram: STFT of the onset strength envelope at hop 1: * stft(onset_envelope, n_fft=win_length, hop_length=1, center, window) * * DIVERGENCE NOTE: pleco's radix-2 stft zero-pads non-power-of-2 FFT sizes, * which would silently regrid the tempo axis — so win_length must be a power * of two here (default 512; the tempo axis is * convert.fourier_tempo_frequencies(sr, win_length, hop_length)). * * @param {Float32Array|Array|null} y - audio time series (optional if * onset_envelope provided) * @param {number} sr - sample rate * @param {Float32Array|Array|null} onset_envelope - pre-computed envelope * @param {number} hop_length - hop length used for the onset envelope * @param {number} win_length - STFT window in envelope frames (power of 2) * @param {boolean} center - center the STFT windows * @param {string} window - window function type * @returns {Array>} complex Fourier * tempogram [win_length/2 + 1][n_envelope_frames + 1] (center=true) * @throws {Error} if win_length is not a power of two */ export function fourier_tempogram(y?: Float32Array | any[] | null, sr?: number, onset_envelope?: Float32Array | any[] | null, hop_length?: number, win_length?: number, center?: boolean, window?: string): Array>; /** * Tempogram ratio features (a.k.a. spectral rhythm patterns). * Summarizes tempogram energy at * metrically important multiples of the estimated tempo by sampling the * tempogram at harmonic/subharmonic ratios of the per-frame BPM: * * tg = tempogram(...) # [win_length][n] * freqs= tempo_frequencies(n_bins=win_length, ...) # BPM per lag bin * bpm = tempo(tg=tg, aggregate=None, ...) # per-frame BPM * tgr = f0_harmonics(tg, freqs=freqs, f0=bpm, harmonics=factors) * * Options use a keyword-only signature. * * @param {Object} [options] * @param {Float32Array|Array|null} [options.y] - audio time series (used only * when neither tg nor onset_envelope is supplied) * @param {number} [options.sr=22050] - sample rate * @param {Float32Array|Array|null} [options.onset_envelope] - pre-computed * onset strength envelope * @param {Array|null} [options.tg] - pre-computed * tempogram [n_lags][n_frames]; if given, y/onset_envelope are ignored and * win_length is inferred from n_lags * @param {Float64Array|Array|null} [options.bpm] - pre-computed per-frame * tempo (length n_frames); estimated from tg when null * @param {number} [options.hop_length=512] * @param {number} [options.win_length=384] - tempogram autocorrelation window * @param {number} [options.start_bpm=120] - center of the log-normal prior * @param {number} [options.std_bpm=1.0] - prior std (log2 space) * @param {number|null} [options.max_tempo=320.0] - mask tempi at/above this * @param {Float64Array|Array|null} [options.freqs] - BPM per tempogram lag * bin; defaults to tempo_frequencies(n_lags, hop_length, sr) * @param {Array|null} [options.factors] - tempo multiples to sample; * defaults to the Prockup'15 13-factor table * @param {Function|null} [options.aggregate] - if given, called on each * harmonic's per-frame Float64Array to collapse the time axis * (aggregate(tgr, axis=-1)); null keeps the per-frame matrix * @param {boolean} [options.center=true] - center tempogram windows * @param {string} [options.window='hann'] - tempogram window * @param {string} [options.kind='linear'] - interpolation kind (only 'linear' * is validated against the reference fixtures; others throw rather than silently approximate) * @param {number} [options.fill_value=0] - value for out-of-range harmonics * @param {number|null} [options.norm=Infinity] - tempogram normalization * @returns {Array|Float64Array} tempogram ratio * [n_factors][n_frames], or [n_factors] when aggregate is provided * @throws {Error} on invalid parameters or shape mismatches — never fabricates */ export function tempogram_ratio(options?: { y?: Float32Array | any[] | null; sr?: number; onset_envelope?: Float32Array | any[] | null; tg?: Array | null; bpm?: Float64Array | any[] | null; hop_length?: number; win_length?: number; start_bpm?: number; std_bpm?: number; max_tempo?: number | null; freqs?: Float64Array | any[] | null; factors?: Array | null; aggregate?: Function | null; center?: boolean; window?: string; kind?: string; fill_value?: number; norm?: number | null; }): Array | Float64Array; /** * Estimate the global tempo from a (lag) tempogram using tempo scoring: * time-mean of the tempogram, pseudo-log-normal prior * logprior = -0.5 * ((log2(bpm) - log2(start_bpm)) / std_bpm)^2 * and argmax of log1p(1e6 * mean) + logprior with tempi at/above max_tempo * masked out. (The previous raw argmax had no prior and returned the 60 BPM * subharmonic on a plain 120 BPM click train.) * * @param {Array} tgram - tempogram * [n_lags][n_frames] as returned by tempogram() * @param {number} sr - sample rate * @param {number} hop_length - hop length used for the onset envelope * @param {number} start_bpm - center of the log-normal prior * @param {number} std_bpm - prior standard deviation (log2 space) * @param {number|null} max_tempo - mask tempi at/above this value * @returns {{tempo: number, strength: number}} tempo in BPM and the measured * mean-tempogram value at the chosen lag (never a fabricated confidence) * @throws {Error} on empty input or when every lag is masked */ export function estimate_tempo(tgram: Array, sr?: number, hop_length?: number, start_bpm?: number, std_bpm?: number, max_tempo?: number | null): { tempo: number; strength: number; };