Skip to content

Possible Code Modifications for Adafruit_VS1053 Files #96

Description

@Warren52
  • Arduino board: Adafruit VS1053B (https://www.adafruit.com/product/1381)
  • Arduino IDE version: 1.8.19
  • Code modifications by whh - Feb 2024
  • I was looking for an audio board to work with an AVR128DB28 MCU running
  • under Spence Konde's DxCore (https://github.com/SpenceKonde/DxCore) with
  • IR Remote support via TinyIRReceiver (Arduino-IRremote) as the basis for
  • my next projects. I looked over the Adafruit VS1053B (product 1381), the
  • various documentation Adafruit provided, how to hook it up, evaluated my
  • MCU, etc., and chose to give it a try.
  • I ended up downloading the Adafruit_VS1053.h and .cpp files from github,
  • found I also needed the Adafruit_SPIDevice.h and .cpp files, put the files
  • into my local directory (and modified includes to access the local files,
  • and tried to get things working. EVENTUALLY - I starting hearing audio
  • out of an Adafruit 3.7W amp to a set of speakers. But I could never get
  • a full file to play.
  • I went through the VS1053 code to understand what was going on and put
  • debug prints here and there. I found the interrupts were happening quite
  • rapidly and feedBuffer_noLock could take 16 ms or more. But everything I
  • tried never allowed me to have audio and IR Remote working together. So
  • I chose a different approach.
  • I made an exec() function pattered after the interrupt handler that would
  • call a runBuffer() function pattered after feedBuffer_noLock. The exec()
  • function would be called in void loop() of an .ino sketch and defines in
  • Adafruit_VS1053.h file would separate interrupt code from exec code. I had
  • wanted to put the define just before the include in the .ino file but it
  • would not pass through and be recognized in the Adafruit_VS1053.h header.
  • So long story short, using the exec() function, I can play mp3 audio files
  • from the SD Card while at the same time processing IR Remote signals via
  • IRRemote TinyIRReceiver. I can start a specific audio file (e.g. buttons
  • 1 thru 9), change the volume up or down, mute or unmute the volume, or
  • stop playing WITHOUT any interruption or degradation in playback. All
  • while only clocking my MCU at 8 MHz. (Oh yea, I also have a fair amount
  • of debug content being output while all of this is going on!)
  • I have gone back and tried the interrupt method but even with setting
  • the MCU clock to the highest frequency of 24 MHz, it will not finish
  • playing a mp3 file. I even changed the attachInterrupt parameter from
  • CHANGE to RISING. The only way I can get all I want running to run is
  • to use the exec() function.
  • Ok, so what am I doing. I am giving back to Adafruit. Comments have
  • been added to the Adafruit_VS1053.h and .cpp files I have been working
  • on. I have also tried to put my initials (e.g. whh) where I have made
  • changes. I hope I can zip these files up and submit them to github so
  • you can look them over and choose to do what you would like to with
  • the code. Maybe one day there is a new code version with instructions
  • of how to use either interrupts or the exec() function. Worst go to
  • worst, I now have working code for me. Now as soon as more VS1053
  • boards become available, I will be able to use them.
  • Warren H. Holt (whh) - 17feb2024

Adafruit_VS1053_Mods_Feb_2024.zip

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions