Post Go back to editing

Loading into DSP, processing and playing externally prepared audio samples

Hello everybody!

Recently I started a topic on a possibility of loading and playing/processing an external audio sample in SS (adau1701 in my case). Since new questions appeared, I decided to bring all that into a separated topic and hope that the moderators wont object. Thanks to Brett, I found out that such thing was possible, the major problem was conversion of a, say, wav file into a set of values, suitable for loading into a lookup table. I think there is a quite simple way, which I will put here in details. Meanwhile please somebody help me with some additional questions. Say, I have the data values, I start a new projects, which just takes the values from memory and plays them through an output. Could anybody please help me with blocks, before I have done something foolish? I believe, I should take a stopwatch (w/external reset if I need the sample to be repeated), connect it to the "index lookup table" block and then... Should I simply connect the out pin of the lookup table right to the output? Or there must be some additional block "X" in between? Other words, if the lookup table will simply shoot the data values from its output, then I believe I am simply to connect the table to the output of the 1701, right? Or I missed something... Anyways, many thanks in advance for help and here is the detailed guide how to convert an audio file into them data values.

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!

  • Sorry a follow up question - how many numbers after period should I have for 5.23 format? 2^23 is 8.38861e+06, so probably 6? I know it is a stupid question, but I just couldn't find an answer anywhere.

  •      Hello Skfir,

         Thanks for the tutorial on how to get a sampled sound into numeric form, I'm sure this will be helpful to the community.

         It's OK to branch from your previous post to continue an answered discussion.  Doing this differs from duplicating the original question just to get attention, which is generally frowned upon.  In your first post at http://ez.analog.com/message/131125#131125 Brett suggested a counter and a lookup table to output your sound file.  All we need do now is to load your sound into the lookup table and then realize the rest of his design.

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

         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:

         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::

         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

    attachments.zip
  • Excellent work, Skfir and KJBob!

    I have re-formatted your conversation and posted it as an FAQ:

    http://ez.analog.com/docs/DOC-10801

  • Thank you Bob for the great help ones again good man!

  • Just one more question, sorry. 800 samples limit, is it something compelled, or it is an arbitrary limitation and the limit can be expanded in next versions of SigmaStudio?

  •      Hello Skfir,

         Looking at the compiler_output file for this project, it appears that the LUT uses one parameter memory spot for each sample.  The -1701 has 1024 available (at any sample rate).  Thus there won't be much room to go up, which could be one reason why ADI limited the LUT block to 800 samples.  Filters and other blocks also use parameter memory.

         Bob

  • Hello,
    how did you get the 800 lines needed in the lockup table to play this frequency?
    I did the procedure described but already the result of the TXT file obtained with CoolEdit Pro 2.1 also removing all 0 is about 2000 lines.
    The file I converted to TXT was resampled at 6000 Hz 16 bits and last 0.45 seconds. pronounces the word ONE

  •      I had used Excel at that time, over two years ago.  Now I've only got Open Office so I can't duplicate the above method or results today.  And no Corel at all.  Thus, you'll need to experiment (preferably with a much smaller LUT of perhaps 10 entries) until you come up with a method providing a one-to-one correspondence between each spreadsheet cell and LUT entry.  It may be as easy as selecting the table's contents and block-copying them into the LUT table entry box, as shown below:

     

         Best regards,

     

         Bob