Jump to content
  • 0

Playing pre-recorded samples on the audio-out port on Nexys 4 DDR


noureddine-as

Question

Hello,

I am working on a project where I need to playback some sounds depending on specific inputs.

The system contains a BRAM containing pre-recorded audio samples (pronunciation of numbers from 1 to 10). From that memory, and depending  on input dip switches (4 LSB bits), the appropriate sound sample is loaded from the memory and transferred to the audio output.

My target FPGA board is the Nexys 4 DDR, the IP will be integrated with a softcore that already uses the DDR2 Memory cannot use is to store the samples, I have to instaciate memory from BRAM. The softcore already uses many resources (65% of available BRAM is already taken).

1- I would like to ask for some guidance on how to convert a typical sound (.wav or mp3 or whatever) to an appropriate format that I can store (.Coe for example)?

2- Assuming the sounds take around 1 second, how much memory will I need?

3- What parameters should I use (output frequency ....)? Any pointers on how to compute that?

I have no background on audio processing but I am open to learn, so any pointers are appreciated.

Best regards.

 

 

Link to comment
Share on other sites

1 answer to this question

Recommended Posts

WAV files are the simplest to work with.

1. The WAV file have s small header on it, then they are all raw sample data, usually stereo pairs of 16-bit signed numbers. Just write a small program in your favorite scripting language to print out data after about 64 bytes.

2. For phone-quality audio, you need bandwidth of 300Hz to 3kHz. -  this needs around 8000 samples per second, and about 8-bit sample depth . You could use some u-law or a-law compression to increase dynamic range (https://en.wikipedia.org/wiki/Μ-law_algorithm)

3. - 8 kilobyes per second, if you play raw 8-bit samples.

Oh, and to convert data from a WAV file to lower sample rates (e.g. from 48kS/s to 8kS/s) you can't just drop 5 out of six samples - you need to first filter off the frequencies greater than half the target sample rate. It's not that challenging to actually do in code (usually just a couple of 'for' loops around something like "out[x] += in[x+i] * filter[j]') but generating the magic values for the filter can be interesting.

 

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...