everything, up to 4.2.3 in the lab

This commit is contained in:
Gabri6 2023-03-29 23:53:56 +02:00
parent 7e417b271f
commit 9a9dbe0e86
1 changed files with 56 additions and 4 deletions

View File

@ -16,16 +16,15 @@ pkg load signal;
t=[1:1:size(y,1)];
figure;
subplot(1,1,1);
plot(t,y)
%xlabel('Time (s)');
%ylabel('Sound (dB)');
%Frequency spectrum using DFT
%%%%%[powerDFT durationDFT] = frequencySpectrum(y, fs, false);
[powerDFT durationDFT] = frequencySpectrum(y, fs, false);
%Frequency spectrum using FFT
%%%%%[powerFFT durationFFT] = frequencySpectrum(y, fs, true);
[powerFFT durationFFT] = frequencySpectrum(y, fs, true);
sprintf(["time used for DFT: " num2str(durationDFT)])
sprintf(["time used for FFT: " num2str(durationFFT)])
@ -40,4 +39,57 @@ spectrogram(y(0.76*fs:0.96*fs), fs, 5, 30);
spectrogram(y(1.38*fs:1.64*fs), fs, 5, 30);
%spectrogram of "three"
spectrogram(y(1.88*fs:2.18*fs), fs, 5, 30);
spectrogram(y(1.88*fs:2.18*fs), fs, 5, 30);
%frequency spectrum for one
n = length(y(0.76*fs:0.96*fs));
n = 2^nextpow2(n);
t_one=[0:1/fs:(n-1)/fs];
signal = [ y(0.76*fs:0.96*fs); zeros( n-length(y(0.76*fs:0.96*fs)), 1)];
figure;
plot(t_one, signal)
xticks(0:0.1*fs:n*fs);
xticklabels(0:0.1:n/fs);
xlabel('Time (s)');
ylabel('Amplitude (a.u.)');
%frequency spectrum for two
n = length(y(1.38*fs:1.64*fs));
n = 2^nextpow2(n);
t_one=[0:1/fs:(n-1)/fs];
signal = [ y(1.38*fs:1.64*fs); zeros( n-length(y(1.38*fs:1.64*fs)), 1)];
figure;
plot(t_one, signal)
xticks(0:0.1*fs:n*fs);
xticklabels(0:0.1:n/fs);
xlabel('Time (s)');
ylabel('Amplitude (a.u.)');
%frequency spectrum for three
n = length(y(1.88*fs:2.18*fs));
n = 2^nextpow2(n);
t_one=[0:1/fs:(n-1)/fs];
signal = [ y(1.88*fs:2.18*fs); zeros( n-length(y(1.88*fs:2.18*fs)), 1)];
figure;
plot(t_one, signal)
xticks(0:0.1*fs:n*fs);
xticklabels(0:0.1:n/fs);
xlabel('Time (s)');
ylabel('Amplitude (a.u.)');
downsampled_signal = downsample(y, fs/4000);
audiowrite("modulator_downsampled.wav", downsampled_signal, 4000);
decimated_signal = decimate(y, 6);
audiowrite("modulator_decimated.wav", decimated_signal, 4000);
low_fir = fir1(30, 1/1000, 'low')
freqz(low_fir);
low_fir_signal = filter(low_fir, 1, y);
audiowrite("low_fir_signal.wav", low_fir_signal, fs);
[a, b] = butter(8, 1/1000, 'low')
low_butter_signal = filter(a, b, y);
audiowrite("low_butter_signal.wav", low_butter_signal, fs);
low_fir_signal2 = downsample(low_fir_signal, fs/4000);