ESP32, We Have Ways to Make You Talk

One of our favorite scenes from the [James Bond] franchise is the classic exchange between [Goldfinger] and [Bond]. [Connery] (the One True Bond) says, “You expect me to talk?” And the reply is, “No Mr. Bond, I expect you to die!” When it comes to the ESP32, though, apparently [XTronical] expects it to talk. He posted a library to simplify playing WAV files on the ESP32. There is also a video worth watching, below.

Actually, you might want to back up to his previous post where he connects a speaker via one of the digital to analog converters on the board. In that post, he just pushes out a few simple waveforms, but the hardware is the same setup he uses for playing the WAV files.

By wrapping up the WAV code in a library, [XTronical] makes the actual playback simple. Here’s the core of his simple example:


void loop() {
static uint32_t i=0; // simple counter to output
if(ForceWithYou.Completed) // if completed playing, play again
DacAudio.PlayWav(&ForceWithYou); // play the wav (pass the wav class object created at top of code
Serial.println(i); // print out the value of i
i++; // increment the value of i
}

Not very hard, but, of course, the heavy lifting is hidden in the two objects PlayWav and ForceWithYou. The video explains how you can add more, but you can probably guess, too. The short version is he uses Audacity to prepare the WAV file and then a hex editor to get the bytes into an array. Since many of us use Linux or Cygwin, we might have been tempted to use od or hexdump, but however you do it, it has to wind up in an array.

If you want to experiment more with waveform generation, [Elliot Williams] did a good piece on that. You might also get some ideas from our signal generator.



from Hackaday http://ift.tt/2E6Cher
via IFTTT