(This is a cross-post from StackOverflow. But I wondered wether some people here might be the better audience to answer this.)

I am using libswresample to resample from any PCM format to 44.1kHz, 16bit int, stereo.

I was playing around with some audio volume analyzing of the resulting audio stream and I figured out that in case I have 44.1kHz, 16bit int mono as the source, I have roughly the formular:

leftSample = sourceSample / sqrt(2);
rightSample = sourceSample / sqrt(2);

But I was expecting:

leftSample = sourceSample;
rightSample = sourceSample;

(In case the source is stereo, I simply have leftSample = leftSourceSample; rightSample = rightSourceSample;.)

My expectation comes from several sources:

  1. That is how my own straight forward solution would probably have been.
  2. I searched a bit around and other people seem to do the same, e.g. here.
  3. In a very common ReplayGain implementation (the only one I know actually, used basically everywhere, I think initially from mp3gain; one copy can be seen here), it also does it.

    This is esp. relevant because ReplayGain was calibrated by this implementation using a reference sound (a pink noise, can be downloaded here) which is in mono.

    In the ReplayGain specification, it is also calculated like this (see here).

My confusion raised after I tried to implement ReplayGain myself and I stumbled upon this.

So, some questions:

  1. Why does libswresample do this?
  2. Is this expected in libswresample or a bug? (I'm trying to understand from the source (e.g. here) but I haven't fully understood it all yet.)
  3. What is the "right" solution?
  4. What are other players doing?
  5. What is a common soundcard doing if you feed mono samples to it?
  • Hi Albert, you have a few questions in here. You'd be better off separating them out as per the faq guidance in order to get good answers.
    – Rory Alsop
    Oct 4, 2012 at 7:29

1 Answer 1


This appears to be an attempt at a total power conversion. If you have a mono signal at a given power and played it through a speaker and then compared the volume to two speakers playing the sound, the overall volume would be higher. They are adjusting for that power increase due to two channels being used instead of one, thus the combined signal should have closer to the same power when combined.

This is the more technically correct way to approach the problem if you want to preserve total power which is common on higher end equipment when dealing with this kind of a problem. I'm not sure if other players do the same though most likely some do. The behavior of any particular sound card would depend on how the hardware and drivers for that sound card are implemented and can't be answered generically.

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.