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