2

Let's say I have two audio files, both at 60 seconds length, .m4a or equivalent. When I overlap these two files, I get one audio file at 60 seconds. What is the technical necessary process to minimize quality loss?

Let's say I get another audio file, and I'd like to merge this file with the one I mentioned, now making one single audio file at 60 seconds, with 'three' original separate files. With my current method (simply adding), results in decreased quality after 3-4 overlappings/merges. What needs to be done? I found one example somewhere that simply changed the volume to 80% before merging, is there not more to it? If the files are 44.1, should I not increase the result by 44.1 for each overlapping (88.2, or 96), or would this not do anything?

As you now understand, I know little of this. Where can I learn about how this works?

0

1 Answer 1

5

Mixing audio in a computer is very analogous to how sound mixes in the real world. In the real world, sound is simply pressure waves that cause vibrations in our eardrum that get converted to what we hear by our brain. In the computer, that level of pressure of the wave is represented as a series of samples that describe how strong the pressure wave was.

When two sounds mix in the real world, they both cause overlapping changes in pressure. This works in an additive manner. Similarly, all we need to do with an audio file is additively combine it with another audio file with the same sample rate (assuming samples are measured as positive and negative values around neutral pressure, if it is not, then we have to adjust for the difference from the midpoint.)

The only real special concern is that adding two audio files together may result in the signal clipping as it does add additional signal strength. In that case, it may be necessary to scale back the intensity of each clip so that the new combined waveform does not exceed the range supported by the audio format.

You don't have to add more samples because sounds blend additively, they are not maintained separately and actually, if you were to offset them as every other sample, the result wouldn't at all represent blending of audio and would result in an extremely noisy and impossible to play audio file that doesn't represent a waveform.

3
  • Can one formulaically determine the necessary amplitude adjustment for n clips, presuming each clip's volume will stay constant relative to one another? My intuition is that 1/n is going to end up too quiet overall, what with decibels being logarithmic and all, but that's slightly out of my area.
    – NReilingh
    Commented Aug 8, 2014 at 15:11
  • @NReilingh, I was thinking the same thing. If both clips are reduced to 50% and merged, then a new merging happens, wouldn't each of the two original tracks be at 25%? Next up 12.5% while the newest member is at 50%? Perhaps the additive-part "takes care" of this..? Anyway, I am also wondering about the general quality, not just clipping. Would it not help to increase the bit rate/depth or anything like that?
    – Sti
    Commented Aug 8, 2014 at 19:00
  • 2
    Whoops, apparently my comment got dropped by my phone. The most efficient way I can think of would be to actually perform the summation across the files to something with an increased bit depth (or simply keep track of the max and min sum of all the samples). With the knowledge of both the positive and negative peak sample for the final file, you can calculate the scale factor needed so that all the files never sum up to more or less than the final file can hold. If you used a higher bit depth intermediary, you could simply apply the scale factor to the output, thus saving some time.
    – AJ Henderson
    Commented Aug 8, 2014 at 19:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.