Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

MATLAB Multi-Octave Generation from one Scale The C major scale, covering one oc

ID: 2079243 • Letter: M

Question

MATLAB Multi-Octave Generation from one Scale

The C major scale, covering one octave, is given by the notes {C CS D DS E F FS G GS A AS B}, where CS, DS, FS, GS and AS stand for C-sharp etc. The reference pitch is the note "A above middle C, " and equals 440 Hz. The successive notes differ by a factor of 2%^(1/12). For example, the note C has the pitch of [440*2^(-9/12)] Hz, and the note B has the pitch of [440*2^(2/12)] Hz. Generate the sinusoids that correspond to one octave of notes given above. You have to make a choice of sampling frequency for generating the discrete sinusoids; call this sampling frequency f_s1. Play the octave scale with various sampling frequencies, including f_s1. For example try 2* f_s1 and 0.5* f_s1. Comment on the pitch that you hear. This is an example of sampling at one rate and reconstructing at another. Compose your own short piece of music, or choose any another short piece and play using the notes that you generated. You may need more than one octave scale; how would you generate the notes for an octave above? [Caution: In practice, you will need to use the same reconstruction rate for all octaves!]. Many musical instruments produce notes that contain "overtones, " which are harmonics of the pitch. Try to incorporate the overtones to produce a more natural sounding set of notes.

Explanation / Answer


for p=1:1:10
n=randi([1,p])
fs=n*10000;
t=0:1/fs:1000;
k=sin(2*pi*400*t);
sound(k,fs);
pause(0.001);
end