How to use the applyPatch() function in the Adafruit VS1053

For other supported Arduino products from Adafruit: Shields, accessories, etc.

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
jtlechem
 
Posts: 6
Joined: Mon May 09, 2022 7:46 pm

How to use the applyPatch() function in the Adafruit VS1053

Post by jtlechem »

Is there any example code out there for using the applyPatch() function?


I'm using the VS1053 codec breakout with my Arduino Uno.
(https://www.adafruit.com/product/1381)

And using the Adafruit VS1053 Library for Arduino.
(https://github.com/adafruit/Adafruit_VS1053_Library)

The maker of the VS1053 chip has some patch files for added functionality (https://www.vlsi.fi/en/support/software ... tches.html) I need to use the pitch/tempo shifter patch, which is sort of explained in this document from VLSI, page 19: https://www.vlsi.fi/fileadmin/software/ ... atches.pdf

So to the makers of the Adafruit VS1053 Library, I'm wondering how do you use the applyPatch() function? I'm not sure what to write for the two input variables.

I tried attaching here the patch/plugin file, but won't let me. It's called "vs1053b-patches-pitch.plg" from the patches folder found in the link above.
It has the necessary plugin array but also has a lot of the same code as the applyPatch() function, so I'm confused how that works, what to write in my arduino script, what not to write in the arduino script, etc.

Here is the applyPatch() function from github (also linked above):

Code: Select all

void Adafruit_VS1053::applyPatch(const uint16_t *patch, uint16_t patchsize) {
  uint16_t i = 0;

  // Serial.print("Patch size: "); Serial.println(patchsize);
  while (i < patchsize) {
    uint16_t addr, n, val;

    addr = pgm_read_word(patch++);
    n = pgm_read_word(patch++);
    i += 2;

    // Serial.println(addr, HEX);
    if (n & 0x8000U) { // RLE run, replicate n samples
      n &= 0x7FFF;
      val = pgm_read_word(patch++);
      i++;
      while (n--) {
        sciWrite(addr, val);
      }
    } else { // Copy run, copy n samples
      while (n--) {
        val = pgm_read_word(patch++);
        i++;
        sciWrite(addr, val);
      }
    }
  }
}

User avatar
jtlechem
 
Posts: 6
Joined: Mon May 09, 2022 7:46 pm

Re: How to use the applyPatch() function in the Adafruit VS1

Post by jtlechem »

*small title typo: How to use the applyPatch() function from the Adafruit VS1053 Library

Locked
Please be positive and constructive with your questions and comments.

Return to “Other Arduino products from Adafruit”