Dolby Pro-Logic Encoder

Discussion in '3-D Audio' started by xzero1, Jul 12, 2005.

  1. xzero1

    xzero1 New Member

    Joined:
    Jun 28, 2005
    Messages:
    18
    Likes Received:
    0
    Trophy Points:
    0
    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.php?p=145721#post145721
     
  2. Tril

    Tril Triple screen racing ftw

    Joined:
    Sep 26, 2004
    Messages:
    1,665
    Likes Received:
    19
    Trophy Points:
    48
    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.
     
  3. xzero1

    xzero1 New Member

    Joined:
    Jun 28, 2005
    Messages:
    18
    Likes Received:
    0
    Trophy Points:
    0
    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.
     
  4. ojlehtin

    ojlehtin Kx User

    Joined:
    Sep 8, 2003
    Messages:
    31
    Likes Received:
    0
    Trophy Points:
    0
    That's really cool. I wonder if it's a lot more complicated to encode to ac-3 or true surround sound. Any ideas?
     
  5. xzero1

    xzero1 New Member

    Joined:
    Jun 28, 2005
    Messages:
    18
    Likes Received:
    0
    Trophy Points:
    0
    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).
     
  6. ojlehtin

    ojlehtin Kx User

    Joined:
    Sep 8, 2003
    Messages:
    31
    Likes Received:
    0
    Trophy Points:
    0
    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.
     
  7. ojlehtin

    ojlehtin Kx User

    Joined:
    Sep 8, 2003
    Messages:
    31
    Likes Received:
    0
    Trophy Points:
    0
  8. RejZoR

    RejZoR New Member

    Joined:
    Apr 16, 2005
    Messages:
    154
    Likes Received:
    5
    Trophy Points:
    0
    Yeah,FFDShow filter can encode to AC3 in realtime it appears:w00t:
     
  9. ojlehtin

    ojlehtin Kx User

    Joined:
    Sep 8, 2003
    Messages:
    31
    Likes Received:
    0
    Trophy Points:
    0
    Really?! Cool. Can you tell how exactly? Thanks.
     
  10. RejZoR

    RejZoR New Member

    Joined:
    Apr 16, 2005
    Messages:
    154
    Likes Received:
    5
    Trophy Points:
    0
    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.
     
  11. ojlehtin

    ojlehtin Kx User

    Joined:
    Sep 8, 2003
    Messages:
    31
    Likes Received:
    0
    Trophy Points:
    0
    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...
     
  12. Maddogg6

    Maddogg6 Tail Razer

    Joined:
    Jun 21, 2005
    Messages:
    4,027
    Likes Received:
    26
    Trophy Points:
    0
    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.
     
  13. ojlehtin

    ojlehtin Kx User

    Joined:
    Sep 8, 2003
    Messages:
    31
    Likes Received:
    0
    Trophy Points:
    0
    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.
     
  14. Maddogg6

    Maddogg6 Tail Razer

    Joined:
    Jun 21, 2005
    Messages:
    4,027
    Likes Received:
    26
    Trophy Points:
    0
    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.
     
  15. CrimsonKnight13

    CrimsonKnight13 Eternal Sentinel

    Joined:
    Aug 28, 2004
    Messages:
    100
    Likes Received:
    0
    Trophy Points:
    0
    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.
     
  16. mummyjohn

    mummyjohn New Member

    Joined:
    Dec 27, 2006
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    0
    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!
     
  17. Maddogg6

    Maddogg6 Tail Razer

    Joined:
    Jun 21, 2005
    Messages:
    4,027
    Likes Received:
    26
    Trophy Points:
    0
    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.
     
  18. Max M.

    Max M. h/h member-shmember

    Joined:
    Dec 7, 2002
    Messages:
    2,690
    Likes Received:
    9
    Trophy Points:
    63

    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).

     
    Last edited: Dec 29, 2006
  19. mummyjohn

    mummyjohn New Member

    Joined:
    Dec 27, 2006
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    0
    Thank you!
     
  20. bobo1on1

    bobo1on1 New Member

    Joined:
    Oct 13, 2003
    Messages:
    21
    Likes Received:
    0
    Trophy Points:
    0
    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.
     

Share This Page

visited