function varargout = Homestar(mode) %[hr fs] = homestar(mode) plays various sound clips by % Homestar Runner (http://www.HomestarRunner.com). % Especially useful for signaling the end of a program % run. Sound clips are played through the computer. % %INPUT: % 'mode': can be one of the following % 'r' for random sound clip. % 'who' to display a list of soundclips. % N integer, where N is less than or equal to % the number of *.wav files in the \homestar\ % directory plays that specific sound clip. % %OUTPUT: % 'hr': the vector containing the values for the sound clip % at the sample rate 'fs', playable by 'sound(hr,fs)' % %NOTE: wave files are stored well at 11.025kHz sample % rate using 8-bit PCM encoding. I do this in a complicated % way. I play the flash from the website directly into % my Archos mp3 jukebox recorder and then transfer the mp3 % to the computer. I then use Audacity to save the small % sample I want, but the results are usually ~500kB (and at % 44.1kHz sample rate, 16 bits), so I take them into my % Matlab script "wavResample.m" and change them to 11.025kHz % at 8-bits, which sounds the essentially the same as the % original but is 10 times smaller. % %Sample Usage: % homestar('r'); % % Last edit by Colin Joye, 3/12/04 folder = 'C:\MATLAB6p1\work\homestar\'; % find which *.wav files we have: files = dir(folder); [f,n] = sortrows(str2mat(files(3:end).name)); % order files. F = cellstr(f); % Turns sorted files into a cell array. Lf = length(F); % check mode type: if ischar(mode) if strcmp(lower(mode),'r'), mode = 1 + floor(Lf * rand); else s = 32*ones(Lf,1); disp([ num2str(n) s char(F)]) return; end end % now the mode is a number we can use. % current file path & name for file 'mode'. c = [folder F{ n(mode) }]; if exist(c)~=7, % ignores directories. Lc = length(c); try, [hr,fs,n] = wavread(c); sound(hr,fs); catch, disp(['Homestar: file not found or not *.wav:' c]); end end varargout{1} = hr; varargout{2} = fs; % ------- END Homestar.m ---------------------