(Michaela Carrieres HW#1) |
|||
(2 intermediate revisions by the same user not shown) | |||
Line 6: | Line 6: | ||
%SMOKE ON THE WATER | %SMOKE ON THE WATER | ||
+ | |||
delta = 0.00005; | delta = 0.00005; | ||
+ | |||
bpm = 112; %beats per minute | bpm = 112; %beats per minute | ||
+ | |||
bps = bpm/60; %beats per second | bps = bpm/60; %beats per second | ||
+ | |||
z = zeros(2/delta,1); %silence | z = zeros(2/delta,1); %silence | ||
%frequencies | %frequencies | ||
+ | |||
freqG = 440*(2^(-2/12)); %frequency of the G note | freqG = 440*(2^(-2/12)); %frequency of the G note | ||
+ | |||
freqBflat = 440*(2^(1/12)); %frequency of the Bflat note | freqBflat = 440*(2^(1/12)); %frequency of the Bflat note | ||
+ | |||
freqC = 440*(2^(3/12)); %frequency of the C note | freqC = 440*(2^(3/12)); %frequency of the C note | ||
+ | |||
freqDflat = 440*(2^(4/12)); %frequency of the Dflat note | freqDflat = 440*(2^(4/12)); %frequency of the Dflat note | ||
+ | |||
%note durations part 1a | %note durations part 1a | ||
+ | |||
durquarter1 = 0:delta:bps/4;%duration of a quarter note | durquarter1 = 0:delta:bps/4;%duration of a quarter note | ||
+ | |||
durhalf1 = 0:delta:bps/2;%duration of a half note | durhalf1 = 0:delta:bps/2;%duration of a half note | ||
+ | |||
durqdot1 = 0:delta:((bps/4) + (bps/8));%duration of a dotted quarter note | durqdot1 = 0:delta:((bps/4) + (bps/8));%duration of a dotted quarter note | ||
+ | |||
dureighth1 = 0:delta:bps/8;%duration of an eighth note | dureighth1 = 0:delta:bps/8;%duration of an eighth note | ||
+ | |||
%note durations part 1b | %note durations part 1b | ||
+ | |||
durquarter2 = 0:delta:bps/8; %duration of a quarter note sped up | durquarter2 = 0:delta:bps/8; %duration of a quarter note sped up | ||
+ | |||
durhalf2 = 0:delta:bps/4; %duration of a half note sped up | durhalf2 = 0:delta:bps/4; %duration of a half note sped up | ||
+ | |||
durqdot2 = 0:delta:((bps/4) + (bps/8))/2; %duration of a dotted quarter note sped up | durqdot2 = 0:delta:((bps/4) + (bps/8))/2; %duration of a dotted quarter note sped up | ||
+ | |||
dureighth2 = 0:delta:bps/16; %duration of an eighth note sped up | dureighth2 = 0:delta:bps/16; %duration of an eighth note sped up | ||
+ | |||
%notes for song part 1a | %notes for song part 1a | ||
+ | |||
G = sin(2*pi*freqG*durquarter1); | G = sin(2*pi*freqG*durquarter1); | ||
+ | |||
Bflat = sin(2*pi*freqBflat*durquarter1); | Bflat = sin(2*pi*freqBflat*durquarter1); | ||
+ | |||
Cdot = sin(2*pi*freqC*durqdot1); | Cdot = sin(2*pi*freqC*durqdot1); | ||
+ | |||
Dfeight = sin(2*pi*freqDflat*dureighth1); | Dfeight = sin(2*pi*freqDflat*dureighth1); | ||
+ | |||
Chalf = sin(2*pi*freqC*durhalf1); | Chalf = sin(2*pi*freqC*durhalf1); | ||
+ | |||
song1 = [G,Bflat,Cdot,G,Bflat,Dfeight,Chalf,G,Bflat,Cdot,Bflat,G]; | song1 = [G,Bflat,Cdot,G,Bflat,Dfeight,Chalf,G,Bflat,Cdot,Bflat,G]; | ||
+ | |||
sound(song1,1/delta) | sound(song1,1/delta) | ||
+ | |||
sound(z,1/delta) | sound(z,1/delta) | ||
+ | |||
wavwrite(song1,1/delta,'SmokeOnTheWater_normal'); | wavwrite(song1,1/delta,'SmokeOnTheWater_normal'); | ||
+ | |||
%notes for song part 1b | %notes for song part 1b | ||
+ | |||
G = sin(2*pi*2*freqG*durquarter2); | G = sin(2*pi*2*freqG*durquarter2); | ||
+ | |||
Bflat = sin(2*pi*2*freqBflat*durquarter2); | Bflat = sin(2*pi*2*freqBflat*durquarter2); | ||
+ | |||
Cdot = sin(2*pi*2*freqC*durqdot2); | Cdot = sin(2*pi*2*freqC*durqdot2); | ||
+ | |||
Dfeight = sin(2*pi*2*freqDflat*dureighth2); | Dfeight = sin(2*pi*2*freqDflat*dureighth2); | ||
+ | |||
Chalf = sin(2*pi*2*freqC*durhalf2); | Chalf = sin(2*pi*2*freqC*durhalf2); | ||
+ | |||
song2 = [G,Bflat,Cdot,G,Bflat,Dfeight,Chalf,G,Bflat,Cdot,Bflat,G]; | song2 = [G,Bflat,Cdot,G,Bflat,Dfeight,Chalf,G,Bflat,Cdot,Bflat,G]; | ||
+ | |||
sound(song2,1/delta) | sound(song2,1/delta) | ||
+ | |||
sound(z,1/delta) | sound(z,1/delta) | ||
+ | |||
wavwrite(song2,1/delta,'SmokeOnTheWater_higherandfaster'); | wavwrite(song2,1/delta,'SmokeOnTheWater_higherandfaster'); | ||
+ | |||
%notes for song part 1c | %notes for song part 1c | ||
+ | |||
G = sin(2*2*pi*freqG*durquarter1); | G = sin(2*2*pi*freqG*durquarter1); | ||
+ | |||
Bflat = sin(2*2*pi*freqBflat*durquarter1); | Bflat = sin(2*2*pi*freqBflat*durquarter1); | ||
+ | |||
Cdot = sin(2*2*pi*freqC*durqdot1); | Cdot = sin(2*2*pi*freqC*durqdot1); | ||
+ | |||
Dfeight = sin(2*2*pi*freqDflat*dureighth1); | Dfeight = sin(2*2*pi*freqDflat*dureighth1); | ||
+ | |||
Chalf = sin(2*2*pi*freqC*durhalf1); | Chalf = sin(2*2*pi*freqC*durhalf1); | ||
+ | |||
song3 = [G,Bflat,Cdot,G,Bflat,Dfeight,Chalf,G,Bflat,Cdot,Bflat,G]; | song3 = [G,Bflat,Cdot,G,Bflat,Dfeight,Chalf,G,Bflat,Cdot,Bflat,G]; | ||
+ | |||
sound(song3,1/delta) | sound(song3,1/delta) | ||
+ | |||
sound(z,1/delta) | sound(z,1/delta) | ||
+ | |||
wavwrite(song3,1/delta,'SmokeOnTheWater_higher'); | wavwrite(song3,1/delta,'SmokeOnTheWater_higher'); | ||
+ | |||
%BEATLES SONG | %BEATLES SONG | ||
+ | |||
[beatles,Fs] = wavread('Beatles.wav'); | [beatles,Fs] = wavread('Beatles.wav'); | ||
+ | |||
revbeatles = flipud(beatles); %reversing the clip from the Beatle's song | revbeatles = flipud(beatles); %reversing the clip from the Beatle's song | ||
+ | |||
sound(revbeatles,Fs) %playing the reversed clip | sound(revbeatles,Fs) %playing the reversed clip | ||
+ | |||
wavwrite(revbeatles, Fs, 'Reversed Beatles'); | wavwrite(revbeatles, Fs, 'Reversed Beatles'); | ||
+ | |||
%Played normally, the song says "number nine" | %Played normally, the song says "number nine" | ||
+ | |||
%Played in reverse, the song sounds like it says "Turn me on done men" | %Played in reverse, the song sounds like it says "Turn me on done men" | ||
+ | |||
[[Media:SmokeOnTheWater_normal.wav]] | [[Media:SmokeOnTheWater_normal.wav]] | ||
+ | |||
[[Media:SmokeOnTheWater_higherandfaster.wav]] | [[Media:SmokeOnTheWater_higherandfaster.wav]] | ||
+ | |||
[[Media:SmokeOnTheWater_higher.wav]] | [[Media:SmokeOnTheWater_higher.wav]] | ||
+ | |||
[[Media:Reversed Beatles.wav]] | [[Media:Reversed Beatles.wav]] |
Latest revision as of 07:59, 19 January 2011
%Michaela Carrieres %HW#1
clear; clc;
%SMOKE ON THE WATER
delta = 0.00005;
bpm = 112; %beats per minute
bps = bpm/60; %beats per second
z = zeros(2/delta,1); %silence
%frequencies
freqG = 440*(2^(-2/12)); %frequency of the G note
freqBflat = 440*(2^(1/12)); %frequency of the Bflat note
freqC = 440*(2^(3/12)); %frequency of the C note
freqDflat = 440*(2^(4/12)); %frequency of the Dflat note
%note durations part 1a
durquarter1 = 0:delta:bps/4;%duration of a quarter note
durhalf1 = 0:delta:bps/2;%duration of a half note
durqdot1 = 0:delta:((bps/4) + (bps/8));%duration of a dotted quarter note
dureighth1 = 0:delta:bps/8;%duration of an eighth note
%note durations part 1b
durquarter2 = 0:delta:bps/8; %duration of a quarter note sped up
durhalf2 = 0:delta:bps/4; %duration of a half note sped up
durqdot2 = 0:delta:((bps/4) + (bps/8))/2; %duration of a dotted quarter note sped up
dureighth2 = 0:delta:bps/16; %duration of an eighth note sped up
%notes for song part 1a
G = sin(2*pi*freqG*durquarter1);
Bflat = sin(2*pi*freqBflat*durquarter1);
Cdot = sin(2*pi*freqC*durqdot1);
Dfeight = sin(2*pi*freqDflat*dureighth1);
Chalf = sin(2*pi*freqC*durhalf1);
song1 = [G,Bflat,Cdot,G,Bflat,Dfeight,Chalf,G,Bflat,Cdot,Bflat,G];
sound(song1,1/delta)
sound(z,1/delta)
wavwrite(song1,1/delta,'SmokeOnTheWater_normal');
%notes for song part 1b
G = sin(2*pi*2*freqG*durquarter2);
Bflat = sin(2*pi*2*freqBflat*durquarter2);
Cdot = sin(2*pi*2*freqC*durqdot2);
Dfeight = sin(2*pi*2*freqDflat*dureighth2);
Chalf = sin(2*pi*2*freqC*durhalf2);
song2 = [G,Bflat,Cdot,G,Bflat,Dfeight,Chalf,G,Bflat,Cdot,Bflat,G];
sound(song2,1/delta)
sound(z,1/delta)
wavwrite(song2,1/delta,'SmokeOnTheWater_higherandfaster');
%notes for song part 1c
G = sin(2*2*pi*freqG*durquarter1);
Bflat = sin(2*2*pi*freqBflat*durquarter1);
Cdot = sin(2*2*pi*freqC*durqdot1);
Dfeight = sin(2*2*pi*freqDflat*dureighth1);
Chalf = sin(2*2*pi*freqC*durhalf1);
song3 = [G,Bflat,Cdot,G,Bflat,Dfeight,Chalf,G,Bflat,Cdot,Bflat,G];
sound(song3,1/delta)
sound(z,1/delta)
wavwrite(song3,1/delta,'SmokeOnTheWater_higher');
%BEATLES SONG
[beatles,Fs] = wavread('Beatles.wav');
revbeatles = flipud(beatles); %reversing the clip from the Beatle's song
sound(revbeatles,Fs) %playing the reversed clip
wavwrite(revbeatles, Fs, 'Reversed Beatles');
%Played normally, the song says "number nine"
%Played in reverse, the song sounds like it says "Turn me on done men"
Media:SmokeOnTheWater_normal.wav
Media:SmokeOnTheWater_higherandfaster.wav