DriverHeaven.net

Looking for the skin chooser?
 
 
  • Home

  • Reviews

  • Articles

  • News

  • Tools

  • GamingHeaven

  • Forums

  • Network

 

Go Back   DriverHeaven.net > Forums > Hardware and Related Topics > kX Project Audio Driver Support Forum > 3-D Audio


Reply
 
LinkBack (2) Thread Tools
Old Jul 11, 2005, 09:16 PM   2 links from elsewhere to this Post. Click to view. #1
DriverHeaven Newbie
 
Join Date: Jun 2005
Posts: 18
Rep Power: 0
xzero1 is on a distinguished road

Big Grin Dolby Pro-Logic Encoder

I have coded a very simple plugin for encoding surround sound into a Dolby Pro-Logic signal. The code works well for some games (try bf 1942) and its function can be seen using rightmark 3d analyser. The best part is the encode can be sent to a single SPDIF output and decoded by an external encoder. The information came from a linux thread and also gives info for encoding Dolby Pro-Logic II. My code is derived directly from this info and no doubt has room for improvement. Any suggestions would be welcome.
dsp code:
input L,R,Ls,Rs,C
output Lt,Rt
temp tL,tr
macs tL,L,C,.707
macsn tL,tL,ls,.707
macsn tL,tL,Rs,.707
macs tr,R,C,.707
macs tr,tr,Ls,.707
macs tr,tr,Rs,.707
macs Lt,tL,0,0
macs Rt,tr,0,0
end
thread link:
http://forum.doom9.org/showthread.ph...721#post145721
xzero1 is offline   Reply With Quote


Old Jul 11, 2005, 09:54 PM   #2
S-3D enthusiast
 
Tril's Avatar
 
Join Date: Sep 2004
Location: Canada
Posts: 1,557
Rep Power: 39
Tril is just really niceTril is just really niceTril is just really niceTril is just really niceTril is just really nice
System Specs

Replace 0.707 by a more exact constant.
1/sqrt(2) = 0.70710678118654752440084436210485

Code:
input L,R,Ls,Rs,C;
output Lt,Rt;
static theconstant = 0.70710678118654752440084436210485;
temp tL, tR;
 
macs tL, L, C, theconstant; tL = L + C * theconstant 
macsn tL, tL, ls, theconstant; tL = tL - ls * theconstant 
macsn Lt, tL, Rs, theconstant; tL = tL - Rs * theconstant 
 
macs tR, R, C, theconstant; tR = R + C * theconstant 
macs tR, tR, Ls, theconstant; tR = tR + Ls * theconstant 
macs Rt, tR, Rs, theconstant; tR = tR + Rs * theconstant 
 
end
I combined some of the lines of code.
Tril is offline   Reply With Quote
Old Jul 12, 2005, 12:52 PM   #3
DriverHeaven Newbie
 
Join Date: Jun 2005
Posts: 18
Rep Power: 0
xzero1 is on a distinguished road

Thanks for the help.
I have added wave 0/1 to the F/R input and level controls for front and center via kx plugins in the dsp. This helps games with no sound at all or games using software only sound.
xzero1 is offline   Reply With Quote
Old Jul 13, 2005, 03:42 AM   #4
Kx User
 
Join Date: Sep 2003
Location: Finland
Posts: 31
Rep Power: 0
ojlehtin is on a distinguished road

That's really cool. I wonder if it's a lot more complicated to encode to ac-3 or true surround sound. Any ideas?
__________________
Oswald
ojlehtin is offline   Reply With Quote
Old Jul 13, 2005, 02:24 PM   #5
DriverHeaven Newbie
 
Join Date: Jun 2005
Posts: 18
Rep Power: 0
xzero1 is on a distinguished road

As I understand it ac-3 is much more complicated. I believe there is FFT involved in the compression algorythm. No one has yet done FFT in emu 10kx dsp code. A software solution must be real time -- minimal latency for games otherwise the sound would lag the video in games. Some new sound cards with Dolby Digital Live (DDL) at least claim to do this. Be warned about the Turtle Beach Montego and digital output for games (see my post in another thread).
xzero1 is offline   Reply With Quote
Old Jul 14, 2005, 08:05 AM   #6
Kx User
 
Join Date: Sep 2003
Location: Finland
Posts: 31
Rep Power: 0
ojlehtin is on a distinguished road

While surfing the net I found this:

http://essej.net/ac3jack/

It claims to be some kind of a soft which can do real-time ac3 encoding. Unfortunately I have no clue what to do with it or how to use it (or compile it). Maybe some one with more knowledge on this kind of stuff could take a look and say if it's of any use. Thanks.
__________________
Oswald
ojlehtin is offline   Reply With Quote
Old Jul 14, 2005, 08:14 AM   #7
Kx User
 
Join Date: Sep 2003
Location: Finland
Posts: 31
Rep Power: 0
ojlehtin is on a distinguished road

Some more info on this AC3Jack...

I found this page where the author of the soft i.q. comments on some stuff. Especially he says, that the encoder is supplied by FFMPEG's libavcodec. Ring any bells? This page is at:

http://music.columbia.edu/pipermail/...er/005888.html
__________________
Oswald
ojlehtin is offline   Reply With Quote
Old Jul 15, 2005, 09:16 AM   #8
DriverHeaven Lover
 
Join Date: Apr 2005
Location: Europe/Slovenia/Ljubljana
Posts: 157
Rep Power: 0
RejZoR is on a distinguished road

Yeah,FFDShow filter can encode to AC3 in realtime it appears
RejZoR is offline   Reply With Quote
Old Jul 15, 2005, 01:25 PM   #9
Kx User
 
Join Date: Sep 2003
Location: Finland
Posts: 31
Rep Power: 0
ojlehtin is on a distinguished road

Really?! Cool. Can you tell how exactly? Thanks.
__________________
Oswald
ojlehtin is offline   Reply With Quote
Old Jul 16, 2005, 04:51 AM   #10
DriverHeaven Lover
 
Join Date: Apr 2005
Location: Europe/Slovenia/Ljubljana
Posts: 157
Rep Power: 0
RejZoR is on a distinguished road

Go to Start menu and open ffdShow submenu. Select Audio Decoder configiration shortcut.
Scroll left side panel all way down and select Output.
Look under supported output samples and select AC3 and select desired AC3 bitrate. Under Connect to: select if which interface to use for output and if you want to direct it through SPDIF. I assume this is it,but i can't try it on SPDIF because i have only normal analog 4.1 speakers. I guess you have to connect it to external Dolby decoder or something.
RejZoR is offline   Reply With Quote
Old Jul 18, 2005, 06:03 AM   #11
Kx User
 
Join Date: Sep 2003
Location: Finland
Posts: 31
Rep Power: 0
ojlehtin is on a distinguished road

Apparently I have a different version of FFDShow. All the tabs you mentioned weren't the same here. Actually I didn't find any Connect To: tab, but didn't need it anyways.
The main thing: Now my external decoder really does recognise an AC-3 signal coming from the computer. So this really seems to work! Thanks a bunch. Unfortunately I got it to work only with Media Player (and with some files the sound is really distorted and clipping and stuff).
Is this supposed to work with all kinds of audio outputs? Especially, is it possible to encode a games 3D-sound to AC-3 with FFDShow or is it somehow Media Player (or generally some media player) specific? I mean, do DirectShow filters have anything to do with in-game audio?
Also, perhaps more kX related, as it is meant for musicians, Cubases output doesn't get encoded either. This isn't a big problem though, because I'm woking with plain ol' stereo when it comes to music and use different speakers for that too. In that area kX ofcourse kicks ass. Just want to spice up my gaming adventures...
__________________
Oswald
ojlehtin is offline   Reply With Quote
Old Jul 18, 2005, 12:14 PM   #12
Tail Razer
 
Maddogg6's Avatar
 
Join Date: Jun 2005
Location: Bernyurass, AZ - USA
Posts: 4,027
Rep Power: 36
Maddogg6 has a spectacular aura aboutMaddogg6 has a spectacular aura about

Just FYI, three is an AUDIO settings applet and A VIDEO settings applet for FFDShow. - I first thought the same thing, look in your start menu for 'Audio Filter Configuration' - I have it, but I also have the latest version from sourceforge installed.
Maddogg6 is offline   Reply With Quote
Old Jul 18, 2005, 01:39 PM   #13
Kx User
 
Join Date: Sep 2003
Location: Finland
Posts: 31
Rep Power: 0
ojlehtin is on a distinguished road

Yes, I found the Audio Configuration. I had to enable the AC3 there and so on... I just can't find the 'Connect to' part there. Don't seem to need it either, because the signal gets passed through just fine as is.
__________________
Oswald
ojlehtin is offline   Reply With Quote
Old Jul 18, 2005, 04:13 PM   #14
Tail Razer
 
Maddogg6's Avatar
 
Join Date: Jun 2005
Location: Bernyurass, AZ - USA
Posts: 4,027
Rep Power: 36
Maddogg6 has a spectacular aura aboutMaddogg6 has a spectacular aura about

Quote:
Originally Posted by ojlehtin
Yes, I found the Audio Configuration. I had to enable the AC3 there and so on... I just can't find the 'Connect to' part there. Don't seem to need it either, because the signal gets passed through just fine as is.
I *think* it was refering to the KX mixer setting (Master Page) - the 'Toggle AC3 Pass thru Mode' - in mine, its set to none, but imagine I would need to 'redirect' ac3 streams to the desired SPDIF out port/device using this setting.

But, I most certainly could be wrong - I would try playing with that to see how it affects you/this subject.
Maddogg6 is offline   Reply With Quote
Old Aug 13, 2005, 02:35 AM   #15
Eternal Sentinel
 
Join Date: Aug 2004
Location: Norfolk, VA, USA
Posts: 98
Rep Power: 0
CrimsonKnight13 is on a distinguished road
System Specs

Can anyone give me an explanation as to how I can integrate this into my DSP settings? I have an Audigy 2 and I'd like to add in Dolby and any other encoders that may be. I'd like to know if anyone has any DSP tweaks and plugin addons that I could use.
__________________
CrimsonKnight13 is offline   Reply With Quote
Old Dec 28, 2006, 10:15 PM   #16
DriverHeaven Newbie
 
Join Date: Dec 2006
Posts: 3
Rep Power: 0
mummyjohn is on a distinguished road

Ok, first I'll just say that I'm new here.

Anyway, back to the subject, I saw the code on the first couple posts. I understand it, but what does it go to? What program do you put this code into to make a software pro logic encoder? Basically what I'm asking is "what do you do with this code?"

Plese help. Thank you!
mummyjohn is offline   Reply With Quote
Old Dec 28, 2006, 10:42 PM   #17
Tail Razer
 
Maddogg6's Avatar
 
Join Date: Jun 2005
Location: Bernyurass, AZ - USA
Posts: 4,027
Rep Power: 36
Maddogg6 has a spectacular aura aboutMaddogg6 has a spectacular aura about

Quote:
Originally Posted by Tril View Post
Replace 0.707 by a more exact constant.
1/sqrt(2) = 0.70710678118654752440084436210485

Code:
input L,R,Ls,Rs,C;
output Lt,Rt;
static theconstant = 0.70710678118654752440084436210485;
temp tL, tR;
 
macs tL, L, C, theconstant; tL = L + C * theconstant 
macsn tL, tL, ls, theconstant; tL = tL - ls * theconstant 
macsn Lt, tL, Rs, theconstant; tL = tL - Rs * theconstant 
 
macs tR, R, C, theconstant; tR = R + C * theconstant 
macs tR, tR, Ls, theconstant; tR = tR + Ls * theconstant 
macs Rt, tR, Rs, theconstant; tR = tR + Rs * theconstant 
 
end
I combined some of the lines of code.
Copy this into notepad (any simple text editor will work)
Make sure you have a blank line AFTER THE 'END'.

Save the file as 'anyfilename.da' - then just double click on it to register it.
It then becomes available as a plugin in the KX DSP.
Maddogg6 is offline   Reply With Quote
Old Dec 29, 2006, 11:22 AM   #18
d/h member-shmember
 
Max M.'s Avatar
 
Join Date: Dec 2002
Location: Evil Empire
Posts: 2,400
Rep Power: 47
Max M. will become famous soon enough

[color=gray]
interesting, i've missed this topic in 2005. My two cents - just in case someone will request it to be included to the main kX package.

Actually such module already exists in kX (it was there since 2002) - it's titled "cnv51to20" for a few reasons:

1. You can't use "Pro-Logic" title without a permission form the Dolby.
2. Real Dolby Pro-Logic I has a bit more complex algorithm then such simple "matrix encoding".

p.s. actually "Surrounder(+)" (in "2.x, on" mode) uses similar encoding too (even with a bit more magic).

[/color]

Last edited by Max M.; Dec 29, 2006 at 11:48 AM.
Max M. is offline   Reply With Quote
Old Dec 30, 2006, 02:24 PM   #19
DriverHeaven Newbie
 
Join Date: Dec 2006
Posts: 3
Rep Power: 0
mummyjohn is on a distinguished road

Thank you!
mummyjohn is offline   Reply With Quote
Old Jan 2, 2007, 10:28 AM   #20
DriverHeaven Junior Member
 
Join Date: Oct 2003
Posts: 21
Rep Power: 0
bobo1on1 is on a distinguished road

I did this myself a while back, but I added a 20 ms delay to front-left and front-right to prevent strange addition/subtract effects when the same signal is sent to all speakers.

I also added a 8 kHz lowpass to rear-left and rear-right, otherwise rear signals with a frequency above 8 kHz are sent to the fronts.

To prevent equal front-left and front-right signals bleeding into the center speaker, you can add a very small delay to either front-left or front-right, a delay as small as 1 sample should be sufficient.
bobo1on1 is offline   Reply With Quote
Old Mar 29, 2007, 09:53 AM   #21
DriverHeaven Newbie
 
Join Date: Nov 2004
Posts: 2
Rep Power: 0
Remboooo is on a distinguished road

I've been using this plugin now and indeed it seems to work! There's one thing i don't understand though.. The wikipedia article about Dolby Pro Logic says that it adds the surround channel with phase shifting, but the only thing this plugin does is add the center channel to both left and right channels, substract the surround channel from the left channel and add it to the right.
Could anyone tell me why substracting the surround channel from the signal is the same as phase-shifting it +90° and adding it is the same as phase-shifting it -90°? Or is this just a dirty hack that will work quite well, but not optimal?

-edit-
ah, I get it now. In stead of rotating one left 90° and the other right 90°, you just leave one untouched and negate the other one to approximate 180° rotation. Somehow in my setup the abovementioned 8kHz filter wasn't necessary and only (obviously) decreased sound quality from the rear channel.

The code I now use in the dolby encoder component:
Code:
input L, R, Ls, Rs, C;
output Lout, Rout;
static theconstant=0.7071;
temp tL, tR, tS

; Code
macs tL, L, C, theconstant; add center channel to left channel
macs tR, R, C, theconstant; add center channel to right channel
macs tS, Ls, Rs, 0x7fffffff; combine Ls & Rs to one temporary surround channel
macsn Lout, tL, tS, theconstant; add 180° rotated (negated) surround to left channel
macs Rout, tR, tS, theconstant; add untouched surround to right channel
And before inputting the surround channels into the dolby encoder component, i make use of the TimeBalanceV2 component to add some delays to eliminate interference when the same audio plays on all channels. The settings that I use and seem to work fine (although they've just been established by trial and error - no science going on here):
Front Left: 1.010m
Front Right: 0.990m
Rear Left: 0.808m
Rear Right: 0.808m
Center: 1.000m

Last edited by Remboooo; Mar 29, 2007 at 11:43 AM.
Remboooo is offline   Reply With Quote
Old Mar 29, 2007, 04:40 PM   #22
DriverHeaven Junior Member
 
Join Date: Oct 2003
Posts: 21
Rep Power: 0
bobo1on1 is on a distinguished road

A dolby pro logic decoder has an 8 kHz lowpass for the rear speakers, sounds above 8 kHz in the rear channels will come out of the front speakers.
bobo1on1 is offline   Reply With Quote
Old Apr 15, 2007, 02:22 PM   #23
DriverHeaven Senior Member
 
ROBSCIX's Avatar
 
Join Date: Mar 2004
Posts: 1,745
Rep Power: 0
ROBSCIX is on a distinguished road

A person was asking for a 5.1 encoder aswell, doesn't Trils redocneKX plug do this exact feature?
ROBSCIX is offline   Reply With Quote
Reply

Bookmarks

Thread Tools


LinkBacks (?)
LinkBack to this Thread: http://www.driverheaven.net/3-d-audio/79137-dolby-pro-logic-encoder.html
Posted By For Type Date
surround sound on a stereo sound card. - LinuxQuestions.org This thread Refback Oct 5, 2008 10:12 AM
surround sound on a stereo sound card. - LinuxQuestions.org This thread Refback Jun 1, 2008 02:14 PM