Skip to main content

hpcp

Function hpcp 

Source
pub fn hpcp(
    peak_freqs: &[f32],
    peak_mags: &[f32],
    n_peaks: usize,
    ref_freq_hz: f32,
    n_pc: usize,
    out: &mut [f32],
) -> Result<(), AudioError>
Expand description

Accumulate spectral peaks into a Harmonic Pitch Class Profile.

  • peak_freqs / peak_mags: parallel arrays of peak frequency (Hz) and magnitude, e.g. from crate::features::peaks::spectral_peaks().
  • n_peaks: how many leading entries of those arrays to use (clamped to the shorter of the two).
  • ref_freq_hz: tuning reference frequency (frequency of A4); parameterised, default-by-convention 440 Hz — never assume it.
  • n_pc: pitch classes per octave (12 for 12-TET; any ≥ 1 accepted).
  • out: destination profile; the first n_pc entries are overwritten with the accumulated magnitudes (raw, not normalised).

§Errors