DAC Audio Library 3.1 (Version 2) released

Minor updates to the beta release version 3.1 (this is version 2 of 3.1), see download page. There was a bug where you couldn’t have the same WAV file (or whatever play item, music for example) more than once in a sequence. So for example if you wanted to do this:

Sequence.AddPlayItem(MyWav);
Sequence.AddPlayItem(MyWav2);
Sequence.AddPlayItem(MyWav);

Then it would get confused and not play the first MyWav. Now the library will correctly play MyWav,MyWav2,MyWav. There is no real limit on how many times a play item can be added to a sequence. To showcase this fix I’ve added a new example to the available examples with the library called “SequenceDemo2”, catchy title huh? This code will speak out any number that you send to it over the serial link 1 number at a time. Compile and upload to your system and open the serial monitor. At the top there is a space for you to type in characters to send to the Arduino. Type in a number such as 12321 and press return, your hardware should speak back the number to you. In addition it will send your entry back to the serial monitor for you to see.

That’s it for this update, hope that sorts out any issues people were having with playing the same WAV more than once.

7 Comments

  1. There is a bug in the code, on all the #include’s. It says:
    #includThere is a bug in the code, on all the #include’s. It says:
    #include “MusicDefinitions.h”;
    but that is not valid. The trailing semicolon is invalid.

    ——————–
    About memory requirements:
    If you put “const” on a declaration, the data goes into flash (like code) instead of data.
    Like this: const unsigned char Force[40923] = {…}

    When I did that for the PlayWav example:
    (w/const):
    Sketch uses 229156 bytes (17%) of program storage space. Maximum is 1310720 bytes.
    Global variables use 16016 bytes (4%) of dynamic memory, leaving 311664 bytes for local variables.

    Original (w/o const):
    Sketch uses 229156 bytes (17%) of program storage space. Maximum is 1310720 bytes.
    Global variables use 56940 bytes (17%) of dynamic memory, leaving 270740 bytes for local variables.

    But that caused another problem, which was solved with a cast:
    XT_Wav_Class ForceWithYou((unsigned char*)Force);

    I think the library code could be fixed so that it would work with or without the “const”.
    Looks like you can do it by changing to
    “XT_Wav_Class::XT_Wav_Class(const unsigned char *WavData)”
    in XT_DAC_Audio.cpp
    and
    “const unsigned char *Data;”
    in XT_DAC_Audio.he “MusicDefinitions.h”;
    but that is not valid. The trailing semicolon is invalid.

    —-
    So far, great library. Thanks.
    I’m going to see if I can figure out an easy way to feed it with mp3’s as well as wav’s.

    • I’ve been using the PROGMEM directive which is supposed to put it into program memory, at least on Arduino. Just done a little research and seems it isn’t implement on ESP32, but the directive does not throw an error. In my Space Invaders project (Arduino based) I use both const and PROGMEM, if I’d stuck to that pattern it would seem all would have been OK. Hey ho.

    • I have worked on this today and yes I got the data to store correctly in program memory (which I hadn’t noticed it wasn’t!).I changed the types being used to const and with large files it would still stop at around 8 seconds in on my test (around 65K of data read). I then just implemented exactly as you did above and still the same result. The wav I’m playing is around 38s long. I’ve poked around the code a lot and there seems to be some variable corruption – perhaps. Are you definitely able to play a long sample size? Perhaps you could send me your project or I’ll send you my wav file?

  2. I’ve looked at that work, it’s amazing, thank you very much for your help. It all worked first time and I will implement your suggestions to have the buffer size changeable in code, which seems a very sensible idea with a default of 4-6K I think as you mentioned. I did send you an email to the address used in these blog comments, did you get that? I haven’t tried the converter utils yet but will do shortly, sound very good. In the next video/ blog article would you like me to mention your contribution and YouTube user name?

Comments are closed.