You are viewing an older revision! See the latest version
RS Audio Codec

This page provides information and some examples for the use of the RS Audio Codec sub board, based on TI's TLV320 chip. This chip provides a high quality audio link out and in to the mbed with IO including: an amplified stereo headphone out, an stereo line out, a stereo line in and an pre-amped mono microphone input. Such a capable chip opens up a lot of options for high quality audio on mbed.
One can get this board from RS: AudioCODEC for mbed
The easiest way to get something working is to load a test wave file (such as this one or this one) onto a flash drive, plug it into the Lab Board and load up this program:
Import program
00001 // This is all set up for the RS Labboard: Just plug a memory stick with a wav file called test.wav on it 00002 //(such as the one you can get from: https://mbed.org/media/uploads/p07gbar/test.wav) and have a listen! 00003 // Any 16bit PCM Wav files with channel*sample rate less than 48kHz should work. 00004 00005 #include "mbed.h" 00006 #include "WavPlayer.h" 00007 #include "MSCFileSystem.h" 00008 00009 MSCFileSystem msc("msc"); // Mount flash drive under the name "msc" 00010 WavPlayer player; 00011 00012 int main() { 00013 FILE *fp = fopen("/msc/test.wav", "r"); // Open "out.txt" on the local file system for writing 00014 player.open(&fp); 00015 player.play(); 00016 fclose(fp); 00017 }
This program doesn't need a flash drive or any files:
Import programTLV320_Write_test
A test program for the TLV320, Generates some sine waves.
Other info¶
Both programs use the TLV320 library and the I2S library:
Import libraryI2S
A well tested I2S library where the send and recieve parts are seperate instances.
Import libraryTLV320
A fairly well tested TLV320 library for I2C configuration and control of the TI TLV320 part
A WAV library was written to make the process of playing wave files easier:
Import library
Public Member Functions |
|
| WavPlayer () | |
|
Create a
WavPlayer
instance.
|
|
| WavPlayer (FILE **fpp) | |
|
Create a
WavPlayer
instance.
|
|
| void | open (FILE **fpp) |
|
Set the file to read out of.
|
|
| int | getConfig () |
|
Extract the header infomation, automatically called by open.
|
|
| float | play () |
|
Play the entire file.
|
|
| float | play (float time) |
|
Play the file for a certain number of seconds.
|
|
| float | play (float start, float timefor) |
|
Play the file for a certain number of seconds, from a certain start point.
|
|
