Home > ACA-Code > FeatureSpectralTonalPowerRatio.m

FeatureSpectralTonalPowerRatio

PURPOSE ^

computes the tonal power ratio from the magnitude spectrum

SYNOPSIS ^

function [vtpr] = FeatureSpectralTonalPowerRatio(X, f_s, G_T)

DESCRIPTION ^

computes the tonal power ratio from the magnitude spectrum
> called by ::ComputeFeature
>
> @param X: spectrogram (dimension FFTLength X Observations)
> @param f_s: sample rate of audio data (unused)
> @param G_T: energy threshold
>
> @retval vtpr tonal power ratio
 ======================================================================

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 %computes the tonal power ratio from the magnitude spectrum
0002 %> called by ::ComputeFeature
0003 %>
0004 %> @param X: spectrogram (dimension FFTLength X Observations)
0005 %> @param f_s: sample rate of audio data (unused)
0006 %> @param G_T: energy threshold
0007 %>
0008 %> @retval vtpr tonal power ratio
0009 % ======================================================================
0010 function [vtpr] = FeatureSpectralTonalPowerRatio(X, f_s, G_T)
0011 
0012     % initialize
0013     if (nargin < 3)
0014         G_T = 5e-4;
0015     end
0016 
0017     % allocate memory
0018     vtpr = zeros(1, size(X, 2));
0019 
0020     % convert to power spectrum
0021     X = X.^2;
0022     fSum = sum(X, 1);
0023  
0024     for n = 1:size(X, 2)
0025         if (fSum(n) == 0)
0026             % do nothing for 0-blocks
0027             continue;
0028         end
0029         % find local maxima
0030         [afPeaks] = findpeaks(X(:, n));
0031         
0032         % find peaks above the threshold
0033         k_peak = find(afPeaks > G_T);
0034         
0035         % calculate the ratio
0036         vtpr(n) = sum(afPeaks(k_peak)) / fSum(n);
0037     end
0038 end

Generated on Fri 22-Apr-2022 20:59:51 by m2html © 2005