diff --git a/modulator22.wav b/data/modulator22.wav similarity index 100% rename from modulator22.wav rename to data/modulator22.wav diff --git a/data/modulator22_decimate.wav b/data/modulator22_decimate.wav new file mode 100644 index 0000000..f49943e Binary files /dev/null and b/data/modulator22_decimate.wav differ diff --git a/data/modulator22_downsample.wav b/data/modulator22_downsample.wav new file mode 100644 index 0000000..865f22e Binary files /dev/null and b/data/modulator22_downsample.wav differ diff --git a/modulator22_speedown.wav b/data/modulator22_speedown.wav similarity index 100% rename from modulator22_speedown.wav rename to data/modulator22_speedown.wav diff --git a/speech_analysis.m b/speech_analysis.m index 48775b9..8e6249b 100644 --- a/speech_analysis.m +++ b/speech_analysis.m @@ -2,7 +2,7 @@ pkg load signal clear all close all -[y,fs]=audioread('modulator22.wav'); +[y,fs]=audioread('./data/modulator22.wav'); t=0:1/fs:length(y)/fs-1/fs; @@ -12,9 +12,8 @@ t=0:1/fs:length(y)/fs-1/fs; ##xlabel('time(s)'); ##ylabel('amplitude(n.u.'); - -audiowrite('modulator22_speedown.wav', y , fs/2); -[y_speedown,fs_speedown]=audioread('modulator22_speedown.wav'); +audiowrite('./data/modulator22_speedown.wav', y , fs/2); +[y_speedown,fs_speedown]=audioread('./data/modulator22_speedown.wav'); t_speedown=0:1/fs_speedown:length(y_speedown)/fs_speedown-1/fs_speedown; ##figure; @@ -27,4 +26,77 @@ t_speedown=0:1/fs_speedown:length(y_speedown)/fs_speedown-1/fs_speedown; %frequencySpectrum(y_speedown, fs_speedown, true); %spectrogram(y_speedown, fs_speedown, 5, 30); -%spectrogram(y_speedown, fs_speedown, 5, 5); \ No newline at end of file +%spectrogram(y_speedown, fs_speedown, 5, 5); + +##y_downsampled = downsample(y, 2); +##fs_downsample = fs/2; +##audiowrite('./data/modulator22_downsample.wav', y_downsampled , fs_downsample); +##t_downsample=0:1/fs_downsample:length(y_downsampled)/fs_downsample-1/fs_downsample; +##y_decimated = decimate(y, 2); +##fs_decimate = fs/2; +##audiowrite('./data/modulator22_decimate.wav', y_decimated , fs_decimate); +##t_decimate=0:1/fs_decimate:length(y_decimated)/fs_decimate-1/fs_decimate; +## +##figure; +##set(gcf, 'name','Decimate vs Downsample'); +##title('Decimate vs Downsample'); +##plot(t_downsample,y_downsampled,'b'); +##hold on; +##plot(t_decimate,y_decimated,'g'); +##xlabel('time(s)'); +##ylabel('amplitude(n.u)'); +##legend('downsample()','decimate()',"location","southeastoutside"); +## +##frequencySpectrum(y_decimated, fs_decimate, true); +##frequencySpectrum(y_downsampled, fs_downsample, true); + +%%%FILTER IMPLEMENTATION %%%% +%creating a low pass filter FIR +N=30; +fc=1000; +bfir=fir1(N,fc/(fs/2)); +freqz(bfir,1); + +%filter the signal +y_FIR_filter=filter(bfir,1,y); + +%plot of the signal FIR +##figure; +##plot(y_FIR_filter,'g'); + +%creating a low pass filter IIR +N=8; +fc=1000; +[biir,a]=butter(N,fc/(fs/2)); +freqz(biir,a); +Z=roots(biir); %zeros of the transfer fct +P=roots(a); %poles fo the transfer fct + +%representation of zeros/poles in complex plan +##figure; +##zplane(Z,P); +##title('Zeros and poles of the transfer function of the IIR filter'); +##legend('zeros','poles'); +##grid on; + +%filter the signal +y_IIR_filter=filter(biir,a,y); + +%plot of the signal IIR +##figure; +##plot(y_IIR_filter,'b'); + +%downsample of the IIR signal +y_IIR_downsample = downsample(y_downsampled, 2); +fs_IIR_downsample = fs/2; +t_IIR_downsample=0:1/fs_IIR_downsample:length(y_IIR_downsample)/fs_IIR_downsample-1/fs_IIR_downsample; + +figure; +set(gcf, 'name','Downsample of IIR'); +plot(t_IIR_downsample,y_IIR_downsample,'b'); +xlabel('time(s)'); +ylabel('amplitude(n.u)'); +legend('downsample()',"location","southeastoutside"); + + +