-
Notifications
You must be signed in to change notification settings - Fork 0
/
Featurespectralcrest.m
36 lines (32 loc) · 1.35 KB
/
Featurespectralcrest.m
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
29
30
31
32
33
34
35
36
% ======================================================================
%> @brief computes the spectral crest from the magnitude spectrum
%> called by ::ComputeFeature
%>
%> @param X: spectrogram (dimension FFTLength X Observations)
%> @param f_s: sample rate of audio data (unused)
%>
%> @retval vtsc spectral crest factor
% ======================================================================
function [vtsc] = Featurespectralcrest (X, iBlockLength, iHopLength, f_s)
vtsc1 = max(X,[],1) ./ sum(X,1);
vrms = Featuretimerootmeansquare(X, iBlockLength, iHopLength, f_s);
vtsc2=vtsc1.*vrms;
vtsc=sum(vtsc2)./sum(vrms);
% dlmwrite('spectralcrest.txt', vtsc, 'delimiter', '\t');
end
% ======================================================================
%> @brief computes the RMS of a time domain signal
%> called by ::ComputeFeature
%>
%> @param x: audio signal
%> @param iBlockLength: block length in samples
%> @param iHopLength: hop length in samples
%> @param f_s: sample rate of audio data (unused)
%>
%> @retval vrms root mean square
%> @retval t time stamp
% ======================================================================
function [vrms] = Featuretimerootmeansquare(x, iBlockLength, iHopLength, f_s)
% calculate the rms
vrms = sqrt(mean(x.^2));
end