Mail Archives: djgpp/1998/02/10/15:16:44
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
- Raw text -