|
1 |
| -% function [time_yin, f0_yin] = yin_estimator(p,f,t,x, fs, varargin) |
2 |
| - |
3 |
| -% Yin estimator function + segmentation of the results |
4 |
| - |
5 |
| -function [time_yin, f0_yin, Start, End ] = lea_yin_estimator(x,fs,delta_t,delta_f,signal_mini_duration_s,varargin) |
6 |
| -% from https://github.com/orchidas/Pitch-Tracking/blob/master/yin_estimator.m |
7 |
| -% function that implements YIN algorithm for |
8 |
| -% fundamental pitch tracking |
9 |
| -% x - input audio signal |
10 |
| -% fs - sampling rate |
11 |
| -% time_yin,f0_yin - time_yin vector and associated fundamental frequencies estimated |
12 |
| - |
| 1 | +% function [time, f0, Start, End ] = lea_yin_estimator(x,fs,delta_t,delta_f,signal_mini_duration_s,varargin) |
| 2 | +% |
| 3 | +% This pitch tracking function is based on the function https://github.com/orchidas/Pitch-Tracking/blob/master/yin_estimator.m |
| 4 | +% that implements YIN algorithm for fundamental pitch tracking. |
| 5 | +% |
| 6 | + % INPUTS: |
| 7 | + % - x: observation signal, |
| 8 | + % - fs: sampling frequency (Hz), |
| 9 | + % - delta_t: minimum time interval between two tonals (s), |
| 10 | + % - delta_f: minimum frequency interval between two tonals (Hz), |
| 11 | + % - signal_mini_duration: minimum tonal signal duration (samples). |
| 12 | + % |
| 13 | + % OUTPUTS: |
| 14 | + % - f0: frequency estimate, |
| 15 | + % - time: time vector of the frequency tracks, |
| 16 | + % - Start: Starting sample of each detected tonal signal, |
| 17 | + % - End: Ending sample of each tonal signal. |
| 18 | + |
| 19 | +function [time, f0, Start, End ] = lea_yin_estimator(x,fs,delta_t,delta_f,signal_mini_duration_s,varargin) |
13 | 20 | % window size - we assume the minimum f0_yin to be 1/0.25 = 4Hz
|
14 | 21 | win = round(0.25*fs);
|
15 | 22 | N = length(x);
|
|
157 | 164 | Start = [Start(1:ind-1) Start(ind+1:end)];
|
158 | 165 | end
|
159 | 166 |
|
160 |
| -f0_yin = f0_short; |
| 167 | +f0 = f0_short; |
161 | 168 | % Good size
|
162 |
| - time_yin = (0:N-1)/fs; |
| 169 | + time = (0:N-1)/fs; |
163 | 170 | if length(Start) > 1
|
164 | 171 |
|
165 | 172 | f0_yin_final = NaN(size(time_yin));
|
|
170 | 177 | End(i) = find(time_yin >= t_short(End_old),1)-1;
|
171 | 178 | f0_yin_final(Start(i):End(i)) = interp1(t_short(Start_old:End_old),f0_yin(Start_old:End_old),time_yin(Start(i):End(i)));
|
172 | 179 | end
|
173 |
| - f0_yin = f0_yin_final; |
| 180 | + f0 = f0_yin_final; |
174 | 181 |
|
175 | 182 | end
|
176 | 183 | end
|
|
0 commit comments