DacAudio Ver. 4.1.0

This latest version adds the ability to speed up or slow down the playback speed of a WAV file, either by setting the speed before playing or actually changing the speed on the fly whilst it’s playing! A supporting video is available below and the new library is available on the downloads page. To implement this new functionality there is a new property called “Speed” for WAV files and you would use it as below;

MyWav.Speed=1.5; // Play at 1.5 times normal speed

So a value of 2 would double playback speed and 0.5 would half it. A very low or high value will likely end up in you hearing nothing as the human ear cannot hear very low or very high pitched sounds.

Two new examples have been included to showcase this new ability called WavSpeed and AdjustableSpeed and are available under the normal Arduino IDE examples menu option.

WavSpeed needs no additional hardware over the normal setup but AdjustableSpeed requires a potentiometer adding to give a varying voltage to the default analog input on Pin36 (the VP pin). The demo reads this value and alters the speed of playback in real time as the sample plays over and over again.

Here’s the video:

13 Comments

  1. Hello Friend! How to work with XT_Wav_Class and
    XT_DAC_Audio_Class during program execution? I need to dynamically play wavedata from files (sd card) and I cannot determine the data to play in advance. Thanks!

    • It can be done, but the library has no built in functionality to do this at present. It is something I will look at but it isn’t in the immediate future I’m afraid. There are some very cheap mp3 players (for pennies) available with an SD card built on them that you can control the playback of using an arduino, and they have built in amplifiers as well.

  2. Hi!

    If I have a sequence of WAV-files playing, how can I check to see if the sequende is done playing?

    /GG

    • The sequence object, like the other objects that can be played, has a property called “Playing”, just check this, when it’s still playing it will be true, when completed it will be false. It will not become false until all items in your sequence have completed. For example

      if(MySequence.Playing==false)
      {
      // your code to handle what happens when a sequence has completed.
      }

  3. Thank you for this great library, the only thing I could not do is create WAV files that have almost no background noise.

    • Do you mean they had noise in Audacity or when played on the hardware? I have experienced some minor low level high pitch noise which I think is an issue with the PAM8401 audio amp used.

  4. Hello,

    Thank you for publishing your XT_DAC_Audio 4.1 library. I’ve installed it on a Lolin ESp32 D32 Pro. Sound quality is good and the mixing feature is very nice.

    My project uses ESP32’s EEPROM emulation library. I’m experiencing a crash/reboot issue that is caused whenever EEPROM.commit() is used to save new data to flash. It appears that the crash occurs from XT_DAC_Audio’s call to dacWrite() in the onTimer() isr (see XT_DAC_Audio.cpp file, line 130).

    As an experiment I commented out the dacWrite() and the EEPROM.commit() crash is avoided. But of course there’s no audio.

    It seems that dacWrite() is a troublemaker in the isr routine. I found an ESP32 github discussion about a similar crash report. There’s an interesting comment from a user named atanisoft on Mar 20 about the usage of dacWrite() in a isr:
    https://github.com/espressif/arduino-esp32/issues/2575

    I’ve tried to solve this on my own but so far no joy. Do you have any suggestions?

    In case it helps, here’s the serial debug log from the crash:
    Guru Meditation Error: Core 0 panic’ed (Cache disabled but cached memory region accessed)
    Guru Meditation Error: Core 0 panic’ed (IllegalInstruction). Exception was unhandled.
    Memory dump at 0x400f72f0: bad00bad bad00bad bad00bad
    Guru Meditation Error: Core 0 panic’ed (IllegalInstruction). Exception was unhandled.
    Memory dump at 0x400f72f0: bad00bad bad00bad bad00bad
    Guru Meditation Error: Core 0 panic’ed (IllegalInstruction). Exception was unhandled.
    Memory dump at 0x400f72f0: bad00bad bad00bad bad00bad
    Guru Meditation Error: Core 0 panic’ed (IllegalInstruction). Exception was unhandled.
    Memory dump at 0x400f72f0: bad00bad bad00bad bad00bad
    Guru Meditation Error: Core 0 panic’ed (IllegalInstruction). Exception was unhandled.
    Memory dump at 0x400f72f0: bad00bad bad00bad bad00bad
    Guru Meditation Error: Core 0 panic’ed (IllegalInstruction). Exception was unhandled.
    Memory dump at 0x400f72f0: bad00bad bad00bad bad00bad
    Guru Meditation Error: Core 0 panic’ed (IllegalInstruction). Exception was unhandled.
    Memory dump at 0x400f72f0: bad00bad bad00bad bad00bad
    Guru Meditation Error: Core 0 panic’ed (IllegalInstruction). Exception was unhandled.
    Memory dump at 0x400f72f0: bad00bad bad00bad bad00bad
    Guru Meditation Error: Core 0 panic’ed (IllegalInstruction). Exception was unhandled.
    Memory dump at 0x400f72f0: bad00bad bad00bad bad00bad
    Guru Meditation Error: Core 0 panic’ed (IllegalInstruction). Exception was unhandled.
    Memory dump at 0x400f72f0: bad00bad bad00bad bad00bad
    Guru Meditation Error: Core 0 panic’ed (IllegalInstruction). Exception was unhandled.
    Memory dump at 0x400f72f0: bad00bad bad00bad bad00bad
    Guru Meditation Error: Core 0 panic’ed (IllegalInstruction). Exception was unhandled.
    Memory dump at 0x400f72f0: bad00bad bad00bad bad00bad
    Guru Meditation Error: Core 0 panic’ed (IllegalInstruction). Exception was unhandled.
    Memory dump at 0x400f72f0: bad00bad bad00bad bad00bad
    Guru Meditation Error: Core 0 panic’ed (IllegalInstruction). Exception was unhandled.
    Memory dump at 0x400f72f0: bad00bad bad00bad bad00bad
    Guru Meditation Error: Core 0 panic’ed (IllegalInstruction). Exception was unhandled.
    Memory dump at 0x400f72f0: bad00bad bad00bad bad00bad
    Guru Meditation Error: Core 0 panic’ed (IllegalInstruction). Exception was unhandled.
    Memory dump at 0x400f72f0: bad00bad bad00bad bad00bad
    Guru Meditation Error: Core 0 panic’ed (IllegalInstruction). Exception was unhandled.
    Memory dump at 0x400f72f0: bad00bad bad00bad bad00bad
    Guru Meditation Error: Core 0 panic’ed (IllegalInstruction). Exception was unhandled.
    Memory dump at 0x400f72f0: bad00bad bad00bad bad00bad
    Guru Meditation Error: Core 0 panic’ed (IllegalInstruction). Exception was unhandled.
    Memory dump at 0x400f72f0: bad00bad bad00bad bad00bad
    Guru Meditation Error: Core 0 panic’ed (IllegalInstruction). Exception was unhandled.
    Memory dump at 0x400f72f0: bad00bad bad00bad bad00bad
    Guru Meditation Error: Core 0 panic’ed (IllegalInstruction). Exception was unhandled.
    Memory dump at 0x400f72f0: bad00bad bad00bad bad00bad
    Guru Meditation Error: Core 0 panic’ed (IllegalInstruction). Exception was unhandled.
    Memory dump at 0x400f72f0: bad00bad bad00bad bad00bad
    Guru Meditation Error: Core 0 panic’ed (IllegalInstruction). Exception was unhandled.
    Memory dump at 0x400f72f0: bad00bad bad00bad bad00bad
    Guru Meditation Error: Core 0 panic’ed (IllegalInstruction). Exception was unhandled.
    Memory dump at 0x400f72f0: bad00bad bad00bad bad00bad
    Guru Meditation Error: Core 0 panic’ed (IllegalInstructiGuru Meditation Error: Core 0 panic’ed (Unhandled debug exception)
    Debug exception reason: BREAK instr
    Guru Meditation Error: Core 0 panic’ed (ets Jun 8 2016 00:22:57

    Regards,
    Thomas

  5. @Xtronical, I was able to solve my crash/reboot issue. I removed dacWrite() from the ontimer() isr and replaced it with inline code that emulates the dacWrite function. So now I can use your audio library along with the ESP32’s EEPROM feature without inviting crashes.

    I also added a volume control function to the XT_DAC_Audio_Class. The global audio volume is now adjustable from 0-100%. For example, 50% volume is set like this:
    DacAudio.DacVolume = 50;

    If you would like to review these changes for possible use in a future release then please let me know. I appreciate all the effort that went into building your library and it is the least I can do.

    – Thomas

Comments are closed.