-
Notifications
You must be signed in to change notification settings - Fork 0
/
centerfreq.m
20 lines (18 loc) · 866 Bytes
/
centerfreq.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
function [mediaF,medianF,f,dP] = centerfreq(Fs,x)
% Entrada: Fs -> Frecuencia de muestreo
% x -> Señal de voz preprocesada
% Salida: mF: Frecuencia media donde està el mayor contenido de potencia de
% la voz
% f -> vector de frecuencias del espectro
% dP -> vector de Potencia en decibeles
L = max(size(x)); % Calcula el tamaño máximo de la señal
NFFT = 2^nextpow2(L); % Next power of 2 from length of y
dP = 20*log10(abs(fft(x,NFFT)));% Transformada Fourier para hallar potencia
f = Fs/2*linspace(0,1,NFFT/2+1);% Interfalo para la frecuencia
dP = dP(1:NFFT/2+1); % Crea vector
dPmax = max(dP);
abovecutoff = dP > dPmax-3; %3 dB is factor of 2
lowbin = find(abovecutoff, 1, 'first');
higbin = find(abovecutoff, 1, 'last');
mediaF = mean([f(lowbin),f(higbin)]);
medianF = median([f(lowbin),f(higbin)]);