harmonicRatio
Harmonic ratio
Description
specifies options using one or more name-value arguments.hr
= harmonicRatio(audioIn
,fs
,Name=Value
)
Example: 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.
harmonicRatio(___)
with no output arguments plots the
harmonic ratio against time. You can specify an input combination from any of the previous
syntaxes.
Examples
Input Arguments
Output Arguments
Algorithms
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].
References
[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
Extended Capabilities
Version History
Introduced in R2019a