VEX Speaker module

Jump to: navigation, search
Tutorials → VEX Speaker module

VEX Robotics just announced (and released) their new Speaker accessory for the VEX Cortex Microcontroller. This cool new speaker will allow you to play tones, sounds and wave (.wav) sound files from your VEX Cortex. The new speaker plugs into the “SP” port on the Cortex – check near the bottom of the sensor bank of ports. The speaker even has a built in volume control:

Check out our cool unboxing photos below, exclusive from the VEX World Championships!

The awesome thing with this new speaker accessory is that ROBOTC already has support for this new speaker built into version 3.08! For more information on how to use the speaker, check the ROBOTC help documentation built into ROBOTC, or look at our new (under construction) ROBOTC code wiki!

Wiki Link: VEX2_Functions_Sound

To help you get started, here are two sample programs to try out your new VEX speaker attachment.

VEX Speaker


Uploading Sound Files to the Cortex

Before you can start using the VEX Speaker with ROBOTC, you must first move the sound files you wish to use onto the Cortex. The sound files must be formatted for 8-bit, 8.000 kHz, Mono output and saved as a .wav (waveform audio file format) file. You can use a free, open source program called Audacity to perform this conversion.

1) Download and install Audacity from their download site,

2) Open Audacity and open the file you wish to convert (File -> Open).

3) Play the opened sound file to ensure Audacity was able to read it properly by pressing the green 'Play' button.


4) In the bottom left corner of the screen, change the 'Project Rate (Hz)' setting to 8000 Hz.

Project Rate.jpg

5) Navigate to the File menu and select 'Export'. A window will pop up asking you how and where you would like to save the file. Choose an appropriate file location and change the 'Save as type:' drop menu to 'Other uncompressed files', then click the 'Options' button.

Export Type.png

6) Another window will pop up labelled 'Specify Uncompressed Options'. Select 'WAV (Microsoft)' for the Header option and 'Unsigned 8 bit PCM' for the Encoding, then click OK.

Specify Uncompressed.png

7) On the Export File page click 'Save' to save the file to your computer. A window will pop up labelled 'Edit Metadata'. You must click select all of the information provided (including any blank cells) and click the 'Remove' button. There will still be some Tag titles remaining; this is normal. Once the information is removed, click the 'OK' button to save the file.

Edit Metadata.png

8) With the Cortex connect to the computer and turned on, open ROBOTC and navigate to the 'Robot -> Advanced Tools -> File Management' window.

File Management.png

9) On the right hand side of the window, click the 'Download' button and select the formatted audio file. Once the file is uploaded it will appear in the Cortex's file list and the window can be closed.

File Download.jpg

10) Now that the file is on the Cortex, you can access it via code by using the 'PlaySoundFile("filename.wav");' command.

Example Code

Sound Test:

task main()
  //Basic "Play Sound" commands
  //Intelligent "Play Sound" command
  //Delay until sound is done playing
  //Play a tone:
  //First Parameter: Frequence in Hz
  //Second Parameter: Length to play in 1/100th of a seconds (50 = .5 seconds)
  PlayTone(440, 50);
  //Play a Sound File (need to use the File Management to Upload First)

Sample Program Downloads

PowerPoint explaining VEX Speaker

Sound Files