Line 1: Line 1:
 +
%ECE 301 Homework 1
 +
%Carolyn McMican
 +
clc;
 +
clear all;
 +
 +
%PART 1
 +
deltat = 5e-5;
 +
bpm = 112;
 +
afreq = 440;
 +
%1a
 +
q = 60/bpm; %quarter length
 +
e = q/2; %eighth length
 +
d_q = q + e; %dotted quarter length
 +
h = 2*q; %half note length
 +
quarter = [0:deltat:q];
 +
eighth = [0:deltat:e];
 +
dQuarter = [0:deltat:d_q];
 +
half = [0:deltat:h];
 +
rest_len = [0:deltat:(h+e)]; %rest at the end
 +
%the notes of the tune
 +
q_g = sin(2*pi*2^(-2/12)*afreq*quarter);
 +
q_bf = sin(2*pi*2^(1/12)*afreq*quarter);
 +
dQ_c = sin(2*pi*2^(3/12)*afreq*dQuarter);
 +
e_df = sin(2*pi*2^(4/12)*afreq*eighth);
 +
h_c = sin(2*pi*2^(3/12)*afreq*half);
 +
r = zeros(size(rest_len));
 +
 +
smokeWaterA = [q_g, q_bf, dQ_c, q_g, q_bf, e_df, h_c, q_g, q_bf, dQ_c, q_bf, q_g, r];
 +
 +
wavwrite(smokeWaterA, 20000, 'smokeWater1a');
 +
 +
%1b
 +
quarter2 = [0:deltat:q/2];
 +
eighth2 = [0:deltat:e/2];
 +
dQuarter2 = [0:deltat:d_q/2];
 +
half2 = [0:deltat:h/2];
 +
rest_len2 = [0:deltat:(h+e)/2];
 +
%notes of the faster tune
 +
q_g = sin(2*pi*2^(-2/12)*afreq*quarter2);
 +
q_bf = sin(2*pi*2^(1/12)*afreq*quarter2);
 +
dQ_c = sin(2*pi*2^(3/12)*afreq*dQuarter2);
 +
e_df = sin(2*pi*2^(4/12)*afreq*eighth2);
 +
h_c = sin(2*pi*2^(3/12)*afreq*half2);
 +
r = zeros(size(rest_len2));
 +
 +
smokeWaterB = [q_g, q_bf, dQ_c, q_g, q_bf, e_df, h_c, q_g, q_bf, dQ_c, q_bf, q_g, r];
 +
 +
wavwrite(smokeWaterB, 20000, 'smokeWater1b');
 +
 +
%1c - the 2t tune
 +
q_g = sin(2*(2*pi*2^(-2/12)*afreq*quarter));
 +
q_bf = sin(2*(2*pi*2^(1/12)*afreq*quarter));
 +
dQ_c = sin(2*(2*pi*2^(3/12)*afreq*dQuarter));
 +
e_df = sin(2*(2*pi*2^(4/12)*afreq*eighth));
 +
h_c = sin(2*(2*pi*2^(3/12)*afreq*half));
 +
r = zeros(size(rest_len));
 +
 +
smokeWaterC = [q_g, q_bf, dQ_c, q_g, q_bf, e_df, h_c, q_g, q_bf, dQ_c, q_bf, q_g, r];
 +
 +
wavwrite(smokeWaterC, 20000, 'smokeWater1c');
 +
 +
%PART 2
 +
beatles = wavread('Beatles.wav');
 +
b_flipped = flipud(beatles);
 +
wavwrite(b_flipped, 40000, 'flipped');
 +
%going forward, it says "number nine"
 +
%going backwards, honestly it sounds like "num yawn dud man", but most
 +
%people seem to think that it sounds like "turn me on dead man"
 +
 
[[Media:SmokeWater1a.wav]]
 
[[Media:SmokeWater1a.wav]]
  

Revision as of 13:34, 16 January 2011

%ECE 301 Homework 1 %Carolyn McMican clc; clear all;

%PART 1 deltat = 5e-5; bpm = 112; afreq = 440; %1a q = 60/bpm; %quarter length e = q/2; %eighth length d_q = q + e; %dotted quarter length h = 2*q; %half note length quarter = [0:deltat:q]; eighth = [0:deltat:e]; dQuarter = [0:deltat:d_q]; half = [0:deltat:h]; rest_len = [0:deltat:(h+e)]; %rest at the end %the notes of the tune q_g = sin(2*pi*2^(-2/12)*afreq*quarter); q_bf = sin(2*pi*2^(1/12)*afreq*quarter); dQ_c = sin(2*pi*2^(3/12)*afreq*dQuarter); e_df = sin(2*pi*2^(4/12)*afreq*eighth); h_c = sin(2*pi*2^(3/12)*afreq*half); r = zeros(size(rest_len));

smokeWaterA = [q_g, q_bf, dQ_c, q_g, q_bf, e_df, h_c, q_g, q_bf, dQ_c, q_bf, q_g, r];

wavwrite(smokeWaterA, 20000, 'smokeWater1a');

%1b quarter2 = [0:deltat:q/2]; eighth2 = [0:deltat:e/2]; dQuarter2 = [0:deltat:d_q/2]; half2 = [0:deltat:h/2]; rest_len2 = [0:deltat:(h+e)/2]; %notes of the faster tune q_g = sin(2*pi*2^(-2/12)*afreq*quarter2); q_bf = sin(2*pi*2^(1/12)*afreq*quarter2); dQ_c = sin(2*pi*2^(3/12)*afreq*dQuarter2); e_df = sin(2*pi*2^(4/12)*afreq*eighth2); h_c = sin(2*pi*2^(3/12)*afreq*half2); r = zeros(size(rest_len2));

smokeWaterB = [q_g, q_bf, dQ_c, q_g, q_bf, e_df, h_c, q_g, q_bf, dQ_c, q_bf, q_g, r];

wavwrite(smokeWaterB, 20000, 'smokeWater1b');

%1c - the 2t tune q_g = sin(2*(2*pi*2^(-2/12)*afreq*quarter)); q_bf = sin(2*(2*pi*2^(1/12)*afreq*quarter)); dQ_c = sin(2*(2*pi*2^(3/12)*afreq*dQuarter)); e_df = sin(2*(2*pi*2^(4/12)*afreq*eighth)); h_c = sin(2*(2*pi*2^(3/12)*afreq*half)); r = zeros(size(rest_len));

smokeWaterC = [q_g, q_bf, dQ_c, q_g, q_bf, e_df, h_c, q_g, q_bf, dQ_c, q_bf, q_g, r];

wavwrite(smokeWaterC, 20000, 'smokeWater1c');

%PART 2 beatles = wavread('Beatles.wav'); b_flipped = flipud(beatles); wavwrite(b_flipped, 40000, 'flipped'); %going forward, it says "number nine" %going backwards, honestly it sounds like "num yawn dud man", but most %people seem to think that it sounds like "turn me on dead man"

Media:SmokeWater1a.wav

Media:SmokeWater1b.wav

Media:SmokeWater1c.wav

Media:flipped.wav

Alumni Liaison

To all math majors: "Mathematics is a wonderfully rich subject."

Dr. Paul Garrett