delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/02/02/18:18:17

From: "Adam Christopher Lawrence" <guruman AT nospam DOT interlog DOT nospam DOT com>
Newsgroups: comp.os.msdos.djgpp
Subject: Allegro: allocate_voice, voice_start, check_voice ...
Date: Mon, 2 Feb 1998 14:14:04 -0500
Organization: Interlog Internet Services
Lines: 39
Message-ID: <6b5545$d8$1@news.interlog.com>
NNTP-Posting-Host: ip203-95.cc.interlog.com
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

    Be warned: I am a self-taught C programmer and prone to idiotic
mistakes.

    I am writing a program that uses numerous datafiles. Each datafile
contains (among other things) two digital samples of varying lengths. What
I'm trying to do is code a routine that will play the sample, wait until the
sample is done playing, and then carry on.

    I could easily throw a rest(whatever) after a play_sample() call, but if
the sample that happens to be playing is short, there would be a lot of
'dead' time in there, which I don't want.

    This is what I tried to do

    tmp = allocate_voice(qfile[Clue].dat); // Clue is the datafile sample
    voice_start(tmp);
    do
    {
        test = check_voice(tmp); // test is a previously defined sample
    } while (test != NULL);
    voice_stop(tmp);
    // carry on execution here, (hopefully) once sample is concluded

    It plays the sample fine, but never breaks out of the Do loop.

    According to the Allegro docs (it's ver 3.0 by the way), check_voice
returns a sample if the voice is in use "or NULL if the voice is inactive."

    This obviously means that if the voice is allocated, whether or not it
is playing, the sample will be returned if check_voice is called.

    How can I detect when a loaded and started sample has concluded playing?
I don't want to have to add a sample length parameter to every datafile and
tell the program to pause for that length of time while the sample is
playing unless I absolutely have to.



- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019