Acoustic stimulus

Although a large number of acoustic stimuli can be found on the experimental PC, it is often desirable to design your own. A number of MATLAB routines have been developed to generate single channel wav-files.

Cookbook

In principle, you need to:

  1. generate a signal
  2. filter the signal
  3. apply a ramp
  4. check for setup idiosyncrasies
  5. write the signal to a file

These steps are shown in figure 1, and described below.

image

This figure is created with pa_how2createsounds_example

1. Signal

The following MATLAB routines can be used for the most frequently used stimulus types:

  • pa_gengwn - generate Gaussian White Noise (by defining a randomly distributed time
    signal). This sound is most often used for sound localization experiments. See below for example.
  • pa_gengwnflat - generate Gaussian White Noise (by defining a flat magnitude and random
    phase in the frequency domain)
  • pa_gensweep - generate a frequency sweep with a flat power spectrum. This is used to record head-related transfer functions. Guide
  • pa_gentone - generate a pure tone, for sound elevation localization experiments
  • pa_genripple - generate a ripple, for spectrotemporal-resolution electrophysiological and psychophysical measurements Guide
  • pa_gendmr - generate dynamic moving ripple

For the hoop / sound localization setup, the sampling rate of the RP2.1 for DA-conversion is set at 48828.125 Hz, so that the inter-sampling distance is 20.48 μsec.

2. Filter

After the generation of a signal, you generally want to filter your signal, either to bandpass your signal:

  • pa_lowpass - low-pass filter the signal (remove high-frequency frequencies that are not heard, to prevent aliasing, or for specific research questions)
  • pa_highpass - high-pass filter the signal (important to remove low-frequency signals that usually end up distorted when played by the speaker)

or to equalize the signal:

3. Ramp

To prevent onset distortions, you need to ramp the data

  • pa_ramp - add a squared-sine onset and squared-cosine offset

4. Level Ramp

Because of an idiosyncrasy in our set-up, we need to pre- and append 20 milliseconds of zeros to the signal. This is because the second TDT RP2.1 DA-channel is used to control the sound level. Switching this on will also create a sudden onset peak, that needs to be prevented. This is solved by a level-ramp within the RCO. We need to consider this level-ramp by applying:

All steps (generation, filtering, equalizing, and ramping) can be done by TDT, but at present this takes precious time.

5. Save wav-file

And when this is done, we need to save the data, so that it can be used by the TDT system:

  • pa_ writewav - saves the stimulus as a wav file for the DA converter (this also applies a normalization)

You can check whether the stimulus generation has succeeded, with:

  • wavread - MATLAB routine to read an existing wav-file in MATLAB format
  • audioplayer - Matlab routine to play sounds (wavplay)
  • psd - Matlab routine, to determine power spectral density
  • pa_getpower - get power spectrum

Some examples

Let‟s generate a GWN stimulus. Stimulus 3.0 sec, bandwidth from 0.5 to 20 kHz, with on- and offset envelopes.
In Matlab:

 
 
  Noise  = pa_gengwn(3); % Default envelope (250 pnts) and filter
 
  % noise is lp-filtered at 20 kHz
 
  % and hp-filtered at 500 Hz
 
  psd(Noise);
Frequencies below 500 Hz are never useful, and produce distortions on speakers, so they should be filtered out with a highpass-filter. This is already done by default in gengwn.
The GWN stimulus is a well-localizable sound eliciting all binaural difference (ITD and ILD) cues and spectral cues. Sometimes, it is desirable to use lowpass- or highpass-filtered noise, to separate the effects of ITD and ILD. These sounds are created by generating a GWN as above, and filtering it with the functions lowpassnoise and highpassnoise:
 
  HP = pa_highpass(Noise); % noise is hp-filtered at 3 kHz
 
  psd(HP);
 
  LP = pa_lowpass(Noise); % noise is lp-filtered at 3 kHz
 
  psd(LP);
 
 

You might want to equalize the signal:

 
  Noise = pa_equalizer(Noise);
  HP = pa_equalizer(HP);
  LP = pa_equalizer(LP);


Then apply a ramp:

 
  Noise = pa_ramp(Noise);
  HP = pa_ramp(HP);
  LP = pa_ramp(LP);
 
 

In the FART1-setup, speakers will have on onset ramp produced by the TDT-system to ramp to a voltage on the speakers. You will have to take this into account, by putting zeros in front of the stimuli (of about 20 ms worth 20*48.8828125 978 samples):

 
  Noise = pa_levelramp(Noise); %This "prepends" the zerovector to the Noise
 
  HP = pa_levelramp(HP);
 
  LP =  pa_levelramp(LP); 

After this, you should save the matrix to a wav-file, that can be played with the TDT-system:
 
  writewav(Noise,"snd001.wav);
 
  writewav(HP,"snd002.wav");
 
  writewav(LP,"snd003.wav");