82 lines
1.9 KiB
Mathematica
82 lines
1.9 KiB
Mathematica
|
|
||
|
|
||
|
%rand('seed',100*sum(clock));
|
||
|
%fe=32000;
|
||
|
%f0=440;
|
||
|
%tsig=1280;
|
||
|
%xx=cos(2*pi*f0/fe*[1:tsig]+2*pi*rand(1,1))+cos(2*pi*(f0+40)/fe*[1:tsig]+2*pi*rand(1,1))+cos(2*pi*2*f0/fe*[1:tsig]+2*pi*rand(1,1))+cos(2*pi*(2*f0+40)/fe*[1:tsig]+2*pi*rand(1,1));
|
||
|
%xx=cos(2*pi*f0/fe*[1:tsig]+2*pi*rand(1,1))+1e-2*randn(1,tsig);
|
||
|
%pp=2;
|
||
|
%MM=10;
|
||
|
|
||
|
% returns sampling frequency in Hz and data
|
||
|
[xx,fe] = audioread('fluteircam.wav');
|
||
|
xx = xx';
|
||
|
|
||
|
pp=4;
|
||
|
MM=210;
|
||
|
|
||
|
lenW = 0.04*fe;
|
||
|
|
||
|
maxFreqs = [];
|
||
|
|
||
|
for i = 0:floor((length(xx)-lenW+1)/lenW)
|
||
|
xxsub = xx(1,lenW*i+1:lenW*(i+1));
|
||
|
[ff, mydsp] = mymusic_matlab(xxsub,pp,MM,fe);
|
||
|
|
||
|
mydspP = mydsp(floor(length(mydsp)/2):end,:);
|
||
|
ffP = ff(:,floor(length(mydsp)/2):end);
|
||
|
[maxi,ind] = max(mydspP);
|
||
|
maxFreq = ffP(ind);
|
||
|
maxFreqs = [maxFreqs maxFreq];
|
||
|
end
|
||
|
|
||
|
figure()
|
||
|
tt = (lenW/2:lenW:length(xx))/fe;
|
||
|
plot(tt,maxFreqs)
|
||
|
xlabel('temps (s)')
|
||
|
ylabel('fréquences (Hz)')
|
||
|
title('Frequency max DSP MUSIC signal flureircam (p = 2, M = 200)')
|
||
|
|
||
|
%%% figures
|
||
|
% figure();
|
||
|
% clf;
|
||
|
% grid on;
|
||
|
% hold on;
|
||
|
% plot(ff,mydsp,'linewidth',2);
|
||
|
% xlabel('frequency (in Hz)','fontsize',20);
|
||
|
% ylabel('magnitude','fontsize',20);
|
||
|
% title('zoom MUSIC');
|
||
|
% xlim([400 506]);
|
||
|
% hold off;
|
||
|
|
||
|
% figure();
|
||
|
% clf;
|
||
|
% grid on;
|
||
|
% hold on;
|
||
|
% plot(ff,mydsp,'linewidth',2);
|
||
|
% xlabel('frequency (in Hz)','fontsize',20);
|
||
|
% ylabel('magnitude','fontsize',20);
|
||
|
% title('MUSIC');
|
||
|
% hold off;
|
||
|
% drawnow;
|
||
|
|
||
|
% % montrer intéret paramétrique par rapport à FFT
|
||
|
% figure();
|
||
|
% fftxx = abs(fftshift(fft(xx))); % fftshift permet de passer de la fft entre 0 et fe à la fft entre -fe/2 et fe/2
|
||
|
% freq = linspace(-fe/2,fe/2,length(fftxx));
|
||
|
% plot(freq,fftxx);
|
||
|
% grid on;
|
||
|
% xlabel('fréqunce (Hz)');
|
||
|
% ylabel('amplitude (u.a.)');
|
||
|
% title('fft');
|
||
|
%
|
||
|
% figure();
|
||
|
% xx = [xx zeros(1,32768-length(xx))]; % 2^15 = 32768
|
||
|
% fftxx = abs(fftshift(fft(xx)));
|
||
|
% freq = linspace(-fe/2,fe/2,length(fftxx));
|
||
|
% plot(freq,fftxx);
|
||
|
% grid on;
|
||
|
% xlabel('fréqunce (Hz)');
|
||
|
% ylabel('amplitude (u.a.)');
|
||
|
% title('fft zero padding');
|