updated octave code very nice

This commit is contained in:
Camille CONJAT 2023-03-21 17:05:43 +01:00
parent b8ed5c4198
commit 4a81dac6b2
4 changed files with 42 additions and 1 deletions

BIN
modifiedwithdecimate.wav Normal file

Binary file not shown.

BIN
modifiedwithdownsample.wav Normal file

Binary file not shown.

BIN
modulator22.wav Normal file

Binary file not shown.

View File

@ -1 +1,42 @@
pkg load signal
pkg load signal;
[y, fs] = audioread("modulator22.wav");
range = 0:1/fs:(1/fs)*(size(y)-1);
#plot (range, y);
#xlabel ("Time (s)");
#ylabel ("Amplitude (arbitrary unit)");
b=fir1(30,1000/(fs/2));
yfiltered=filter(b,1,y);
a=butter(8,1000/(fs/2));
ybuttered=filter(a,1,y);
[h,w]=freqz(a,1)
freqz_plot(w,h);
newfsdwn = 4000;
n=fs/newfsdwn;
ydwn = downsample(ybuttered, n);
audiowrite("modifiedwithdownsample.wav",ydwn,newfsdwn);
ydec = decimate(ybuttered,6);
fsndec = fs*size(ydec)/size(y);
audiowrite("modifiedwithdecimate.wav",ydec,fsndec);
y_min = find(range >= 0,1);
y_max = find(range <= 0.3,1,"last");
yf= y(y_min:y_max);
[power, duration] = frequencySpectrum(ybuttered, fs, true);
spectrogram(ybuttered, fs, 5, 30);