:: Style
:: Using Sound with Dual Computer Cortex  
GENERAL INFORMATION:

The ability to play sounds in Cortex has been added to the dual computer Cortex program. Sound can be used not only as stimuli, but also as an auditory feedback mechanism to assist in training. With this code, up to 256 different sound (.wav) files can be played during an experiment. Additionally, the volume and mix of the sound from the speakers can be changed during the experiment through function calls in the Cortex timing file.

The sound code for the DOS version of the Cortex program was written by David Mechner at New York University. The sound code is provided “as-is”, but problems/questions can be sent to tnorden@helix.nih.gov. In Cortex version 5.9.2 (and later), sound is available when using the DirectX receive program as well. The differences in the capabilities, installation, and the interface of the two versions will be outlined below.

Because the sound code was integrated with the 32-bit Cortex “send/receive” code, it can only be used with the two computer 32-bit version of Cortex. Also, be aware that the sound code has not yet been tested for latencies.

CAPABILITIES:

A. DOS (rvesactx.exe) version

Up to 256 different sound (.wav) files can be played one at a time during an experiment. Additionally, the volume and mix of the sound from the speakers can be changed. Changes in the volume and mix will apply to all subsequent sounds which are played.

B. DirectX (dxrecv.exe) version

The sound component of the DirectX receive program has more functionality than the DOS version of the sound code. For example, DirectX supports the overlaying of multiple sounds, the ability to continually loop a sound, the individual control of the volume of each sound, and the ability to stop each sound one at a time. Because of these differences, the timing file functions supporting sound had to be changed to accommodate these features. In particular, SOUNDvol() and SOUNDstop() must take the sound number as input, since each sound must be controlled individually. Also, SOUNDplay() and SOUNDstart() must take a parameter to control whether or not to loop the sound continuously until SOUNDstop() is called. Existing timing files written for the DOS version should work. However, please note that these extra parameters will be set to 0. Therefore, there will be no looping, and SOUNDvol() and SOUNDstop() will operate on the first sound (i.e. sound number 0) only.

DirectX also allows the user to specify what type of speakers are being used, and also the orientation of the stereo speakers, in order to optimize the sound produced. The SOUND parameter in the CORTEX.CFG file can be used to customize these features.

INSTALLATION:

A. DOS (rvesactx.exe) version

A SoundBlaster card must be installed in the receive computer. Any modern SoundBlaster card should work (e.g., SB16, AWE32, or AWE64). It might also work on SB16 compatible cards, but it has not been tested. If the SoundBlaster card has been installed properly in the computer, there is no additional configuration necessary to use the Cortex sound capabilities. The code reads the DOS “BLASTER” environment variable to get the addresses and IRQs of the card. Certain problems with the sound initialization and execution during the use of Cortex are logged to the file “rvesactx.err” on the receive computer. Please note that the sound (.wav) files must be present on the receive computer.

B. DirectX (dxrecv.exe) version

Any sound card which is supported by DirectX can be installed in the receive computer. After the sound card is installed in the computer, the DirectX driver must be installed. Please refer to the document entitled, "Instructions for the DirectX Receive Program (DXRECV.EXE)" for information on how to obtain and install the DirectX driver. Certain problems with the sound initialization and execution during the use of Cortex are logged to the file “dxrecv.err” on the receive computer. Please note that the sound (.wav) files must be present on the receive computer.

INTERFACE:

A. DOS (rvesactx.exe) version

The following functions can be included in a Cortex timing file:


int SOUNDload(int i, char* soundfile);

  causes the sound file soundfile to be loaded as sound i (0 – 255) and readied to play.

  Returns: 1 if successful, 0 if not


int SOUNDplay(int i);

  plays loaded sound i

  Returns: 1 if successful, 0 if not.

  Note: The SOUNDplay() call internally invokes the same code as SOUNDprep() and SOUNDstart(). Therefore, if you use   SOUNDplay(), you do not need to call SOUNDprep() or SOUNDstart().


void SOUNDstop();

  stops the sound playing


int SOUNDprep(int i);

  prepares sound i to be started

  Returns: 1if successful, 0 if not.


int SOUNDstart(int i);

  starts a sound i that has already been prepared with SOUNDprep()

  Returns: 1 if successful, 0 if not.


void SOUNDvol(int left, int right);

  sets the left and right mixer volume in each speaker (valid values, 0-31)

  Example:
  Refer to the timing file “sound.tim” in the \cortex\demos\misc directory of the Cortex distribution files.

B. DirectX (dxrecv.exe) version

The following functions can be included in a Cortex timing file:


int SOUNDload(int i, char* soundfile);

  causes the sound file soundfile to be loaded as sound i (0 – 255) and readied to play.

  Returns: 1 if successful, 0 if not


int SOUNDplay(int i, int looping)

  plays loaded sound i
  uses the looping parameter to specify whether to play the wave file once (0),
  or to keep playing it continously (1) until SOUNDstop() is called.

  Returns: 1 if successful, 0 if not.

  Note: The SOUNDplay() call internally invokes the same code as SOUNDprep() and SOUNDstart(). Therefore, if you use SOUNDplay(), you do not need to call SOUNDprep() or SOUNDstart().


void SOUNDstop(int i)

  stops the sound i from playing. Must specify the number that is to be stopped, since sound is controlled on a per-sound buffer basis.


int SOUNDprep(int i);

  prepares sound i to be started

  Returns: 1if successful, 0 if not.


int SOUNDstart(int i, int looping);

  starts a sound i that has already been prepared with SOUNDprep()
  uses the looping parameter to specify whether to play the wave file once (0),
  or to keep playing it continously (1) until SOUNDstop() is called.

Returns: 1 if successful, 0 if not.


void SOUNDvol(int left, int right, int i);

  sets the left and right mixer volume in each speaker (valid values, 0-31) for sound number i.
  Must specify the sound for which the volume is to be set, since each are set individually.

  Example:
  Refer to the timing file “dxsound.tim” in the \cortex\demos\dx directory of the Cortex distribution files.


Technical Notes:

Refer to the end of the document "sound.doc" in the \cortex\docs directory of the Cortex distribution files.


NIMH CORTEX was written by a team of dedicated researchers for the NIMH Laboratory of Neuropsychology.
Questions or problems regarding this web site should be directed to CortexSite@salk.edu.