auto balance control dsp code

Discussion in 'General Discussion' started by xzero1, Apr 27, 2006.

  1. xzero1

    xzero1 New Member

    Joined:
    Jun 28, 2005
    Messages:
    18
    Likes Received:
    0
    Trophy Points:
    0
    This code can used to automatically re-balance an stereo input. In effect, it will turn an imaginary balance control for you. The code also minimizes any gain loss. Still, I recommended using the Eyagos AGC control to compensate for gain loss incurred. Feel free to create a plugin using the code although it would be nice to give credit where it is due. The basic coding technique used was adapted from analysis of the Eyagos AGC control.
    KX rules!

    ; New microcode
    name "auto bal";
    copyright "";
    created "02/23/2006";
    engine "kX";
    comment "created by Keith Nuesslein";
    guid "665f73e3-783e-46e9-9313-5da5e1527e58"
    ; -- generated GUID


    ; itramsize 0
    ; xtramsize 0

    ; code

    input in_L, in_R
    output out_L,out_R,L,R
    static gr=.5
    static gl=.5
    temp tl,tr,t3
    const inc= .0000005
    const inc2=.00000001
    macs out_L,0,in_L,1
    macs out_R,0,in_R,1

    ;get abs value
    tstneg tl,out_L,out_L,0
    tstneg tr,out_R,out_R,0
    tstneg gl,gl,gl,0
    tstneg gr,gr,gr,0

    macs tl,0,tl,gl
    macs tr,0,tr,gr

    ;comments may be outdated

    macsn t3,tl,tr,1 ; TL < TR tl - tr < 0
    skip ccr,ccr,0x1008,0x2
    macs gr,gr,inc,1 ; TL < TR
    macsn gl,gl,inc,1 ; TL >= TR

    macsn t3,tr,tl,1 ; GL >= GR
    skip ccr,ccr,0x1008,0x2
    macs gl,gl,inc,1
    macsn gr,gr,inc,1

    macs t3,gl,1,inc
    skip ccr,ccr,0x10,0x4
    macs t3,gr,1,inc
    skip ccr,ccr,0x10,0x2
    macs gl,gl,inc2,1
    macs gr,gr,inc2,1


    macs out_L,0,out_L,gl
    macs out_R,0,out_R,gr
    macs L,gl,0,0 ; used for debugging
    macs R,gr,0,0 ; "

    end
     
    Last edited: Apr 28, 2006
  2. Tril

    Tril Triple screen racing ftw

    Joined:
    Sep 26, 2004
    Messages:
    1,665
    Likes Received:
    19
    Trophy Points:
    48
    Nice. I suggest you edit your post and :
    • Add a GUID. There is currently none and it will cause problems.
    • Add "" after the word copyright.
    • remove ; before the word comment. This way, if a user right-click the plugin in the DSP and clicks Info..., it will show the comment.
     
  3. xzero1

    xzero1 New Member

    Joined:
    Jun 28, 2005
    Messages:
    18
    Likes Received:
    0
    Trophy Points:
    0
    Thanks, Tril. I thought the GUID was autogenerated and leaving it in would be a problem.
     
  4. Tril

    Tril Triple screen racing ftw

    Joined:
    Sep 26, 2004
    Messages:
    1,665
    Likes Received:
    19
    Trophy Points:
    48
    You need to uncomment the line with the GUID or else it won't work.


    Would it be easy to add some adjustements to the plugin. Lower or increase the speed at which it adapts. If it can't be done easily with a dane plugin control, which line needs to be changed and how?
     
  5. xzero1

    xzero1 New Member

    Joined:
    Jun 28, 2005
    Messages:
    18
    Likes Received:
    0
    Trophy Points:
    0
    Thanks again. Constant inc is how fast you balance and inc2 is how fast you maximize your gain. The smaller the values the longer each correction will take. I don't know how to give a user control over their values with the default dane control. Its easy to see the control in action if you place a standard balance control ahead of it or just disconnect an input.
     

Share This Page

visited