I'm working on a program that has to do with adding sound waves on top of sound waves. Currently what I'm doing is simply an average of the two waves. So if I have wave A
, and I want to write wave B
'on top' of it, every sample in the new A
is equal to the average of two matching samples in the original waves.
This works decently, however sometimes it leads to a significant decrease of loudness in wave A
. Is there a better way to combine sound waves?
For example, if I have a sound wave of a guitar playing, I want to be able to add on top of it a sound wave of a saxophone playing, without decreasing the volume of the guitar. What's the best way to do this?