(Derek Richards's first hw assignment in ece301 S2011)
 
 
(7 intermediate revisions by 2 users not shown)
Line 1: Line 1:
%Derek Richards
+
The following code is what composes the .m file that satisfies this homework assignment. The first part (labeled "Part 1") plays the first line of 'Smoke on the Water' by Deep Purple, then plays it at 2x speed, then 2x amplitude. The second part load the Beatles song, plays it, then reverses it, and plays it again. The source code below is attached, as well as the .wav file of the reversed beatles song. I am not certain what it says in revers, but I have to believe that whatever the random collection of notes is that would be produced by playing it in reverse would not be intentional, or even particularly legible.
%HW 1 ECE 301
+
<pre>&nbsp;%Derek Richards
%______          _     __ %
+
%HW 1 ECE 301  
%| ___ \         | |   / | %
+
%######                            # 
%| |_/ /__ _ _ __| |_ `| | %
+
%#     #  ##  #####  #####      ## 
%| __// _` | '__| __|  | | %
+
  %#    #  #  #  #    #  #      # # 
%| | | (_| | | | |_  _| |_%
+
%######  #    # #    #  #         #    
%\_|  \__,_|_|  \__| \___/%
+
  %#      ###### #####    #        # 
 +
  %#      #    # #  #    #        # 
 +
  %#      #    # #    #  #      #####
 +
   
 +
  b=(112/60);&nbsp;%b is the time of one standard beat
 +
half_b=0.5*(112/60);
 +
delta=0.000025;&nbsp;%arbitray variable small enough to sample well
  
b=(112/60); %b is the time of one standard beat
+
w=@(tempo)0:delta:tempo;&nbsp;%whole note
half_b=0.5*(112/60);
+
h=@(tempo)0:delta:0.5*tempo;&nbsp;%half note
delta=0.000025; %arbitray variable small enough to sample well
+
q=@(tempo)0:delta:0.25*tempo;&nbsp;%quarter note
 +
dotq=@(tempo)0:delta:1.5*0.25*tempo;&nbsp;%dotted quarter note
 +
e=@(tempo)0:delta:0.125*tempo;&nbsp;%eigth note
 +
A4=440;&nbsp;%Frequency of note A4
 +
 +
%Note funtion takes 2 variables
 +
%ntype: type of note (w,h,q,dotq,e)
 +
%dev_A4: deviation from note A4 positive is up the scale, negative is down
 +
NOTE = @(ntype,dev_A4) sin(2*pi*2^(dev_A4/12)*A4*ntype);
 +
 +
%Smoke on the Water, by Deep Purple
 +
sound(NOTE(q(b),-2),1/delta);
 +
sound(NOTE(q(b),1),1/delta);
 +
sound(NOTE(dotq(b),4),1/delta);
 +
sound(NOTE(q(b),-2),1/delta);
 +
sound(NOTE(q(b),-2),1/delta);
 +
sound(NOTE(q(b),1),1/delta);
 +
sound(NOTE(e(b),5),1/delta);
 +
sound(NOTE(h(b),4),1/delta);
 +
sound(NOTE(q(b),-2),1/delta);
 +
sound(NOTE(q(b),1),1/delta);
 +
sound(NOTE(dotq(b),4),1/delta);
 +
sound(NOTE(e(b),1),1/delta);
 +
sound(NOTE(e(b),1),1/delta);
 +
sound(NOTE(h(b),-2),1/delta);
 +
%Silence to create a pause before 2x speed
 +
sound(NOTE(q(8),68),1/delta);
 +
%Smoke on the Water, by deep Purple, twice tempo
 +
sound(NOTE(q(half_b),-2),1/delta);
 +
sound(NOTE(q(half_b),1),1/delta);
 +
sound(NOTE(dotq(half_b),4),1/delta);
 +
sound(NOTE(q(half_b),-2),1/delta);
 +
sound(NOTE(q(half_b),-2),1/delta);
 +
sound(NOTE(q(half_b),1),1/delta);
 +
sound(NOTE(e(half_b),5),1/delta);
 +
sound(NOTE(h(half_b),4),1/delta);
 +
sound(NOTE(q(half_b),-2),1/delta);
 +
sound(NOTE(q(half_b),1),1/delta);
 +
sound(NOTE(dotq(half_b),4),1/delta);
 +
sound(NOTE(e(half_b),1),1/delta);
 +
sound(NOTE(e(half_b),1),1/delta);
 +
sound(NOTE(h(half_b),-2),1/delta);
 +
%Silence to create a pause before x(2*t) speed
 +
sound(NOTE(q(8),68),1/delta);
 +
%Smoke on the Water, by deep Purple, x(2*t)
 +
NOTE = @(ntype,dev_A4) sin(2*2*pi*2^(dev_A4/12)*A4*ntype);
 +
sound(NOTE(q(b),-2),1/delta);
 +
sound(NOTE(q(b),1),1/delta);
 +
sound(NOTE(dotq(b),4),1/delta);
 +
sound(NOTE(q(b),-2),1/delta);
 +
sound(NOTE(q(b),-2),1/delta);
 +
sound(NOTE(q(b),1),1/delta);
 +
sound(NOTE(e(b),5),1/delta);
 +
sound(NOTE(h(b),4),1/delta);
 +
sound(NOTE(q(b),-2),1/delta);
 +
sound(NOTE(q(b),1),1/delta);
 +
sound(NOTE(dotq(b),4),1/delta);
 +
sound(NOTE(e(b),1),1/delta);
 +
sound(NOTE(e(b),1),1/delta);
 +
sound(NOTE(h(b),-2),1/delta);
 +
 +
%######                          ##### 
 +
%#    #  ##  #####  #####    #    #
 +
%#    #  #  #  #    #  #            #
 +
%######  #    # #    #  #      ##### 
 +
%#      ###### #####    #      #     
 +
%#      #    # #  #    #      #     
 +
%#      #    # #    #  #      #######
 +
 +
%lets assume the file Beatles.wav is in the current directory...
 +
[beatle_song, Fs] = wavread('Beatles.wav');
 +
sound(beatle_song,Fs);
 +
beatle_song_rev = flipud(beatle_song);
 +
sound(beatle_song_rev,Fs);
 +
wavwrite(beatle_song_rev,Fs,'Ece301_HW1_part2');
 +
%END CODE
  
w=@(tempo)0:delta:tempo; %whole note
+
</pre>
h=@(tempo)0:delta:0.5*tempo; %half note
+
Beatles Song: [[Media:Ece301_HW1_part2_Derek_Richards.wav]]
q=@(tempo)0:delta:0.25*tempo; %quarter note
+
dotq=@(tempo)0:delta:1.5*0.25*tempo; %dotted quarter note
+
e=@(tempo)0:delta:0.125*tempo; %eigth note
+
A4=440; %Frequency of note A4
+
 
+
%Note funtion takes 2 variables
+
%ntype: type of note (w,h,q,dotq,e)
+
%dev_A4: deviation from note A4 positive is up the scale, negative is down
+
NOTE = @(ntype,dev_A4) sin(2*pi*2^(dev_A4/12)*A4*ntype);
+
 
+
%Smoke on the Water, by Deep Purple
+
sound(NOTE(q(b),-2),1/delta);
+
sound(NOTE(q(b),1),1/delta);
+
sound(NOTE(dotq(b),4),1/delta);
+
sound(NOTE(q(b),-2),1/delta);
+
sound(NOTE(q(b),-2),1/delta);
+
sound(NOTE(q(b),1),1/delta);
+
sound(NOTE(e(b),5),1/delta);
+
sound(NOTE(h(b),4),1/delta);
+
sound(NOTE(q(b),-2),1/delta);
+
sound(NOTE(q(b),1),1/delta);
+
sound(NOTE(dotq(b),4),1/delta);
+
sound(NOTE(e(b),1),1/delta);
+
sound(NOTE(e(b),1),1/delta);
+
sound(NOTE(h(b),-2),1/delta);
+
%Silence to create a pause before 2x speed
+
sound(NOTE(q(8),68),1/delta);
+
%Smoke on the Water, by deep Purple, twice tempo
+
sound(NOTE(q(half_b),-2),1/delta);
+
sound(NOTE(q(half_b),1),1/delta);
+
sound(NOTE(dotq(half_b),4),1/delta);
+
sound(NOTE(q(half_b),-2),1/delta);
+
sound(NOTE(q(half_b),-2),1/delta);
+
sound(NOTE(q(half_b),1),1/delta);
+
sound(NOTE(e(half_b),5),1/delta);
+
sound(NOTE(h(half_b),4),1/delta);
+
sound(NOTE(q(half_b),-2),1/delta);
+
sound(NOTE(q(half_b),1),1/delta);
+
sound(NOTE(dotq(half_b),4),1/delta);
+
sound(NOTE(e(half_b),1),1/delta);
+
sound(NOTE(e(half_b),1),1/delta);
+
sound(NOTE(h(half_b),-2),1/delta);
+
%Silence to create a pause before x(2*t) speed
+
sound(NOTE(q(8),68),1/delta);
+
%Smoke on the Water, by deep Purple, x(2*t)
+
NOTE = @(ntype,dev_A4) sin(2*2*pi*2^(dev_A4/12)*A4*ntype);
+
sound(NOTE(q(b),-2),1/delta);
+
sound(NOTE(q(b),1),1/delta);
+
sound(NOTE(dotq(b),4),1/delta);
+
sound(NOTE(q(b),-2),1/delta);
+
sound(NOTE(q(b),-2),1/delta);
+
sound(NOTE(q(b),1),1/delta);
+
sound(NOTE(e(b),5),1/delta);
+
sound(NOTE(h(b),4),1/delta);
+
sound(NOTE(q(b),-2),1/delta);
+
sound(NOTE(q(b),1),1/delta);
+
sound(NOTE(dotq(b),4),1/delta);
+
sound(NOTE(e(b),1),1/delta);
+
sound(NOTE(e(b),1),1/delta);
+
sound(NOTE(h(b),-2),1/delta);
+
%______          _    _____ %
+
%| ___ \        | |  / __  \%
+
%| |_/ /__ _ _ __| |_  `' / /'%
+
%|  __// _` | '__| __|  / /  %
+
%| |  | (_| | |  | |_  ./ /___%
+
%\_|  \__,_|_|  \__| \_____/%
+
 
+
%lets assume the file Beatles.wav is in the current directory...
+
[beatle_song, Fs] = wavread('Beatles.wav');
+
sound(beatle_song,Fs);
+
beatle_song_rev = flipud(beatle_song);
+
sound(beatle_song_rev,Fs);
+
wavwrite(beatle_song_rev,Fs,'Ece301_HW1_part2');
+
%END CODE
+

Latest revision as of 12:13, 15 January 2011

The following code is what composes the .m file that satisfies this homework assignment. The first part (labeled "Part 1") plays the first line of 'Smoke on the Water' by Deep Purple, then plays it at 2x speed, then 2x amplitude. The second part load the Beatles song, plays it, then reverses it, and plays it again. The source code below is attached, as well as the .wav file of the reversed beatles song. I am not certain what it says in revers, but I have to believe that whatever the random collection of notes is that would be produced by playing it in reverse would not be intentional, or even particularly legible.

 %Derek Richards
 %HW 1 ECE 301 
 %######                            #   
 %#     #   ##   #####  #####      ##   
 %#     #  #  #  #    #   #       # #   
 %######  #    # #    #   #         #   
 %#       ###### #####    #         #   
 %#       #    # #   #    #         #   
 %#       #    # #    #   #       ##### 
 
 b=(112/60); %b is the time of one standard beat
 half_b=0.5*(112/60);
 delta=0.000025; %arbitray variable small enough to sample well

 w=@(tempo)0:delta:tempo; %whole note
 h=@(tempo)0:delta:0.5*tempo; %half note
 q=@(tempo)0:delta:0.25*tempo; %quarter note
 dotq=@(tempo)0:delta:1.5*0.25*tempo; %dotted quarter note
 e=@(tempo)0:delta:0.125*tempo; %eigth note
 A4=440; %Frequency of note A4
 
 %Note funtion takes 2 variables
 %ntype: type of note (w,h,q,dotq,e)
 %dev_A4: deviation from note A4 positive is up the scale, negative is down
 NOTE = @(ntype,dev_A4) sin(2*pi*2^(dev_A4/12)*A4*ntype);
 
 %Smoke on the Water, by Deep Purple
 sound(NOTE(q(b),-2),1/delta);
 sound(NOTE(q(b),1),1/delta);
 sound(NOTE(dotq(b),4),1/delta);
 sound(NOTE(q(b),-2),1/delta);
 sound(NOTE(q(b),-2),1/delta);
 sound(NOTE(q(b),1),1/delta);
 sound(NOTE(e(b),5),1/delta);
 sound(NOTE(h(b),4),1/delta);
 sound(NOTE(q(b),-2),1/delta);
 sound(NOTE(q(b),1),1/delta);
 sound(NOTE(dotq(b),4),1/delta);
 sound(NOTE(e(b),1),1/delta);
 sound(NOTE(e(b),1),1/delta);
 sound(NOTE(h(b),-2),1/delta);
 %Silence to create a pause before 2x speed
 sound(NOTE(q(8),68),1/delta);
 %Smoke on the Water, by deep Purple, twice tempo
 sound(NOTE(q(half_b),-2),1/delta);
 sound(NOTE(q(half_b),1),1/delta);
 sound(NOTE(dotq(half_b),4),1/delta);
 sound(NOTE(q(half_b),-2),1/delta);
 sound(NOTE(q(half_b),-2),1/delta);
 sound(NOTE(q(half_b),1),1/delta);
 sound(NOTE(e(half_b),5),1/delta);
 sound(NOTE(h(half_b),4),1/delta);
 sound(NOTE(q(half_b),-2),1/delta);
 sound(NOTE(q(half_b),1),1/delta);
 sound(NOTE(dotq(half_b),4),1/delta);
 sound(NOTE(e(half_b),1),1/delta);
 sound(NOTE(e(half_b),1),1/delta);
 sound(NOTE(h(half_b),-2),1/delta);
 %Silence to create a pause before x(2*t) speed
 sound(NOTE(q(8),68),1/delta);
 %Smoke on the Water, by deep Purple, x(2*t)
 NOTE = @(ntype,dev_A4) sin(2*2*pi*2^(dev_A4/12)*A4*ntype);
 sound(NOTE(q(b),-2),1/delta);
 sound(NOTE(q(b),1),1/delta);
 sound(NOTE(dotq(b),4),1/delta);
 sound(NOTE(q(b),-2),1/delta);
 sound(NOTE(q(b),-2),1/delta);
 sound(NOTE(q(b),1),1/delta);
 sound(NOTE(e(b),5),1/delta);
 sound(NOTE(h(b),4),1/delta);
 sound(NOTE(q(b),-2),1/delta);
 sound(NOTE(q(b),1),1/delta);
 sound(NOTE(dotq(b),4),1/delta);
 sound(NOTE(e(b),1),1/delta);
 sound(NOTE(e(b),1),1/delta);
 sound(NOTE(h(b),-2),1/delta);
 
 %######                          #####  
 %#     #   ##   #####  #####    #     # 
 %#     #  #  #  #    #   #            # 
 %######  #    # #    #   #       #####  
 %#       ###### #####    #      #       
 %#       #    # #   #    #      #       
 %#       #    # #    #   #      #######
 
 %lets assume the file Beatles.wav is in the current directory...
 [beatle_song, Fs] = wavread('Beatles.wav');
 sound(beatle_song,Fs);
 beatle_song_rev = flipud(beatle_song);
 sound(beatle_song_rev,Fs);
 wavwrite(beatle_song_rev,Fs,'Ece301_HW1_part2');
 %END CODE

Beatles Song: Media:Ece301_HW1_part2_Derek_Richards.wav

Alumni Liaison

ECE462 Survivor

Seraj Dosenbach