DAC Audio 4.2.1 Released

This version fixes some bugs and adds an additional master volume option. Most of this work is courtesy of two subscribers. One of which did some significant bug fixes, especially on making the library work whilst writing to EEPROM. I only fixed one minor bug. But they don’t want any credit, so I’ll take it all 😉

The download is available here : Downloads

The bugs fixed were as mentioned writing to EEPROM at the same time and an occasional garbled sound that could occur now and then. In addition there was an issue playing the same WAV in a sequence. It would cause a delay within the subsequent sounds of the type, and the more of the same you had in the sequence the worse the delay got as it played the later ones.

Extra – Master Volume Control
An additional feature added by one of the contributers was the ability to alter the playback volume for whatever is currently playing back. This is different from altering the volume for individual items (which is possible also). To use you simple pass a volume level as a percentage (0-100) with 0 being silent and 100 max volume to the DacAudio object.

DacAudio.DacVolume=50;

This will set the volume at half the volume for whatever sounds are currently playing.

Extra – More volume control across all playable items
Not every playable object supported altering it’s individual volume, this has now been added.

Extra – Sequences – clearing after playing
You can now instruct a “sequence class object” to clear its list after the sequence has been fully finished playing (i.e. after any repeats etc.). Simply set this property to true

SequenceObject.ClearAfterPlay=true;

if you desire this affect. This can make your coding a little simpler if you are assembly different sequences all the time regularly in your code.

Here’s the video:

13 Comments

  1. Thanks for the update.
    I have an issue with 16k sample rate files being too large. or so I think. If the file is around 1Mb I get ‘DRAM segment data does not fit.’ and ‘region `dram0_0_seg’ overflowed’ errors. How did you get your ‘AdjustableSpeed.ino’ to accept the large file?

    • The actual raw binary data is only 189K in size (check the array definition at the top of the file for that sound), the actual text file holding the data is over a meg for sure, but that is not what is written to the ESP32 as raw data. Is your raw data more that 1meg- checke the array definition for it. Also check that you are using mono sound, not stereo.

  2. Thanks for replying so soon. what I meant was your .h array is over 1meg, and mine is under one meg. however, I did spot one difference, in your PlayWav example SoundData.h, you use ‘unsigned char PROGMEM’, and in your AdjustableSpeed SoundData.h you use ‘const unsigned char’. Once I made the changes to my data.h to ‘const unsigned char’ it worked a charm. I am now able to encode 15seconds of 16K samples to give me the 8khz b/w required. Do you know the upper rate of sampling?

    • Thanks for that, I need to alter those examples to all be consistent and use “const unsigned char”, sorry for the confusion. The upper limit is 44100Hz

  3. Hi XTronical, Thanks so much for this awesome package. I have a question for you: I have a variety of buttons and I want to tie a specific sound to each button so that when a button is pressed it plays that sound. What is the best way to do that with this library? I seem to get a lot of repeating/overlapping of sounds when I do it, is that because I am not clearing the buffer correctly? Thank you.

    • So, when you press a button you want the previous sound to stop and then play the new? By default sounds are mixed when you call the

      DacAudio.Play(MyWav);

      All you need do is add a extra param to the command to tell it not to mix and to just play this one single sound, like this;

      DacAudio.Play(MyWav,false); // stops all sounds and starts playing this one – no mixing

  4. Hi guys, great work done with this library! I have not actually used it yet, but try to understand how it works first. Reading and understanding code written by others is boosting knowledge sometimes quicker than going through the efforts of analyses, trial and error yourself 😉 Though doing it on your own may be a little more satisfying in the end. Just some questions so far:

    To my understanding the routine that checks the WAV CHUNKS as of today will return the data of the last data sub chunk in a file (if there is more than one), correct?

    In XT_Wav_Class::NextByte() at line 514 it says “// First we subtract 1 from IncreaseBy”. If I am not wrong it should read Speed instead of IncreaseBy.
    Anyway it does not reduce the excellent work done, and if I am wrong, I have taken the chance to learn ;-))

    • Ha ha, well spotted. That comment was just wrong! I think it was a comment left in by accident from some other code or something. It makes no sense to what is actually happening in the code! I’ve removed it ready for the next version of the library.

Comments are closed.