Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion.

Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules.

 

Go Back   Doom9's Forum > General > Audio encoding

Reply
 
Thread Tools Search this Thread Display Modes
Old 20th April 2014, 21:27   #1  |  Link
Richard1485
Guest
 
Posts: n/a
4.1/5.1/7.1 Channel Configuration/Order

Is this order correct when merging six channels?

fl=WavSource("L.wav")
fr=WavSource("R.wav")
c=WavSource("C.wav")
lfe=WavSource("LFE.wav")
sl=WavSource("SL.wav")
sr=WavSource("SR.wav")

MergeChannels(fl,fr,c,lfe,sl,sr)

I also need to know how to use MergeChannels() for 7.1.

Moreover, when I decode Dolby TrueHD 7.1 to wavs, I don't which channel configuration to select in the DTS-HD MA encoding suite. There are two options:

1. 7.1 – L,R,C,LFE,Lss,Rss,Lsr,Rsr;
2. 7.1 – L,R,C,LFE,Ls,Rs,Lsr,Rsr.

1.


2.


How does one know which to select?

Last edited by Richard1485; 6th June 2017 at 01:41.
  Reply With Quote
Old 21st April 2014, 03:32   #2  |  Link
AMED
Registered User
 
AMED's Avatar
 
Join Date: Sep 2004
Location: Auckland, New Zealand
Posts: 466
Wouldn't it be easier to convert to FLAC and not WAV's?

Then use EAC3TO to do the downmix?
__________________
A Man Eating Duck
AMED is offline   Reply With Quote
Old 21st April 2014, 03:34   #3  |  Link
Overdrive80
Anime addict
 
Overdrive80's Avatar
 
Join Date: Feb 2009
Location: Spain
Posts: 673
For DTS 7.1 first option is correct. http://forum.doom9.org/showthread.ph...85#post1443085
__________________
Intel i7-6700K + Noctua NH-D15 + Z170A XPower G. Titanium + Kingston HyperX Savage DDR4 2x8GB + Radeon RX580 8GB DDR5 + ADATA SX8200 Pro 1 TB + Antec EDG750 80 Plus Gold Mod + Corsair 780T Graphite
Overdrive80 is offline   Reply With Quote
Old 21st April 2014, 10:07   #4  |  Link
Richard1485
Guest
 
Posts: n/a
Thanks, Overdrive80. I'll just have to hope that if I come across 7.1 with the "strange setup" it will be apparent somehow.

@AMED
No, for various reasons in my workflow. Thanks for the suggestion though.
  Reply With Quote
Old 21st April 2014, 10:11   #5  |  Link
tebasuna51
Moderator
 
tebasuna51's Avatar
 
Join Date: Feb 2005
Location: Spain
Posts: 6,915
Quote:
Originally Posted by Richard1485 View Post
MergeChannels(fl,fr,c,lfe,sl,sr)
Correct.
Quote:
I also need to know how to use MergeChannels() for 7.1.
MergeChannels(fl,fr,c,lfe,bl,br,sl,sr)
bl,br means BackLeft, BackRight

Quote:
Moreover, when I decode Dolby TrueHD 7.1 to wavs, I don't which channel configuration to select in the DTS-HD MA encoding suite.
Thats one: 7.1 – L,R,C,LFE,Lss,Rss,Lsr,Rsr;

BTW I don't know for what you recode TrueHD (free decoder) to DTS-MA (commercial decoder), with big size for the same quality.
__________________
BeHappy, AviSynth audio transcoder.
tebasuna51 is offline   Reply With Quote
Old 21st April 2014, 10:26   #6  |  Link
Richard1485
Guest
 
Posts: n/a
Thanks, tebasuna.

Quote:
Originally Posted by tebasuna51 View Post
BTW I don't know for what you recode TrueHD (free decoder) to DTS-MA (commercial decoder), with big size for the same quality.
I have two reasons. First, the free version of EasyBD Lite, which is my muxer of choice, does not like TrueHD. Secondly, I sometimes need to edit the audio track and recompress it without quality loss.

As always, thanks for your help.
  Reply With Quote
Old 21st April 2014, 10:37   #7  |  Link
SeeMoreDigital
Life's clearer in 4K UHD
 
SeeMoreDigital's Avatar
 
Join Date: Jun 2003
Location: Notts, UK
Posts: 12,227
Quote:
Originally Posted by Richard1485 View Post
First, the free version of EasyBD Lite, which is my muxer of choice, does not like TrueHD.
Really...

Is this because your TrueHD stream does not contain an Dolby Digital core?
__________________
| I've been testing hardware media playback devices and software A/V encoders and decoders since 2001 | My Network Layout & A/V Gear |
SeeMoreDigital is offline   Reply With Quote
Old 21st April 2014, 10:43   #8  |  Link
Richard1485
Guest
 
Posts: n/a
Quote:
Originally Posted by SeeMoreDigital View Post
Really...
Yes.

Quote:
Originally Posted by SeeMoreDigital View Post
Is this because your TrueHD stream does not contain an Dolby Digital core?
No.
  Reply With Quote
Old 6th June 2017, 01:49   #9  |  Link
Richard1485
Guest
 
Posts: n/a
How does one merge five channels and end up with a 3/1.1 channel configuration?

MergeChannels( fl, fr, cc, lfe, bc) seems to results in 5.0, because eac3to splits the result like this...

Code:
Writing WAVs...
Creating file "SR.wav"...
Creating file "R.wav"...
Creating file "C.wav"...
Creating file "L.wav"...
Creating file "SL.wav"...
...rather than like this...

Code:
Writing WAVs...
Creating file "C.wav"...
Creating file "LFE.wav"...
Creating file "BC.wav"...
Creating file "R.wav"...
Creating file "L.wav"...
  Reply With Quote
Old 6th June 2017, 08:14   #10  |  Link
Midzuki
Unavailable
 
Midzuki's Avatar
 
Join Date: Mar 2009
Location: offline
Posts: 1,480
Quote:
Originally Posted by Richard1485 View Post
How does one merge five channels and end up with a 3/1.1 channel configuration?

MergeChannels( fl, fr, cc, lfe, bc) seems to results in 5.0, because eac3to splits the result like this...

Code:
Writing WAVs...
Creating file "SR.wav"...
Creating file "R.wav"...
Creating file "C.wav"...
Creating file "L.wav"...
Creating file "SL.wav"...
...rather than like this...

Code:
Writing WAVs...
Creating file "C.wav"...
Creating file "LFE.wav"...
Creating file "BC.wav"...
Creating file "R.wav"...
Creating file "L.wav"...
You must use the decimal value 271 for the channel mask.

Code:
Speaker Position     Decimal Value
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯     ¯¯¯¯¯¯¯¯¯¯¯¯¯

FRONT_LEFT             1
FRONT_RIGHT            2
FRONT_CENTER           4
LOW_FREQUENCY          8
BACK_LEFT              16
BACK_RIGHT             32
FRONT_LEFT_OF_CENTER   64
FRONT_RIGHT_OF_CENTER  128
BACK_CENTER            256
SIDE_LEFT              512
SIDE_RIGHT             1024
TOP_CENTER             2048
TOP_FRONT_LEFT         4096
TOP_FRONT_CENTER       8192
TOP_FRONT_RIGHT        16384
TOP_BACK_LEFT          32768
TOP_BACK_CENTER        65536
TOP_BACK_RIGHT         131072
RESERVED               262144
Midzuki is offline   Reply With Quote
Old 6th June 2017, 10:10   #11  |  Link
tebasuna51
Moderator
 
tebasuna51's Avatar
 
Join Date: Feb 2005
Location: Spain
Posts: 6,915
# open your 5.1
a = ConvertAudioToFloat()
flr = Getchannel(a, 1, 2, 3, 4)
sl = Getchannel(a, 5)
sr = Getchannel(a, 6)
sur = MixAudio(sr, br, 1.0, 1.0).SoftClipperFromAudX(0.0)
mergechannels(flr,sur)
#convert to desired bitdepth

and put channel mask to 271, like Midzuki say, with BeHappy.
__________________
BeHappy, AviSynth audio transcoder.
tebasuna51 is offline   Reply With Quote
Old 6th June 2017, 13:14   #12  |  Link
Richard1485
Guest
 
Posts: n/a
Quote:
Originally Posted by Midzuki View Post
You must use the decimal value 271 for the channel mask.
Ah, so the channel mask is obtained by adding the decimal values of all the speakers together. Thanks! Previously, I have used MergeChannels() only with 2.0, 5.1, and 7.1 and have never had to set a channel mask.

@tebasuna51
Thank you very much! Does the conversion to float affect only the channels that are to be mixed? I am using mono wavs. Is the following correct?

Code:
fl=WavSource("l.wav")
fr=WavSource("r.wav")
c=WavSource("c.wav")
lfe=WavSource("lfe.wav")
sl=WavSource("sl.wav").ConvertAudioToFloat()
sr=WavSource("sr.wav").ConvertAudioToFloat()
sur=MixAudio(sl, sr, 1.0, 1.0).SoftClipperFromAudX(0.0).ConvertAudioTo24bit()

MergeChannels(fl,fr,c,lfe,sur)
EDIT: I'm running up against the file-size limit for WAV; my output is truncated. Is it possible to export W64/RF64 from BeHappy? I've exported as WV WavPack High Quality, and the file is no longer truncated, but eac3to doesn't accept it as input (and the channel configuration is still wrong, despite the fact that I set it in BeHappy).



EDIT (again): The channel configuration is right only when I export as WAV from BeHappy. When I export as FLAC or WV WavPack, it's wrong. Does Writing RIFF_EXT header to encoder's StdIn not mean that the channel configuration is being passed to the encoder?

Last edited by Richard1485; 6th June 2017 at 17:47.
  Reply With Quote
Old 6th June 2017, 22:52   #13  |  Link
tebasuna51
Moderator
 
tebasuna51's Avatar
 
Join Date: Feb 2005
Location: Spain
Posts: 6,915
Quote:
Originally Posted by Richard1485 View Post
Does the conversion to float affect only the channels that are to be mixed? I am using mono wavs. Is the following correct?
Is perfect, if input wavs are 24 bits

Quote:
I'm running up against the file-size limit for WAV; my output is truncated.
Behappy wav output can be greater than 4GB, and many soft (encoders) can manage that with the help of some parameters.
--ignore-chunk-sizes for instance for flac.

Quote:
Is it possible to export W64/RF64 from BeHappy?
Yep, check Head (below ChMask) an put 1 (with mouse in word Head you can se: 0 = WAV, 1 = W64, 2 = RF64)

Quote:
When I export as FLAC or WV WavPack, it's wrong. Does Writing RIFF_EXT header to encoder's StdIn not mean that the channel configuration is being passed to the encoder?
To WavPack the header with correct Channel Mask is sended, then seems a encoder problem.

To flac the wav header is not sended, only raw PCM data without Channel Mask info.

You can replace e_Flac.ext in Behappy\extensions by the attached one to send before the RIFF_EXT header. But you obtain a System.IO.IOException with a message like this:

ERROR: WAVEFORMATEXTENSIBLE chunk with unsupported channel mask=0x010F

The same if you try send the FL-FR-FC-LF-BC.wav to flac encoder:

flac FL-FR-FC-LF-BC.wav

Only accept channel mask than match: https://xiph.org/flac/format.html

Quote:
Channel assignment

0000-0111 : (number of independent channels)-1. Where defined, the channel order follows SMPTE/ITU-R recommendations. The assignments are as follows:
1 channel: mono
2 channels: left, right
3 channels: left, right, center
4 channels: front left, front right, back left, back right
5 channels: front left, front right, front center, back/surround left, back/surround right
6 channels: front left, front right, front center, LFE, back/surround left, back/surround right
7 channels: front left, front right, front center, LFE, back center, side left, side right
8 channels: front left, front right, front center, LFE, back left, back right, side left, side right
1000 : left/side stereo: channel 0 is the left channel, channel 1 is the side(difference) channel
1001 : right/side stereo: channel 0 is the side(difference) channel, channel 1 is the right channel
1010 : mid/side stereo: channel 0 is the mid(average) channel, channel 1 is the side(difference) channel
1011-1111 : reserved
All other channel mask is rejected.
https://sourceforge.net/p/flac/feature-requests/96/

eac3to, accesing to libFLAC.dll, seems know how override the error and put the correct channel mask, but I don't know how make that with the command line encoder flac.exe.

Then output the wav or w64 or RF64 file, and encode to flac with eac3to.
Attached Files
File Type: 7z e_Flac.7z (7.5 KB, 51 views)
__________________
BeHappy, AviSynth audio transcoder.

Last edited by tebasuna51; 6th June 2017 at 23:04.
tebasuna51 is offline   Reply With Quote
Old 6th June 2017, 23:26   #14  |  Link
Richard1485
Guest
 
Posts: n/a
Quote:
Originally Posted by tebasuna51 View Post
Is perfect, if input wavs are 24 bits
They are! :-)

Quote:
Yep, check Head (below ChMask) an put 1 (with mouse in word Head you can se: 0 = WAV, 1 = W64, 2 = RF64)
Great! I've got my W64 file (with the correct length). ¡Muchísimas gracias!

Quote:
eac3to, accesing to libFLAC.dll, seems know how override the error and put the correct channel mask, but I don't know how make that with the command line encoder flac.exe.

Then output the wav or w64 or RF64 file, and encode to flac with eac3to.
Ah, I wondered if FLAC might not support the channel mask. Thanks! I'll use eac3to.

EDIT: I've just figured out that SoundOut() doesn't get the channel mask right either.

By the way, would you use SoftClipperFromAudX(0.0) when converting 5.1 to mono? So far, I've been using RaWavSource(,1).ConvertToMono().Normalize(), but perhaps there is a better way.

Last edited by Richard1485; 7th June 2017 at 00:43.
  Reply With Quote
Old 7th June 2017, 12:52   #15  |  Link
tebasuna51
Moderator
 
tebasuna51's Avatar
 
Join Date: Feb 2005
Location: Spain
Posts: 6,915
Quote:
Originally Posted by Richard1485 View Post
EDIT: I've just figured out that SoundOut() doesn't get the channel mask right either.
Inside AviSynth we can't know the channel mask of a audio stream.
This is a old feature request to AviSynth than was rejected because is dificult to do.

There are two "patch" to manage the problem:

1) After v2.58 we can set:

Global OPT_UseWaveExtensible=True

That must be the default, and not a option, in 21 Century.
Not needed in BeHappy or MeGUI because the special AvisynthWrapper.dll

2) After v2.60 we can set:

Global OPT_dwChannelMask={int}

But who know the ChannelMask is the decoder and a old plugin like SoundOut() don't output WaveExtensible header.

Quote:
By the way, would you use SoftClipperFromAudX(0.0) when converting 5.1 to mono? So far, I've been using RaWavSource(,1).ConvertToMono().Normalize(), but perhaps there is a better way.
The problem of Normalize() is when there are a big peak in all channels.
Forgeting LFE channel, than can't be used to downmix, we can have a peak at 500% and force reduce the overall volume to 1/5.

Now a normal (50%) dialog in FC is reduced to 10%.
Maybe we can do something than:

fl=WavSource("l.wav").ConvertAudioToFloat()
fr=WavSource("r.wav").ConvertAudioToFloat()
c=WavSource("c.wav").ConvertAudioToFloat()
sl=WavSource("sl.wav").ConvertAudioToFloat()
sr=WavSource("sr.wav").ConvertAudioToFloat()
left=MixAudio(fl,sl, 1.0, 1.0).SoftClipperFromAudX(0.0)
right=MixAudio(fr,sr, 1.0, 1.0).SoftClipperFromAudX(0.0)
c = MixAudio(left,c, 0.8, 1.0)
MixAudio(c, right, 1.0, 0.8).Normalize()
ConvertAudioTo24bit()

Or other balance instead 0.8, 1.0, 0.8

EDIT: Before I used a wrong MixAudio(left,c, right, 1.0, 0.8, 1.0).Normalize()
wrong because MixAudio only support 2 clips. Sorry.
__________________
BeHappy, AviSynth audio transcoder.

Last edited by tebasuna51; 9th June 2017 at 21:12. Reason: Mistake explained.
tebasuna51 is offline   Reply With Quote
Old 8th June 2017, 00:43   #16  |  Link
Richard1485
Guest
 
Posts: n/a
Tebasuna, many thanks for providing me with a more refined way to downmix to mono! I'll give it a try as soon as possible.

Quote:
Originally Posted by tebasuna51 View Post
Or other balance instead 0.8, 1.0, 0.8
I'm sorry, but I don't understand. Is this balance meant to differ from the script above? :-)

I appreciate your information about channel masks in AviSynth/SoundOut. It seems safer/easier to set them in BeHappy.
  Reply With Quote
Old 8th June 2017, 10:05   #17  |  Link
tebasuna51
Moderator
 
tebasuna51's Avatar
 
Join Date: Feb 2005
Location: Spain
Posts: 6,915
The problem of the downmix is let the dialog volume (FC most the times) too low to listen.

If we mix the 5 channel together and after Normalize() we can obtain a dialog volume at 20% than original.

For that I propose mix the left and right channels before with a limited volume (SoftClipperFromAudX) and after mix only 3 channel.
That can let the FC channel at 33% than original.

Even if you want priorize the FC you can do the last mix un-balanced (left,c,right, 0.8, 1.0, 0.8), FC at 38%.
But is dificult to know the proper value than can change with each audio.
You can try between balanced (left,c,right, 1.0, 1.0, 1.0), than let FC at 33%, until more un-balanced (left,c,right, 0.5, 1.0, 0.5) than let FC at 50%.
__________________
BeHappy, AviSynth audio transcoder.
tebasuna51 is offline   Reply With Quote
Old 8th June 2017, 21:00   #18  |  Link
Richard1485
Guest
 
Posts: n/a
Got it! I appreciate the detailed explanation, tebasuna51.
  Reply With Quote
Old 9th June 2017, 16:56   #19  |  Link
Richard1485
Guest
 
Posts: n/a
^^ Unfortunately, I receiver an error when using the script.

Quote:
Script error: Invalid arguments to function "MixAudio"
The reference is to the line:

Code:
MixAudio(left,c,right, 0.8, 1.0, 0.8).Normalize()
I don't see the error. Obviously, the fact that the audio is float means that the volume factor can exceed 1.0, and I presume from other people's scripts that MixAudio() can take more than two clips, but the script won't load unless I remove one of them. I'm confused.
  Reply With Quote
Old 9th June 2017, 20:43   #20  |  Link
hello_hello
Registered User
 
Join Date: Mar 2011
Posts: 4,829
Isn't MixAudio() limited to two inputs?

You could make a function out of it like the script below. 5.1ch downmix, LFE not included by default and normalising is enabled, so it might be slow to open. Then all you'd need is Downmix() in a script with ConvertAudioTo16bit(), or whatever output you want, or something like the following to adjust settings if need be:

Downmix(CentreGain=1.1, SurroundGain=0.7, Normalise=False).ConvertAudioTo16bit()

Quote:
# Defaults: FrontGain=1.0, CentreGain=0.8, LFEGain=0.0, SurroundGain=1.0, EnableSoftClip=True, SoftClipFactor=0.0, Normalise=True

function Downmix(clip a, float "FrontGain", float "CentreGain", float "LFEGain", float "SurroundGain", bool "EnableSoftClip", float "SoftClipFactor", bool "Normalise")
{
a.ConvertAudioToFloat()

FL = GetChannel(a, 1)
FR = GetChannel(a, 2)
FC = GetChannel(a, 3)
LFE = GetChannel(a, 4)
SL = GetChannel(a, 5)
SR = GetChannel(a, 6)

assert(a.AudioChannels == 6, """The audio must have 6 channels""")

FrontGain = default(FrontGain, 1.0)
CentreGain = default(CentreGain, 0.8)
LFEGain = default(LFEGain, 0.0)
SurroundGain = default(SurroundGain, 1.0)
EnableSoftClip = default(EnableSoftClip, True)
SoftClipFactor = default(SoftClipFactor, 0.0)
Normalise = default(Normalise, True)

# Mix Front Left/Right & Surround Left/Right
FL_SL = MixAudio(FL, SL, FrontGain, SurroundGain)
FR_SR = MixAudio(FR, SR, FrontGain, SurroundGain)

# Add LFE & Apply Limiting
FSL_LFE = MixAudio(FL_SL, LFE, 1.0, LFEGain)
FSR_LFE = MixAudio(FR_SR, LFE, 1.0, LFEGain)
FSL_LFE_Soft = MixAudio(FL_SL, LFE, 1.0, LFEGain).SoftClipperFromAudX(SoftClipFactor)
FSR_LFE_Soft = MixAudio(FR_SR, LFE, 1.0, LFEGain).SoftClipperFromAudX(SoftClipFactor)

Mix_Left = (EnableSoftClip == False) ? FSL_LFE : FSL_LFE_Soft
Mix_Right = (EnableSoftClip == False) ? FSR_LFE : FSR_LFE_Soft

# Add Centre
Left = MixAudio(Mix_Left, FC, 1.0, CentreGain)
Right = MixAudio(Mix_Right, FC, 1.0, CentreGain)

AudioOut = (Normalise == false) ? MergeChannels(Left, Right) : MergeChannels(Left, Right).Normalize(0.95)

Return AudioOut
}
Mind you I prefer using a GUI. Mostly foobar2000. There's a Matrix Mixer DSP you can add to the conversion chain and you can save conversion setups as presets, and there's a plugin that lets it open Avisynth scripts, so you could load a script like the one above and convert it that way. Messing around with individual mono wave files or intermediate files seems too hard when you can just open a file, right click and convert, and let the GUI take care of the channel mask stuff.
You can use ffmpeg as an audio encoder with foobar2000, and ffmpeg will accept any channel mask when converting to flac, although the official flac encoder will do the same if you add --channel-map=none to the command line. The channel mask info is saved to a WAVEFORMATEXTENSIBLE tag, so I guess it'd be up to the player to decide if it will read it and output the correct channels for non standard layouts, but I assume it works the same way when encoding with libFLAC etc.

Last edited by hello_hello; 10th June 2017 at 17:18.
hello_hello is offline   Reply With Quote
Reply

Tags
configuration, dts-hd ma, merge channels, truehd

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 05:17.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.