process_song.m

process_song.m - function power = process_song(filename) %...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
Sheet1 Page 1 function power = process_song(filename) % Usage: process_song( song_file_name ) % This function does a segmented resampling of a song array, 1000000 % samples at a time, and then applies various filters. [song, fs] = wavread(filename) % NOTE: There's a bug in Matlab's resample.m which we can avoif by setting % the sampling frequency to 64 kHz (which is roughly correct). fs = 64000 % we want a row vector not a column vector [h w] = size(song) if h ~= 1 song = song' end len = length(song) numblocks = ceil(len/1000000) disp(['Breaking the song into ' num2str(numblocks) ' blocks.']) for i =1:numblocks disp(['Resampling block ' num2str(i) ' of ' num2str(numblocks) '. ..']) start_index = ((i-1)*1000000) + 1 end_index = start_index + 999999 if end_index > len end_index = len end temp1 = song(start_index:end_index) temp2 = resample(temp1, 44100, fs) if ~exist('newsong') newsong = temp2 else newsong = [newsong temp2] end end newsong = 0.99*newsong/max(abs(newsong)) % now some basic filtering
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 04/20/2008 for the course ENGR 190 taught by Professor Staff during the Spring '08 term at Santa Clara.

Page1 / 4

process_song.m - function power = process_song(filename) %...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online