Skip to content

Commit 3e2e80b

Browse files
authored
Update lea_yin_estimator.m
1 parent b85a63e commit 3e2e80b

File tree

1 file changed

+22
-15
lines changed

1 file changed

+22
-15
lines changed

lea_yin_estimator.m

+22-15
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,22 @@
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)
1320
% window size - we assume the minimum f0_yin to be 1/0.25 = 4Hz
1421
win = round(0.25*fs);
1522
N = length(x);
@@ -157,9 +164,9 @@
157164
Start = [Start(1:ind-1) Start(ind+1:end)];
158165
end
159166

160-
f0_yin = f0_short;
167+
f0 = f0_short;
161168
% Good size
162-
time_yin = (0:N-1)/fs;
169+
time = (0:N-1)/fs;
163170
if length(Start) > 1
164171

165172
f0_yin_final = NaN(size(time_yin));
@@ -170,7 +177,7 @@
170177
End(i) = find(time_yin >= t_short(End_old),1)-1;
171178
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)));
172179
end
173-
f0_yin = f0_yin_final;
180+
f0 = f0_yin_final;
174181

175182
end
176183
end

0 commit comments

Comments
 (0)