Line 1: Line 1:
clear all;<br>clc
+
= Michael Meyer: ECE 301 Homework 1 =
  
%%Question 1. Part 1.%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
  
bpm = 112;
 
  
delta = 0.00005;
 
  
%%Note lengths.<br>half = [0:delta:120/bpm];<br>quart = [0:delta:60/bpm];<br>eighth = [0:delta:30/bpm];<br>dotquart = [0:delta:90/bpm];
+
clear all;<br>clc
  
%%Note Frequencies.<br>gfreq = 2^(-2/12)*440;<br>bffreq = 2^(1/12)*440;<br>cfreq = 2^(3/12)*440;<br>dffreq = 2^(4/12)*440;
+
%%Question 1. Part 1.%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  
%%Notes<br>G = sin(2*pi*gfreq*quart);<br>Bf = sin(2*pi*bffreq*quart);<br>Cdq = sin(2*pi*cfreq*dotquart);<br>Df = sin(2*pi*dffreq*eighth);<br>Ch = sin(2*pi*cfreq*half);
+
bpm = 112;  
  
%%Song<br>song = [G, Bf, Cdq, G, Bf, Df, Ch, G, Bf, Cdq, Bf, G];
+
delta = 0.00005;  
  
sound(song, 1/delta)<br>wavwrite(song, 1/delta, '112bpm.wav')<br>pause(1);
+
%%Note lengths.<br>half = [0:delta:120/bpm];<br>quart = [0:delta:60/bpm];<br>eighth = [0:delta:30/bpm];<br>dotquart = [0:delta:90/bpm];  
  
<br>%%Question 1. Part 2.%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
%%Note Frequencies.<br>gfreq = 2^(-2/12)*440;<br>bffreq = 2^(1/12)*440;<br>cfreq = 2^(3/12)*440;<br>dffreq = 2^(4/12)*440;
  
bpmfast = 224;
+
%%Notes<br>G = sin(2*pi*gfreq*quart);<br>Bf = sin(2*pi*bffreq*quart);<br>Cdq = sin(2*pi*cfreq*dotquart);<br>Df = sin(2*pi*dffreq*eighth);<br>Ch = sin(2*pi*cfreq*half);  
  
%%Note lengths.<br>half = [0:delta:120/bpmfast];<br>quart = [0:delta:60/bpmfast];<br>eighth = [0:delta:30/bpmfast];<br>dotquart = [0:delta:90/bpmfast];
+
%%Song<br>song = [G, Bf, Cdq, G, Bf, Df, Ch, G, Bf, Cdq, Bf, G];  
  
%%Notes<br>G = sin(2*pi*gfreq*quart);<br>Bf = sin(2*pi*bffreq*quart);<br>Cdq = sin(2*pi*cfreq*dotquart);<br>Df = sin(2*pi*dffreq*eighth);<br>Ch = sin(2*pi*cfreq*half);
+
sound(song, 1/delta)<br>wavwrite(song, 1/delta, '112bpm.wav')<br>pause(1);  
  
%%Fast Song<br>fastsong = [G, Bf, Cdq, G, Bf, Df, Ch, G, Bf, Cdq, Bf, G];
+
<br>%%Question 1. Part 2.%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  
sound(fastsong, 1/delta)<br>wavwrite(fastsong, 1/delta, '224bpm.wav')<br>pause(1);
+
bpmfast = 224;  
  
%%Question 1. Part 3.%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
%%Note lengths.<br>half = [0:delta:120/bpmfast];<br>quart = [0:delta:60/bpmfast];<br>eighth = [0:delta:30/bpmfast];<br>dotquart = [0:delta:90/bpmfast];
  
bpm = 112;
+
%%Notes<br>G = sin(2*pi*gfreq*quart);<br>Bf = sin(2*pi*bffreq*quart);<br>Cdq = sin(2*pi*cfreq*dotquart);<br>Df = sin(2*pi*dffreq*eighth);<br>Ch = sin(2*pi*cfreq*half);  
  
delta = 0.00005;
+
%%Fast Song<br>fastsong = [G, Bf, Cdq, G, Bf, Df, Ch, G, Bf, Cdq, Bf, G];  
  
%%Note lengths.<br>half = [0:delta:120/bpm];<br>quart = [0:delta:60/bpm];<br>eighth = [0:delta:30/bpm];<br>dotquart = [0:delta:90/bpm];
+
sound(fastsong, 1/delta)<br>wavwrite(fastsong, 1/delta, '224bpm.wav')<br>pause(1);  
  
%%Note Frequencies.<br>gfreq = 2^(-2/12)*440;<br>bffreq = 2^(1/12)*440;<br>cfreq = 2^(3/12)*440;<br>dffreq = 2^(4/12)*440;
+
%%Question 1. Part 3.%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  
%%Notes<br>G = sin(4*pi*gfreq*quart);<br>Bf = sin(4*pi*bffreq*quart);<br>Cdq = sin(4*pi*cfreq*dotquart);<br>Df = sin(4*pi*dffreq*eighth);<br>Ch = sin(4*pi*cfreq*half);
+
bpm = 112;  
  
%%Song<br>highsong = [G, Bf, Cdq, G, Bf, Df, Ch, G, Bf, Cdq, Bf, G];
+
delta = 0.00005;  
  
sound(highsong, 1/delta)<br>wavwrite(highsong, 1/delta, 'highpitch.wav')
+
%%Note lengths.<br>half = [0:delta:120/bpm];<br>quart = [0:delta:60/bpm];<br>eighth = [0:delta:30/bpm];<br>dotquart = [0:delta:90/bpm];
  
%%Combining all songs into one.<br>combined = horzcat(1, song, fastsong, highsong);
+
%%Note Frequencies.<br>gfreq = 2^(-2/12)*440;<br>bffreq = 2^(1/12)*440;<br>cfreq = 2^(3/12)*440;<br>dffreq = 2^(4/12)*440;  
  
wavwrite(combined, 1/delta, 'combined.wav')
+
%%Notes<br>G = sin(4*pi*gfreq*quart);<br>Bf = sin(4*pi*bffreq*quart);<br>Cdq = sin(4*pi*cfreq*dotquart);<br>Df = sin(4*pi*dffreq*eighth);<br>Ch = sin(4*pi*cfreq*half);
  
 +
%%Song<br>highsong = [G, Bf, Cdq, G, Bf, Df, Ch, G, Bf, Cdq, Bf, G];
  
 +
sound(highsong, 1/delta)<br>wavwrite(highsong, 1/delta, 'highpitch.wav')
  
%%Question 2. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
%%Combining all songs into one.<br>combined = horzcat(1, song, fastsong, highsong);
  
[Beatles, fs, N] = wavread('Beatles.wav');<br>RevBeatles = flipud(Beatles);<br>sound(RevBeatles, fs)<br>wavwrite(RevBeatles, fs, N, 'seltaeB.wav');
+
wavwrite(combined, 1/delta, 'combined.wav')  
  
 +
<br>
  
 +
%%Question 2.&nbsp;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  
Output Files:
+
[Beatles, fs, N] = wavread('Beatles.wav');<br>RevBeatles = flipud(Beatles);<br>sound(RevBeatles, fs)<br>wavwrite(RevBeatles, fs, N, 'seltaeB.wav');
 +
 
 +
<br>
 +
 
 +
Output Files:  
  
 
[[Media:112bpm.wav|112bpm.wav]]  
 
[[Media:112bpm.wav|112bpm.wav]]  

Revision as of 01:24, 18 January 2011

Michael Meyer: ECE 301 Homework 1

clear all;
clc

%%Question 1. Part 1.%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

bpm = 112;

delta = 0.00005;

%%Note lengths.
half = [0:delta:120/bpm];
quart = [0:delta:60/bpm];
eighth = [0:delta:30/bpm];
dotquart = [0:delta:90/bpm];

%%Note Frequencies.
gfreq = 2^(-2/12)*440;
bffreq = 2^(1/12)*440;
cfreq = 2^(3/12)*440;
dffreq = 2^(4/12)*440;

%%Notes
G = sin(2*pi*gfreq*quart);
Bf = sin(2*pi*bffreq*quart);
Cdq = sin(2*pi*cfreq*dotquart);
Df = sin(2*pi*dffreq*eighth);
Ch = sin(2*pi*cfreq*half);

%%Song
song = [G, Bf, Cdq, G, Bf, Df, Ch, G, Bf, Cdq, Bf, G];

sound(song, 1/delta)
wavwrite(song, 1/delta, '112bpm.wav')
pause(1);


%%Question 1. Part 2.%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

bpmfast = 224;

%%Note lengths.
half = [0:delta:120/bpmfast];
quart = [0:delta:60/bpmfast];
eighth = [0:delta:30/bpmfast];
dotquart = [0:delta:90/bpmfast];

%%Notes
G = sin(2*pi*gfreq*quart);
Bf = sin(2*pi*bffreq*quart);
Cdq = sin(2*pi*cfreq*dotquart);
Df = sin(2*pi*dffreq*eighth);
Ch = sin(2*pi*cfreq*half);

%%Fast Song
fastsong = [G, Bf, Cdq, G, Bf, Df, Ch, G, Bf, Cdq, Bf, G];

sound(fastsong, 1/delta)
wavwrite(fastsong, 1/delta, '224bpm.wav')
pause(1);

%%Question 1. Part 3.%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

bpm = 112;

delta = 0.00005;

%%Note lengths.
half = [0:delta:120/bpm];
quart = [0:delta:60/bpm];
eighth = [0:delta:30/bpm];
dotquart = [0:delta:90/bpm];

%%Note Frequencies.
gfreq = 2^(-2/12)*440;
bffreq = 2^(1/12)*440;
cfreq = 2^(3/12)*440;
dffreq = 2^(4/12)*440;

%%Notes
G = sin(4*pi*gfreq*quart);
Bf = sin(4*pi*bffreq*quart);
Cdq = sin(4*pi*cfreq*dotquart);
Df = sin(4*pi*dffreq*eighth);
Ch = sin(4*pi*cfreq*half);

%%Song
highsong = [G, Bf, Cdq, G, Bf, Df, Ch, G, Bf, Cdq, Bf, G];

sound(highsong, 1/delta)
wavwrite(highsong, 1/delta, 'highpitch.wav')

%%Combining all songs into one.
combined = horzcat(1, song, fastsong, highsong);

wavwrite(combined, 1/delta, 'combined.wav')


%%Question 2. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

[Beatles, fs, N] = wavread('Beatles.wav');
RevBeatles = flipud(Beatles);
sound(RevBeatles, fs)
wavwrite(RevBeatles, fs, N, 'seltaeB.wav');


Output Files:

112bpm.wav

224bpm.wav

highpitch.wav

combined.wav

seltaeB.wav

Alumni Liaison

Abstract algebra continues the conceptual developments of linear algebra, on an even grander scale.

Dr. Paul Garrett