MATLAB Code
% Hang Zhang % ECE301 % Homework 1.1 % 9-5-08 %Preparation clc clear all %Solve for X given 440Hz is an A note by using the directions given on instruction sheet. A = 440; x = 440*3/5; upC = 2*x; %upper C B = 15*x/8; G = 3*x/2; F = 4*x/3; E = 5*x/4; D = 9*x/8; midC = x; %middle C delta = 1/20000; noteLength = .25;%length of note being played noteList = [A, B, D, D*2, E, G, G, G*2, G*2, G*2, D*2, E, F, G]; %list of notes %Normal speed song = [0]; for count=1:length(noteList); t = 0:delta:0.5; song = [song sin(2*pi*t*noteList(count))]; end sound(song, 1/delta); wavwrite(song, 20000, 16, 'hailPurd_norm.wav'); fprintf('Press enter after music stops....\n') pause %Twice as fast songFast = [0]; for count=1:length(noteList); t = 0:delta:0.25; songFast = [songFast sin(2*pi*t*noteList(count))]; end sound(songFast, 1/delta); wavwrite(songFast, 20000, 16, 'hailPurd_fast.wav'); fprintf('Press enter after music stops....\n') pause %Twice the frequency songHigh = [0]; for count=1:length(noteList) t = 0:delta:0.5; songHigh = [songHigh sin(2*pi*t*2*noteList(count))]; end sound(songHigh, 1/delta); wavwrite(songHigh, 20000, 16, 'hailPurd_highpitch.wav');
Sound Files
Normal Rate: Media:HailPurd_norm_ECE301Fall2008mboutin.wav
Fast Rate: Media:HailPurd_fast_ECE301Fall2008mboutin.wav
Higher pitched: Media:HailPurd_highpitch_ECE301Fall2008mboutin.wav