Log in

View Full Version : BeSweet v1.4b12 & Dolby Surround II Matrix


frank
24th June 2002, 23:39
BeSweet 1.4b7 has a plugin that can downmix DS2 audio tracks. In newer versions this downmix is built-in. But the downmix has heavy bugs, centre channel C sounds 16 dB louder than L, R! I searched the internet for the right downmix matrix but no success.
In this thread I'll explain the technics and derive the right DS2 downmix matrix parameters. Basics of Dolby Pro Logic are published on http://www.dolby.com

Dolby Surround Pro Logic II (DS2)Dolby:
In Pro Logic decoders the control circuit is looking at the relative level and phase between the input signals. This information is sent to the variable output matrix stage to adjust VCAs (voltage controlled amplifiers) controlling the level of antiphase signals. This is called a feed-forward system.
Pro Logic II looks at the same input signals and servos them to match their levels. These matched audio signals are sent directly to the matrix stages to derive the various output channels. Because the same audio signals that feed the output matrix are themselves used to control the servo loop, it is called a feedback-design.Dolby says that DS2 is compliant to Pro Logic. The encoding matrix is simpler, the decoder has significant improvements.

Downmix matrix
In Pro Logic the rear channels Ls, Rs are stored as ONE mono surround signal S with symmetrical amounts into the stereo wave. In DS2 the rears Ls, Rs are stored with DIFFERENT amount of levels. That's the trick! The new feedback-design allows to steer the gain of Ls, Rs.

Pro Logic
Lt = 1.0*L + 0.707*C - 0.707*Ls - 0.707*Rs left-total
Rt = 1.0*R + 0.707*C + 0.707*Ls + 0.707*Rs right-totalThe level amounts are stored symmetrically into the wav (Lt, Rt).

Pro Logic II
We set the amount of acoustic power of Rs in Lt equal to the half of Ls. Or, Rs has a level of -3 dB referred to Ls. Same to Ls in Rt. The total power sum of each channel L, R, C, Ls, Rs equals 1.
For acoustic power we must square!

a*a*Ls*Ls + 2*a*a*Rs*Rs = 1
max levels = 1
a*a + 2*a*a = 1
--> a*a = 1/3 = 0.3333 --> a = 0.5774
--> 2*a*a = 2/3 = 0.6666 = b*b --> b = 0.8165Lt = 1.0*L + 0.707*C - 0.8165*Ls - 0.5774*Rs
Rt = 1.0*R + 0.707*C + 0.5774*Ls + 0.8165*RsNow it's possible to generate a rear directional steering signal with an operational amplifier, computing Lt+Rt but eliminating L, R, C. The output
(Lt+Rt)' = 0.2391*(Rs - Ls)
is fed to a polarity splitter which will control Ls, Rs outputs.
If amount of Rs < Ls then output will be negative for left directional dominance, and if Rs > Ls the output will be positive for right directional dominance.
So far to the principle of operation, in reality the Pro Logic II decoder is much more complicated.

The actual coefficients used must be scaled downwards to prevent arithmetic overflow.
The sum of unscaled coefficients is
1 + 0.707 + 0.8165 + 0.5774 = 3.101
All coefficients must be multiplied by 1/3.101 = 0.3225
Downwards scaling by -9.8 dB.

That means the DS2 downmix has an attenuation of -9.8 dB.
The probability of overflow is very small. You should start a 1-step decoding with a static gain of +9.8 dB. The resulting dialog level will be unchanged in this case.

Important: For downmix you ever have to use DRC because more acoustic power will be concentrated in less channels!

Pro Logic II with LFE (Not recommended by Dolby)
Lt = 1.0*L + 0.707*C + 0.707*LFE - 0.8165*Ls - 0.5774*Rs
Rt = 1.0*R + 0.707*C + 0.707*LFE + 0.5774*Ls + 0.8165*RsAll coefficients must be multiplied by 1/3.808 = 0.2626
Downwards scaling by -11.6 dB.

Because of the small overflow probability and low LFE level it is sufficient to work with -9.8 dB scaling from above.

frank
25th June 2002, 00:49
Here comes the corrected DS2 BeeSweet plugin.
Please help compile, I don't have MS C++.
With Besweet 1.4b7 you can test the plugin. The following BeeSweet versions until b11 include the buggy version.

Debugged source BS_downmix.c from DSPGuru in the next thread.

Corrected downmix matrix:
{ // l,c,r,sl,sr,lfe
buffer[j] =buffer[i++]* 0.3225; // fl. -> l.
buffer[j] +=buffer[i] * 0.2280; // c. -3db -> l.
buffer[j+1] =buffer[i++]* 0.2280; // c. -3dB -> r.
buffer[j+1]+=buffer[i++]* 0.3225; // fr. -> r.
buffer[j] +=buffer[i] *-0.2633; // sl -1.76dB -> l.
buffer[j+1]+=buffer[i++]* 0.1862; // sl -4.77dB -> r.
buffer[j] +=buffer[i] *-0.1862; // sr -4.77dB -> l.
buffer[j+1]+=buffer[i++]* 0.2633; // sr -1.76dB -> r.

frank
25th June 2002, 01:09
Here the debugged source to compile.

DSPguru
25th June 2002, 04:55
frank's matrix had been integrated into beta12.
didn't debug it.

post your comments.

trg100
25th June 2002, 11:12
Brilliant work frank :D It works great now. I had a quick look at the source myself but it would've taken me ages to figure it all out. Thanks.

For completeness' sake here (http://members.aol.com/trg100uk/ds_tests_2.html#frank) is a shot of my test file downmixed with your new matrix. (It is zoomed not normalised ;))

I have written to cyberlink asking why DS2 encoded wav/mp3 files don't work in PoerDVD but AC3 files do. Am not holding my breath though!

frank
25th June 2002, 13:26
Thanks for the quick help DSPGuru, trg100. I'm very pleased.

trg100,
your tests show an issue on BeSweet's LFE level.
I'm missing the -3 dB attenuation to each track. The LFE level must be equal to the centre. Did you set Azid's LFE downmix parameters right? (-3db into L,R)
Or, is there another issue in BeSweet? BeSweet does the LFE downmix prior the matrix.
Please verify.

trg100
25th June 2002, 14:10
You're quite right frank. I had specified -L 0db. I had rerun the test with -L -3db and updated the picture (http://members.aol.com/trg100uk/ds_tests_2.html#frank). The LFE channel is now equal in voume to the centre channel :)

To be honest I wasn't exactly sure why the -3db was necessary but I notice HeadAC3he does it automatically.

I've added another picture (8) which shows that the transitions are not perfectly smooth. I wonder if this is due to the Dolby Digital compression.

frank
25th June 2002, 15:21
Yeah! Now I can sleep well. :cool:
The constant signal power for all reproduced channels is maintained now.

C and LFE are splitted in two parts with half of the power. Means -3 db level attenuation if you don't want any power change. The decoder sums the two parts back into ONE channel!

LFE is a small bandwith low bass channel. Greater signal raising time and delaying. I think these artifacts come from Dolby compression and aren't audible at this low frequencies.

For downmixing is no need to mix the LFE if the AC-3 tracks are right mastered - Dolby says. 5ch into 2ch mix is a consumer adaption. And which consumer has a separated active subwoofer (30 cm loudspeakers)? Very expensive technics, needed by THX systems only. But this HiFi fans normally use 5.1 audio.

kxy
26th June 2002, 14:24
trg100,

Your picture #4 and #7 are identical, at least I dont see a difference. Does it mean HeadAC3he and BeSweet now produces the identical ds2 downmix?

frank
26th June 2002, 17:46
In principle YES. :)


Here a DS2 file to test the surround channels (speaking voice).

frank
27th June 2002, 07:05
I compared transcoding to WAVs (no floating point).

1) DS2 downmix is fully compliant to DS :). Sounds equal on my DS receiver if the rear filter was disabled on DS (less muffled sound in the rears).

2) Now DS2 downmix has additional -4...-5 dB attenuation compared with DS and old versions!
I've tested with +11.7 dB static gain to DS and 9.8 dB to DS2. There should be same results.
I think that comes from Azid's different operating modes (2/0 vs. 3/2) and the implementation in BeSweet.
More tests are running to this issue.

Regards
frank

frank
27th June 2002, 23:11
Latest test results of transcoding AC-3 5.1 49 min
-27 dB dialog level, DRC normal

Gain to maintain dialog level
(compensation of downmix attenuation)

BeSweet 1.4B12
DS +11.7 dB
DS2 +14.5 dB (6+8.5, LFE included )

headAC3he
+10 dB

DSPguru
28th June 2002, 08:56
Originally posted by frank
BeSweet 1.4B12
DS +11.7 dB
DS2 +14.5 dB (6+8.5)good work frank! please post logfiles.

fiorettoe
28th June 2002, 09:08
Frank, I had tried to play your mp3 file with PowerDVD4 (with Dolby Pro Logic2 enabled).

It works, I hear the sound in the rear speakers.
But how can I play the same file in DS2 in OGG format? PowerDVD4 doesn't accept OGG file format.

frank
28th June 2002, 09:53
Convert mp3 with WinAmp's Diskwriter into WAVs, and encode what ever you want. :D

fiorettoe
28th June 2002, 10:03
If I open a OGG file with PowerDVD4 doesn't work....why???

frank
28th June 2002, 10:12
Hey, since when is OGG a DVD/VCD/SVCD/AUDIO standard??
PowerDVD knows: PCM, AC3, mp2, DTS...

fiorettoe
28th June 2002, 10:19
So which player must I use for OGG?

If I use Windows Media Player, it doesn't support the multi-speaker.

frank
29th June 2002, 09:05
Compensation of downmix attenuation
BeSweet 1.4B12
DS +11.7 dB
DS2 +14.5 dB (6+8.5)Sorry, no log file :(
But the commandline I used at DS2 was

"d:\DVD\AudioTools\BeSweet\BeSweet.exe"
-core( -input "i:\test\kiss1 AC3 T01 3_2ch 448Kbps DELAY 0ms.ac3"
-output "i:\test\test-ds2.wav" -2ch )
-azid( -s surround2 -c normal -g 6db -L -3db )
-ota( -g 8.5db )
-ssrc( --rate 44100 )

The tests included LFE.

Following tests without splitted gain and without LFE brought the expected results. :D
LFE ( -L -3 dB ) reduced the sound level about -4.4 dB!! That's wrong, in Azid's 2/0 downmix matrix that reduction is only -1.78 dB.

DS2 +10 dB setting as ota gain compensates the matrix attenuation (equal to the theory). Same results as headAC3he.
...
-output "i:\test\test-ds2.wav" -2ch )
-azid( -s surround2 -c normal ) <<<<< or -L 0 (not 0db!)
-ota( -g 10db )
...

BeSweet has ~6dB lower bit noise at lowest sound levels than headAC3he. Measured with CEpro2.

trg100
30th June 2002, 16:21
fiorettoe: What sounds card/speaker setup are you using to play back frank's file? Does the DS2 channel mapping works correctly with powerDVD? On my 4 channel SBlive it is messed up unless I reencode to a 2.0 AC3. PowerDVD and WinDVD 4 are the only payers with DPL2 I know of so there's nothing that can playback DS2 oggs as far as I know.

fiorettoe
1st July 2002, 07:41
I have a SbLive 4 channels.

Another little question:

Why I cannot play a OGG file correctly (without trouble) with Windows Media Player 6.4?
With Winamp 2.80 I have none problem; while con Windows Media Player 6.4 yes. PS: I have a Pentium 2 450MHz, 128Mb RAM.

Thank You

frank
1st July 2002, 10:21
A little bit off-topic in this thread...

Well, your problem ist WINDOWS and the Direct Show filters (that used by MP6.4)! The are a part of DirectX. May be a DirectX update helps.
Or delete other DS filters.
OGG inserts a DS filter, it seams that doesn't work for you, or isn't activated in MP6.4 or PowerDVD.
And I've heard that SBL drivers are buggy on multi ch decoding.

Winamp uses it's own well operating plugins.

fiorettoe
1st July 2002, 15:56
Could be that The OGG's Directshow filter aren't so optimized like the winamp's plugin?

fiorettoe
1st July 2002, 18:54
BINGO!!!!!!

If in the Graphedit Graphic I use "Defaul WaveOut Device" the sound is trouble, while with "Default Directsound Device" is all OK.

Why OGG file doesn't work with "Defaul WaveOut Device" for audio renderers?

Is it a bug?

I would use "Defaul WaveOut Device" cause to play AC3 file is the only audio renderers that permit me to hear in multi-speaker

TNX

frank
2nd July 2002, 16:53
Have made some additions to my first posting for better understanding.

fiorettoe
2nd July 2002, 17:59
Sorry Frank :(

but who can help me about my/our problem?

Valex
10th October 2002, 12:21
@frank

As I understand all your math is based on:
We set the amount of acoustic power of Rs in Lt equal to the half of Ls.

Where in the sources at dolby.com I can find this (I read Principles of operation but did not find such statement)?

As I understand servo circuit in DPLII looks for _current_ levels. So before both cannles are scaled:

Lt' = kl * Lt = k * Lt
Rt' = kr * Rt = (1/k) * Rt
[k = kl = 1/kr]

Lt = 1.0*L + 0.707*C - 0.8165*Ls - 0.5774*Rs
Rt = 1.0*R + 0.707*C + 0.5774*Ls + 0.8165*Rs

C = Lt' + Rt' = k*Lt + (1/k)*Rt = ... -(0.81*k + 0.57/k) * Ls + (0.57*k + 0.81/k) * Rs

So we cannot get rid of surround in center channel! But DPLII is stated to provide more channel separation. Where am I wrong?

frank
10th October 2002, 16:27
As I understand all your math is based on:
We set the amount of acoustic power of Rs in Lt equal to the half of Ls.Yes, it is.
This relation should maintain the compatibility to normal Dolby Surround (DS).
The rest of the math is based on the principle of constant power.
If you enhance the difference of Ls, Rs you'll get lower compatibility to DS, if you lower the difference you'll get less separation of the rear channels.

PL2 was created by Jim Fosgate letting Dolby handle the license for PL2. The decoder details are not published.
Dolby Surround Pro Logic II Decoder Principles of Operation (http://www.dolby.com/tech/l.wh.0007.PLIIops.html)

But we can measure the output, and analyze the operation!
And that has been done.
Since summertime you can buy in europe receivers with built-in DPL2 decoder. With a special DPL2-mastered test CD I could verify the function.
You also can make tests with PowerDVD XP 4.0 Deluxe and the built-in Dolby certified DPL2 decoder (You need a 5.1 sound chip and decoded outputs on your sound card.)

As Roger Dressler (Dolby) said: The Encoder is simple but the decoder was significant improved.
The job of an active decoder like Pro Logic or Pro Logic II is to keep a dominant signal such as dialogue from leaking from the surround speakers whether it is directly in the center channel, slightly off center, or even panned all the way to the full left or right of the soundstage.

The decoding equations are not simply. In Pro Logic II, the most significant technical difference from Pro Logic is that it incorporates a "feed back" design, in that the directional enhancements are applied back to the input of the active matrix.
The compensation of C channel is realized in such a manner. You cannot describe the function of the DPL2 decoder with linear equations as a passive matrix.

Dolby Surround Pro Logic II - The Technology and the Sound (http://www.hometheaterhifi.com/volume_8_1/dolby-prologic2-3-2001.html)

Valex
11th October 2002, 09:06
@frank
You cannot describe the function of the DPL2 decoder with linear equations as a passive matrix.

If encoded channels are a linear combination of input channels what non-linear operations could be done in decoder?

If you enhance the difference of Ls, Rs you'll get lower compatibility to DS

Why? (math?)

But we can measure the output, and analyze the operation! And that has been done.

But what we get at output of DPLII decoder is not the same as it was at input of DPLII encoder. Maybe it is more useful to analyse DPLII encoder?

DSPguru
11th October 2002, 13:09
Originally posted by Valex
If encoded channels are a linear combination of input channels what non-linear operations could be done in decoder?linear is when vector of samples out equals to a matrix multiply M with input vector in. or, you could look at it as :
out(i)=in(1)*ai1+in(2)*ai2, etc'..
when aij are constant coefficients.
dpl2 decoders implements an adaptive matrix M, which its coefficients is derived from a feedback of previous results.
that's not linear.

Why? (math?)anything that violates ds coefficients will lower compatability.

ux-3
11th October 2002, 13:20
@Valex: You will never be able to restore the dpl2 input precisely! That is math, linear transforms. You come from R5 and transform to R2. If you actually make full use of the R5, there is no way back. Should you actually use not the full R5 but only a subspace, then it could be done. But if your original signal carries 5 independent signals, it will not work. So whatever the decoder does, it is going to be psychoaccoustic guesswork. I can tell you from experience, that it is pretty good guesswork! The articles that Frank linked to turned out to be pretty interesting and informative. I took links to them for reference. Lots of reading! Thanks Frank for linking to them!

Valex
11th October 2002, 14:03
@ux-3
You will never be able to restore the dpl2 input precisely! That is math, linear transforms. You come from R5 and transform to R2.

Yes! It is what I mean when said, that maybe is is better to analyze the encoder (R5->R2) process then decoder (R2->R5) because it is different processes! So we cannot suppose that output vector of channels Sout = [Lout, Cout, Rout, SLout, SRout] after decoder is the same that that was at encoder's input Sin = [Lin, Cin, Rin, SLin, SRin] and we cannot just reverse R2->R5 transform and say that it is R5->R2 transform.

Just one more interesting link:
http://www.smartdev.com/CS-paper.html
This surround mixing method uses 5-to-2-channel transform backwards-compatible with DPL (not II). And it have variable mixing coeffs at encoder stage.

frank
11th October 2002, 14:19
...what non-linear operations could be done in decoder?Please read the last linked article in my posting carefully. It's a very good explanation. But it's hard to understand when you are not familiar with electronics.
And this Implementing Dolby Pro Logic I/II Decoder (http://forum.doom9.org/showthread.php?s=&threadid=35209)
Pro Logic has the signal-cancellation built-in. The decoder includes an active matrix with feedback design, servo circuits...
A DPL software decoder therefore needs some DSP modules, and a lot of engineering know-how to simulate that.
Are you familiar with analogue circuits an her digital simulation, with Fourier-, Z-transformation, digital filters, DSP signal processing??If you enhance the difference of Ls, Rs you'll get lower compatibility to DS.Hm, should better saying to stereo, because of unsymmetrical rear signal parts with different phase? In DS you have a symmetrical splitting into Lt, Rt.
May be there is something to screw. Greater Ls-Rs difference enhances the rear left/right side separation of DPL2 matrix.
But what we get at output of DPLII decoder is not the same as it was at input of DPLII encoder.Have you made some measurements?? Then let us know.
Our encoder is the Besweet downmixer, the DPL2 decoder is in the receiver/amplifier, and has 2 operational modes: movie and music.
We speak about movie sound.

What I wanted is the right downmix to DPL2, not more. The rest has been done by Dolby.
So, what can we do? We can create 5 test wavs testing the main directions and between them. After encoding to DPL2 (BeSweet), burn on SVCD or feed it via SPDIF to the receiver.
Then we can measure the output levels and create a vector diagram.

Hint: The DVD Pink Floyd THE WALL has a good AC-3 sound test to calibrate amplifiers with pink noise.
I would post my DPL2 encoded test stream but it has about 600k :(

Valex
11th October 2002, 15:42
@frank
A DPL software decoder therefore needs some DSP modules, and a lot of engineering know-how to simulate that.

Now we are talking about encoder which is very simple :). And we do not need to fully simulate all DSP circuits. For example negative-feedback balancing scheme on firure 4 (Principles of operation) can be simulated with the equations I wrote in my first post. Yes, it is not the exact simulation (it will have different lag for example) but does the same in general.

Have you made some measurements?? Then let us know.

I want to.

What I wanted is the right downmix to DPL2, not more. The rest has been done by Dolby.
So, what can we do? We can create 5 test wavs testing the main directions and between them. After encoding to DPL2 (BeSweet), burn on SVCD or feed it via SPDIF to the receiver.

As I understand total process WAVs -> BeSweet (as DPLII encoder) -> DPL II decoder -> WAVs'. As result we'll get differences between WAVs and WAVs'. It is inevitable, because DPLII have no absolute channel separation. And how we can check that this downmix equations are right?

So I think that only reliable method is to compare with other DPLII encoder.

What I wanted is the right downmix to DPL2, not more.

I want this too.
I'm just trying to understand...

ux-3
11th October 2002, 21:01
Just for the record: I have seen the coefficients frank posted and I think they are also in the BS_Downmix Source. I can understand the math for RMS compensation etc. But the basic premise for dpl2 encoding I just quote from Frank:
We set the amount of acoustic power of Rs in Lt equal to the half of Ls
Where does this definition come from. Is it sop? Or a guess?

frank
12th October 2002, 18:53
Reverse engineering... The results - basing on this - are important. The sound rocks. And a lot of people have tested incl. diagrams as trg100 did.
Please, make your own real tests (I described above), and if there are great loudness differences in any direction we can change something.
BTW: HeadAC3he handles DS2 in the same manner.DSPGuru:Anything that violates ds coefficients will lower compatibility.Or, ask Dolby, I know the answer... :D

ux-3
13th October 2002, 10:48
@Frank:
So basically you are saying the encoder formulae is an empirical one, derived partially by trial and error. As I stated above, I am also quite amazed by the result the encoder delivers with dpl2. The only grain of salt is, that dpl2 does some magic on almost anything you feed it. But if you did a lot of testing, I will simply believe you that this premise is a good working hypothesis. Good enough for me anyway. The days where the most expensive was barely good enough have vaned with the arrival of a substancial income - something I do find amusing. Wonder if others make the same discovery about their perceived needs?

user
14th October 2002, 20:24
So now we can say, that latest HeadAC3he and BeSweet produce both very well DS2 surround encoded stereo waves ?!

Fr4nz
16th August 2003, 00:58
Hey guys I just wanted to know: on a DPL system sounds better a DS-encoded soundtrack or a DS2-encoded soundtrack?

It seems the first to me.

For the people who are interested: I've a very cool AC3 sample from Creative which gives you the idea of how much good is your surround system (you hear voices from the left, center, right and rear). It's 15 megs, if anyone is interested I can upload it to my site. Lemme know!

Kurtnoise
24th October 2005, 12:16
wtf with BeSweet ???