WAV Trigger programming questions

The project: The Doorbell From Hell. an annunciator that lets me know when someone enters the driveway, when they exit the driveway and enter the yard, and when they enter or bypass a gate. when you have a 400 foot driveway you have time to change into a tuxedo or a ghillie suit, if you have a proper annunciator.

The Plan:

  • When a vehicle breaks the beam at the outer marker, play a sound file from a group of one bell bong / gong / whistle sounds.
  • when they cross the inner marker, a file from a second group of dual bell bong / gong / whistle sounds plays
  • if they enter my yard, play a sound file from a group of three bell bong / gong / whistle sounds.
  • if they enter my neighbors yard, play a sound file consisting of 4 ships bells.
  • if they push the obvious in plain sight bright red DONNONOMO button they get one of 200 or so bland sounds; bird songs, elephants, car horns ( DONNONOMO: Don't Know No Mo better than to press the obvious button at my house )
  • if they tip the garden gnome, that causes one of 500 or so movie and TV sounds to play
  • if they walk around the house without entering by one of the three legitimate gates, one of about 60 obnoxious "lock and load" alerts go off

so, 5 triggers, each trigger sets off one sound from a library of sounds. the sounds are grouped in blocks like 1 - 16 for the single sound, 17 - 32 for the doubles, et cetera

the files were randomized before they were numbered, so if you play them in order, you don't get Bugs Bunny three times in a row.

the sensors are handled, the PA is up and running. working on the GPS time and sensor number dataloger

The Problem: what I need to know is how to tell the WAV Trigger to play the next file in the list, and recycle when you run out of files. If you have 36 lock and load files, and the numbers from 64 to 127 are allocated to this group, something like:

if sensor 4 play
for file# = 64 to 127
( play file# )
if no next file then file#=64

I can't be the first person who needs this, but I can't find any code that does this. does anyone know of a sketch that deals with this?

Unknown code.
Unknown Arduino.
Unknown file support.
Unknown audio support.
Unknown trigger support.

Result: Unknown answer.

What WAV Trigger library are you using? What options does it have to selecting a pile to play?

My best guess, without answers to those questions, is that you keep track of your position in the list yourself. If your system frequently looses power you can store indexes in the EEPROM. It should be quite a while before you reach the life limit of the EEPROM.

const int SingleChimeStartingIndex = 0
const int SingleChimeCount = 5;
int SingleChimeIndex = 0;

const int DoubleChimeStartingIndex = SingleChimeStartingIndex + SingleChimeCount;
const int DoubleChimeCount = 12;
int DoubleChimeIndex = 0;

const int AlarmStartingIndex = DoubleChimeStartingIndex + DoubleChimeCount;
const int AlarmCount = 7;
int AlarmIndex = 0;
.
.
.
    // Sound the alarm!
    WAVshield.PlayByIndex(AlarmStartingIndex + AlarmIndex);
    AlarmIndex = (AlarmIndex+1) % AlarmCount;

I'm using this library: GitHub - robertsonics/Tsunami-Arduino-Serial-Library: Arduino Serial Control Library for Arduino
it's the only Tsunami specific library I have found

I believe the function I need is:

tsunami.trackPlaySolo(int t, int out, bool lock) - this function stops any and all tracks that are currently playing and starts track number t from the beginning. The track is routed to the specified stereo output. If lock is TRUE, the track will not be subject to Tsunami's voice stealing algorithm.

I was trying to find the necessary code in the examples. It appears that what I need was in the fine manual, and I had not found the fine manual.