Finally we have got to a point where we are going to install and use the DACAudio library. This page will contain the latest version of the software and past versions (except the first two initial releases). It will download as a zip file and to install just follow this guide here to install zip file libraries. If all goes well then go to “File->Examples->XT_DAC_Audio” and you should see several examples you can try. If you’ve installed a previous version of the library then please remove it first, see this guide if your not sure what to do. The next article in this series explains how to get the library to play WAV files from the ESP32’s built in program storage (not yet written but try the examples!).
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 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.
XT_DAC_Audio_4_1_0
In this version I’ve added the facility to speed up or slow down WAV files. To do this a new property has been added to WAV objects called ‘Speed’. Simply set this to a value that will change the speed by that amount. For example 2 would double the playback speed and 0.5 would half it. 0 would mean it would stop playing, although very low or high values will probably be beyond the range of human hearing any so you won’t hear anything anyway even if it’s playing. Here’s how you might use it
1 |
MyWav.Speed=1.5; // Will play at 1.5 times the speed |
There is also a bug fix where under certain circumstances “junk” would play for around a second on reboot. For more information click the Blog-Post.
XT_DAC_Audio_4.0.1
Minor bug fix where clearing the play items of a sequence class would crash the ESP32 if it hadn’t completed playing all items. Now it stops them playing first then clears the items. Also the default “mix” action for any play item played with the “play” command has been changed from not mixing to mixing. i.e. writing
1 |
DacAudio.Play(MyWav); |
will now automatically play this sound with any others currently playing rather than cancelling all other sounds before playing. Previously to force a mix you would write
1 |
DacAudio.Play(MyWav,true); |
now to force it to not mix and cancel any other sound you must write
1 |
DacAudio.Play(MyWav,false); |
This was done because it was felt that coders were more likely than not to want to mix sounds into whatever is currently playing than to cancel them all and play a sound. They were then also more likely to forget to add the “true” statement to make this happen and hence possibly get confused as to why things were not happening as they thought.
Version 4.0 is a main update to the DacAudio software as it now adds in one main feature and some nice enhancements. The main part of this release is the ability to play more than one sound at once, whatever that sound is, whether it’s 2 WAV’s or a WAV and a music score, it makes no difference, mix them together as much as you want and output them together! This is a facility I’ve wanted right from the first version but has always been put on the back burner as more important updates/fixes came first. Other additions are the ability to set the amount of buffer used when you create the DAC Audio object and improvements to repeating sounds. A write up will be available shortly.
As 3.1 (V2) below but bugs fixed so that it can now play longer WAV files that take up more data space. See this blog post for more details.
As 3.1 (V1) below but the bug where you couldn’t have the same wav or music score or whatever more than once has been removed and you can now add the same play item multiple times.
New added (SequenceDemo2) to show adding the same play item multiple times
XT_DAC_Audio 3.1 (V1) Warning : Beta (well they are all beta really but this one more so!).
As mentioned above, limited testing has occurred in this version as it is not complete yet and is still being worked on. Some bugs may be present. Released early to provide some updates to users.
Added function “RemoveAllPlayItems” to Sequence class. This allows you to clear a sequence you have set up prior in order to replace it with another.
Class Name Change : The sequence class previously called “XT_MultiPlay_Class” has been renamed to “XT_Sequence_Class”. This is to make it’s name match it’s functionality more closely. The previous name for the class was a little confusing (IMO).
Code tidied up
Added basic synthesis of piano, organ, and harpsichord
Added facility to play basic musical scores.
Added ability to play sequences of any sounds (i.e. you could mix and match WAVs and music scores etc.)
DAC Audio Version 2
Less buggy, plays WAV’s only.
Dac Audio Version 1
Initial buggy release plays WAV’s only.