original commit
BIN
rossignol/parametrique/fluteircam-dsp_AR.png
Normal file
After Width: | Height: | Size: 71 KiB |
BIN
rossignol/parametrique/fluteircam-dsp_AR_full.png
Normal file
After Width: | Height: | Size: 110 KiB |
BIN
rossignol/parametrique/fluteircam-dsp_fft.png
Normal file
After Width: | Height: | Size: 97 KiB |
BIN
rossignol/parametrique/fluteircam-dsp_max_AR.png
Normal file
After Width: | Height: | Size: 22 KiB |
BIN
rossignol/parametrique/fluteircam-dsp_max_fft.png
Normal file
After Width: | Height: | Size: 21 KiB |
BIN
rossignol/parametrique/fluteircam-signal.png
Normal file
After Width: | Height: | Size: 36 KiB |
57
rossignol/parametrique/mylevinsondurbin.m
Normal file
|
@ -0,0 +1,57 @@
|
||||||
|
%%% Algorithme de Levinson-Durbin pour la d\'etermination des param\`etres AR
|
||||||
|
%%%
|
||||||
|
%%% entr\'ees :
|
||||||
|
%%% - xx : signal
|
||||||
|
%%% - pp : ordre du mod\`ele AR (choisi de mani\`ere ind\'ependante)
|
||||||
|
%%% - fe : fr\'equence d'\'echantillonnage
|
||||||
|
%%%
|
||||||
|
%%% sorties :
|
||||||
|
%%% - aa : les param\`etres AR
|
||||||
|
%%% - sigma2 : variance du bruit
|
||||||
|
%%% - ref : coefficients de r\'eflexion
|
||||||
|
%%% - ff : fr\'equences auxquelles la dsp a \'et\'e calcul\'ee
|
||||||
|
%%% - mydsp : la dsp elle-m\^eme
|
||||||
|
%%%
|
||||||
|
%%% exemple : fe=32000;f0=440;xx=cos(2*pi*f0/fe*[1:1280]+2*pi*rand(1,1));mylevinsondurbin(xx,4,fe);
|
||||||
|
%%%
|
||||||
|
%%% S. Rossignol -- 2012
|
||||||
|
|
||||||
|
function [aa, sigma2, ref, ff, mydsp] = mylevinsondurbin (xx, pp, fe)
|
||||||
|
|
||||||
|
acf = xcorr(xx, pp+1, 'biased'); %% autocorr\'elation
|
||||||
|
acf(1:pp+1) = []; %% on enl\`eve la partie n\'egative
|
||||||
|
acf(1) = real(acf(1)); %% Levinson-Durbin requiert c(1)==conj(c(1))
|
||||||
|
|
||||||
|
ref = zeros(pp,1);
|
||||||
|
gg = -acf(2)/acf(1);
|
||||||
|
aa = [ gg ];
|
||||||
|
sigma2 = real( ( 1 - gg*conj(gg)) * acf(1) ); %% real : enl\`eve une \'eventuelle
|
||||||
|
%% partie imaginaire r\'esiduelle
|
||||||
|
ref(1) = gg;
|
||||||
|
for tt = 2 : pp
|
||||||
|
gg = -(acf(tt+1) + aa * acf(tt:-1:2)') / sigma2;
|
||||||
|
aa = [ aa + gg*conj(aa(tt-1:-1:1)), gg ];
|
||||||
|
sigma2 = sigma2 * ( 1 - real(gg*conj(gg)) );
|
||||||
|
ref(tt) = gg;
|
||||||
|
end;
|
||||||
|
aa = [1, aa];
|
||||||
|
|
||||||
|
%%% densit\'e spectrale de puissance
|
||||||
|
interm2=-j*2*pi/fe*[1:pp];
|
||||||
|
df=0.9765625; %%% la dsp est calcul\'ee tous les df Hz
|
||||||
|
ff=-fe/2:df:fe/2;
|
||||||
|
|
||||||
|
interm3=interm2'*ff;
|
||||||
|
interm=1.+aa(2:pp+1)*exp(interm3);
|
||||||
|
mydsp = sigma2./(interm.*conj(interm));
|
||||||
|
|
||||||
|
% figure(1);
|
||||||
|
% clf;
|
||||||
|
% grid on;
|
||||||
|
% hold on;
|
||||||
|
% plot(ff,mydsp,'linewidth',2);
|
||||||
|
% xlabel('frequency (in Hz)','fontsize',20);
|
||||||
|
% ylabel('magnitude','fontsize',20);
|
||||||
|
% hold off;
|
||||||
|
% drawnow;
|
||||||
|
|
BIN
rossignol/parametrique/myson-amp_dsp_AR.png
Normal file
After Width: | Height: | Size: 40 KiB |
BIN
rossignol/parametrique/myson-amp_dsp_AR_full.png
Normal file
After Width: | Height: | Size: 24 KiB |
BIN
rossignol/parametrique/myson-amp_dsp_FFT.png
Normal file
After Width: | Height: | Size: 59 KiB |
BIN
rossignol/parametrique/myson-amp_dsp_FFT_full.png
Normal file
After Width: | Height: | Size: 43 KiB |
BIN
rossignol/parametrique/myson-dsp_max_AR.png
Normal file
After Width: | Height: | Size: 34 KiB |
BIN
rossignol/parametrique/myson-dsp_max_fft.png
Normal file
After Width: | Height: | Size: 31 KiB |
BIN
rossignol/parametrique/myson-signal.png
Normal file
After Width: | Height: | Size: 38 KiB |
101
rossignol/parametrique/parametrique.m
Normal file
|
@ -0,0 +1,101 @@
|
||||||
|
clear;
|
||||||
|
close all;
|
||||||
|
|
||||||
|
% returns sampling frequency in Hz and data
|
||||||
|
[y,Fs] = audioread('myson.wav');
|
||||||
|
|
||||||
|
% Fs = sampling frequency, 32000 for fluteircam.wav
|
||||||
|
lenW = 0.04*Fs; % window of lenW samples, i.e. 40 ms
|
||||||
|
|
||||||
|
df=0.9765625; %%% la dsp est calcul\'ee tous les df Hz
|
||||||
|
ff=-Fs/2:df:Fs/2; % length 32769 for fluteircam.wav
|
||||||
|
ffsub = ff(1:11:end); % compression x11, length 2979
|
||||||
|
|
||||||
|
tt = (0:length(y)-1)/Fs;
|
||||||
|
ttsub = (lenW/2:lenW:length(y))/Fs;
|
||||||
|
|
||||||
|
dsps = zeros(length(ffsub), floor((length(y)-lenW+1)/lenW));
|
||||||
|
|
||||||
|
% dsp fft
|
||||||
|
T = 1/Fs; % Sampling period
|
||||||
|
L = lenW; % Length of signal
|
||||||
|
t = (0:L-1)*T; % Time vector
|
||||||
|
fftsp = zeros(L/2+1, floor((length(y)-lenW+1)/lenW));
|
||||||
|
fftspCpx = zeros(L/2+1, floor((length(y)-lenW+1)/lenW));
|
||||||
|
f = Fs*(0:(L/2))/L;
|
||||||
|
|
||||||
|
for i = 0:floor((length(y)-lenW+1)/lenW)
|
||||||
|
|
||||||
|
% compute dsp AR
|
||||||
|
[~, ~, ~, ~, mydsp] = mylevinsondurbin(y(lenW*i+1:lenW*(i+1))',200,Fs);
|
||||||
|
dsps(:,i+1) = mydsp(1:11:end)'; % compression x11, length 2979
|
||||||
|
|
||||||
|
% compute dsp fft
|
||||||
|
myfft = fft(y(lenW*i+1:lenW*(i+1)));
|
||||||
|
P2 = abs(myfft/L);
|
||||||
|
P1 = P2(1:L/2+1);
|
||||||
|
P1(2:end-1) = 2*P1(2:end-1);
|
||||||
|
fftsp(:,i+1) = P1;
|
||||||
|
end
|
||||||
|
|
||||||
|
% take only positive frequencies for dsp
|
||||||
|
ffsubp = ffsub(1,(length(ffsub)-1)/2+1:end);
|
||||||
|
dspsp = dsps((length(dsps)-1)/2+1:end,:);
|
||||||
|
|
||||||
|
% plot
|
||||||
|
figure()
|
||||||
|
plot(tt,y)
|
||||||
|
xlabel('temps (s)')
|
||||||
|
ylabel('amplitude (u.a.)')
|
||||||
|
title('signal fluteircam')
|
||||||
|
|
||||||
|
% figure()
|
||||||
|
% surf(ttsub,ffsub,dsps,'EdgeColor','None');
|
||||||
|
% xlabel('temps (s)')
|
||||||
|
% ylabel('fréquences (Hz)')
|
||||||
|
% zlabel('amplitudes (u.a.)')
|
||||||
|
% title('Full DSP AR signal fluteircam')
|
||||||
|
|
||||||
|
figure()
|
||||||
|
surf(ttsub,ffsubp,dspsp,'EdgeColor','None');
|
||||||
|
xlabel('temps (s)')
|
||||||
|
ylabel('fréquences (Hz)')
|
||||||
|
zlabel('amplitudes (u.a.)')
|
||||||
|
title('DSP AR signal fluteircam')
|
||||||
|
|
||||||
|
figure()
|
||||||
|
imagesc(ttsub,ffsubp,dspsp)
|
||||||
|
xlabel('temps (s)')
|
||||||
|
ylabel('fréquences (Hz)')
|
||||||
|
title('Amplitude DSP AR signal fluteircam')
|
||||||
|
|
||||||
|
figure()
|
||||||
|
surf(ttsub,f,fftsp,'EdgeColor','None');
|
||||||
|
xlabel('temps (s)')
|
||||||
|
ylabel('fréquences (Hz)')
|
||||||
|
zlabel('amplitudes (u.a.)')
|
||||||
|
title('DSP FFT signal fluteircam')
|
||||||
|
|
||||||
|
figure()
|
||||||
|
imagesc(ttsub,f,fftsp)
|
||||||
|
xlabel('temps (s)')
|
||||||
|
ylabel('fréquences (Hz)')
|
||||||
|
title('Amplitude DSP FFT signal fluteircam')
|
||||||
|
|
||||||
|
|
||||||
|
% take max amplitude frequency
|
||||||
|
[maxDspsp, maxIndDspsp] = max(dspsp);
|
||||||
|
maxFfsubp = ffsubp(maxIndDspsp);
|
||||||
|
figure
|
||||||
|
plot(ttsub,maxFfsubp)
|
||||||
|
xlabel('temps (s)')
|
||||||
|
ylabel('fréquences (Hz)')
|
||||||
|
title('Frequency max DSP AR signal fluteircam')
|
||||||
|
|
||||||
|
[maxFftsp, maxIndFftsp] = max(fftsp);
|
||||||
|
maxF = f(maxIndFftsp);
|
||||||
|
figure
|
||||||
|
plot(ttsub,maxF)
|
||||||
|
xlabel('temps (s)')
|
||||||
|
ylabel('fréquences (Hz)')
|
||||||
|
title('Frequency max DSP FFT signal fluteircam')
|