(8 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
− | clear all; | + | = ECE 301 Homework 1 = |
+ | |||
+ | == Michael Meyer == | ||
+ | |||
+ | <source lang="matlab">clear all; | ||
%%Question 1. Part 1.%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | %%Question 1. Part 1.%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | ||
Line 7: | Line 11: | ||
delta = 0.00005; | delta = 0.00005; | ||
− | %%Note lengths. | + | %%Note lengths. |
+ | half = [0:delta:120/bpm]; | ||
+ | quart = [0:delta:60/bpm]; | ||
+ | eighth = [0:delta:30/bpm]; | ||
+ | dotquart = [0:delta:90/bpm]; | ||
− | %%Note Frequencies. | + | %%Note Frequencies. |
+ | gfreq = 2^(-2/12)*440; | ||
+ | bffreq = 2^(1/12)*440; | ||
+ | cfreq = 2^(3/12)*440; | ||
+ | dffreq = 2^(4/12)*440; | ||
− | %%Notes | + | %%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 |
+ | song = [G, Bf, Cdq, G, Bf, Df, Ch, G, Bf, Cdq, Bf, G]; | ||
− | sound(song, 1/delta) | + | sound(song, 1/delta) |
+ | wavwrite(song, 1/delta, '112bpm.wav') | ||
+ | pause(1); | ||
− | + | ||
+ | %%Question 1. Part 2.%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | ||
bpmfast = 224; | bpmfast = 224; | ||
− | %%Note lengths. | + | %%Note lengths. |
+ | half = [0:delta:120/bpmfast]; | ||
+ | quart = [0:delta:60/bpmfast]; | ||
+ | eighth = [0:delta:30/bpmfast]; | ||
+ | dotquart = [0:delta:90/bpmfast]; | ||
− | %%Notes | + | %%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 | + | %%Fast Song |
+ | fastsong = [G, Bf, Cdq, G, Bf, Df, Ch, G, Bf, Cdq, Bf, G]; | ||
− | sound(fastsong, 1/delta) | + | sound(fastsong, 1/delta) |
+ | wavwrite(fastsong, 1/delta, '224bpm.wav') | ||
+ | pause(1); | ||
%%Question 1. Part 3.%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | %%Question 1. Part 3.%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | ||
Line 35: | Line 68: | ||
delta = 0.00005; | delta = 0.00005; | ||
− | %%Note lengths. | + | %%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')</source><br> | |
− | + | <source lang="matlab">%%Question 2. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
+ | [Beatles, fs, N] = wavread('Beatles.wav'); | ||
+ | RevBeatles = flipud(Beatles); | ||
+ | sound(RevBeatles, fs) | ||
+ | wavwrite(RevBeatles, fs, N, 'seltaeB.wav');</source><br> | ||
+ | I believe that the message is "turn me on dead man", however my opinion was skewed from watching this video: [http://www.youtube.com/watch?v=PG0wksBzKSc www.youtube.com/watch] | ||
− | Output Files: | + | Output Files: |
[[Media:112bpm.wav|112bpm.wav]] | [[Media:112bpm.wav|112bpm.wav]] |
Latest revision as of 01:39, 18 January 2011
ECE 301 Homework 1
Michael Meyer
clear all; %%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');
I believe that the message is "turn me on dead man", however my opinion was skewed from watching this video: www.youtube.com/watch
Output Files: