chordGen - deltat = 1./sf; %determines the time step totalt...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
function vecsnd = chordGen(vecf,sf,duration) %Given a vector containing one or more frequencies, a sampling %frequency, and a duration, write a function chordGen. It will create %a sound vector using the sin function that, when played at the inputted %sampling frequency, lasts for the inputted duration and is a chord of %all of the notes represented by the inputted frequencies. Your chord %should be scaled so that max(abs(chord))==1, it must be a column %vector (Mx1), and 1/fs should be the first time value used.
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: deltat = 1./sf; %determines the time step totalt = deltat:deltat:duration; %determines the total time of the sound file vecsnd = 0; %initializes the output for ndx = 1:length(vecf) vecsnd = vecsnd + sin(2.*pi.*vecf(ndx).*totalt); %generates the sound vector end largest = max(vecsnd); %finds the largest value in the vector vecsnd = vecsnd./largest; %gets the entire vector to be less than or equal to 1 vecsnd = vecsnd(:); %makes the vector vertical to be played like a sound end...
View Full Document

Ask a homework question - tutors are online