Revision as of 20:18, 12 January 2011 by Trother (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Homework 1

Travis Rother


Part 1

% smoke.m
% Author: Travis Rother
% Description: plays beginning of smoke on the water in three different ways
function smoke()
    delta = .00005;

    buf = []; % stores the freq data to be written at the end
    playsmoke(112, 1); % play at normal speed  (Part a)
    playsmoke(224, 1); % play twice as fast    (Part b)
    playsmoke(112, 2); % play with a frequency shift    (Part c)
    
    wavwrite(buf,1/delta,32, 'smoke.wav'); % write to wav file


    function playsmoke(BPM, pitch)
        % define the notes the song uses
        G = note(-2);
        Bf = note(1);
        C = note(3);
        Df = note(4);

        % vector of notes the song plays
        notes = [G Bf C G Bf Df C G Bf C Bf G];

        % corresponding beat values for each note
        beat = [1 1 1.5 1 1 .5 2 1 1 1.5 1 1];

        % play all of the notes
        for i=1:length(notes)
            dur = (60/BPM)*beat(i);
            t = 0:delta:dur;
            z = sin(pitch*2*pi*notes(i)*t);
            sound(z,1/delta);
            buf = [buf; z(:)];
        end
    end

    function freq = note(hsteps)
       freq =  440 * 2^(hsteps/12);
    end
end

Part 2

[data, Fs] = wavread('Beatles.wav');
rev = flipud(data);
sound(rev,Fs);
wavwrite(rev,Fs,'revBeatles.wav');

a) "number 9, number 9, number 9... "
b) Yes I think it is possible that there is a hidden message. To me it sounds like "carry on, gentlemen". Or it could be nothing, just my brain trying to make sense of garbled sounds.

Alumni Liaison

Basic linear algebra uncovers and clarifies very important geometry and algebra.

Dr. Paul Garrett