HydrogenAudio

Hosted Forums => foobar2000 => 3rd Party Plugins - (fb2k) => Topic started by: pro_optimizer on 2007-02-21 11:31:03

Title: foo_dsp_downmix
Post by: pro_optimizer on 2007-02-21 11:31:03
Hi, here is once again a new DSP for your pleasure.

The purpose of this plugin is to downmix your 5.1 files to matrix-encoded stereo so you can send them to an external PL1/PL2/etc. capable receiver or just if you have to save quite a deal of harddisk space (you know, the compression ratio between dts and downmixed mp3 is nearly 1:10!). In the latter case I would use foo_dsp_fsurround for decoding (trust me ).

What is the difference to the available downmixers?
- Optional phase shifting. Necessary to handle both AC3 and DTS.
- Very good frequency response for the surround channels (55-24000 Hz @ +/- 0.005db, -3db @ 22Hz)
- Full control over the mixing matrix. Just know what coefficients are used, if it's standards conformant, PL1/PL2 or CS compatible. Customize it if necessary.

Get the plugin here. (http://hosted.filefront.com/prooptimizer)
You also need libfftw (http://files.filefront.com/6628260) for this.
Title: foo_dsp_downmix
Post by: Matyas on 2007-02-21 15:28:50
Now this is awesome.
But to understand it right: This DSP downmixes my 5.1 channel AC3 48kHz, into 2 channel MP3 so that I won't loose _almost_ any channel information, and I will be able to "upmix" it into 5.1 channel with fsurround?

What's the level of lost information (not considering the lost info during lossy-lossy recoding?)

So in this case it is much better than foo_dsp_channelmixer, because it allows you to go back to 5.1?
Title: foo_dsp_downmix
Post by: tebasuna51 on 2007-02-21 18:20:34
1) Propossed controls for left panel 'Mixing coeficients' of 'Downmix AC3/DTS to PL2'

- ProLogic compatibility [CheckBox] (default checked)
If checked Front, Center, LFE, Surround B values not accesibles (grayed)

- LFE Enabled [CheckBox] (default unchecked)
If checked default value 0.7071
If unchecked value 0.0000

- Mix SL + SR ( )  (Option between)  Mix SL - SR (x)

2) The generic matrix is:

Code: [Select]
Lt = FL + 0.7071*FC + A * SL + B * SR
Rt = FR + 0.7071*FC - B * SL - A * SR


When ProLogic compatibility checked:

B = sign(MIX_SL_SR) * sign(A) * sqr(1 - A * A)

3) Values required to recover the exact channels test with Free Surround (Center Image = 1.0, Simple and Non-Linear)

Code: [Select]
- Downmix: A =  0.8165, Mix SL-SR    FS: A = 0.8165, Music Mode (0,0) (Default FS)
- Downmix: A =  0.8660, Mix SL+SR    FS: A = 0.8660, PowerDVD comp. (0,180)
- Downmix: A = -0.8660, Mix SL+SR    FS: A = 0.8660, BeSweet comp. (180,0)

With A = 0.7071, B = 0.7071 and we have dpl I.


@Matyas
Is better than other foo_mixers if we listen through an audio equipment with dpl decoder (attached to PC or standalone player). To listen through headphones or stereo speakers maybe other mixers can be similar or better.

With channel test (each channel separated in time) we can recover the 5 channels with error less than 0.0002. Of course with real sound is not true and is dependent of the relations between the source channels.
For instance, if left and right channel have a common sound is recovered at center channel
Title: foo_dsp_downmix
Post by: pro_optimizer on 2007-02-21 18:50:38
Now this is awesome.
But to understand it right: This DSP downmixes my 5.1 channel AC3 48kHz, into 2 channel MP3 so that I won't loose _almost_ any channel information, and I will be able to "upmix" it into 5.1 channel with fsurround?

What's the level of lost information (not considering the lost info during lossy-lossy recoding?)

So in this case it is much better than foo_dsp_channelmixer, because it allows you to go back to 5.1?


Its hard to explain what information you may exactly lose, so I'll try to be as precise as possible.

The following things may get lost during the encoding step:
- the directions of a few sound sources that "clash". I will later explain what clashing means.
- sounds that accidentally cancel each other out. This is not very likely or noticeable.
- the information whether a center sound should be played by the center speaker or by left+right.
  This may be a problem if one has a weak center speaker but you can still turn down the center image in the decoder
  (and thus have left and right play the center sounds instead).
 
So let's talk about clashing.
Clashing means that in a short period of time (e.g. 0.2 seconds) multiple sound sources at different locations occupy the same freqencies.
There are 2048 frequency bands so this is not as likely as it may seem.
But it usually happens when identical instruments at different locations play the same melody in parallel.
In this case most decoders will place the offending instruments further behind (in the surrounds) than they were in the original sound.
It happens because the phase angles between the offenders (and thus between the stereo left/right channels, if the offenders where placed one left and the other right) are pretty random and this is what the decoders use for front-back positioning.

To make a wild guess, I would say that in an average song, you won't lose 90% of the channel information.
There may be songs where clashes happen relatively frequently which means you get a more diffuse surround image and there may be
songs where the upmix is not distinguishable from the original. That's why you may want to compare the original and the upmix.

There are still some possible improvements in the decoder (e.g. the output channel volumes may be slightly too low,
the positioning could more precise by a few degrees and maybe there are still bugs in it) but these things are only a matter of time.
In fact it should be possible to have the decoder identify the clashes and trace back to which sources those frequencies belong by cross-correlation but
it's not yet clear how one can do this on an average CPU. Once again, time will tell.


Btw: I use the following DSP chains for comparing 5.1 (in my case mostly dts) to the upmix:
1. no dsp
2. downmix ac3/dts (phase shift) -> free surround (center image=0.8, linear steering, exact reconstruction) -> equalizer (+2db, seems necessary)
3. downmix ac3/dts (phase shift) -> pl2 wrapper
4. downmix ac3/dts (phase shift) -> ATSurround-AS2
5. downmix ac3/dts (phase shift) -> ATSurround-ASr
When I do the comparisons via headphones, each of the chains is followed by Dolby Headphone -> SRC Resampler(96000) -> Convolver(Eq)


Just that it's possible doesn't mean that one should do it, though.
I wouldn't replace my 5.1 files by mp3 unless I were _really_ short on disk space.

1) Propossed controls for left panel 'Mixing coeficients' of 'Downmix AC3/DTS to PL2'

- ProLogic compatibility [CheckBox] (default checked)
If checked Front, Center, LFE, Surround B values not accesibles (grayed)

- LFE Enabled [CheckBox] (default unchecked)
If checked default value 0.7071
If unchecked value 0.0000

- Mix SL + SR ( )  (Option between)  Mix SL - SR (x)

2) The generic matrix is:

Code: [Select]
Lt = FL + 0.7071*FC + A * SL + B * SR
Rt = FR + 0.7071*FC - B * SL - A * SR


When ProLogic compatibility checked:

B = sign(MIX_SL_SR) * sign(A) * sqr(1 - A * A)

3) Values required to recover the exact channels test with Free Surround (Center Image = 1.0, Simple and Non-Linear)

Code: [Select]
- Downmix: A =  0.8165, Mix SL-SR    FS: A = 0.8165, Music Mode (0,0) (Default FS)
- Downmix: A =  0.8660, Mix SL+SR    FS: A = 0.8660, PowerDVD comp. (0,180)
- Downmix: A = -0.8660, Mix SL+SR    FS: A = 0.8660, BeSweet comp. (180,0)

With A = 0.7071, B = 0.7071 and we have dpl I.


@Matyas
Is better than other foo_mixers if we listen through an audio equipment with dpl decoder (attached to PC or standalone player). To listen through headphones or stereo speakers maybe other mixers can be similar or better.

With channel test (each channel separated in time) we can recover the 5 channels with error less than 0.0002. Of course with real sound is not true and is dependent of the relations between the source channels.
For instance, if left and right channel have a common sound is recovered at center channel


Thanks for the details.

Checkboxes: ok.
Mix SL - SR (x): Why do we need this? To be able to model SQ encoding, too?
I'll change the defaults from 0.707 to 0.7071.
Title: foo_dsp_downmix
Post by: tebasuna51 on 2007-02-21 19:34:58
Mix SL - SR (x): Why do we need this? To be able to model SQ encoding, too?

The default FS mode: Music Mode (0,0) need a initial downmix with Mix SL-SR.

And other people also experiment with this kind of mixes, this is a old discussion (http://forum.doom9.org/showthread.php?t=112122).

Really for me is not necessary but maybe you need change the default FS.
Title: foo_dsp_downmix
Post by: pro_optimizer on 2007-02-21 19:53:44

Mix SL - SR (x): Why do we need this? To be able to model SQ encoding, too?

The default FS mode: Music Mode (0,0) need a initial downmix with Mix SL-SR.

And other people also experiment with this kind of mixes, this is a old discussion (http://forum.doom9.org/showthread.php?t=112122).

Really for me is not necessary but maybe you need change the default FS.


Ah, I see.
I would not use the music mode to play music for which I know that it's properly encoded.
Music Mode is more useful if you don't really know if the music you send through it is encoded or not because
it will at least not invert (potentially arbitrary) parts of it.
One cannot really encode with SL-SR because centered surround sources would be mostly cancelled out by this.
e.g. Lt = 0.8165x-0.5774x = 0.2391x is already quite low and its even worse for the DPL1 matrix:
Lt = Rt = 0.7071x-0.7071x = 0 (in words: zero)
Title: foo_dsp_downmix
Post by: Matyas on 2007-02-22 08:35:54
Quote
When I do the comparisons via headphones, each of the chains is followed by Dolby Headphone -> SRC Resampler(96000) -> Convolver(Eq)


Why do you use the SSRC resampler to go up to 96kHz? And what's the point behind using Convolver instead of the built-in EQ?
Title: foo_dsp_downmix
Post by: pro_optimizer on 2007-02-22 10:17:43
Why do you use the SSRC resampler to go up to 96kHz? And what's the point behind using Convolver instead of the built-in EQ?


The reason why I don't use the built-in EQ is this one. (http://www.hydrogenaudio.org/forums/index.php?showtopic=52385)

The reason for using SRC is much more subjective, probably I cannot ABX it against the PPHS resampler.
I know how SRC works and that it does, in principle, the Right Thing whereas I don't know how a polyphase resampler works and what the quality tradeoffs involved are. So SRC gives me a better gut feeling at the moment
Title: foo_dsp_downmix
Post by: Matyas on 2007-02-23 08:27:59
@EQ: Thanks for the link.
@SSRC: the question is not why SSRC, but why do you need 96Khz before the EQ which anyway goes directly to your headphones. Isn't 44kHz enough in this case?
Title: foo_dsp_downmix
Post by: pro_optimizer on 2007-02-23 15:50:54
@EQ: Thanks for the link.
@SSRC: the question is not why SSRC, but why do you need 96Khz before the EQ which anyway goes directly to your headphones. Isn't 44kHz enough in this case?

Well I resample the music because
a) I have an Audigy soundcard which supports only 48/96/... KHz natively.
Therefore it resamples 44.1 KHz music internally and its resampler is said to be quite crappy.
b) the convolver does not match the sampling rates of the filter kernel and the incoming music.
Therefore one has to resample the music to the rate of the kernel.

So the question remains: why 96 KHz and not 48.
Probably it doesn't matter. But at least I don't have to downsample 96KHz music this way.
(And, even if my soundcard's DACs were really bad their lowpass filter would still not reach down into the audible range. )
Title: foo_dsp_downmix
Post by: Hancoque on 2007-04-25 17:18:35
I have found a strange behaviour when downmixing some DTS material with this plugin. With the "Channel Mixer" plugin the sound seems centered for the listener. But if I use the "Downmix AC3/DTS" plugin instead, some elements seem to be shifted more to the right (DTS mode) or to the left (AC3 mode).
Title: foo_dsp_downmix
Post by: klez on 2008-03-17 21:11:27
For any Reason, this Plugin doesnt Work here...
Its loadable, but every File which leaves the Converter (Wav Output) is still a 5 Channel WAV.
Even if i Change the "Master Gain" in the Configuration Dialog , nothing Happens.

Can someone help me?
Title: foo_dsp_downmix
Post by: pro_optimizer on 2008-08-12 03:33:21
For any Reason, this Plugin doesnt Work here...
Its loadable, but every File which leaves the Converter (Wav Output) is still a 5 Channel WAV.
Even if i Change the "Master Gain" in the Configuration Dialog , nothing Happens.

Can someone help me?


This is because the plugin currently downmixes only 5.1 input (i.e. no 5.0 as it seems to be the case with your source file). A temporary workaround before I pull myself together and add that damn special case would be that you put channel mixer before the downmix plugin and tell it to produce and additional dummy subwoofer channel.

Btw: Sorry for the immense posting delay! Somehow I didn't receive a reply notification for you.
Title: foo_dsp_downmix
Post by: -Tiziano- on 2009-12-31 09:41:38
Dear Friends

Tod S indicated me in this topic:
http://www.hydrogenaudio.org/forums/index....mp;#entry676408 (http://www.hydrogenaudio.org/forums/index.php?showtopic=77125&st=0&gopid=676408&#entry676408)
the presence of your interesting topic.

I'm interested to experiment Foobar2000 as Dolby Prologic II encoder. So I ask:

the library:libfftw3f-3.dll for windows .. where do I have to install it ? In what directory please ?
What file of foo_dsp_downmix I need please ? because in your link there are several files. Anyway I have not clue were to install it/them ...

And I have aother qeustions as:
Is it possible to encode in Pro logic IIx and IIz ? Or is it too soon ?


About LFE Channel: I start from 6 files and or an interleaved 6 channel .WAV file that has discrete tracks for each channel LFE included. In what manner can I treat it please ?
Because till now, the LFE's separate tracks gave me some issue.

I thank you very much for your help and: happy new year 2010 to everybody
Title: foo_dsp_downmix
Post by: 2E7AH on 2009-12-31 09:47:07
the library:libfftw3f-3.dll for windows .. where do I have to install it ? In what directory please ?

In foobar's installation folder

Is it possible to encode in Pro logic IIx and IIz ? Or is it too soon ?

I posted you link in your own thread: http://www.hydrogenaudio.org/forums/index....showtopic=50713 (http://www.hydrogenaudio.org/forums/index.php?showtopic=50713)
Title: foo_dsp_downmix
Post by: -Tiziano- on 2009-12-31 11:00:39
the library:libfftw3f-3.dll for windows .. where do I have to install it ? In what directory please ?

In foobar's installation folder

Is it possible to encode in Pro logic IIx and IIz ? Or is it too soon ?

I posted you link in your own thread: http://www.hydrogenaudio.org/forums/index....showtopic=50713 (http://www.hydrogenaudio.org/forums/index.php?showtopic=50713)


Hi 2E7AH.

ok perfect but in the main directory or in the "component" directory please ?

And: yes I saw your message in my thread but it's not clear to me .. so I have of course questions here below:

Do I have to put foo_dsp_pl2.dll in window/system ? because you are talking about: PL2XDLL.dll and I have not clue if it's the same. ( there are also: foo_dsp_fsurround.dll and foo_dsp_downmix.dll .. I don't know if I need them or not ... )
And also: How can I start conversion with Foobar ? ( I'm looking for some command on it just now without being successful ) ...

EDIT: Sorry i think to have found ho to convert, just now. Please confirm it: right-click and "convert" selecting the plug in .. correct ? Because I find "command line" also and sincerely I would prefer do not have any "command line" .. who remembers about commands to give ?  END-EDIT


Thank you very much
Title: foo_dsp_downmix
Post by: 2E7AH on 2009-12-31 11:18:54
PL2XDLL.dll and libfftw3f-3.dll in main foobar folder, other .dlls in components folder

[edit] about converting, you have DSP window in processing tab of converter dialog
Title: foo_dsp_downmix
Post by: -Tiziano- on 2009-12-31 14:13:54
PL2XDLL.dll and libfftw3f-3.dll in main foobar folder, other .dlls in components folder

[edit] about converting, you have DSP window in processing tab of converter dialog


ok perfect ... but I don't find: PL2XDLL.dll 
Title: foo_dsp_downmix
Post by: lvqcl on 2009-12-31 15:36:45
You need PL2XDLL.dll for foo_dsp_pl2, not for foo_dsp_downmix. But if you use foo_dsp_pl2, look here (http://www.hydrogenaudio.org/forums/index.php?s=&showtopic=50713&view=findpost&p=511297).
Title: foo_dsp_downmix
Post by: -Tiziano- on 2010-01-01 19:32:00
Yep, thank you really very much

2E7AH has helped me to solve some little issue I had and now with Foobar2000 I'm able to get an interleaved 6 channels ( 5.1 ) .WAV ( AC3/DTS is the Foobar2000's library I use ) file, produced with Nuendo, and create a .WAV or .MP3 Pro Logic II encoded ! great !! It works really fine

Now the following step, not yet solved, is:

How to get 7.1 encoded ( Pro Logic IIx ) instead of 5.1.

This is really the maximum to reach, I think ...




P.S. off-topic: I uploaded my Avatar but it's not appearing here yet ...
Title: foo_dsp_downmix
Post by: 2E7AH on 2010-01-02 10:58:48
Do you want to upmix or downmix?

You can use matrix mixer if you know the matrix for DPL IIx
If you don't know the matrix you can try with DPL II upmix to 5.1 and then use matrix mixer for other 2 channels, like this for example:
(http://img685.imageshack.us/img685/5695/sshot6u.th.png) (http://img685.imageshack.us/img685/5695/sshot6u.png)

or use only matrix mixer with this matrix (http://www.hydrogenaudio.org/forums/index.php?showtopic=2087&view=findpost&p=19825) for example (that's for downmix, you should invert it for upmix)

That would be for fast encoding, and none of that has anything to do with DPL of course. Probably the best would be as you were doing with Nuendo, as here you can't change phase, or add delay, or do bend pass as DPL IIx is doing. And you'll need to have that information, or experiment with DPL IIx encoded file and try to distill something
Title: foo_dsp_downmix
Post by: -Tiziano- on 2010-01-02 11:13:40
Do you want to upmix or downmix?

You can use matrix mixer if you know the matrix for DPL IIx
If you don't know the matrix you can try with DPL II upmix to 5.1 and then use matrix mixer for other 2 channels, like this for example:
[a href="http://img685.imageshack.us/img685/5695/sshot6u.png" target="_blank"]
Title: foo_dsp_downmix
Post by: 2E7AH on 2010-01-02 11:29:17
OK, you can try with ffdshow and use downmix to DPL II. it will produce the wanted stereo effect I think
Title: foo_dsp_downmix
Post by: 2E7AH on 2010-01-02 18:55:08
I tried downmixing 8ch with ffdshow Dolby Prologic II and this is the matrix
(http://img22.imageshack.us/img22/4974/sshot2kp.th.png) (http://img22.imageshack.us/img22/4974/sshot2kp.png)

SL and SR aren't downmixed

The stereo effect is similar to what downmixer component from this thread is doing, so try it

CyberLink downmixes very differently: back and side channels are exclusively at corresponding front channels
Title: foo_dsp_downmix
Post by: -Tiziano- on 2010-01-02 19:39:25
I tried downmixing 8ch with ffdshow Dolby Prologic II and this is the matrix
(http://img22.imageshack.us/img22/4974/sshot2kp.th.png) (http://img22.imageshack.us/img22/4974/sshot2kp.png)

SL and SR aren't downmixed

The stereo effect is similar to what downmixer component from this thread is doing, so try it

CyberLink downmixes very differently: back and side channels are exclusively at corresponding front channels


Ok perfect ... in this way the amplitudes' relationships among channels are respected, but what about the phase ? I mean: I have to anticipate 90° some signal and delay 90° etc ... in what manner can I do that with that mixer please ?

P.S. in order to avoid misunderstanding: I have to do the same thing I'm doing now with the plug-in AC3/DTS as we were talking in private message, but coding 8 channels ( 7.1 ) instead of 6 ( 5.1 ) )


( is ffdshow in you website I think ... is it correct ? or is that one please ? ffdshow on Sourceforge.net (http://sourceforge.net/projects/ffdshow/) )
Title: foo_dsp_downmix
Post by: 2E7AH on 2010-01-02 20:11:47
I don't know if phase shifting is needed as rear channels aren't downmixed or else

ffdshow is constantly developed. the latest is from dec.2009, but search other site not sourceforge

eac3to is also tool you may try for batch processing, for example:

eac3to 8ch.wav out.wav -down2 -phaseshift
Title: foo_dsp_downmix
Post by: Sylph on 2010-07-21 15:22:42
This needs to get updated for the latest version.
Title: foo_dsp_downmix
Post by: CoRoNe on 2012-02-11 21:03:54
It seems the downloadlink in the first post is dead and the only place I found so far with a working downloadlink is THIS (https://sites.google.com/site/casksabode/foobar-1/components) one (version 0.2).
Perhaps I'm looking in the wrong place, but otherwise it may seem [a href='index.php?act=findpost&pid=473785']tebasuna51's post[/a], with some useful proposals, is completely ignored.

I was wondering... https://en.wikipedia.org/wiki/Matrix_decode...oding_.282:5.29 (https://en.wikipedia.org/wiki/Matrix_decoder#Dolby_Pro_Logic_II_matrix_encoding_.282:5.29) tells me the DPL2 matrix, which foo_dsp_downmix also seems to be using (except that √½ ≠ 0.7070), is as follows:
1   0   0.7071 (√½)   0.8165 (√⅔)   0.5774 (√⅓)
0   1   0.7071 (√½)   0.5774 (√⅓)   0.8165 (√⅔)
But https://en.wikipedia.org/wiki/Dolby_Pro_Log...coding_matrices (https://en.wikipedia.org/wiki/Dolby_Pro_Logic#Dolby_encoding_matrices) tells me the DPL2 matrix is:
1   0   0.7071 (√½)   0.8718 (√19/25)   0.4899 (√6/25)
0   1   0.7071 (√½)   0.4899 (√6/25)    0.8718 (√19/25)

Which one is the right one?

Furthermore, is there a way to determine if Phase Shifting is necessary for DTS?
Title: foo_dsp_downmix
Post by: romor on 2012-06-16 15:58:35
Links are dead. It wasn't trivial to find it, that's why I uploaded it for future use here: http://www.hydrogenaudio.org/forums/index....showtopic=95569 (http://www.hydrogenaudio.org/forums/index.php?showtopic=95569)
Title: Re: foo_dsp_downmix
Post by: Rollin on 2017-11-11 18:08:57
It seems plugin doesn't work with modern versions of foobar2000. No downmix is done.
Title: Re: foo_dsp_downmix
Post by: zeremy on 2017-11-11 18:30:42
It seems plugin doesn't work with modern versions of foobar2000. No downmix is done.
Use channel mixer http://skipyrich.com/wiki/Foobar2000:Channel_Mixer
( in channel mixer general tab output select 6 channels & in Upmix tab select Mode Off)
before  foo_dsp_downmix in the chain and it will work.
Title: Re: foo_dsp_downmix
Post by: Rollin on 2017-11-26 14:36:22
Use channel mixer http://skipyrich.com/wiki/Foobar2000:Channel_Mixer
( in channel mixer general tab output select 6 channels & in Upmix tab select Mode Off)
before  foo_dsp_downmix in the chain and it will work.
Thanks, it works. But what exactly is going on?
Title: Re: foo_dsp_downmix
Post by: zeremy on 2017-11-26 14:57:33
From what I have understood  the plugin needs FL FR C LFE BL BR  for it to work.
So you need to map SL SR to BL BR.
Channel Mixer does the mapping.
You could also use the Matrix Mixer.

(https://i.imgur.com/pncOhf9.png)