September 1, 2004

Making tones with Matlab

I needed some different beeps for my auditory stimuli. Dave Johnson has a good skeleton at the MathWorks repository. It's actually pretty simple. Remember to change the sampling frequency if you need to get higher frequency tones.
function beep2(w,t)
%plays a short tone as an audible cue
%    beep2
%    beep2(w)    specify frequency (200-1,000 Hz)
%    beep2(w,t)     "       "       and duration in seconds

fs=8192;  %sample freq in Hz

if (nargin == 0)
   w=1000;            %default
   t = [0:1/fs:.2];   %default
elseif (nargin == 1)
   t = [0:1/fs:.2];   %default
elseif (nargin == 2)
   t = [0:1/fs:t];  

%one possible wave form

%play sound
Posted by torque at September 1, 2004 10:25 AM | TrackBack
Post a comment

Remember personal info?