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 5th August 2020, 10:59   #1  |  Link
Dogway
Registered User
 
Join Date: Nov 2009
Posts: 1,072
7.1 downmix function?

I'm curious to know if there's some kind of 7.1 downmix function, among other I made an upmixer based on DPLIIx coefficients so maybe those could be reverse engineered?

One aspect I have been wondering is in the popular DPLII downmix function negative amplitudes are being used, doesn't that imply a 180 phase instead of 90? I think the SoxFilter can do 90 phase shift.
Dogway is offline   Reply With Quote
Old 5th August 2020, 12:41   #2  |  Link
tebasuna51
Moderator
 
tebasuna51's Avatar
 
Join Date: Feb 2005
Location: Spain
Posts: 6,130
Of course there are downmix functions and also upmix functions.

UPMIX DPLII

- Read this old thread: https://hydrogenaud.io/index.php?topic=52235.0 (I'm only interested in upmix to 5.1, 7.1 is usseless for surround 2D in my opinion)

- When you upmix never try create a LFE channel, if you want create it empty because:

All amplifier/receiver filter the low frequencies of ALL CHANNELS to sub-woofer, not only the LFE channel then the job is already make.
If you filter the low frequencies to LFE and leave them in other channels you can obtain interferences, to work properly the filter than you make and the filter than aply the receiver must be the same.
You can guarantee that for all receivers than play your upmix?
The best option LFE empty.

Of course Dolby never recommend use the LFE channel to create a downmix DPL

DOWNMIX

Seems you are talking about downmix to stereo.
In MeGUI and BeHappy (AviSynth) I recommend do the downmix 7.1 -> 5.1 to try preserve the balance between front and surround channels, and
after the plain stereo (formal or with forced coeficients to improve dialogs) or the dpl II downmix.

Of course I can make a direct 7.1 -> 2.0 if you want.

You can see also my recent UsEac3to GUI with downmix 7.1 -> 5.1 and downmix 5.1 -> 2-0 formal (you can modify coeficients) or Dpl II, using ffmpeg.
Quote:
51-20v|-filter_complex "pan=stereo|FL=.3694FL+.2612FC+.3694BL+0.0LFE|FR=.3694FR+.2612FC+.3694BR+0.0LFE, volumedetect"
dplIIv|-filter_complex "pan=stereo|FL=.3254FL+.2301FC+.2818BL+.1627BR|FR=.3254FR+.2301FC-.1627BL-.2818BR, volumedetect"
71-51c|-filter_complex "asplit [f][s]; [f] pan=3.1|c0=c0|c1=c1|c2=c2|c3=c3 [r]; [s] pan=stereo|c0=0.5*c4+0.5*c6|c1=0.5*c5+0.5*c7, compand=attacks=0:decays=0oints=-90/-84|-10/-4|-6/-2|-0/-0.3, aformat=channel_layouts=stereo [d]; [r][d] amerge [a]" -map "[a]"
The full 7.1 -> dpl II can be:

-filter_complex "asplit [f][s]; [f] pan=3.1|c0=c0|c1=c1|c2=c2|c3=c3 [r]; [s] pan=stereo|c0=0.5*c4+0.5*c6|c1=0.5*c5+0.5*c7, compand=attacks=0:decays=0oints=-90/-84|-10/-4|-6/-2|-0/-0.3, aformat=channel_layouts=stereo [d]; [r][d] amerge, pan=stereo|FL=.3254FL+.2301FC+.2818BL+.1627BR|FR=.3254FR+.2301FC-.1627BL-.2818BR, volumedetect [a]" -map "[a]"

The emoticon is
Code:
:p
The negative coeficients are not related with 90 phase shift than must be pre-existent in surround channels with all sounds already presents in front channels.
__________________
BeHappy, AviSynth audio transcoder.

Last edited by tebasuna51; 5th August 2020 at 13:25. Reason: add info
tebasuna51 is offline   Reply With Quote
Old 5th September 2020, 05:14   #3  |  Link
lifta19
Registered User
 
Join Date: Aug 2019
Posts: 19
error:
ffmpeg.exe -threads 0 -hide_banner -y -i "input.mkv" -vn -sn -map 0:2 -filter_complex "asplit [f][s]; [f] pan=3.1|c0=c0|c1=c1|c2=c2|c3=c3 [r]; [s] pan=stereo|c0=0.5*c4+0.5*c6|c1=0.5*c5+0.5*c7, compand=attacks=0:decays=0oints=-90/-84|-10/-4|-6/-2|-0/-0.3, aformat=channel_layouts=stereo [d]; [r][d] amerge [a]" -map "[a]" -c:a ac3 -center_mixlev 0.707 -b:a 640k "output.ac3"

work fine:
ffmpeg.exe -threads 0 -hide_banner -y -i "input.mkv" -vn -sn -filter_complex "asplit [f][s]; [f] pan=3.1|c0=c0|c1=c1|c2=c2|c3=c3 [r]; [s] pan=stereo|c0=0.5*c4+0.5*c6|c1=0.5*c5+0.5*c7, compand=attacks=0:decays=0oints=-90/-84|-10/-4|-6/-2|-0/-0.3, aformat=channel_layouts=stereo [d]; [r][d] amerge [a]" -map "[a]" -c:a ac3 -center_mixlev 0.707 -b:a 640k "output.ac3"


stream map option error (-map 0:1 -map 0:2 ~~~)

Last edited by lifta19; 5th September 2020 at 09:46.
lifta19 is offline   Reply With Quote
Old 5th September 2020, 13:42   #4  |  Link
tebasuna51
Moderator
 
tebasuna51's Avatar
 
Join Date: Feb 2005
Location: Spain
Posts: 6,130
Without -map work fine for first audio track in container.

If you want the second audio track you can include the selection inside the -filter_complex, for instance:

ffmpeg.exe -i "input.mkv" -vn -sn -filter_complex "[0:2] asplit [f][s];..." ...
__________________
BeHappy, AviSynth audio transcoder.
tebasuna51 is offline   Reply With Quote
Old 5th September 2020, 15:21   #5  |  Link
lifta19
Registered User
 
Join Date: Aug 2019
Posts: 19
request

tebasuna51 Thank you very much. Could you possibly set ffmpeg the same as Megui? Or sox remix?

request:
7.1 to 5.1, 7.1 to stereo, 5.1 to stereo

Last edited by lifta19; 5th September 2020 at 15:25.
lifta19 is offline   Reply With Quote
Old 5th September 2020, 17:48   #6  |  Link
tebasuna51
Moderator
 
tebasuna51's Avatar
 
Join Date: Feb 2005
Location: Spain
Posts: 6,130
The ffmpeg 'compand' filter do the same than sox with more speed. Use sox is always slow.

Also use ffmpeg is always fast than use AviSynth and the 'compand' filter do the same (more or less) than the SoftClipperFromAudX() filter used in MeGUI 32 bits.

All the request are in the second post of this thread.

The only difference with AviSynth methods is the 2 pass required (*) to emulate the AviSynth Normalize().

(*) explained in the point 2.1.5 of Readme_UsEac3to.txt attached here
__________________
BeHappy, AviSynth audio transcoder.
tebasuna51 is offline   Reply With Quote
Old 22nd October 2020, 14:52   #7  |  Link
Selur
Registered User
 
Selur's Avatar
 
Join Date: Oct 2001
Location: Germany
Posts: 6,231
@tembasuna5: I just tried to translate
Code:
-filter_complex "asplit [f][s]; [f] pan=3.1|c0=c0|c1=c1|c2=c2|c3=c3 [r]; [s] pan=stereo|c0=0.5*c4+0.5*c6|c1=0.5*c5+0.5*c7, compand=attacks=0:decays=0:points=-90/-84|-10/-4|-6/-2|-0/-0.3, aformat=channel_layouts=stereo [d]; [r][d] amerge [a]" -map "[a]"
to sox and I got the remix part
Code:
remix -m 1v1 2v1 3v1 4v1 5v0.5,7v0.6 4v0.5,8v0.5
problem is I don't get the compand part and I have no clue who to apply the compand part only on the last two channels in sox.
-> can you translate that call to sox (please)?

Cu Selur
__________________
Hybrid here in the forum, homepage
Notice: Since email notifications do not work here any more, it might take me quite some time to notice a reply to a thread,..
Selur is offline   Reply With Quote
Old 22nd October 2020, 18:02   #8  |  Link
tebasuna51
Moderator
 
tebasuna51's Avatar
 
Join Date: Feb 2005
Location: Spain
Posts: 6,130
Quote:
Originally Posted by Selur View Post
... have no clue who to apply the compand part only on the last two channels in sox.
I have the same problem, without a command equivalent to 'asplit' I don't know how make that with sox in only one pass.

BTW, for what you need sox?
ffmpeg uses the same routines than sox and have some advantages:

1) It is much more fast than sox.

2) You can use compressed 7.1 (DTS-HD, TrueHD, EAC3, AAC) like source even without extract from some containers.

3) The output can be uncompressed (WAV, W64), lossless (FLAC, ...) or lossy (EAC3, AC3, AAC,...)

With only one pass you can extract, decode, downmix and recode to other format.
__________________
BeHappy, AviSynth audio transcoder.
tebasuna51 is offline   Reply With Quote
Old 23rd October 2020, 06:13   #9  |  Link
Ghitulescu
Registered User
 
Ghitulescu's Avatar
 
Join Date: Mar 2009
Location: Germany
Posts: 5,735
I think only cheap x.1 amplifiers reroute ALL low signals to LFE/.1 channel, mine is set for "large speakers" (full range) and the LFE (which is active) does not work if there is no LFE channel in the signal.
I would stay for the "definition". if I would "arrange" the soundtrack. This would ensure maximum of compatibility.
__________________
Born in the USB (not USA)
Ghitulescu is offline   Reply With Quote
Old 23rd October 2020, 11:39   #10  |  Link
tebasuna51
Moderator
 
tebasuna51's Avatar
 
Join Date: Feb 2005
Location: Spain
Posts: 6,130
@Ghitulescu
I can't understand the sense of your post. Of course amplifiers/receivers can be configured with "large speakers", I have one without subwoofer configured like this.

But, for what is related with the downmix 7.1 -> 5.1 or 2.0?
__________________
BeHappy, AviSynth audio transcoder.
tebasuna51 is offline   Reply With Quote
Old 24th October 2020, 12:10   #11  |  Link
Ghitulescu
Registered User
 
Ghitulescu's Avatar
 
Join Date: Mar 2009
Location: Germany
Posts: 5,735
On tablet it's a PITA to quote messages. It's your first post.

I wanted to say that not all amplifiers do separate bass to send it to LFE channel. In other words, if one needs the LFE, this channel MUST exist. Stereo has no LFE, so downmixing to 2.0 should distribute the bass to bth channels. Otherwise it's safer to leave it (or create it).
Upmixing creates more channels from a less. This is what most 5.1/7.1/etc-amplifiers do with a stereo source, in particular if the combination has 5 tiny speakers and a cubic box . Creating a fake multichannel audio in these conditions only increases the audio size - and has a deceptive efefct on the customer.
Downsizing to 2.0 is also automatically done, eg in TVs. In the long long past, when such downmix was not possible, the DVDs had 2 audios, one in 5.1 the other in 2.0. I don't even remember when I saw the last DVD with both and the last TV that couldn't downmix. Amplifiers did that for long before TVs.
In one of the sessions of AES, also published in JAES, a number of years ago, after 7.2 was launched, it was mentioned that the extra channels do not contribute essentially for the sound, so it was practically safe to discharge them from mix, in order to be played 1:1 on a 5.1 system.
__________________
Born in the USB (not USA)
Ghitulescu is offline   Reply With Quote
Old 24th October 2020, 18:49   #12  |  Link
tebasuna51
Moderator
 
tebasuna51's Avatar
 
Join Date: Feb 2005
Location: Spain
Posts: 6,130
Quote:
Originally Posted by Ghitulescu View Post
I wanted to say that not all amplifiers do separate bass to send it to LFE channel.
AFAIK all amplifiers/receivers can separate all bass from all channels to send to subwoofer (not LFE channel), even the cheapest 2.1 to connect to stereo output from PC's.

But, of course, if someone need a LFE channel is free to create it.
__________________
BeHappy, AviSynth audio transcoder.
tebasuna51 is offline   Reply With Quote
Old 25th October 2020, 08:21   #13  |  Link
Selur
Registered User
 
Selur's Avatar
 
Join Date: Oct 2001
Location: Germany
Posts: 6,231
Quote:
BTW, for what you need sox?
I do not 'need' it, but I prefer it as an alternative, since it's way easier to compile for different systems and lots of my scripts use it.
__________________
Hybrid here in the forum, homepage
Notice: Since email notifications do not work here any more, it might take me quite some time to notice a reply to a thread,..
Selur is offline   Reply With Quote
Old 25th October 2020, 11:47   #14  |  Link
tebasuna51
Moderator
 
tebasuna51's Avatar
 
Join Date: Feb 2005
Location: Spain
Posts: 6,130
@Selur
With intermediate files:

sox 8c341.wav front.wav remix 1 2 3 4
sox 8c341.wav surr.wav remix -m 5v0.5,7v0.5 6v0.5,8v0.5 compand 0.1,0.1 -90,-84,-16,-10,-0.1,-3 0.0 -90 0.0
sox --combine merge front.wav surr.wav down51.wav
__________________
BeHappy, AviSynth audio transcoder.
tebasuna51 is offline   Reply With Quote
Old 25th October 2020, 11:58   #15  |  Link
Selur
Registered User
 
Selur's Avatar
 
Join Date: Oct 2001
Location: Germany
Posts: 6,231
Thanks
__________________
Hybrid here in the forum, homepage
Notice: Since email notifications do not work here any more, it might take me quite some time to notice a reply to a thread,..
Selur is offline   Reply With Quote
Old 25th October 2020, 18:01   #16  |  Link
Richard1485
AviSynth monkey
 
Richard1485's Avatar
 
Join Date: Feb 2010
Posts: 398
I prefer Sox as well because it's not been updated in so long that you can pretty much guarantee that you'll be dealing with the same version and be assured of consistent behavior, whereas ffmpeg changes, and Linux distros ship with different versions.

Quote:
Originally Posted by tebasuna51 View Post
sox 8c341.wav front.wav remix 1 2 3 4
This works perfectly.

Quote:
Originally Posted by tebasuna51 View Post
sox 8c341.wav surr.wav remix -m 5v0.5,7v0.5 6v0.5,8v0.5 compand 0.1,0.1 -90,-84,-16,-10,-0.1,-3 0.0 -90 0.0
At this stage, I receive a warning.

Quote:
sox WARN compand: compand clipped 1898 samples; decrease volume?
sox WARN sox: `surr.wav' output clipped 911 samples; decrease volume?
My source file is w64, rather than wav, but that shouldn't matter.
Richard1485 is offline   Reply With Quote
Old 25th October 2020, 21:57   #17  |  Link
tebasuna51
Moderator
 
tebasuna51's Avatar
 
Join Date: Feb 2005
Location: Spain
Posts: 6,130
Quote:
Originally Posted by Richard1485 View Post
At this stage, I receive a warning.
The compand function is not perfect.
Try other values decreasing the gain slowly, for instance:

-90,-84,-10,-4,-6,-2,-0,-1

In theory that means: gain 6 dB for input less than -10 dB, decrease the gain until 4 dB when reach input -6 dB, and decrease the gain until attenuate -1dB at max value 0 dB

But some transients because attacks/decays can cause some clip without importance.
__________________
BeHappy, AviSynth audio transcoder.
tebasuna51 is offline   Reply With Quote
Old 25th October 2020, 23:40   #18  |  Link
Richard1485
AviSynth monkey
 
Richard1485's Avatar
 
Join Date: Feb 2010
Posts: 398
Quote:
Originally Posted by tebasuna51 View Post
Try other values decreasing the gain slowly, for instance:

-90,-84,-10,-4,-6,-2,-0,-1
I don't understand. Do I replace

Code:
sox 8c341.wav surr.wav remix -m 5v0.5,7v0.5 6v0.5,8v0.5 compand 0.1,0.1 -90,-84,-16,-10,-0.1,-3 0.0 -90 0.0
with

Code:
sox 8c341.wav surr.wav remix -m 5v0.5,7v0.5 6v0.5,8v0.5 compand 0.1,0.1 -90,-84,-10,-4,-6,-2,-0,-1
and retry? The result seems to be more clipping:

Quote:
sox WARN compand: compand clipped 3058 samples; decrease volume?
sox WARN sox: `surr.wav' output clipped 1400 samples; decrease volume?
But maybe because you say "without importance", I could have ignored the warning in the first place.
Richard1485 is offline   Reply With Quote
Old 26th October 2020, 14:12   #19  |  Link
tebasuna51
Moderator
 
tebasuna51's Avatar
 
Join Date: Feb 2005
Location: Spain
Posts: 6,130
See the attached image to understand how work the dB points in compand, to obtain a gain of 2 (preserving the full volume of 4 channels in only 2 speakers) with low/medium volume input.

Like you can see is not possible the clip, out of transient volumes because attack/decay values. Use attack/decay values of 0.0 to avoid any clip.

See more info about attack/decay, for instance here.

EDIT: added a second compand option.
Each user can select the desired.
Attached Images
 
__________________
BeHappy, AviSynth audio transcoder.

Last edited by tebasuna51; 26th October 2020 at 15:12.
tebasuna51 is offline   Reply With Quote
Old 27th October 2020, 02:59   #20  |  Link
Richard1485
AviSynth monkey
 
Richard1485's Avatar
 
Join Date: Feb 2010
Posts: 398
Thanks! I'll take the second option.
Richard1485 is offline   Reply With Quote
Reply

Tags
downmix, phase shift

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 15:47.


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