Line 109: | Line 109: | ||
%Here are links to the completed sound files | %Here are links to the completed sound files | ||
− | %[[Scott_HamiltonHailPurdueReg_ECE301Fall2008mboutin.wav]] | + | % [[Scott_HamiltonHailPurdueReg_ECE301Fall2008mboutin.wav]] |
− | %[[Scott_HamiltonHailPurdueFast_ECE301Fall2008mboutin.wav]] | + | % [[Scott_HamiltonHailPurdueFast_ECE301Fall2008mboutin.wav]] |
− | %[[Scott_HamiltonHailPurdueOctave_ECE301Fall2008mboutin.wav]] | + | % [[Scott_HamiltonHailPurdueOctave_ECE301Fall2008mboutin.wav]] |
Revision as of 13:19, 4 September 2008
%Scott Hamilton %HW 1 pt 1 %9/4/08 clear clc % Define Sampling rate Sample = 1 / 44100; %Define Pitches %known from class that A above middle C is 440 Hz, although not used in our %song we define it for determining the other notes A = 440; %Determined from the given information one ìhalf stepî is a ratio of (16/15) %therefore Ab can be determined from A and any sequencial notes Hs = 16 / 15; % Finding the frequencies below A Ab = A / Hs; G = Ab / Hs; Gb = G / Hs; F = Gb / Hs; E = F / Hs; Eb = E / Hs; % Finding the frequencies above A Bb = A * Hs; B = Bb * Hs; C = B * Hs; Db = C * Hs; D = Db * Hs; %Define Rest Rest = 0; % Define a beat, assuming the tempo is 140 bpm Beat = (60/140); %Define note durations %Quarter note Q = Beat; %Dotted Quarter Note Qd = 1.5 * Beat; %Half Note H = 2 * Beat; %Dotted Half Note Hd = 3 * Beat; %Eighth Note Et = .5 * Beat; %Define note progression, this is from a copy handed out it MUS 361 Notes = [ Eb, F, G Ab, Bb, C, C, Db, Db, Db, Ab, Bb, B, C, Rest, C, C, ... Bb, Ab, Bb, C, C, Bb, F, G, Ab, G, F, Bb, Rest, Eb, Eb, F, G, Ab,... Bb, C, C, C, Db, Db, Ab, Bb, C, Rest, F, G, Ab, F, Eb, Ab, C, Eb, F,... C, Bb, Ab, Ab]; %Define durations for the note progression Duration = [H, Q, Q, Qd, Et, Q, Q, Q, Et, Et, Q, Et, Et, Hd, Q, H, Q, Q,... Qd, Et, Q, Q, Q, Et, Et, Q, Et, Et, Hd, Q, Qd, Et, Q, Q, Qd, Et, Q,... Et, Et, Q, Q, Q, Q, Hd, Q, Qd, Et, Q, Q, Q, Q, Q, Q, Qd, Et, Qd,... Et, Hd]; Music1 = []; Music2 = []; Music3 = []; %Setup a loop for the notes to be played sequentially for x = 1 : length(Notes); t = 0 : Sample : Duration(x); Tone = sin(2 * pi * Notes(x) * t); Music1 = [Music1; Tone(:)]; end %Play song and write a .wav file sound(Music1, 1 / Sample); wavwrite(Music1, 1 / Sample, 32, 'c:\HailPurdueReg'); %define pause increments n = 5; pause(n); %Playing song in cut time requires halving the value of t for x = 1 : length(Notes); t = 0 : Sample : .5 * Duration(x); Tone = sin(2 * pi * Notes(x) * t); Music2 = [Music2; Tone(:)]; end %Play song and write a .wav file sound(Music2, 1 / Sample); wavwrite(Music2, 1 / Sample, 32, 'c:\HailPurdueFast'); pause(n); %Transform so that y(t)=x(2t), results in raising all pitches up 1 octave for x = 1 : length(Notes); t = 0 : Sample : Duration(x); Tone = sin(2 * pi * Notes(x) * 2 * t); Music3 = [Music3; Tone(:)]; end %Play song and write a .wav file sound(Music3, 1 / Sample); wavwrite(Music3, 1 / Sample, 32, 'c:\HailPurdueOctave');" %Here are links to the completed sound files % [[Scott_HamiltonHailPurdueReg_ECE301Fall2008mboutin.wav]] % [[Scott_HamiltonHailPurdueFast_ECE301Fall2008mboutin.wav]] % [[Scott_HamiltonHailPurdueOctave_ECE301Fall2008mboutin.wav]]