2012-09-01, 17:13
Hi there,
I really like XBMC but for a long time I was seriously disappointed by the way XBMC handled mixing down 5.1 Sound to stereo. While my research showed, that I'm not the only one with this problem I wasn't able to find a proper solution for this.
Some suggested, that this was because of a bad down-mixing matrix, which would disregard the center channel. As an effect the center channel would not be loud enough compared to back left/right and front left/right.
Today I managed to solve this for me, it's messy, it's hardcoded but it's working.
A few words on the principle:
Downmix matrix in EDEN is handled very basic. When you look at the Eden source code provided on the main site you will find a file called "PCMRemap.cpp".
In this file the downmixing is realised. The following structure allows for different channels to be mapped to other channels, while the following number indicates a gain or loss in volume:
So PCM_FRONT_CENTER(FC) maps to PCM_FRONT_LEFT_OF_CENTER(FLC), PCM_FRONT_RIGHT_OF_CENTER(FRC) and itself, in a stereo setting the three of them are not existing. FLC and FRC now map (besides others) on PCM_FRONT_LEFT and PCM_FRONT_RIGHT, so if one likes center to be increased the values for this adjustment should be changed, increased in this case, so for a value of "2.0" it should look like:
Thats no big deal and nearly anybody should be able to do so by changing the "PCMRemap.cpp" and compile XBMC using the HOW-TO in the Wiki, if you manage to get an "XBMC.exe" with your "PCMRemap.cpp" just copy it over to your XBMC-Directory and you should be fine (do a backup of the original "XBMC.exe", just in case...).
For comparison:
with original values (out of the box EDEN):
with values of "2.5"
Well the drawback:
- you may need to enable normalization (remember, in the stable Eden-release ON and OFF are switched, so ON=OFF and vice versa, at least for me!) (depending on the gaining-factor)
- this works just for Eden as with Audio Engine being new in v12 the remapping also changed and at a quick look i haven't been able to easily change this in v12, maybe it won't need changing after all but for the moment I want to stick with EDEN and thus needed this problem fixed in there...
As the process is simple I compiled the XBMC.exe for Values of 1.5, 2.0, 2.5, 3.0 and 3.5, I personally prefer a value of 2.5 but you may decide this on your own
Download here: http://uploaded.net/file/7xmczobv (ca. 21MB) and just replace your "XBMC.exe" with your preferred from the archive (consider making a backup of your own before!)
Enjoy!
Edit: I'm not that much into GPL and publishing Software, but I hope as I explained the changes and as they are very very minor I'm allowed to offer the compiled executables, if not please contact me and i will remove them asap.
I really like XBMC but for a long time I was seriously disappointed by the way XBMC handled mixing down 5.1 Sound to stereo. While my research showed, that I'm not the only one with this problem I wasn't able to find a proper solution for this.
Some suggested, that this was because of a bad down-mixing matrix, which would disregard the center channel. As an effect the center channel would not be loud enough compared to back left/right and front left/right.
Today I managed to solve this for me, it's messy, it's hardcoded but it's working.
A few words on the principle:
Downmix matrix in EDEN is handled very basic. When you look at the Eden source code provided on the main site you will find a file called "PCMRemap.cpp".
In this file the downmixing is realised. The following structure allows for different channels to be mapped to other channels, while the following number indicates a gain or loss in volume:
Code:
static struct PCMMapInfo PCMDownmixTable[PCM_MAX_CH][PCM_MAX_MIX] =
{
/* PCM_FRONT_LEFT */
{
{PCM_INVALID}
},
/* PCM_FRONT_RIGHT */
{
{PCM_INVALID}
},
/* PCM_FRONT_CENTER */
{
{PCM_FRONT_LEFT_OF_CENTER , 1.0},
{PCM_FRONT_RIGHT_OF_CENTER, 1.0},
{PCM_INVALID}
},
/* PCM_LOW_FREQUENCY */
{
/*
A/52B 7.8 paragraph 2 recomends +10db
but due to horrible clipping when normalize
is disabled we set this to 1.0
*/
{PCM_FRONT_LEFT , 1.0},//3.5},
{PCM_FRONT_RIGHT , 1.0},//3.5},
{PCM_INVALID}
},
/* PCM_BACK_LEFT */
{
{PCM_FRONT_LEFT , 1.0},
{PCM_INVALID}
},
/* PCM_BACK_RIGHT */
{
{PCM_FRONT_RIGHT , 1.0},
{PCM_INVALID}
},
/* PCM_FRONT_LEFT_OF_CENTER */
{
{PCM_FRONT_LEFT , 1.0},
{PCM_FRONT_CENTER , 1.0, true},
{PCM_INVALID}
},
/* PCM_FRONT_RIGHT_OF_CENTER */
{
{PCM_FRONT_RIGHT , 1.0},
{PCM_FRONT_CENTER , 1.0, true},
{PCM_INVALID}
},
/* PCM_BACK_CENTER */
{
{PCM_BACK_LEFT , 1.0},
{PCM_BACK_RIGHT , 1.0},
{PCM_INVALID}
},
/* PCM_SIDE_LEFT */
{
{PCM_FRONT_LEFT , 1.0},
{PCM_BACK_LEFT , 1.0},
{PCM_INVALID}
},
/* PCM_SIDE_RIGHT */
{
{PCM_FRONT_RIGHT , 1.0},
{PCM_BACK_RIGHT , 1.0},
{PCM_INVALID}
},
/* PCM_TOP_FRONT_LEFT */
{
{PCM_FRONT_LEFT , 1.0},
{PCM_INVALID}
},
/* PCM_TOP_FRONT_RIGHT */
{
{PCM_FRONT_RIGHT , 1.0},
{PCM_INVALID}
},
/* PCM_TOP_FRONT_CENTER */
{
{PCM_TOP_FRONT_LEFT , 1.0},
{PCM_TOP_FRONT_RIGHT , 1.0},
{PCM_INVALID}
},
/* PCM_TOP_CENTER */
{
{PCM_TOP_FRONT_LEFT , 1.0},
{PCM_TOP_FRONT_RIGHT , 1.0},
{PCM_INVALID}
},
/* PCM_TOP_BACK_LEFT */
{
{PCM_BACK_LEFT , 1.0},
{PCM_INVALID}
},
/* PCM_TOP_BACK_RIGHT */
{
{PCM_BACK_RIGHT , 1.0},
{PCM_INVALID}
},
/* PCM_TOP_BACK_CENTER */
{
{PCM_TOP_BACK_LEFT , 1.0},
{PCM_TOP_BACK_RIGHT , 1.0},
{PCM_INVALID}
}
};
So PCM_FRONT_CENTER(FC) maps to PCM_FRONT_LEFT_OF_CENTER(FLC), PCM_FRONT_RIGHT_OF_CENTER(FRC) and itself, in a stereo setting the three of them are not existing. FLC and FRC now map (besides others) on PCM_FRONT_LEFT and PCM_FRONT_RIGHT, so if one likes center to be increased the values for this adjustment should be changed, increased in this case, so for a value of "2.0" it should look like:
Code:
[...]
/* PCM_FRONT_LEFT_OF_CENTER */
{
{PCM_FRONT_LEFT , 2.0},
{PCM_FRONT_CENTER , 1.0, true},
{PCM_INVALID}
},
/* PCM_FRONT_RIGHT_OF_CENTER */
{
{PCM_FRONT_RIGHT , 2.0},
{PCM_FRONT_CENTER , 1.0, true},
{PCM_INVALID}
},
[...]
For comparison:
with original values (out of the box EDEN):
Code:
17:08:13 T:2660 DEBUG: CPCMRemap: FL = FL(0.292893) CE(0.207107) LFE(0.207107) BL(0.292893)
17:08:13 T:2660 DEBUG: CPCMRemap: FR = FR(0.292893) CE(0.207107) LFE(0.207107) BR(0.292893)
Code:
17:09:48 T:2212 DEBUG: CPCMRemap: FL = FL(0.223470) CE(0.395043) LFE(0.158017) BL(0.223470)
17:09:48 T:2212 DEBUG: CPCMRemap: FR = FR(0.223470) CE(0.395043) LFE(0.158017) BR(0.223470)
Well the drawback:
- you may need to enable normalization (remember, in the stable Eden-release ON and OFF are switched, so ON=OFF and vice versa, at least for me!) (depending on the gaining-factor)
- this works just for Eden as with Audio Engine being new in v12 the remapping also changed and at a quick look i haven't been able to easily change this in v12, maybe it won't need changing after all but for the moment I want to stick with EDEN and thus needed this problem fixed in there...
As the process is simple I compiled the XBMC.exe for Values of 1.5, 2.0, 2.5, 3.0 and 3.5, I personally prefer a value of 2.5 but you may decide this on your own
Download here: http://uploaded.net/file/7xmczobv (ca. 21MB) and just replace your "XBMC.exe" with your preferred from the archive (consider making a backup of your own before!)
Enjoy!
Edit: I'm not that much into GPL and publishing Software, but I hope as I explained the changes and as they are very very minor I'm allowed to offer the compiled executables, if not please contact me and i will remove them asap.