We are working on the same problem in the openmod project. I haven't written any test code yet but some of the research I have done should help. Start with this page http://oxygen.it.net.au/mixing/ all of the code is written in assembly but he does do a fairly good job in explaining how to mix two wav streams togther.

-Jeremy