(9 intermediate revisions by the same user not shown) | |||
Line 41: | Line 41: | ||
Note1a = sin(2*pi*fa*2^(-2/12)*Quarter); | Note1a = sin(2*pi*fa*2^(-2/12)*Quarter); | ||
+ | |||
Note2a = sin(2*pi*fa*2^(1/12)*Quarter); | Note2a = sin(2*pi*fa*2^(1/12)*Quarter); | ||
+ | |||
Note3a = sin(2*pi*fa*2^(3/12)*DottedQuarter); | Note3a = sin(2*pi*fa*2^(3/12)*DottedQuarter); | ||
+ | |||
Note4a = sin(2*pi*fa*2^(-2/12)*Quarter); | Note4a = sin(2*pi*fa*2^(-2/12)*Quarter); | ||
+ | |||
Note5a = sin(2*pi*fa*2^(1/12)*Quarter); | Note5a = sin(2*pi*fa*2^(1/12)*Quarter); | ||
+ | |||
Note6a = sin(2*pi*fa*2^(4/12)*Eighth); | Note6a = sin(2*pi*fa*2^(4/12)*Eighth); | ||
+ | |||
Note7a = sin(2*pi*fa*2^(3/12)*Half); | Note7a = sin(2*pi*fa*2^(3/12)*Half); | ||
+ | |||
Note8a = sin(2*pi*fa*2^(-2/12)*Quarter); | Note8a = sin(2*pi*fa*2^(-2/12)*Quarter); | ||
+ | |||
Note9a = sin(2*pi*fa*2^(1/12)*Quarter); | Note9a = sin(2*pi*fa*2^(1/12)*Quarter); | ||
+ | |||
Note10a = sin(2*pi*fa*2^(3/12)*DottedQuarter); | Note10a = sin(2*pi*fa*2^(3/12)*DottedQuarter); | ||
+ | |||
Note11a = sin(2*pi*fa*2^(1/12)*Quarter); | Note11a = sin(2*pi*fa*2^(1/12)*Quarter); | ||
+ | |||
Note12a = sin(2*pi*fa*2^(-2/12)*Quarter); | Note12a = sin(2*pi*fa*2^(-2/12)*Quarter); | ||
%Combine each of the notes into one sound file | %Combine each of the notes into one sound file | ||
+ | |||
Smoke1 = [Note1a, Note2a, Note3a, Note4a, Note5a, Note6a, Note7a, Note8a, Note9a, Note10a, Note11a, Note12a]; | Smoke1 = [Note1a, Note2a, Note3a, Note4a, Note5a, Note6a, Note7a, Note8a, Note9a, Note10a, Note11a, Note12a]; | ||
%Play the finished sound file | %Play the finished sound file | ||
+ | |||
sound(Smoke1,1/timestep); | sound(Smoke1,1/timestep); | ||
+ | |||
wavwrite(Smoke1,1/timestep,'zflohr_ECE301_HW1_Part1a'); | wavwrite(Smoke1,1/timestep,'zflohr_ECE301_HW1_Part1a'); | ||
+ | [[Media:zflohr_ECE301_HW1_Part1a.wav]] | ||
pause(6); %Has a pause between the different sound files | pause(6); %Has a pause between the different sound files | ||
+ | |||
%PART1-B | %PART1-B | ||
+ | |||
%Play the tune at twice the speed | %Play the tune at twice the speed | ||
%Since the BPM doubles, then the length of each note is cut in half | %Since the BPM doubles, then the length of each note is cut in half | ||
Line 69: | Line 86: | ||
timestep = 0.00001; %seconds | timestep = 0.00001; %seconds | ||
+ | |||
Half = 0:timestep:(2*sec/2); %half note | Half = 0:timestep:(2*sec/2); %half note | ||
+ | |||
Quarter = 0:timestep:(1*sec/2); %quarter note | Quarter = 0:timestep:(1*sec/2); %quarter note | ||
+ | |||
Eighth = 0:timestep:(0.5*sec/2); %eighth note | Eighth = 0:timestep:(0.5*sec/2); %eighth note | ||
+ | |||
DottedQuarter = 0:timestep:(1.5*sec/2); %dotted quarter note | DottedQuarter = 0:timestep:(1.5*sec/2); %dotted quarter note | ||
+ | |||
%Re-composition of each note - Calculated in the same manner as in Part 1 | %Re-composition of each note - Calculated in the same manner as in Part 1 | ||
Line 78: | Line 100: | ||
Note1b = sin(2*pi*fa*2^(-2/12)*Quarter); | Note1b = sin(2*pi*fa*2^(-2/12)*Quarter); | ||
+ | |||
Note2b = sin(2*pi*fa*2^(1/12)*Quarter); | Note2b = sin(2*pi*fa*2^(1/12)*Quarter); | ||
+ | |||
Note3b = sin(2*pi*fa*2^(3/12)*DottedQuarter); | Note3b = sin(2*pi*fa*2^(3/12)*DottedQuarter); | ||
+ | |||
Note4b = sin(2*pi*fa*2^(-2/12)*Quarter); | Note4b = sin(2*pi*fa*2^(-2/12)*Quarter); | ||
+ | |||
Note5b = sin(2*pi*fa*2^(1/12)*Quarter); | Note5b = sin(2*pi*fa*2^(1/12)*Quarter); | ||
+ | |||
Note6b = sin(2*pi*fa*2^(4/12)*Eighth); | Note6b = sin(2*pi*fa*2^(4/12)*Eighth); | ||
+ | |||
Note7b = sin(2*pi*fa*2^(3/12)*Half); | Note7b = sin(2*pi*fa*2^(3/12)*Half); | ||
+ | |||
Note8b = sin(2*pi*fa*2^(-2/12)*Quarter); | Note8b = sin(2*pi*fa*2^(-2/12)*Quarter); | ||
+ | |||
Note9b = sin(2*pi*fa*2^(1/12)*Quarter); | Note9b = sin(2*pi*fa*2^(1/12)*Quarter); | ||
+ | |||
Note10b = sin(2*pi*fa*2^(3/12)*DottedQuarter); | Note10b = sin(2*pi*fa*2^(3/12)*DottedQuarter); | ||
+ | |||
Note11b = sin(2*pi*fa*2^(1/12)*Quarter); | Note11b = sin(2*pi*fa*2^(1/12)*Quarter); | ||
+ | |||
Note12b = sin(2*pi*fa*2^(-2/12)*Quarter); | Note12b = sin(2*pi*fa*2^(-2/12)*Quarter); | ||
%Combine each of the notes into one sound file | %Combine each of the notes into one sound file | ||
+ | |||
Smoke2 = [Note1b, Note2b, Note3b, Note4b, Note5b, Note6b, Note7b, Note8b, Note9b, Note10b, Note11b, Note12b]; | Smoke2 = [Note1b, Note2b, Note3b, Note4b, Note5b, Note6b, Note7b, Note8b, Note9b, Note10b, Note11b, Note12b]; | ||
%Play the finished tune | %Play the finished tune | ||
+ | |||
sound(Smoke2,1/timestep); | sound(Smoke2,1/timestep); | ||
+ | |||
wavwrite(Smoke2,1/timestep,'zflohr_ECE301_HW1_Part1b'); | wavwrite(Smoke2,1/timestep,'zflohr_ECE301_HW1_Part1b'); | ||
+ | |||
+ | [[Media:zflohr_ECE301_HW1_Part1b.wav]] | ||
pause(6); %Has a pause between the sound files | pause(6); %Has a pause between the sound files | ||
+ | |||
%PART1-C | %PART1-C | ||
Line 106: | Line 145: | ||
%Play original file at new frequency and write the sound file | %Play original file at new frequency and write the sound file | ||
+ | |||
sound(Smoke1,2/timestep); | sound(Smoke1,2/timestep); | ||
+ | |||
wavwrite(Smoke1,2/timestep,'zflohr_ECE301_HW1_Part1c'); | wavwrite(Smoke1,2/timestep,'zflohr_ECE301_HW1_Part1c'); | ||
+ | |||
+ | [[Media:zflohr_ECE301_HW1_Part1c.wav]] | ||
pause(6) %Has a pause between the sound files | pause(6) %Has a pause between the sound files | ||
+ | |||
%PART 2 - Beatles Song "Hidden Message" | %PART 2 - Beatles Song "Hidden Message" | ||
Line 119: | Line 163: | ||
%The flipud command reverses the array and saves it as z. I amplified the | %The flipud command reverses the array and saves it as z. I amplified the | ||
%file by 5 to better hear the output. | %file by 5 to better hear the output. | ||
+ | |||
z = flipud(y); | z = flipud(y); | ||
+ | |||
z = z*5; | z = z*5; | ||
%The sound file is played and written to the file. | %The sound file is played and written to the file. | ||
+ | |||
sound(z,fs); | sound(z,fs); | ||
+ | |||
wavwrite(z,fs,'zflohr_ECE301_HW1_Part2'); | wavwrite(z,fs,'zflohr_ECE301_HW1_Part2'); | ||
+ | |||
+ | [[Media:zflohr_ECE301_HW1_Part2.wav]] | ||
%The original sound file repeated the phrase "Number 9" over and over. The | %The original sound file repeated the phrase "Number 9" over and over. The | ||
%reversed file has a repeated phrase as well, which sounds like "Turn me | %reversed file has a repeated phrase as well, which sounds like "Turn me | ||
%on, dead man". | %on, dead man". |
Latest revision as of 15:22, 18 January 2011
%ECE 301 Homework 1
%Zachary Flohr
%Semester - Spring 2011
clear
clc
%PART1-A
%Time and beat information
fa = 440; %Hz
BPM = 112; %beats per minute
sec = 1/(112/60); %seconds per beat
%Length of each type of note
%This is an array of time for each note. The time step is chosen to be
%very small to get a good sampling rate
timestep = 0.00001; %seconds
Half = 0:timestep:(2*sec); %half note
Quarter = 0:timestep:(1*sec); %quarter note
Eighth = 0:timestep:(0.5*sec); %eighth note
DottedQuarter = 0:timestep:(1.5*sec); %dotted quarter note
%Composition of each note - Each frequency is produced for the needed time %of each note
Note1a = sin(2*pi*fa*2^(-2/12)*Quarter);
Note2a = sin(2*pi*fa*2^(1/12)*Quarter);
Note3a = sin(2*pi*fa*2^(3/12)*DottedQuarter);
Note4a = sin(2*pi*fa*2^(-2/12)*Quarter);
Note5a = sin(2*pi*fa*2^(1/12)*Quarter);
Note6a = sin(2*pi*fa*2^(4/12)*Eighth);
Note7a = sin(2*pi*fa*2^(3/12)*Half);
Note8a = sin(2*pi*fa*2^(-2/12)*Quarter);
Note9a = sin(2*pi*fa*2^(1/12)*Quarter);
Note10a = sin(2*pi*fa*2^(3/12)*DottedQuarter);
Note11a = sin(2*pi*fa*2^(1/12)*Quarter);
Note12a = sin(2*pi*fa*2^(-2/12)*Quarter);
%Combine each of the notes into one sound file
Smoke1 = [Note1a, Note2a, Note3a, Note4a, Note5a, Note6a, Note7a, Note8a, Note9a, Note10a, Note11a, Note12a];
%Play the finished sound file
sound(Smoke1,1/timestep);
wavwrite(Smoke1,1/timestep,'zflohr_ECE301_HW1_Part1a');
Media:zflohr_ECE301_HW1_Part1a.wav
pause(6); %Has a pause between the different sound files
%PART1-B
%Play the tune at twice the speed %Since the BPM doubles, then the length of each note is cut in half %The arrays of the notes will only be half the length as the original
timestep = 0.00001; %seconds
Half = 0:timestep:(2*sec/2); %half note
Quarter = 0:timestep:(1*sec/2); %quarter note
Eighth = 0:timestep:(0.5*sec/2); %eighth note
DottedQuarter = 0:timestep:(1.5*sec/2); %dotted quarter note
%Re-composition of each note - Calculated in the same manner as in Part 1
%with the length of the notes being altered.
Note1b = sin(2*pi*fa*2^(-2/12)*Quarter);
Note2b = sin(2*pi*fa*2^(1/12)*Quarter);
Note3b = sin(2*pi*fa*2^(3/12)*DottedQuarter);
Note4b = sin(2*pi*fa*2^(-2/12)*Quarter);
Note5b = sin(2*pi*fa*2^(1/12)*Quarter);
Note6b = sin(2*pi*fa*2^(4/12)*Eighth);
Note7b = sin(2*pi*fa*2^(3/12)*Half);
Note8b = sin(2*pi*fa*2^(-2/12)*Quarter);
Note9b = sin(2*pi*fa*2^(1/12)*Quarter);
Note10b = sin(2*pi*fa*2^(3/12)*DottedQuarter);
Note11b = sin(2*pi*fa*2^(1/12)*Quarter);
Note12b = sin(2*pi*fa*2^(-2/12)*Quarter);
%Combine each of the notes into one sound file
Smoke2 = [Note1b, Note2b, Note3b, Note4b, Note5b, Note6b, Note7b, Note8b, Note9b, Note10b, Note11b, Note12b];
%Play the finished tune
sound(Smoke2,1/timestep);
wavwrite(Smoke2,1/timestep,'zflohr_ECE301_HW1_Part1b');
Media:zflohr_ECE301_HW1_Part1b.wav
pause(6); %Has a pause between the sound files
%PART1-C
%Transform of y(t) = x(2t)
%We can play the original sound file Smoke1 at a frequency twice as fast as
%originally played. The length of the original notes remain in tact while
%the playing frequency is affected by the transformation of y(t) = x(2t)
%Play original file at new frequency and write the sound file
sound(Smoke1,2/timestep);
wavwrite(Smoke1,2/timestep,'zflohr_ECE301_HW1_Part1c');
Media:zflohr_ECE301_HW1_Part1c.wav
pause(6) %Has a pause between the sound files
%PART 2 - Beatles Song "Hidden Message"
%The initial sound file is assumed to be in the same directory. The file
%is read in and saved
[y,fs] = wavread('Beatles.wav');
%The flipud command reverses the array and saves it as z. I amplified the %file by 5 to better hear the output.
z = flipud(y);
z = z*5;
%The sound file is played and written to the file.
sound(z,fs);
wavwrite(z,fs,'zflohr_ECE301_HW1_Part2');
Media:zflohr_ECE301_HW1_Part2.wav
%The original sound file repeated the phrase "Number 9" over and over. The %reversed file has a repeated phrase as well, which sounds like "Turn me %on, dead man".