How to Play Audio (.wav file) like human voice not the beep sound in nrf52832 boards?
How to Play Audio (.wav file) like human voice not the beep sound in nrf52832 boards?
Hi Yesha,
I would suggest to have a look at this case: Play audio snippet via nRF51/52
You can either use PWM or I2S to output the audio.
For PWM, you would need to convert the sound to PCM format and use PWM to output the PCM data. It's is similar to what we did with the Thingy 52. I think it's a good example that you can follow.
Hi Hung,
I used the PWM to output the audio, used this example https://sourceforge.net/projects/nrf52-pwm-audio/ and other audio code example with different sample audios also but it's not giving the original audio, I got lots of noise can you suggest what can be the issue?
Thanks,
Yesha.
Hi,
Could you please send your schematic and a picture of your set-up ?
Hi,
I have the custom board of nrf52832 for which the speaker is already inbuilt, it works for beep sequence
static uint16_t /*const*/ seq_values[] =
{
0x8000, 0,
0x8000, 0,
0x8000, 0,
0x8000, 0,
0x8000, 0,
0x8000, 0,
0x8000, 0,
0x8000, 0,
0x8000, 0
};
nrf_pwm_sequence_t const seq =
{
.values.p_common = seq_values,
.length = NRF_PWM_VALUES_LENGTH(seq_values),
.repeats = 0,
.end_delay = 0
};
but when I tried to use wav file hex code it's making noise
Hi
You have to configure the PWM according to the format of the sound file, with countertop set to 255, and ensure that the wave file is using an 8-bit unsigned format. Secondly, you need to do some processing on your audio data in order to convert the 8-bit samples from the wave file to 16-bit unsigned values for the PWM module.
What was your problem when running the sourceforge project?
Did you get the code to work with the included wave files, but not your own?
Best regards
Torbjørn
Hi,
In sourceforge project I used the same sample files which is given in the code and also tried my own files as well but not getting the voice sound instead of getting crash audio sound which make lots of noise for every audio files
Thanks,
Yesha
Hi Yesha
So running the sourceforge source code as well as the sample files still gives noisy audio?
Would you be able to make a test audio file that just plays a simple sine wave (1 kHz frequency for instance), and record the resulting sound?
Then it might be possible to understand what is going on, based on how the sine wave gets played back.
Best regards
Torbjørn
Hi Yesha
So running the sourceforge source code as well as the sample files still gives noisy audio?
Would you be able to make a test audio file that just plays a simple sine wave (1 kHz frequency for instance), and record the resulting sound?
Then it might be possible to understand what is going on, based on how the sine wave gets played back.
Best regards
Torbjørn
Hi,
Yes, source forge source code with sample files also gives noise. I record the voice but I couldn't able to upload here, can you please guide how can I share the file
Thanks,
Yesha
Hi,
can you suggest how to use the DAC for playing audio from the nrf52 board, is it possible that as I have the custom board of nrf52832 with DAC connection so instead of PWM, can I use the DAC for audio playing?
Thanks,
Yesha
Hi Yesha,
Thanks for the above positive reply's!
I have similar kind of problem when I send audio data to Ble I am getting lots of noise on the other side [Android phone] .
I have used SGTL5000 codec and NRF52832 MCU and I have used I2S protocol to get data from codec
Please note:
- I have set SGTL5000 codec I2S output to 16Khz.
- In LOOPBACK sound is very crystal clear but when I send that data on ble i am getting lots of noise.
- I have taken dummy test where I have sent hard coded audio file to ble device and on the other side means android side we successfully played that audio file.
Do I need to compress or decompress the data for this or can you suggest how to send data on Ble?
we are stuck here for long time!!!
After long time someone open this topic again and as per your above reply in mind born a ray of hope!!
PLEASE GUIDE US!!
Best and regards,
Dipak
Hi
You should be able to attach a file simply by drag dropping it into your reply. If you get the message that the file type is not supported you can zip it first.
I was able to build the soundforge project and run it on a Thingy52 (which comes with a built in speaker). I notice that there is a bit of noise when the sound is being played. Does this sound similar to the noise you are experiencing?
It is definitely possible to connect a DAC to the nRF52 over I2S, and this will give you much better sound quality compared to using the PWM. I will take a look next week if I can find a good example for this.
Best regards
Torbjørn
Hi,
Thanks for the help, my sound file is not similar to this one, here we can hear sample 3 with noise but I am only getting noise but now I am changing output from PWM to DAC using I2C so looking for their examples
Thanks,
Yesha