Matlab File
%Travis Safford (tsafford@purdue.edu %9/5/08 %Hw 1.1 clear; clc; %Google found me this lovely site %http://www.phy.mtu.edu/~suits/notefreqs.html %from the lads at MIT that has the note frequencies on it A = 440; Bb = 466.16; B = 493.88; Cb = 523.25; C = 523.25; Db = 554.37; D = 587.33; Eb = 622.25; E = 659.26; F = 698.46; Gb = 739.99; G = 783.99; Ab = 830.61; %And that's that. %Mimi used this in class, so i'll use it too delta =1/20000; %Assuming 4/4 quarter notes are 172 bmp %Thus 1 quarter note is 60/172 minutes Q = 60/172; %Quarter Note Ei = 0.5*Q; %Eighth note (can't be E because of note) H = 2*Q; %Half Note W = 4*Q; %Whole Note DQ = 1.5*Q; %Dotted Quarter DH = 3*Q; %Dotted Half %timing fot the notes Lengths =[H,Q,Q,DQ,Ei,Q,Q,Q,Ei,Ei,Q,Ei,Ei,DH,H,Q,Q,DQ,E,Q,Q,Q,Ei,Ei,Q,Ei,Ei,W,DQ,Ei,... Q,Q,DQ,Ei,Q,Ei,Ei,Q,Q,Q,Q,W,DQ,Ei,Q,Q,Q,Q,Q,Q,DQ,Ei,Dq,Ei,W,W]; %notes for song Notes =[A,B,Db,D,E,Gb,Gb,G,G,G,D,E,F,Gb,Gb,Gb,E,D,E,Gb,Gb,E,B,Db,D,Db,B,E,... A,A,B,Db,D,E,Gb,Gb,Gb,G,G,D,E,Gb,B,Db,D,B,A,D,Gb,A,B,Gb,E,D,D]; %regular speed for i = 1:length(Notes) t = 0:delta:Lengths(i); wave = sin(2*pi*t*Notes(i)); sound(wave,1/delta); allsound = cat(2, allsound, wave); end pause(5) %double speed %Cut lengths in half for j =1:length(Notes) t =0:delta:0.5*Lengths(j); wave =sin(2*pi*t*Notes(j)); sound(wave,1/delta); allsound = cat(2, allsound, wave); end pause(5) %doubles the frequencies for the transformation %y(t)=x(2t) for k =1:length(Notes) t =0:delta:Lengths(k); wave =sin(2*2*pi*t*Notes(k)); sound(wave,1/delta); allsound = cat(2, allsound, wave); end wavwrite(allsound,delta,'All_Sound.wav');