Harmonic ratio
specifies options using one or more hr
= harmonicRatio(audioIn
,fs
,Name,Value
)Name,Value
pair arguments.
hr =
harmonicRatio(audioIn,fs,'Window',rectwin(round(fs*0.1)),'OverlapLength',round(fs*0.05))
returns the harmonic ratio for the audio input signal sampled at fs
Hz.
The harmonic ratio is calculated for 100 ms rectangular windows with 50 ms
overlap.The harmonic ratio is calculated as described in [1]. The following algorithm is applied independently to each window of audio data. The normalized autocorrelation of the signal is determined as:
where
s is a single frame of audio data with N elements.
M is the maximum lag in the calculation. The maximum lag is 40 ms, which corresponds to a minimum fundamental frequency of 25 Hz.
A first estimate of the harmonic ratio is determined as the maximum of the normalized autocorrelation, within a given range:
where M0 is the lower edge of the search range, determined as the first zero crossing of the normalized autocorrelation.
Finally, the harmonic ratio estimate is improved using parabolic interpolation, as described in [2].
[1] Kim, Hyoung-Gook, Nicholas Moreau, and Thomas Sikora. MPEG-7 Audio and Beyond: Audio Content Indexing and Retrieval. John Wiley & Sons, 2005.
[2] Quadratic Interpolation of Spectral Peaks. Accessed October 11, 2018. https://ccrma.stanford.edu/~jos/sasp/Quadratic_Interpolation_Spectral_Peaks.html