%Speech Processing
pkg load signal

modfile = "modulator22.wav";
carfile = "carrier22.wav";
white = "white.wav";
white_p = "white_periodic.wav";
outfile = "vocodedsound.wav";
[modul, sr1] = audioread(modfile);
[carrier, sr2] = audioread(carfile);
[carrier_w, sr2_w] = audioread(carfile);
[carrier_wp, sr2_wp] = audioread(carfile);

if sr1 ~= sr2
  disp('Your sampling rates dont match');
endif

y = chanvocoder(carrier,modul, 512, 32, .2);
audiowrite("vocodedsound.wav", y, sr1);
y_w = chanvocoder(carrier_w,modul, 512, 32, .2);
audiowrite("vocodedsound_w.wav", y, sr1);
y_wp = chanvocoder(carrier_wp,modul, 512, 32, .2);
audiowrite("vocodedsound_wp.wav", y, sr1);

%spectogram
frequencySpectrum(modul,sr1,1);
frequencySpectrum(carrier,sr2,1);
frequencySpectrum(y,sr1,1);