F0HGRID
Contents
F0HGRID - f0 extraction with harmonic grid
Usage:
F0HGRID F A M DF FMIN FMAX N TABLE COL WIN FFT F0
Inputs:
F | component frequencies in Hz |
A | component amplitudes in dB |
M | number of valid components |
DF | frequency resolution in Hz |
FMIN | minimum f0 |
FMAX | maximum f0 |
N | minimum number of matching components |
TABLE | name of output shell-table |
COL | index of table column |
WIN | length of window (only used for RMSh) |
FFT | FFT length (only used for RMSh) |
F0 | f0 value in Hz or 0 if no f0 was found |
Outputs:
RMSH | harmonic part energy |
Function:
This method uses a harmonic grid to find/extract the best matching fundamental frequency (f0) for the spectral components (peaks: fi/ai) defined by F (f1..fM) and A (a1..aM). The parameters DF, FMIN, FMAX and N are used to control the matching algorithm and can be changed in each evaluation interval. The input M is the number of components stored in the inputs F and A (0 <= M <= length of vectors F/A).
First the test-frequencies for the f0-test T = <t0..tK> are selected. The set of test-frequencies consists of the following values:
- the f0-value extracted in the last cycle (if F0>0)
- all component frequencies in the range FMIN<fi <FMAX
- all difference frequencies di,j=fj-fi (with j > i) in the range FMIN<di,j <FMAX
For all values of the test-frequency set the component frequencies are searched for harmonics. A component fi is a harmonic of tj if the following conditions are true:
- the order o = [fi/tj + ½] is greater than 1
- (fi – DF) / (tj + DF/o) <= o <= (fi + DF) / (tj – DF/o)
For all tj with at least N harmonic components, an f0-candidate is added to the set of candidates. A candidate is defined by the following values:
- the number of harmonic components cn
- the average fundamental frequency cf = (fx + fy + ...) / (ox + oy + ...); f and o are the frequency and order of the harmonic components
- the harmonic error term ce = |cf/tj – 1|
In the last step the best f0 candidate is selected from the set of candidates and stored in the output F0. In the current implementation the best candidate has the highest number of components cn and the minimum error (if more than 1 candidate with max(cn) exists). If no candidate was selected in the first three steps, the output F0 is set to zero.
If the inputs TABLE and COL are connected, all values stored in the F0 output are also stored in the column COL of the table starting at entry 0.
Note: This algorithm works but is still under development. Plans for multiple f0-detection (complex tone analysis) and f0 tracking (over time) are under consideration.
If WIN and FFT are connected, the RMS-value for the harmonic parts, RMSh, is calculated. In this case another column of the table is used.