This program demonstrates the sound output queue ArSoundsQueueShows how to operate the sounds queue and add WAV files to play.
You may specify up to 10 file names on the command line. This example only demonstrates using the sounds queue for WAV file playback. For demonstration of using the sounds queue for speech synthesis, see the examples provided with either the ArSpeechSynth_Cepstral or ArSpeechSynth_Festival libraries.
#include "Aria.h"
#include "ariaTypedefs.h"
#include "ariaUtil.h"
#include "ArSoundsQueue.h"
#include "ArSoundPlayer.h"
#include <iostream>
#include <vector>
void queueNowEmpty() {
printf("The sound queue is now empty.\n");
}
void queueNowNonempty() {
printf("The sound queue is now non-empty.\n");
}
bool no() {
return false;
}
int main(int argc, char** argv) {
if(argc < 2)
{
cerr << "Usage: " << argv[0] << " <up to ten WAV sound file names...>\n";
}
std::vector<const char*> filenames;
for(int i = 1; i < min(argc, 11); i++)
{
filenames.push_back(argv[i]);
}
{
cout << "Queue is " <<
<< "Enter a command followed by the enter key:\n"
<< "\tp\trequest pause state (cumulative)\n"
<< "\tr\trequest resume state (cumulative)\n"
<< "\ti\tinterrupt current sound\n"
<< "\tc\tclear the queue\n"
<< "\tC\tclear priority < 4 from the queue.\n"
<< "\tn\tAdd " << filenames[0] << " to the queue, but with a condition callback to prevent it playing.\n"
<< "\tv\tAdjust volume -50%\n"
<< "\tV\tAdjust volume +50%\n"
<< "\to\tAdjust volume -100%\n"
<< "\tO\tAdjust volume +100%\n"
<< "\tl\tAdjust volume -200%\n"
<< "\tL\tAdjust volume +200%\n"
<< "\t-\tSet volume adjustment to normal level\n"
;
for(size_t i = 0; i < filenames.size(); i++)
cout << "\t" << i << "\tadd " << filenames[i] << " to the queue\n";
cout << "\tq\tquit\n\n";
int c = getchar();
if(c == '\n')
continue;
switch(c)
{
case 'p': soundQueue.
pause();
break;
case 'r': soundQueue.
resume();
break;
case 'n':
{
cout << "Adding \"" << filenames[0] << "\" but with a condition callback that will prevent it from playing...\n";
item.
playbackConditionCallbacks.push_back(&dontPlayItem);
break;
}
default:
if(filenames.size() > 0 && c >= '0' && c <= '9')
{
size_t i = c - '0';
if(i < filenames.size())
{
cout << "Adding \"" << filenames[i] << "\" to the queue...\n";
soundQueue.
play(filenames[i]);
}
}
}
}
cout << "ended.\n";
return 0;
}