Examples

Author Gravatar Image LADY ADA

Getting Stack overflow errors?

These examples are all tested to work with IDE v13 or higher, so try to use that if possible!

Get more RAM & Flash!

This library uses a lot of RAM, if you are using an older '168 or '8 Arduino, you must upgrade to an ATmega328. The shield was designed with the expectation that this upgrade would be available.

Generating speech

If you want a human voice in your project, you can use the free generator at AT&T Text-to-Speech demo page.

It will create a 16KHz, 16-bit audio file so you can use the audio 'right out of the box.'

Sound sample library

Here is huge collection of C.C. Attribution licensed sound samples! A lot of it is already mono, 16 or 22KHz.

Digital audio player

This is the simplest example. It plays every audio file it finds on the SD card in a loop. This sketch is also included in the library.

  1. Sketch (for the waveHC library also check the WaveHC library zip for any newer revision).

PI party!

This example shows how to use the AT&T text-to-speech website to speak the first n digits of pi. The number is stored in flash, each digit is spoken one at a time.

  1. Zip file containing the digits 0 thru 9 and 'point' place the wave files onto the SD card in the root directory.
  2. Sketch (for the waveHC library also check the WaveHC library zip for any newer revision) there's a walkthrough here.

6 buttons, 6 sounds, multiple possibilities!

Here is a collection of different playback techniques with 6 buttons (connected to analog 0-5).

You can change the # of buttons and what they're wired to easily. This isn't an exhaustive list but will give you some ideas about how you can do a lot with the WaveHC library. Note that all the changes occur in loop(). The button checking and everything else is the same.

  1. Play the wave file all the way through, and only once.
  2. Play one wave file all the way through, in a loop.
  3. Play all the pressed wave files all the way through, in a loop.
  4. Play the wave file only when the button is held down and only once (kind of like a musical keyboard).
  5. Play the wave file only when the button is held down and loop it (kind of like a sampler keyboard).
  6. Play the wave file all the way through and loop it, but allow other buttons to interrupt.
  7. Play the wave file all the way through once, but allow other buttons to interrupt.

Playing sound based on input

This similar example plays 6 different files but its for WaveHC library (there's a walkthrough here).

This one plays 4 different files depending on serial characters, good if you have say an xbee you want to use.

Changing the playback rate

By messing with the playback interrupt, you can change the speed of playback for an interesting effect.

Here is the sketch, connect the potentiometer to analog pin 0 (or change the code).

Wave Shield Voice Changer

Speak like everyone's favorite baritone Sith lord or sing along with the Lollipop Guild!

Volume control via software

By changing the #define DVOLUME 1 in wave.cpp and recompiling you can do rudimentary software volume control as in this sketch.
Last updated on 2014-04-23 at 06.04.58 PM Published on 2013-07-17 at 04.39.05 PM