Skip to main content

Notice

Please note that most of the software linked on this forum is likely to be safe to use. If you are unsure, feel free to ask in the relevant topics, or send a private message to an administrator or moderator. To help curb the problems of false positives, or in the event that you do find actual malware, you can contribute through the article linked here.
Topic: Replaygain for more than 2 channels (Read 4381 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

Replaygain for more than 2 channels

Hi.

First off, let me apologize if I am posting this question in the wrong forum.  I wasn't quite sure which forum to post this under.

My question is how to properly calculate Replaygain values for files/formats that contain more than 2 channels of audio samples.  The current method is:

1 channel:  loudness = SQRT (( MS(channel[1]) + MS(channel[1]) ) / 2)

2 channel:  loudness = SQRT (( MS(channel[1]) + MS(channel[2]) ) / 2)

(MS is the mean of the square)
What should be done if there are more than 2 channels?  Should the extra channels be ignored?  Would something as simple as this work:

loudness = SQRT(( MS(channel[1]) + MS(channel[2]) + ... + MS(channel[n]) ) / n)

Would including more than 2 channels require changing the Replaygain spec?  Hopefully David Robinson or someone that has already tackled this problem for a format/player (foobar2000?) can help me out.

Thanks.

kmart

 

Replaygain for more than 2 channels

Reply #1
Strangely, I think the correct answer might be...

loudness = SQRT(( MS(channel[1]) + MS(channel[2]) + ... + MS(channel[n]) ) / 2)

...but let me think about it some more.

The problem is that the existing calculation (which is effectively an addition of powers) is a bodge/kludge which works well for most signals. Extending the same "logic" to 5 or 6 channels might be pushing it.

Like I said, let me think about it... anyone else is welcome to too!

Cheers,
David.

Replaygain for more than 2 channels

Reply #2
this is an old thread, but as multi-channels are starting to be less uncommon, this subject becomes more important..

Quote
Strangely, I think the correct answer might be...

loudness = SQRT(( MS(channel[1]) + MS(channel[2]) + ... + MS(channel[n]) ) / 2)


I thought about it and I agree.
(the "... / 2" part made it falsely seem like an average of stereo tracks, but indeed it's a sum and the algorithm would just be easier to grasp without the division by 2. its effects cancel out anyway, since the same division is applied to the reference signal..)
[ The 1 channel case is treated specifically by the algorithm, because all hi-fi setups treat mono as 2x same channel, rather than truly one channel, and the algorithm reflects that. ]

Is the replaygain code (in foobar and other implementations) already using this formula ?

BTW, that means that if you take a (false-stereo) track, and replicate it into 6 different channels, the replaygain will now be 20*Log(n/2) dB = 9.5 dB *lower*.

Can someone with a multi-channel set-up test this kind of thing and check that it does lead to the same loudness as the original 2 channel track ?

Maybe multi-channel amplifiers & speakers don't work with the same scale when in stereo-mode vs 5.1 mode (e.g., you could imagine 5.1 amplifiers have this 9.5dB attenuation *built in* in 5.1 mode, precisely for the same reason : so that people could switch between 5.1 and stereo without the loudness jumping up and down by 10dB..)

If the power-scaling induced by the number of channel is already cancelled by amplifiers, then the 5.1 replaygain shouldnt work on the powers sum, but indeed on the average power and the formula should precisely be :
loudness = SQRT(( MS(channel[1]) + MS(channel[2]) + ... + MS(channel[n]) ) / n)

Maybe the built-in channel-scaling attenuation isn't exactly 20*Log(n/2) dB either, but, e.g. a bit less to maybe account for the fact the bass channel typically holds less power (or more, or whatever)..

in the end the best choice might be to have replaygain store the *channels-averaged* replaygain, and let the player handle attenuation due to number of channels. It can then, for instance, provide user-customizable additional attenuation settings for all possible number of channels, using 20*log(n/2) dB as a default..


That's probably best in any case, it's more intuitive to have Replaygain values be independant of the number of channels. I know how loud a RG=-11dB stereo track is. But for a 5.1 track, if the powers are summed up, -11dB is equivalent to -1.5 dB stereo, and so -11dB for 5.1 is quiet audio..