-
-
Notifications
You must be signed in to change notification settings - Fork 22
Expand file tree
/
Copy pathFeatureSpectralRolloff.m
More file actions
28 lines (24 loc) · 763 Bytes
/
FeatureSpectralRolloff.m
File metadata and controls
28 lines (24 loc) · 763 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
%computes the spectral rolloff from the magnitude spectrum
%> called by ::ComputeFeature
%>
%> @param X: spectrogram (dimension FFTLength X Observations)
%> @param f_s: sample rate of audio data
%> @param kappa: cutoff ratio
%>
%> @retval vsr spectral rolloff (in Hz)
% ======================================================================
function [vsr] = FeatureSpectralRolloff (X, f_s, kappa)
% initialize parameters
if (nargin < 3)
kappa = 0.85;
end
% allocate memory
vsr = zeros(1, size(X,2));
% compute rolloff
afSum = sum(X, 1);
for n = 1:length(vsr)
vsr(n) = find(cumsum(X(:, n)) >= kappa*afSum(n), 1)-1;
end
% convert from index to Hz
vsr = vsr / (size(X, 1)-1) * f_s / 2;
end