Home Examples Audio via Dexterit-E Computer

Audio via Dexterit-E Computer

This task was previously called the Tone Player.

We get many requests for how to play sound to a subject. There are lots of options for how to do this:

  • Analog outputs to the NI cards
  • Specialized sound cards that are xPC compatible
  • Playing sounds from the Dexterit-E computer

The attached example is a very simple version of the final option: playing sounds from the Dexterit-E computer.

For an alternatively method that plays sounds in REAL-TIME though the Robot computer, please see the other sample task entitled Audio via Robot computer

You will need to have Java available in order to run this example. You can obtain the most recent Java from: http://www.java.com. This example requires a small program to run on the GUI computer. Once you unzip the example files you will need to:

  1. Find the folder you have unzipped the files to using the Windows Explorer.
  2. Hold shift and right click on the folder in Windows Explorer
  3. Select “Open command window here”
  4. At the command prompt type: java -jar toneplayer.jar
  5. At this point you should see: “Ready to play tones…”.

When you run the task, if you have speakers plugged into the Dexterit-E computer and they are turned on then you will hear 3 tones played, one each trial. As the task runs it will create UDP packets that get passed to the tone player program. The program interprets the packets and creates an appropriate tone. It must be noted that sound playback in this way is not real-time, but it will be close to real time.

I have provided the Java code that plays the tones, you are free to modify it to your needs. This code could be modified to play *.wav files or possibly even *.mp3. I have not done that. This is purely a proof of concept.

The task was last tested for Dexterit-E 3.10 and MATLAB 2015a SP1, 18-Aug-23.

Related Tasks

Coding Tips
Persistent Variables
Persistent variables are ones that hold their value between calls to the embedded MATLAB code they are defined in.
Coding Tips
Custom Control of the Trial Protocol Order
Normally, Dexterit-E manages and controls the order in which Trial Protocols (TPs) execute based on what is defined in the block table of the Task Protocol (see the Dexterit-E User Guide for more details).