diff --git a/docs/SARaudio.m b/docs/SARaudio.m index fa6af45b537bbdfcbed3921ddea17dce8f302463..6299c3cddd5f1c12fec0686f5fd3f9d757d53dc1 100644 --- a/docs/SARaudio.m +++ b/docs/SARaudio.m @@ -1,4 +1,4 @@ -cclear all; +clear all; close all; %{ [x,fe]=audioread('/homes/t24dherv/Documents/SAR_audio/single_tone_cello-a3.wav'); @@ -156,7 +156,7 @@ plot(f, (X_saw)); title('Spectre signal dent de scie'); xlabel('Fréquence (Hz)'); ylabel('Amplitude (dB)'); xlim([0 5000]); -%} + % Signal d’entrée : signal dent de scie fe = 44100; @@ -164,24 +164,84 @@ f0 = 10; D = 100/f0; t = linspace(0, D, D*fe); x = sawtooth(2*pi*f0*t); +z = square(2*pi*f0*t); % Filtrage passe-bas d’ordre 1 b = [0.5 0.5]; a = 1; y = filter(b, a, x); +w = filter(b, a, z); % FFT N = length(x); X = fftshift(abs(fft(x))/N); Y = fftshift(abs(fft(y))/N); +Z = fftshift(abs(fft(z))/N); +W = fftshift(abs(fft(w))/N); f = linspace(-fe/2, fe/2, N); + % Affichage figure; -plot(f, 20*log10(X), 'b*'); hold on; +plot(f, 20*log10(X), 'b'); hold on; plot(f, 20*log10(Y), 'r'); legend('Entrée (signal brut)', 'Sortie filtrée'); xlabel('Fréquence (Hz)'); ylabel('Amplitude (dB)'); title('Spectre avant et après filtrage passe-bas'); -xlim([0 5000]); \ No newline at end of file +xlim([0 5000]); + +figure; +plot(f, 20*log(Z), 'b'); hold on; +plot(f, 20*log(W), 'r'); + +figure(2); +legend('Entrée (signal brut)', 'Sortie filtrée'); +xlabel('Fréquence (Hz)'); +ylabel('Amplitude (dB)'); +title('Spectre avant et après filtrage passe-bas'); +xlim([0 5000]); + +soundsc(w,fe) +audiowrite('square_filtre.wav', w, fe); + + +d = designfilt('lowpassiir','FilterOrder',3,'HalfPowerFrequency',1); + +y_2 = filter(d,z); + +Y_2 = fftshift(abs(fft(y_2))/N); + +figure; +plot(f, 20*log10(X), 'b'); hold on; +plot(f, 20*log10(Y_2), 'r'); +legend('Entrée (signal brut)', 'Sortie filtrée'); +xlabel('Fréquence (Hz)'); +ylabel('Amplitude (dB)'); +title('Spectre avant et après filtrage passe-bas'); +xlim([0 5000]); + +soundsc(y_2,fe); +%} + + +load('signal_excitation.mat'); + +%{ +plot(xcorr(xe1,xe1)) +plot(xcorr(xe2,xe2)) +load('signal_excitation.mat'); +y = simule_piece(xe1, fe); +plot(xcorr(y,xe1)); +%} + +[x_test,fe_test]=audioread('/homes/t24dherv/Documents/SAR_audio/single_tone_guitar_nylon_string_a3.wav'); +soundsc(x_test,fe_test); + + + +y = conv(xe1,x_test(:,2)); + + +%plot(y); +soundsc(y,fe); \ No newline at end of file