From: Jose Manuel Lopez-Cepero Newsgroups: comp.os.msdos.djgpp Subject: Re: Allegro sound bug? Date: Thu, 20 Mar 1997 22:42:55 +0100 Organization: Unisource Espana NEWS SERVER Lines: 41 Message-ID: <3331AF5F.2871@ctv.es> References: <5gh3c8$nhi$1 AT news DOT sas DOT ab DOT ca> Reply-To: sigma AT ctv DOT es NNTP-Posting-Host: macarena.ctv.es Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Hya there! kalyniuk AT freenet DOT edmonton DOT ab DOT ca wrote: > I've found a weird problem using Allegro's play_sample() function. If I > use it anywhere in my program other than within a while loop the sample > sounds crappy (scratchy and half the volume). For example: > > while(!keypressed()) > if(mouse_b & 1) > { > play_sample(the_sample, 100, 128, 1000, FALSE) > } > // this works fine Well, think about what it does. If you hold the button for a small while, then you are sending a lot of play_sample()'s statements. Since Allegro has a builtin limit on the number of voices that can be active at any time (8, at least for SBPro), this means that in 8 loops of the while{} statement (very very small time) you flood the mixer with 8 copies of the same sample. Of course it sounds glorious, try doing the same thing on an 8 channel tracker and you'll _hear_ the difference :-) > if(move_guy > 300) > { > play_sample(the_sample, 100, 128, 1000, FALSE) > } > // this does not Well, this only places a copy of the sample on the mixer. Guess what happens :-) As a solution you may want to try this: a) increment the mixing rate and b) duplicate the line (ie. play the sample twice) if it doesn't work. Hope it helps 8-) -- _* \ |/_|\/||\ sigma AT ctv DOT es _\|\/| ||_\ (formerly Sigmatech) Jerez / Cadiz / Spain