Playing audio samples in SigmaDSP

Document created by BrettG Employee on Feb 4, 2014
Version 1Show Document
  • View in full screen mode

EngineerZone community members Skfir and KJBob collaborated to create a great tutorial describing how to play short audio samples directly from the data memory of a SigmaDSP. I decided to re-post their discussion as a Frequently Asked Question in order to reach a larger audience. Keep in mind that SigmaDSPs have very limited memory sizes, but as this example shows, simple audio sample playback is still possible!

 

Skfir's Tutorial - Converting Audio Files to Raw Sample Data

 

1. Create or open a sound file in Cool Edit pro (versions 1.0-2.1 will work)

2. Press "Save as" and choose .txt file as an output. The out file will have numbers, but much greater than 1 to -1  integers, shortly speaking.

3. Copy all the values into the clipboard.

4. Open Excel and paste all the values.

5. Now it is time to remove the empty cells (caused by line changes in the txt file)

6. Select all the cells, press Edit>Go To>Special, select "blanks" and press OK  Now all the blank cells are selected

7. Press edit>delete to delete the empty cells.

8. Now, in a new cell, type a constant by which you want to divide the data values (in case of a 16-bit sound file the constant is 32767)

9. Copy the cell with the constant into the clipboard.

10. Select all cells you want to process.

11. Press Edit>Paste Special, select "Divide" and press ok.

12. Done!! The values are ready!

 

KJBob's Tutorial - Loading the Sample Data into SigmaStudio and Playing Back the Audio

 

     The lookup table needs a simple text file with just a list of values like this (six decimal places is enough, as you said):

PCM-sound-txt_pic.jpg

     To produce your text file from Excel, use its export function and choose text file (tab delimited).  Look at the resulting file in Notepad to see if it appears OK.

 

     To output your sound, load your text file into a lookup table and have a counter step through all its values.  As usual there are several possible circuits, one is shown below:

Play-PCM-sch_pic.jpg

     In this particular circuit the sound repeats as long as the switch is ON, but single-shot playback and various logic triggers are also possible.  My sound file is just one cycle of a sine wave, 500 samples at fs = 48KHz.  It repeats at f = 48000 / 500 = 96 Hz.  Of course, you're playing something more interesting than that.  The comparator sets how much of the LUT is played before it repeats.

 

     The lookup table only fits up to 800 samples, or 16.6 mS at 48KHz.  If your project runs at 192KHz, you only get about 4.1mS.  If that's too short for the job, and your sound has a normal audio bandwidth, you can modify this circuit to step through the LUT at a slower rate.  For example, the circuit below runs at 192K while playing the same sound sampled at 48K.  The circuits sound alike:Play-PCM-div4-sch_pic.jpg:

     The LUT's output is "DAC ready", but I suggest adding a lowpass filter to smooth things out a bit.  The sound file and the circuit are attached.

 

     Best regards,

 

     Bob

 

This FAQ was generated from the following discussion: Loading into DSP, processing and playing externally prepared audio samples

Outcomes