cancel
Showing results for 
Search instead for 
Did you mean: 

How to play voice prompts stored in external flash using Nucleo-L433RC-P board W25Q128

freeflyer
Associate II

I have a Nucleo-L433RC-P board and would like to be able to play audio voice prompts which are stored in external flash (W25Q128) and output using the internal DAC. 

The voice prompts are only short and will call out number digits, so there is plenty of space on the flash to store these in WAV format raw PCM.

However, I cannot find any example code that will do this. 

The only exapmple I've tried tis shown in the following link where the audio is stored in the internal flash, but I cant even get that to work. 

https://community.st.com/t5/analog-and-audio/tkb-p/analog-audio-knowledge-base

The sound played just screeches, despte following the instructions step by step, including converting the WAV file to IMA ADPCM etc.  I never got as far as trying the example which uses the external flash, because I could not get it working on the internal flash !

I just need an example that plays the voice prompts (preferably raw PCM) from the external flash using the internal DAC.  I don't need the complexity of IMA ADPCM, the voice prompts should easily fit in a raw PCM format on the external flash. 

The voice prompts dont need to be high quality, but I do want the voice prompts to be clear when played back, I dont want it to sound crackly like the type you get in musical birthday cards.

Surely someone must have done something like this before ?

 

 

 

 

3 REPLIES 3
Saket_Om
ST Employee

Hello @freeflyer 

Please refer to this example which read audio file from external flash.

STM32CubeH7RS/Projects/STM32H7S78-DK/Examples/BSP at main · STMicroelectronics/STM32CubeH7RS · GitHub

To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.
Saket_Om

>>Surely someone must have done something like this before ?

Some may even have gotten paid to do it..

DMA a pattern buffer to a DAC? Yes probably, the internal vs external would depend on the W25Q128 being QSPI and Memory Mapped into the L4's address space.

Get the INTERNAL working as a starting point.

The DAC takes 12-bit unsigned values, so perhaps not directly correlating to a .WAV file.

Two register addresses manage left/right alignment. Expect to have to transcode the data in the file, to range/expectations of the DAC

Start by making a SINE WAVE in a data table YOU CREATE, and playing that in a LOOP. ie Circular DMA. You can make tones, and check your work on a scope.

Understand the relationship between the data you've created, the rate you're sending it to the DAC (notionally DMA w/TIM). Make output rate is below 1 MHz (1Msps)

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

"Get the INTERNAL working as a starting point."

Thats what I tried to do without sucess, either the example guide is incorrect or I am doing something wrong.

I did come across what seems to be an error in the example guide when converting the WAV file using SoX.

The guide says to use the following syntax...

sox myaudiofile.wav -r 15625 myaudiofile.ima gain -12

However, this does not change the encoding to IMA ADPCM which is what the example is based on.  When I checked the file using "ffmpeg -i myaudiofile.wav" it showed it was still in raw PCM format.

After further investigation I had to change the SoX syntax to convert to ADPCM (i.e. I added "-e ima-adpcm")...

sox myaudiofile.wav -r 15625 -e ima-adpcm myaudiofile.ima gain -12

 So this makes me question if there are other mistakes or missing information in the example ?