Revision as of 12:50, 15 January 2011 by Mrgardne (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
% ECE 301, Homework 1
% Michael Gardner

%% PART 1

clear
clc

%initialize counter
i=0;

%performs the loop 3 times, second time twice as fast. (Changed BPM)
for BPM=[112,112*2,112]

    %reset smoke vector
    clear smoke
    
    %counter
    i=i+1;
    
    A=440;
   
    %assign frequency values to notes
    fdb5=2^(4/12)*A;
    fg4=2^(-2/12)*A;
    fbb4=2^(1/12)*A;        
    fc5=2^(3/12)*A;        
        
    qnote=60/BPM; %length of quarter note
    delta=.00005;
    
    %assign length to different notes
    tq=0:delta:qnote; %quarter
    tdq=0:delta:qnote*1.5; %dotted quarter
    te=0:delta:qnote*0.5; %eighth note
    th=0:delta:2*qnote; %half note
    t25=0:delta:2.5*qnote; %for the final rest
    


    smoke=[sin(2*pi*fg4*tq),sin(2*pi*fbb4*tq),sin(2*pi*fc5*tdq),...
        sin(2*pi*fg4*tq),sin(2*pi*fbb4*tq),sin(2*pi*fdb5*te),...
        sin(2*pi*fc5*th),sin(2*pi*fg4*tq),sin(2*pi*fbb4*tq),...
        sin(2*pi*fc5*tdq),sin(2*pi*fbb4*tq),sin(2*pi*fg4*tq),...
        sin(0*t25)];


    if i==1
        sound(smoke,1/delta);
        wavwrite(smoke,1/delta,32,'mrgardne_smoke_one')
    elseif i==2
        sound(smoke,1/delta);
        wavwrite(smoke,1/delta,32,'mrgardne_smoke_two')
    elseif i==3
        sound(smoke,2/(delta));
        wavwrite(smoke,2/(delta),32,'mrgardne_smoke_three')
    end 
    
    
    
end

%% PART 2

clear
clc

%read the file and store in beat, fs, nbits
[beat,fs,nbits]=wavread('Beatles.wav');
%play original
sound(beat,fs,nbits);
%flip the matrix
beat=flipud(beat);
%play backwards
sound(beat,fs,nbits);
%write backwards song to file
wavwrite(beat,fs,nbits,'mrgardne_beatles_backwards');

%Forwards, the song says "Number nine."
%Backwards, the song seems to say "Turn me on Edmund."



Attached Files:

Part 1 -

Media:Mrgardne_smoke_one.wav

Media:Mrgardne_smoke_two.wav

Media:Mrgardne_smoke_three.wav

Part 2 -

Media:Mrgardne_beatles_backwards.wav

Alumni Liaison

Ph.D. 2007, working on developing cool imaging technologies for digital cameras, camera phones, and video surveillance cameras.

Buyue Zhang