diff --git a/FIR.wav b/FIR.wav new file mode 100644 index 0000000..e9c4f27 Binary files /dev/null and b/FIR.wav differ diff --git a/butter.wav b/butter.wav new file mode 100644 index 0000000..5fc2ac5 Binary files /dev/null and b/butter.wav differ diff --git a/buttering.m b/buttering.m new file mode 100644 index 0000000..6cefc3e --- /dev/null +++ b/buttering.m @@ -0,0 +1,18 @@ +clear all +close all +pkg load signal +[y,fs] = audioread('modulator22.wav'); +sound(y, fs); +n = length(y); +t=0:1/fs:(n-1)/fs; % time range +spectrogram(y,fs,5,30); + +[y, fs] = audioread('modulator22.wav'); +n = 8; +Wn = 0.0453; +[b, a] = butter(n, Wn); + +y = filter(b, a, y); +spectrogram(y,fs,5,30); +sound(y, fs); +audiowrite('butter.wav',y,fs); diff --git a/carrier22.wav b/carrier22.wav new file mode 100644 index 0000000..8b2526c Binary files /dev/null and b/carrier22.wav differ diff --git a/chanvocoder.m b/chanvocoder.m new file mode 100644 index 0000000..959a711 --- /dev/null +++ b/chanvocoder.m @@ -0,0 +1,37 @@ +function y = chanvocoder(carrier, modul, chan, numband, overlap) +% y = chanvocoder(carrier, modul, chan, numband, overlap) +% The Channel Vocoder modulates the carrier signal with the modulation signal +% chan = number of channels (e.g., 512) +% numband = number of bands (chan, error('# bands must be < # channels'), end +[rc, cc] = size(carrier); if cc>rc, carrier = carrier'; end +[rm, cm] = size(modul); if cm>rm, modul = modul'; end +st = min(rc,cc); % stereo or mono? +if st~= min(rm,cm), error('carrier and modulator must have same number of tracks'); end +len = min(length(carrier),length(modul)); % find shortest length +carrier = carrier(1:len,1:st); % shorten carrier if needed +modul = modul(1:len,1:st); % shorten modulator if needed +L = 2*chan; % window length/FFT length +w = hanning(L); if st==2, w=[w w]; end % window/ stereo window +bands = 1:round(chan/numband):chan; % indices for frequency bands +bands(end) = chan; +y = zeros(len,st); % output vector +ii = 0; +while ii*L*overlap+L <= len + ind = round([1+ii*L*overlap:ii*L*overlap+L]); + FFTmod = fft( modul(ind,:) .* w ); % window & take FFT of modulator + FFTcar = fft( carrier(ind,:) .* w ); % window & take FFT of carrier + syn = zeros(chan,st); % place for synthesized output + for jj = 1:numband-1 % for each frequency band + b = [bands(jj):bands(jj+1)-1]; % current band + syn(b,:) = FFTcar(b,:)*diag(mean(abs(FFTmod(b,:)))); + end % take product of spectra + midval = FFTmod(1+L/2,:).*FFTcar(1+L/2,:); % midpoint is special + synfull = [syn; midval; flipud( conj( syn(2:end,:) ) );]; % + and - frequencies + timsig = real( ifft(synfull) ); % invert back to time + y(ind,:) = y(ind,:) + timsig; % add back into time waveform + ii = ii+1; +end +y = 0.8*y/max(max(abs(y))); % normalize output \ No newline at end of file diff --git a/decimated.wav b/decimated.wav new file mode 100644 index 0000000..5d25dd9 Binary files /dev/null and b/decimated.wav differ diff --git a/decimato.m b/decimato.m new file mode 100644 index 0000000..c6131ab --- /dev/null +++ b/decimato.m @@ -0,0 +1,14 @@ +clear all +close all +pkg load signal +[x, fs] = audioread('modulator22.wav'); +sound(x, fs); +y = decimate(x, 5); +new_fs = fs/5; +display(new_fs); +audiowrite('decimated.wav', y, new_fs); +spectrogram(x,fs,5,30); +title('original'); +spectrogram(y,fs,5,30); +title('decimato'); +sound(y, new_fs); \ No newline at end of file diff --git a/down.wav b/down.wav new file mode 100644 index 0000000..f946903 Binary files /dev/null and b/down.wav differ diff --git a/downsampl.m b/downsampl.m new file mode 100644 index 0000000..c510bbb --- /dev/null +++ b/downsampl.m @@ -0,0 +1,15 @@ +clear all +close all +pkg load signal +[x, fs] = audioread('butter.wav'); +sound(x, fs); +new_fs = fs/5; +display(new_fs); +r = fs/new_fs; +y = downsample(x, r); +audiowrite('down.wav', y, new_fs); +spectrogram(x,fs,5,30); +title('original'); +spectrogram(y,fs,5,30); +title('dowsampled'); +sound(y, new_fs); \ No newline at end of file diff --git a/downsampling.m b/downsampling.m deleted file mode 100644 index ca694e6..0000000 --- a/downsampling.m +++ /dev/null @@ -1,10 +0,0 @@ -clear all -close all -pkg load signal -[y,fs] = audioread('modulator22.wav'); -audiowrite('outmodulator22.wav',y,fs/2); -n = length(y); -t=0:1/fs:(n-1)/fs; % time range -downsample(y,4000); -spectrogram(y,fs,5,30); -[power,duration]=frequencySpectrum(y, fs, false); \ No newline at end of file diff --git a/fir.m b/fir.m new file mode 100644 index 0000000..e3b4f2f --- /dev/null +++ b/fir.m @@ -0,0 +1,19 @@ +clear all +close all +pkg load signal +[y,fs] = audioread('modulator22.wav'); +sound(y, fs); +n = length(y); +t=0:1/fs:(n-1)/fs; % time range +spectrogram(y,fs,5,30); + +[y, fs] = audioread('modulator22.wav'); +n = 30; +fc = 1000/(fs/2); +w = hamming(n+1); +b = fir1(n, fc, w); +filtered_signal = filter(b, 1, y); +spectrogram(filtered_signal,fs,5,30); +sound(filtered_signal, fs); +audiowrite('FIR.wav',filtered_signal,fs); + diff --git a/last.m b/last.m new file mode 100644 index 0000000..a69da34 --- /dev/null +++ b/last.m @@ -0,0 +1,21 @@ +pkg load signal + +[x, fs] = audioread('carrier22.wav'); +recording_duration = 5; % in seconds % in Hz + + +printf('Start recording...\n'); +recording = record(5, 22400); +printf('Recording finished.\n'); +audiowrite('recording.wav', recording, fs); +plot(recording); +recording1= 'recording.wav'; +carrierfile = 'carrier22.wav'; +outfile = 'vocodedsound.wav'; + +[modul, sr1] = audioread(recording1); +[carrier, sr2] = audioread(carrierfile); +if sr2 ~= fs, disp('your sampling rates dont match'); end + +y = chanvocoder(carrier, modul, 512, 16, 0.2); +audiowrite('outfile.wav', y, sr1); \ No newline at end of file diff --git a/ouaiouai.m b/ouaiouai.m new file mode 100644 index 0000000..4fdfb5c --- /dev/null +++ b/ouaiouai.m @@ -0,0 +1,40 @@ +pkg load signal +[y,fs] = audioread('modulator22.wav'); +audiowrite('outmodulator22.wav',y,fs/2); +n = length(y); +t=0:1/fs:(n-1)/fs; % time range +i=1; +ldft=[]; +while (i<6) + [power,duration]=frequencySpectrum(y, fs, false); + disp(i); + disp (duration); + ldft(i)=duration; + i=i+1; +end +disp (ldft); +lfft=[]; +i=1; +while (i<6) + [power,duration]=frequencySpectrum(y, fs, true); + disp(i); + disp (duration); + lfft(i)=duration; + i=i+1; +end +disp (lfft); +i=1; +ratio=[]; +while (i<6) + ratio(i)=(lfft(i))/(ldft(i)); + i=i+1; +end +disp('ratio'); +disp(ratio); +avgratio=mean(ratio); +disp('avgratio'); +disp(avgratio); + +stdratio= std(ratio); +disp('stdratio'); +disp(stdratio); diff --git a/outfile.wav b/outfile.wav new file mode 100644 index 0000000..080a11d Binary files /dev/null and b/outfile.wav differ diff --git a/outmodulator22.wav b/outmodulator22.wav index b00d743..1205046 100644 Binary files a/outmodulator22.wav and b/outmodulator22.wav differ diff --git a/outmodulator22_downsampled.wav b/outmodulator22_downsampled.wav new file mode 100644 index 0000000..c1c4b6a Binary files /dev/null and b/outmodulator22_downsampled.wav differ diff --git a/output.wav b/output.wav new file mode 100644 index 0000000..5034ae1 Binary files /dev/null and b/output.wav differ diff --git a/recording b/recording new file mode 100644 index 0000000..e69de29 diff --git a/recording.wav b/recording.wav new file mode 100644 index 0000000..0fc2ec3 Binary files /dev/null and b/recording.wav differ diff --git a/speech_anlysisall.m b/speech_anlysisall.m deleted file mode 100644 index a894f66..0000000 --- a/speech_anlysisall.m +++ /dev/null @@ -1,11 +0,0 @@ -clear all -close all -pkg load signal -[y,fs] = audioread('modulator22.wav'); -audiowrite('outmodulator22.wav',y,fs/2); -n = length(y); -t=0:1/fs:(n-1)/fs; % time range -spectrogram(y,fs,5,30); -y=y(floor(0.7*fs):floor(1.15*fs)); -[power,duration]=frequencySpectrum(y, fs, false); -spectrogram(y,fs,5,30); diff --git a/vocodedsound.wav b/vocodedsound.wav new file mode 100644 index 0000000..b4c7b37 Binary files /dev/null and b/vocodedsound.wav differ diff --git a/vocoder.m b/vocoder.m new file mode 100644 index 0000000..a37b916 --- /dev/null +++ b/vocoder.m @@ -0,0 +1,9 @@ +pkg load signal +modfile = 'modulator22.wav'; +carfile = 'carrier22.wav'; +outfile = 'vocodedsound.wav' +[modul, sr1] = audioread(modfile); +[carrier, sr2] = audioread(carfile); +if sr1~=sr2, disp('your sampling rates dont match'); end +y = chanvocoder(carrier, modul, 512, 16, .2); +audiowrite('outfile.wav',y,sr1) \ No newline at end of file diff --git a/white.wav b/white.wav new file mode 100644 index 0000000..98c77ea Binary files /dev/null and b/white.wav differ diff --git a/white_periodic.wav b/white_periodic.wav new file mode 100644 index 0000000..f24def4 Binary files /dev/null and b/white_periodic.wav differ