This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

LM3S3748 EK: Array containing sample audio in PCM format?

Other Parts Discussed in Thread: LM3S3748, EK-LM3S1968, LM3S1968

Hello All,

     I’m sure this question has been asked all thought I cannot find it on the TI forms.

In the LM3S3748 Evaluation Kit there is an “Audio” sample. The pcm.h file has an array containing sample audio in PCM format. It there a utility that can convert WAV, or any other format for that matter, to an array like in the “Audio” sample?

  • For everyone else out there, I found the answer...

    There is a utility included with other EVB kits. Its called converter

    From the documentation:

    The EK-LM3S1968 example applications show how to utilize features of the Cortex-M3 microprocessor, the peripherals on the Stellaris microcontroller, and the drivers provided by the peripheral driver library. These applications are intended for demonstration and as a starting point for new applications.

    There is a board specific driver for the RiTdisplay 128x96 4-bit gray-scale OLED graphical display on the Stellaris LM3S1968 Evaluation Kit board. There is also a board specific driver for the Class-D audio amplifier and speaker on the board. In order to use this driver, the system clock should be as high as possible and must be at least 256 KHz; increasing the system clock rate result in higher quality audio. This driver will play both 8-bit PCM data and 4-bit ADPCM data; the converter application (converter.c is the source code, and converter.exe is a pre-built binary) will take raw 16-bit signed PCM data and convert it into a C array that can be included in an application for playback purposes. For example, to encode voice.pcm with ADPCM and produce a C array called g_pucVoice:

     

    converter -a -n g_pucVoice -o voice.h voice.pcm

     

    To do the same, but encode to 8-bit PCM:

    converter -p -n g_pucVoice -o voice.h voice.pcm

     

    Since the Class-D audio driver will only play 8 KHz mono streams, and the converter application will only handle raw PCM input, an application such as sox will be needed to convert arbitrary wave files to the required format. To convert voice.wav to the required format for converter:

    sox voice.wav -t raw -r 8000 -c 1 -s -w voice.pcm polyphase

    The polyphase at the end selects a higher quality sample rate conversion algorithm. It may be helpful (and/or necessary) to also include vol {factor} before polyphase in order to increase the volume of the waveform. If sox complains of clipping, the volume needs to be reduced. sox can be found at http://sox.sourceforge.net. There are numerous other audio applications (both open source and commercial) that can be used instead of sox.