lordmulder / LameXP

Audio Encoder Front-End
http://lordmulder.github.io/LameXP
Other
184 stars 18 forks source link

Multi-Channel Handing. #44

Closed BiatuAutMiahn closed 7 years ago

BiatuAutMiahn commented 7 years ago

I would consider this a feature request, and I don't really know how this can be implemented, however... Would it be possible to map Back/Front-Left, to the Left Channel, Back/Front-Right to the Right, and The Center or Bass to the applied to both Left and Right Channels? Effectively preserving the channels when converting a multi-channel stream to a stereo? Thank you.

This comes up because I notice that the MultiChannel to Stereo function actually strips out the channels, and thus audio is lost.

lordmulder commented 7 years ago

Actually, the "Downmix" in LameXP filter does mix all the existing channels of the multi-channel file in order to produce the new Left and Right channels. It certainly does not simply discard the other channels.

It does so by invoking SoX' with the "remix" filter and the appropriate weights for each channel:

--> Number of channels is: 6

C:/Users/MuldeR/AppData/Local/Temp/9714aa95acadd9f3/lxp_sox.exe -V3 -S --guard --temp . C:\Users\MuldeR\AppData\Local\Temp\9714aa95acadd9f3\30238050d52f017d.wav C:\Users\MuldeR\AppData\Local\Temp\9714aa95acadd9f3\98d08703647f423a.wav remix 1v0.4,3v0.2,4v0.2,5v0.2 2v0.4,3v0.2,4v0.2,6v0.2

C:\Users\MuldeR\AppData\Local\Temp\9714aa95acadd9f3\lxp_sox.exe: SoX v14.4.2
C:\Users\MuldeR\AppData\Local\Temp\9714aa95acadd9f3\lxp_sox.exe INFO formats: detected file format type `wav'
C:\Users\MuldeR\AppData\Local\Temp\9714aa95acadd9f3\lxp_sox.exe INFO wav: EXTENSIBLE
Input File : 'C:\Users\MuldeR\AppData\Local\Temp\9714aa95acadd9f3\30238050d52f017d.wav'
Channels : 6
Sample Rate : 48000
Precision : 16-bit
Duration : 01:48:25.57 = 312267264 samples ~ 487918 CDDA sectors
File Size : 4294966844M
Bit Rate : 42949667704294966844M
Sample Encoding: 16-bit Signed Integer PCM
Endian Type : little
Reverse Nibbles: no
Reverse Bits : no
C:\Users\MuldeR\AppData\Local\Temp\9714aa95acadd9f3\lxp_sox.exe INFO sox: Overwriting `C:\Users\MuldeR\AppData\Local\Temp\9714aa95acadd9f3\98d08703647f423a.wav'
Output File : 'C:\Users\MuldeR\AppData\Local\Temp\9714aa95acadd9f3\98d08703647f423a.wav'
Channels : 2
Sample Rate : 48000
Precision : 16-bit
Duration : 01:48:25.57 = 312267264 samples ~ 487918 CDDA sectors
Sample Encoding: 16-bit Signed Integer PCM
Endian Type : little
Reverse Nibbles: no
Reverse Bits : no
Comment : 'Processed by SoX'
C:\Users\MuldeR\AppData\Local\Temp\9714aa95acadd9f3\lxp_sox.exe INFO sox: effects chain: input 48000Hz 6 channels
C:\Users\MuldeR\AppData\Local\Temp\9714aa95acadd9f3\lxp_sox.exe INFO sox: effects chain: remix 48000Hz 2 channels
C:\Users\MuldeR\AppData\Local\Temp\9714aa95acadd9f3\lxp_sox.exe INFO sox: effects chain: gain 48000Hz 2 channels
C:\Users\MuldeR\AppData\Local\Temp\9714aa95acadd9f3\lxp_sox.exe INFO sox: effects chain: dither 48000Hz 2 channels
C:\Users\MuldeR\AppData\Local\Temp\9714aa95acadd9f3\lxp_sox.exe INFO sox: effects chain: output 48000Hz 2 channels
Done.

Exited with code: 0x0000

This is the important part:

lxp_sox.exe [...] remix 1v0.4,3v0.2,4v0.2,5v0.2 2v0.4,3v0.2,4v0.2,6v0.2

So, as you can see, two channels (Stereo) are created by mixing from all the existing channels. In particular, the new "Left" channels is created by mixing the Front/Left, Front/Center, Back/Left and LFE channels; and the new "Right" channels is created by mining the Front/Right, Front/Center, Back/Right and LFE channels.

We assume standard Wave channel ordering here: https://msdn.microsoft.com/en-us/library/windows/hardware/dn653308(v=vs.85).aspx

BiatuAutMiahn commented 7 years ago

Ah, ok

lordmulder commented 7 years ago

So, I think we can close it, for now.