%HW 1 ECE 301
%Jeff Gaines

%REGULAR SPEED
%beats/min = 112 -> quarter note = .5357 sec
delta = 0.00005;
half = [0:delta:1.0714];
dottedquarter = [0:delta:0.8036];
quarter = [0:delta:0.5357];
eighth = [0:delta:0.26785];

%Notes used
quarter_g = sin(2*pi*(2^(-1/6)*440)*quarter);
quarter_bf = sin(2*pi*(2^(1/12)*440)*quarter);
dottedquarter_c = sin(2*pi*(2^(1/4)*440)*dottedquarter);
eighth_df = sin(2*pi*(2^(1/3)*440)*eighth);
half_c = sin(2*pi*(2^(1/4)*440)*half);
half_g = sin(2*pi*(2^(-1/6)*440)*half);

%Note sequence (I made the last note a half G instead of quarter G since it
%sounds more like the song)
melody = [quarter_g, quarter_bf, dottedquarter_c, quarter_g, quarter_bf, eighth_df, half_c, quarter_g, quarter_bf, dottedquarter_c, quarter_bf, half_g];
sound(melody, 1/delta)
wavwrite(melody, 1/delta, 32, 'regular.wav');
pause(8)

%FAST SPEED
delta = 0.00005;
half = [0:delta:1.0714*.5];
dottedquarter = [0:delta:0.8036*.5];
quarter = [0:delta:0.5357*.5];
eighth = [0:delta:0.26785*.5];

%Notes used
quarter_g = sin(2*pi*(2^(-1/6)*440)*quarter);
quarter_bf = sin(2*pi*(2^(1/12)*440)*quarter);
dottedquarter_c = sin(2*pi*(2^(1/4)*440)*dottedquarter);
eighth_df = sin(2*pi*(2^(1/3)*440)*eighth);
half_c = sin(2*pi*(2^(1/4)*440)*half);
half_g = sin(2*pi*(2^(-1/6)*440)*half);

%Note sequence
fast_melody = [quarter_g, quarter_bf, dottedquarter_c, quarter_g, quarter_bf, eighth_df, half_c, quarter_g, quarter_bf, dottedquarter_c, quarter_bf, half_g];
sound(fast_melody, 1/delta)
wavwrite(fast_melody, 1/delta, 32, 'fast.wav');
pause(5)

%HIGHER PITCH
delta = 0.00005;
half = [0:delta:1.0714*.5];
dottedquarter = [0:delta:0.8036*.5];
quarter = [0:delta:0.5357*.5];
eighth = [0:delta:0.26785*.5];

%Notes used
quarter_g = sin(4*pi*(2^(-1/6)*440)*quarter);
quarter_bf = sin(4*pi*(2^(1/12)*440)*quarter);
dottedquarter_c = sin(4*pi*(2^(1/4)*440)*dottedquarter);
eighth_df = sin(4*pi*(2^(1/3)*440)*eighth);
half_c = sin(4*pi*(2^(1/4)*440)*half);
half_g = sin(4*pi*(2^(-1/6)*440)*half);

%Note sequence
high_melody = [quarter_g, quarter_bf, dottedquarter_c, quarter_g, quarter_bf, eighth_df, half_c, quarter_g, quarter_bf, dottedquarter_c, quarter_bf, half_g];
sound(high_melody, 1/delta)
wavwrite(high_melody, 1/delta, 32, 'higher.wav');
pause(5)

%PART 2
[beatles, fs, bits] = wavread('Beatles.wav');
sound(beatles, fs, bits)
pause(30)
%"number 9" over and over
reverse = flipud(beatles);
sound(reverse, fs, bits)
wavwrite(reverse, fs, 32, 'reverse.wav');
pause(30)
%sounds to me like "let me on the money", but I've read in the past people
%think it says "turn me on dead man"

Media:regular.wav
Media:fast.wav
Media:higher1.wav
Media:reverse.wav

Alumni Liaison

Correspondence Chess Grandmaster and Purdue Alumni

Prof. Dan Fleetwood