Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how to use the applyPatch() function? #78

Open
jtlechem opened this issue Jun 14, 2022 · 4 comments
Open

how to use the applyPatch() function? #78

jtlechem opened this issue Jun 14, 2022 · 4 comments

Comments

@jtlechem
Copy link

jtlechem commented Jun 14, 2022

  • Arduino board: Arduino Uno, with vs1053 codec breakout (https://www.adafruit.com/product/1381)

  • Arduino IDE version: 1.8.19

  • List the steps to reproduce the problem below: looking for how to use applyPatch() function.

How do you use the applyPatch() function?
Is there any example code out there?

I need to use the patch called "vs1053b-patches-pitch.plg" from https://www.vlsi.fi/en/support/software/vs10xxpatches.html

The loadPlugin() function doesn't work for this, because it seems to be for loading SPI boot images, not .plg files.

@TheNitek
Copy link
Contributor

@jtlechem
Copy link
Author

Thank you, I did my best but doesn't seem to work. I copied that _patchVS1053() function into my Arduino script to just call it locally. Had to tweak a couple things like
sdfat::File32 file = _SD.open("patches.053", sdfat::O_READ); if (!file.isOpen()) { return false; }
to
File file = SD.open("/pshift.053", O_READ); if (!file) { return false; }
Doesn't throw any errors, but it doesn't seem to load. I tried the patches.053 and pshift.053 files.

Any good ways to simply use the original .plg file from https://www.vlsi.fi/en/support/software/vs10xxpatches.html ?

@bimac
Copy link

bimac commented Jul 9, 2022

Here's how I did it - maybe this helps?

@dgnuff
Copy link

dgnuff commented Feb 8, 2024

18 months later, here's the solution I used. The patches I used were downloaded from VLSI's web page at https://www.vlsi.fi/en/support/software/vs10xxpatches.html

I downloaded the vs1053b-patches290.zip file from the "VS1053b Patches w/ FLAC Decoder" section. When you look inside that ZIP, there are a bunch of .c files. Pick which one you want and extract it to your project. You'll need to rename it to a .cpp file, because it's going to works with the classes in Adafruit_VS1053.h

It'll have a small routine at the top that is #if 0ed out. and a couple of arrays: unsigned char atab[]; and unsigned short dtab[];. Leave all that alone, but first add the following #includes at the top:

#include <Arduino.h>
#include <SPI.h>
#include <SD.h>
#include <Adafruit_VS1053.h>

Then go to the bottom and append the following subroutine:

void VS1053Patch(Adafruit_VS1053_FilePlayer &musicPlayer)
{
    int i;
    for (i = 0; i < CODE_SIZE; i++)
    {
        musicPlayer.sciWrite(atab[i], dtab[i]);
    }
}

It'll probably also work if the type of the parameter is Adafruit_VS1053, since it only actually cares about one routine in there, and it's inherited from the base Adafruit_VS1053 class.

Add a prototype for that function to your main sketch, and call it immediately after you initially begin() the player, or any time you do a hard or soft reset on it.

I could probably hack together a script to convert the data in the .c file to something that the applyPatch() routine would accept, but I can't be bothered. In the grand scheme of things, the memory saving would be so miniscule by comparison with the ram available on the ESP32-S2 I'm using that it's just not worth my time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants