From: Shawn Hargreaves Newsgroups: comp.os.msdos.djgpp Subject: Re: Audio recording and mixing Date: Tue, 10 Feb 1998 18:52:54 +0000 Organization: None Distribution: world Message-ID: References: <34E10439 DOT 17FF AT netvision DOT net DOT il> NNTP-Posting-Host: talula.demon.co.uk MIME-Version: 1.0 Lines: 27 To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Precedence: bulk Guy Rauscher writes: >I'm using Allegro for my audio output and I want to combine recording >ability in a future application; Any suggestions? Allegro doesn't support audio input, so you will have to write your own soundcode. Depending on the situation you might be able to just modify the Allegro sb.c file to flip the direction of the DMA transfer, but it would be tricky to set this up in a really generic way because most cards don't support simultaneous recording and playback... >Also, how do I mix to samples? I tried averaging the values of each two >bytes from the two samples by the volume I got was too low. I also >tried adding every two bytes but the the values were out of range. What >do I do? You just have to live with some loss of quality. The 'correct' solution is to take an average, but that does lose a lot of volume and precision. Adding the samples can work ok if you clamp when the value overflows, but you will get a lot of distortion if it overflows too often. The best approach is probably somewhere in between, for example you could mix four samples by halving the inputs, adding, and then clamping when the result overflows. -- Shawn Hargreaves - shawn AT talula DOT demon DOT co DOT uk - http://www.talula.demon.co.uk/ "Pigs use it for a tambourine" - Frank Zappa