From 5a5fdef3c9df8b926c0d7a05191da8663be96cd4 Mon Sep 17 00:00:00 2001 From: Gabri6 Date: Thu, 30 Mar 2023 17:52:51 +0200 Subject: [PATCH] record mic and use chanvocode on it with white sound --- vocoder.m | 48 ++++++++++++++++++++++++++++++------------------ 1 file changed, 30 insertions(+), 18 deletions(-) diff --git a/vocoder.m b/vocoder.m index 090079c..2e459f4 100644 --- a/vocoder.m +++ b/vocoder.m @@ -12,7 +12,7 @@ pkg load signal; modfile = 'modulator22.wav'; -carfile = 'carrier22.wav'; +carfile = 'white_periodic.wav'; outfile = 'vocodedsound.wav' [modul, sr1] = audioread(modfile); [carrier, sr2] = audioread(carfile); @@ -20,26 +20,38 @@ if sr1~=sr2, disp('your sampling rates dont match'); end y = chanvocoder(carrier, modul, 512, 16, .2); audiowrite(outfile, y, sr1); -figure; +%figure; -subplot(3,1,1); -t=[1:1:size(modul,1)]; +%subplot(3,1,1); +%t=[1:1:size(modul,1)]; -plot(t,modul); -xlabel('Time (s)'); -ylabel("Modulator's Amplitude (a.u.)"); +%plot(t,modul); +%xlabel('Time (s)'); +%ylabel("Modulator's Amplitude (a.u.)"); -subplot(3,1,2); -t=[1:1:size(carrier,1)]; +%subplot(3,1,2); +%t=[1:1:size(carrier,1)]; -plot(t,carrier); -xlabel('Time (s)'); -ylabel("Carrier's Amplitude (a.u.)"); +%plot(t,carrier); +%xlabel('Time (s)'); +%ylabel("Carrier's Amplitude (a.u.)"); -subplot(3,1,3); -[y fs]=audioread(outfile); -t=[1:1:size(y,1)]; +%subplot(3,1,3); +%[y fs]=audioread(outfile); +%t=[1:1:size(y,1)]; -plot(t,y); -xlabel('Time (s)'); -ylabel("Outfile's Amplitude (a.u.)"); \ No newline at end of file +%plot(t,y); +%xlabel('Time (s)'); +%ylabel("Outfile's Amplitude (a.u.)"); + +recorded_signal=record(size(carrier,1)/sr2, sr1); +audiowrite("recorded_signal.wav", recorded_signal, sr1); + +modfile = "recorded_signal.wav"; +carfile = 'white_periodic.wav'; +outfile = 'recorded_coded_sound.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, y, sr1);