Giter VIP home page Giter VIP logo

Comments (9)

TheNitek avatar TheNitek commented on August 29, 2024 1

You can do it like this:

bool patchVS1053() {
  uint16_t i = 0;

  Serial.println(F("Installing patch to VS1053"));

  SdFile file;
  if (!file.open("patches.053", O_READ)) return false;

  uint16_t addr, n, val;

  while (file.read(&addr, 2) && file.read(&n, 2)) {
    i += 2;
    if (n & 0x8000U) {
      n &= 0x7FFF;
      if (!file.read(&val, 2)) {
        file.close();
        return false;
      }
      while (n--) {
        musicPlayer.sciWrite(addr, val);
      }
    } else {
      while (n--) {
        if (!file.read(&val, 2)) {
          file.close();
          return false;
        }
        i++;
        musicPlayer.sciWrite(addr, val);
      }
    }
  }
  file.close();

  Serial.print(F("Number of bytes: ")); Serial.println(i);
}

from adafruit_vs1053_library.

mycroft2k avatar mycroft2k commented on August 29, 2024

thx it works great

from adafruit_vs1053_library.

akoebbe avatar akoebbe commented on August 29, 2024

I'm having trouble with this solution. The first problem was that the following lines errored out...

  SdFile file;
  if (!file.open("/patches/flac.028", O_READ)) return false;

with the following error

src/main.cpp:54:45: error: no matching function for call to 'SdFile::open(const char [18], const uint8_t&)'

So I changed the code to the following

  File file = SD.open("/patches/flac.028", O_READ);
  if (!file) return false;

At this point the program can compile, but it doesn't seem like the patch is completely loading. It keeps bailing at the commented line below...

bool patchVS1053() {
  uint16_t i = 0;

  Serial.println(F("Installing patch to VS1053"));

  SdFile file;
  if (!file.open("/patches/flac.028", O_READ)) return false;

  uint16_t addr, n, val;

  while (file.read(&addr, 2) && file.read(&n, 2)) {
    i += 2;
    if (n & 0x8000U) {
      n &= 0x7FFF;
      if (!file.read(&val, 2)) {
        file.close();
        return false;
      }
      while (n--) {
        musicPlayer.sciWrite(addr, val);
      }
    } else {
      while (n--) {
        if (!file.read(&val, 2)) {
          file.close();
          return false; // <--- returning here!!!!
        }
        i++;
        musicPlayer.sciWrite(addr, val);
      }
    }
  }
  file.close();

  Serial.print(F("Number of bytes: ")); Serial.println(i); // I'm never getting here
}

Just to be sure, I should be using the .plg files from VLSI, correct?

from adafruit_vs1053_library.

akoebbe avatar akoebbe commented on August 29, 2024

Ok. So I just looked at the actual .plg file from VLSI. I was expecting to see binary, but instead I'm seeing what looks like C code. I'm getting the feeling I'm not loading the right file. What should I be looking for?

from adafruit_vs1053_library.

TheNitek avatar TheNitek commented on August 29, 2024

https://raw.githubusercontent.com/madsci1016/Sparkfun-MP3-Player-Shield-Arduino-Library/master/plugins/patches.053

from adafruit_vs1053_library.

akoebbe avatar akoebbe commented on August 29, 2024

Thanks @TheNitek but that seems like a really old patch. VLSI has patches as recent as 2020-04-29 (http://www.vlsi.fi/en/support/software/vs10xxpatches.html) so how do I get them in to the right format?

from adafruit_vs1053_library.

akoebbe avatar akoebbe commented on August 29, 2024

I just found the perl script (https://github.com/madsci1016/Sparkfun-MP3-Player-Shield-Arduino-Library/blob/master/plugins/vs_plg_to_bin.pl) in that same repo. I'll give it a shot.

from adafruit_vs1053_library.

akoebbe avatar akoebbe commented on August 29, 2024

It worked! Thanks.

from adafruit_vs1053_library.

caternuson avatar caternuson commented on August 29, 2024

Closing. Seems resolved.

from adafruit_vs1053_library.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.