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