diff --git a/FT_times.m b/FT_times.m index d18fccf..46402f4 100644 --- a/FT_times.m +++ b/FT_times.m @@ -16,4 +16,6 @@ for j = 1:item_num endfor printf('Average DFT time: %d \n', mean(times(1:item_num, 1))) -printf('Average FFT time: %d \n', mean(times(1:item_num, 2))) \ No newline at end of file +printf('Standard deviation of DFT time: %d \n', std(times(1:item_num, 1))) +printf('Average FFT time: %d \n', mean(times(1:item_num, 2))) +printf('Standard deviation of FFT time: %d \n', std(times(1:item_num, 2))) \ No newline at end of file diff --git a/one.png b/one.png new file mode 100644 index 0000000..1cbb2e5 Binary files /dev/null and b/one.png differ diff --git a/sound/output.wav b/sound/output.wav index b00d743..ce603f2 100644 Binary files a/sound/output.wav and b/sound/output.wav differ diff --git a/spectral_analysis.m b/spectral_analysis.m index c79bb80..8963dd3 100644 --- a/spectral_analysis.m +++ b/spectral_analysis.m @@ -3,7 +3,44 @@ close all clc [y, fs] = audioread("sound/modulator22.wav"); -%frequencySpectrum(y, fs, 0); %true does FFT, false DFT -step_size = 5; %ms -window_size = 30;%ms -spectrogram(y, fs, step_size, window_size) \ No newline at end of file +ranges = [17000, 20000; 29000, 37000; 41000, 46000]; +one = y(ranges(1,1):ranges(1,2)); +two = y(ranges(2,1):ranges(2,2)); +three = y(ranges(3,1):ranges(3,2)); + +word = one; + +n = length(word); +f = (0:n-1)*(fs/n); +f1 = 0;%Hz +f2 = 4000;%Hz +idx = find(f >= f1 & f <= f2); %define the index of the freq range +f = f(idx); +y = fft(word, n);% compute DFT of input signal +power = abs(y).^2/n; +power = power(idx); +[val, ind] = max(power); + +%lowpass for the formant + +Fc = 2000; % define the cutoff frequency of the low-pass filter +[b, a] = butter(6, Fc/(fs/2), 'low'); % design a 4th-order Butterworth low-pass filter +Pxx_filt = filter(b, a, power); % apply the filter to the power spectrum +length(Pxx_filt) +length(f) + + +figure; + +subplot(1,2,1) % time plot +plot(0:1/fs:(length(word)-1)/fs,word); +xlabel('Time (s)'); +ylabel('Amplitude (a.u.)'); + +subplot(1,2,2) % freq range plot +plot(f,10*log10(power/power(ind))); hold on; +plot(f, 10*log10(Pxx_filt), 'r'); +xlabel('Frequency (Hz)') +ylabel('Power (dB)') + + diff --git a/spectrogram_analysis.m b/spectrogram_analysis.m new file mode 100644 index 0000000..8d0ba45 --- /dev/null +++ b/spectrogram_analysis.m @@ -0,0 +1,8 @@ +clear all +close all +clc + +[y, fs] = audioread("sound/modulator22.wav"); +step_size = 5; %ms +window_size = 30;%ms, ideal value 25 +spectrogram(y, fs, step_size, window_size) \ No newline at end of file diff --git a/three.png b/three.png new file mode 100644 index 0000000..e43cf70 Binary files /dev/null and b/three.png differ diff --git a/two.png b/two.png new file mode 100644 index 0000000..acd8f7b Binary files /dev/null and b/two.png differ