#!../src/tops  -i -s ../sys  -u ../usr
/*
Program Tops - a stack-based computing environment
Copyright (C) 1999-2008  Dale R. Williamson

Author: Dale R. Williamson <dale.williamson@prodigy.net>

File test/tsnd2  December 2008

Using the sound file queue.

Reference: Words for sound, file sys/snd.v

----------------------------------------------------------------------*/

   if(!fallow("/dev/dsp")) 
      exit(nl(.(" tsnd2: sound device not found, test skipped")));
<< 
   "tsnd2: run sound files in succession using sound file queue" 
   . nl 
   "tsnd2: next file is not played until resonance dies out" 
   . nl 
>>
   nl(.("tsnd2: is speaker on?"));
   .("tsnd2: writing bytes to /dev/dsp for about 25 seconds...");

   source(catmsg(no), "snd.v"); // load words for sound

   wavque_start(); // start the queue

   wavque_add((W1 = GONG(2))); // file queued up
   wavque_play(); // start playing immediately

   wavque_add((W2 = BONG(2))); // file queued up
   wavque_add((W3 = TING(2))); // file queued up

   t = wavTime(W1) + wavTime(W2) + wavTime(W3); // total time
   idle(t); // idle here to prevent script from running to completion
            // before the last file starts

   .(nl, "tsnd2: sound queuing test complete");

   nl; nl; nl;
