This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

PWM Audio driver

Hello,

I just wanted to throw in that for a hobby project I created a PWM audio driver, with which one can play back 8-bit audio data very easily. Since it may be useful for others, too, I have uploaded the sources to https://nrf52-pwm-audio.sourceforge.io/, along with SES project files for nRF52832 and nRF52840. Plus, there you will also find a link to a video to see what you can do with the driver.

Cheers,
Tamas

  • Hi tamas,

    I read more about MP3 decoding and yes, for MP3 1152 is a fixed frame size for mono. FIFO totally makes sense, but increasing the PWM buffer keeps code simpler.

    Currently I am struggling with "Data Access Violation". I already tried to change CONFIG_MAIN_STACK_SIZE and CONFIG_HEAP_MEM_POOL_SIZE, but that doesn't help. Maybe you know a working memory setting or what needs to be tweaked.

    Cheers,
    Felix

  • Hi

    I had a hand in testing your library. It works pretty well, however, I noticed something strange in the way my melody is played and I wonder if I'm doing something wrong.

    I created a simple melody in LMMS (I'm using ubuntu), and I export it to a .WAV file. Then, I used audacity to trim it and export it to .raw (headerless) and a signed 8-bit PCM. I made sure to also set in preferences the sample rate to one of the supported frequencies you mentioned.

    After this, I use xxd -i to convert it to a .c file. I also create a .h file based on it to include in my main.c file.

    The melody reproduces faithfully, except for the fact that it's about half the tempo I originally created it for. Could it be something caused by the xxd, some setting in your library I didn't set properly?

    To initialize it I'm using:
        bool const pwm_audio_highdrive = true;
        nrf_pwm_audio_init(buzzer_external_pin, pwm_audio_highdrive);
    where buzzer_external_pin = 3.

    Thanks in advance if there's any suggestion

  • Hi,

    have you tried to re-sample your file with ffmpeg as described in my github project:

    https://github.com/don41382/nrf52-pwm-wav-sbc-decoder-player/blob/main/files/decode.sh#L32

    That worked for me pretty good.

    Cheers,
    Felix

Related