SFEMP3Shield
1.02.15
Arduino Library for VS10xx shield
|
The Arduino SFEMP3Shield Library is a driver for VSLI's VS10xx, implemented as a Slave co-processor to audio decode streams of Ogg Vorbis/MP3/AAC/WMA/FLAC/WAVMIDI formats, across the SPI bus of the Arduino, along with mixing input signals. Principally this library is developed for the VS1053, where it may be compatible with other VS10xx's
Initial development was implemented on an Arduino 328 UNO/Duemilanove with a SparkFun MP3 Player Shield. Where additional support has been provided for Arduino base systems and Shields. Hardware and documentation is provided as to how to implement these. Where this driver is modular in concept to allow ready porting to other Arduino or Wiring platforms.
To install 1, 2, 3 !
An example is provided in the SFEMP3Shield/examples folder. Which is developed to test SFEMP3Shield and illustrate its various common uses.
As mentioned the initial and principal support of this library is with Arduino 328 UNO/Duemilanove with a SparkFun MP3 Player Shield. Although various other boards and shields may be implemented by customing the SFEMP3ShieldConfig.h file.
Support for Bare Conductive's Touch Board is provided and documented in SFEMP3ShieldConfig.h.
Support for Arduino and Seeeduino Mega's are documented in SFEMP3ShieldConfig.h, which simply REQUIRES additional jumpers. As the SPI are not on the same pins as the UNO/Duemilanove.
Support for Arduino Leonardo's are afflicted by having the SPI and INT0 pins not routed to the same pins as the UNO/Duemilanove . This is similar to the Arduino Mega. Which simply REQUIRES additional jumpers, as documented in SFEMP3ShieldConfig.h to correct the SPI. The swapping of INT0/INT1 is automatically corrected based on the Leonardo's processor type of AVR_ATmega32U4 being detected.
SFE Arduino Pro's while similar to UNO/Duemilanove's pin outs, they are available in either 5V or 3.3V. Where the SFE MP3 Player Shield requires 5V and locally generating the needed 3.3V and 1.8V for the VS10xx chip. Noting that 3.3V Pro's do not supply 5V, this causes a problem. It is possible to modify the shield as to use base Arduino supplied 3V's.
SparkFun MP3 Player Shield should just work out of the box (bag) with a Arduino 328 UNO/Duemilanove, with Interrupts.
Support for Seeduino MP3 Player Shield please see SEEEDUINO and may require additional libraries, as per Requirements
Support for Gravitech MP3-4NANO shield please see GRAVITECH
Understanding that every byte streamed to the VS10xx needs also to be read from the SdCard over the same shared SPI bus, resulting in the SPI bus being less than half as efficient. Along with overhead. Depending upon the Bitrate of the file being streamed to the VSdsp, there is only so much Real Time available. This may impact the performance of high bit-rate audio files being streamed. Additionally the Play Speed Multiplier feature can be exhausted quickly. Where on a typical UNO there is plenty of real-time to transfer good quality files, with CPU to spare for other tasks, assuming they do not consume too much time either.
The available CPU can be increased by either or both increasing the speed of the SPI and or the Arduino F_CPU. Where the Speed of the SPI is individually maintained by both this driver and SdFatLib. As not to or be interfered with each other and or other libraries using the same SPI bus. The SdCard can be increased from SPI_HALF_SPEED to SPI_FULL_SPEED argument in the SD.begin. Where this library will set the Read and Write speeds to the VSdsp correspondingly, based on F_CPU of the Arduino.
The actual consumed CPU utilization can be measured by defining the PERF_MON_PIN to a valid pin, which generates a low signal on configured pin while servicing the VSdsp. This is inclusive of the SdCard reads.
The below table show's typical average CPU utilizations of the same MP3 file that has been resampled to various bit rates and using different configurations. Where a significant difference is observed in performance.
BitRate | SdCard | Refilling | IDLE |
---|---|---|---|
128K | Half | 12% | 88% |
128K | Full | 10% | 90% |
96K | Full | 7% | 93% |
56K | Full | 4% | 96% |
The VS10xx chips are DSP's that run firmware out of ROM, that is internal to the VS10xx chip itself. Where the VSdsp's RAM can additionally be loaded with externally provided firmware and executed, also known as patches or plug-ins, over the SPI port and executed. This allows the VSdsp to have a method for both fixing problems that may exist in the factory ROM's firmware and or add new features provided by VLSI's website. It is even possible to write your own custom VSdsp code, using there Integrated Development Tools (VSIDE).
vs_plg_to_bin.pl is a perl script, that is provided in this library to run on your PC, to read and digest the .plg files converting them to raw binary as to be read by SFEMP3Shield::VSLoadUserCode() from the SdCard. Allowing updates to the VSDsp into its volatile memory after each reset. These updates may be custom features or accumulated patches.
By storing them on the SdCard these plug-ins do not consume the Arduino's limited Flash spaces
Below are pre-compiled binary's of corresponding provided VSLI patches/plugins. The filenames are kept short as SdCard only support 8.3.
.\pcm.053 .\vs1053-pcm110\vs1053pcm.plg .\admxleft.053 .\vs1053b-admix130\admix-left.plg .\admxmono.053 .\vs1053b-admix130\admix-mono.plg .\admxrght.053 .\vs1053b-admix130\admix-right.plg .\admxster.053 .\vs1053b-admix130\admix-stereo.plg .\admxswap.053 .\vs1053b-admix130\admix-swap.plg .\patchesf.053 .\vs1053b-patches195\vs1053b-patches-flac.plg .\patches.053 .\vs1053b-patches195\vs1053b-patches.plg .\rtmidi.053 .\vs1053b-rtmidistart\rtmidistart.plg .\eq5.053 .\vs1053b-eq5-090\vs1053b-eq5.plg
The below is a list of basic questions to ask when attempting to determine the problem.
...do not have a sd.begin in the main sketch, See Trouble Shooting Guide.
"...undefined reference to `sd'
"Free RAM = 1097 Should be a base line of 1095, on ATmega328 when using INTx
" then nothing...SdFat::begin()
to be initialized in the main sketch.ino, as shown in the below example. This provides more immediate access to the SdCard's files by the main sketch. However, if not done there is no immediate compiler error and the sketch will lock up after as it attempts SFEMP3Shield::begin. "Error code: 1 when \b trying to play track"
"Warning: patch file not found, skipping."
Free RAM = 1090 Should be a base line of 1094
'd'
menu command to display directory contents of the SdCard. "longfilename.mp3"
will be converted to "longfi~1\.mp3"
. Where one can not predict the value of the 1. The DOS command of "dir \c /x"
will list a cross reference, so that you know exactly, what is what.Error Codes typically are returned from this Library's object's in place of Serial.print messages. As to both save Flash space and Serial devices may not always be present. Where it becomes the responsibility of the calling sketch of the library's object to appropiately react or display corresponding messages.
The following error codes return from the SFEMP3Shield::begin() member function.
0 OK 1 *Failure of SdFat to initialize physical contact with the SdCard 2 *Failure of SdFat to start the SdCard's volume 3 *Failure of SdFat to mount the root directory on the volume of the SdCard 4 Other than default values were found in the SCI_MODE register. 5 SCI_CLOCKF did not read back and verify the configured value. 6 Patch was not loaded successfully. This may result in playTrack errors
sd.begin()
as global, starting version 1.1.0The following error codes return from the SFEMP3Shield::playTrack() or SFEMP3Shield::playMP3() member functions.
0 OK 1 Already playing track 2 File not found 3 indicates that the VSdsp is in reset.
The following error codes return from the SFEMP3Shield::skipTo()member function.
0 OK 1 Not Playing track 2 Failed to skip to new file location
The code has been written with plenty of appropiate comments, describing key components, features and reasonings in Doxygen markdown style as to autogenerate this html suppoting document. Which is loaded into the repositories' gh-page branch to be displayed on the projects's GitHub Page.
Additional support may be reached from any of the following: Please read through this document and refering linked resources.
VLSI's software download of Apps, Patches, Plugins and tools.
VS10XX AppNote: Connecting analog outputs.