title: How to mix audio samples?
body: <p>My question is not completely programming-related, but nevertheless I think SO is the right place to ask.</p>
  
  <p>In my program I generate some audio data and save the track to a WAV file. Everything works fine with one sound generator. But now I want to add more generators and mix the generated audio data into one file. Unfortunately it is more complicated than it seems at first sight.
  Moreover I didn't find much useful information on how to mix a set of audio samples.</p>
  
  <p>So is there anyone who can give me advice?</p>
  
  <p>edit:</p>
  
  <p>I'm programming in C++. But it doesn't matter, since I was interested in the theory behind mixing two audio tracks. The problem I have is that I cannot just sum up the samples, because this often produces distorted sound.</p>