MATLAB: signal processing chorus with sample

function song = playSong(theVoices)
fs = 8000;
spp = 0.2;
   %a zero vector with respect to the final pulse position and duration
song = zeros(1, 321*spp*fs);

   %cycling thought the different voices f
or ii = 1:length(theVoices)
       %cycling through each voice to build the song

    for kk = 1:length(theVoices(ii).noteNumbers) 
      note = real(0.1*exp(1j*2*pi*(440*2^((theVoices(ii).noteNumbers(kk)- 49)/12))*((1/fs):(1/fs):            (theVoices(ii).durations(kk)*spp))));

     %start and end pulses with regards to fs locstart = theVoices(ii).startPulses(kk)*1600;
     locend = locstart + length(note) - 1;
     song(locstart:locend) = song(locstart:locend) + note;
   end
end

load 'handel.mat';
filename = 'lab3song5.wav';
soundsc(song, fs);
audiowrite(filename, song, 8000);

OUTPUT




Comments

Post a Comment

Popular posts from this blog