- sfactor=s_rate/1000; %% drop the sampling rate by factor of 1000
prate=44; %% This is the 44 KHz sampling rate required for sound card output
qrate=sfactor;
wave=resample(wave,prate,qrate); %%resamples wave by factor of p/q

- number_entries=size(wave); %%required to manually recalculate new timebase
number_entries=number_entries(1);
maxtime=size(time);
maxtime=maxtime(2);
accum_num=(time(maxtime)-time(1))/number_entries;
%%calculate the new time spacing for resampled signal
accum=time(1);
time=[];
for x=1:number_entries %%loop creates new time matrix
time=[time accum];
accum=accum+accum_num;
end;

- if time(1) < -2
for x=1:number_entries
if time(x) < -2
lowhold=x;
end;
if time(x) < 2
highhold=x;
end;
end;
%Truncate wave into 4 ms frame
wave=wave(lowhold:highhold);
time=time(lowhold:highhold);

There were two specified ways for generating the wave intervals. Both of them generate a matrix of 100 points, with a 1 representing a time period when the wave should be played and a 0 representing silcence. The first method of generating this matrix is a random selection of pulse intervals separations from 10 per second to 1 per second. In the interest of keeping roughly symmetrical spacings, 6 different permutations of pulses and silences were used. The

The other method for selecting intervals is an attempt to more closely approximate the spacing which would ideally exist in nature. The user inputs a mean value for the interval spacing, a standard deviation, and a minimum interval spacing length. The code for implementing this spacing algorithm traverses the 100 points between 0 and 10 seconds, jumping by a random interval based on the normal curve with the entered data as shown.

- wavetime=zeros(100,1);
wavetime(1)=1;
i=1;
while i < 101
interval=round(max(int_mean+sd*randn,min_interval)*10);
i=i+interval;
wavetime(i)=1;
end

There were two different options for outputing the sound. The first one implemented was "continuous tenths". The reason for this option was mostly for testing purposes. However, the feature was left as it might be useful if a person just wants a continuous burst. One problem discovered while testing was that the tightly looped sound output function caused errors opening the sound device. The reason discovered was that the Matlab function

The other output option was to follow the previously created timebase. This function worked basically the same as the continuous one. However, this function traverses the interval matrix of 100 points and only plays if the point it is at is a '1', indicating that the sound should be played at that point.

Webpage created by Joel Avrunin ('01).