transposeSound - Ştermines the new duration if newdur>...

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

View Full Document Right Arrow Icon
function vecamp = transposeSound(amp,sf,half,newdur) %Write a function, transposeSound, that takes in an amplitude vector and %sampling frequency from wavread, the number of half steps to transpose %the note, and the new duration of the note. This function should %transpose the note using round(linspace(. ..)). After it is transposed, %it should either be truncated or zero-filled so that the note is the %specified length. Be sure to index using an integer; round if %necessary. amp = amp(round(linspace(1,end,(end/2.^(half./12))))); %transposes the note duration2 = length(amp)./sf;
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: %determines the new duration if newdur > duration2 %checks to see if the desired duration is longer or shorter than the %new duration change = round((newdur - duration2).*sf); %determines the length of the change vector newlength = zeros(change,1); %creates the silence vector vecamp = [amp;newlength]; %concatenates the silence vector else change = round(newdur.*sf); %if the desired length is shorter than the new length then part of the %sound will not be played vecamp = [amp(1:change)]; %cuts of the undesired sound end end...
View Full Document

{[ snackBarMessage ]}

Ask a homework question - tutors are online