From: Luca Bisti Newsgroups: comp.os.msdos.djgpp Subject: Sound stream corruption with Allegro? Date: Thu, 2 Dec 1999 00:28:04 +0000 Organization: Universita' di Pisa Lines: 20 Message-ID: NNTP-Posting-Host: studenti.ing.unipi.it Mime-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com Hi Allegro gurus, I have the following problem with the Allegro audio stream routines: for some reason that I haven't been able to find out myself, the sound samples generated by my program are somewhat distorted by the Allegro play routines, that is the music which comes out of the soundcard is a bit "scratchy". I say that because I dump the same sample buffer to a WAV file just before passing it to the free_audio_stream() function and the music recorded into that WAV sounds perfectly (not distorted at all) when played back with any other sound player (such as Windows' Media Player itself). This "corruption" does not consist in noise clicks at regular intervals or things like that, but it's rather like a continuos sample "cut" which seems to reduce sound dynamics... sorry, I can't explain it in words :-) Just to clarify, the situation is the following: mix_samples(buffer, size); // generate some music samples write_wav(buffer, size); // write them to the WAV file, which will play back clean music free_audio_stream(); // pass the buffer to Allegro, which plays it slightly distorted I am using a single audio stream (with a single voice) which can be mono/stereo and 8/16 bit. Depending on the voice mode set, I mix a sample of the same type myself and then play it through that voice. I use my own mixing routines because I need to do some postprocessing on the final result and Allegro won't let me do that if I open several independent voices and let it mix them. In all the four combinations, the result is always the same. Note that the sound corruption is particularly evident only when playing certain sounds, while in general it's hardly audible. Anyway, I'd like to get rid of this problem, since I don't want a player of waveform-dependant quality! The voice frequency is the same as the soundcard playback rate, centered voice panning, max volume, and my samples have amplitude 64 (just to make sure that clipping cannot occur). Nothing changes if I use signed or unsigned samples, or if I allocate a mono/stereo - 8/16 bit voice. My soundcard is a Creative SB 32. What could be wrong? Since the WAV data is clean, my suspect is that the waveform is altered by Allegro's mixing code (volume tables and so on). If so, how can I make sure that my buffer is passed directly to the DMA without any further processing by the Allegro routines? Thanks, Luca.