Auto Mute plugin?

Discussion in 'Effects and the DSP' started by Maddogg6, Feb 21, 2007.

  1. Maddogg6

    Maddogg6 Tail Razer

    Joined:
    Jun 21, 2005
    Messages:
    4,027
    Likes Received:
    26
    Trophy Points:
    0
    Is there a plugin - that exists that will act as a sort of binary 'ducker'.
    Binary in that - it acts as a switch (on or off only, not mix amount like a traditional ducker would do with say a sidechannel input of a compressor)

    What Im looking to do is...
    Say I am using Prologica to upmix stereo signals. Which I send FXBuss 0/1 to.
    I mix the REAR outputs of prologica with FXBuss 6/7 - and output to epilogs rear outputs.
    This works fine EXCEPT - that when I say, use foobar to UPMIX - or play a DVD, I would like so way to automatically mute the prologica REAR from going to epilog - so FXBUSS 6/7 is ONLY heard..

    I realize this may be possible with dynamics processor, I havent tried yet, but its kinda a resource hog to as I dont want compression/expansion - just a simple ON or OFF 'ducker'.
    Does this exist, if not - how is 'ON or OFF' figured in KX DSP (more precisely, DANE ONLY).

    *Hopes that made sense*

    Thanks,
    Mark
     
  2. Russ

    Russ Well-Known Member

    Joined:
    Jan 17, 2005
    Messages:
    5,722
    Likes Received:
    13
    Trophy Points:
    48
    Assuming that the audio to FxBus 6/7 is not gated (so that when something is playing, there is always some minimum level to use for detection), then it should be pretty easy to do using conditional logic (use skip instructions).

    Something like (pseudocode):

    if (abs(in2) > 0)
    out = in2
    else
    out = in1

    Is this something that you want to try and make yourself?

    <edit>
    Actually the abs (above) is not even necessary, since you can just check for a non-zero value at the input (use a skip instruction using 0x100 as the test_value) .
    i.e.
    if (in2 != 0)
    out = in2
    else
    out = in1
    </edit>
     
    Last edited: Feb 21, 2007
  3. Maddogg6

    Maddogg6 Tail Razer

    Joined:
    Jun 21, 2005
    Messages:
    4,027
    Likes Received:
    26
    Trophy Points:
    0
    Ahh - ok the skip instruction - yes I would like to make this myself in DANE - I guess I was making sure I didnt set out on an impossible quest. :D
    (I wasnt sure if it was possible with DANE only)

    Thank you sir...
     
  4. Russ

    Russ Well-Known Member

    Joined:
    Jan 17, 2005
    Messages:
    5,722
    Likes Received:
    13
    Trophy Points:
    48
    Just remember that the skip instruction, skips if the test condition is true (sort of the opposite of using if..then).

    Let me know if you need any help with it.
     
  5. Maddogg6

    Maddogg6 Tail Razer

    Joined:
    Jun 21, 2005
    Messages:
    4,027
    Likes Received:
    26
    Trophy Points:
    0
    Ok - here it is, I added level controls too.

    edit:
    Description: If signal is present on FXBIn - then mute PL inputs. With level controls

    Code:
    input FXBInL, FXBInR, PLInL, PLInR
    output OutL, OutR
    control FXB=1, PL =1
    temp t1, t2
    
    ; code
    
    macs t1, 0, FXBInL, FXB ; t1 = T1 + PLInL * PL
    macs t2, 0, FXBInR, FXB ; t2 = T2 + PLInR * PL
    skip t1, ccr, 0x100, 2 ; if FXBInL = 0.. then Skip next 2 instructions
    
    macs t1, 0, PLInL, PL ; t1 = T1 + PLInL * PL
    macs t2, 0, PLInR, PL ; t2 = T2 + PLInR * PL
    macs OutL, 0, t1, 1 ; 
    macs OutR, 0, t2, 1 ;  
    Edit: Fixed as per Russ' keen eye - pointing out this dumb guy. :D
    (Now!) Seems to work as I expect - but any suggestions to optimize or potential problems please post em...


    Thanks again Russ.
     
    Last edited: Feb 21, 2007
  6. Russ

    Russ Well-Known Member

    Joined:
    Jan 17, 2005
    Messages:
    5,722
    Likes Received:
    13
    Trophy Points:
    48
    Ok, there are some optimizations that you can do:

    Use Outputs instead of temp registers when possible (save gprs).
    Add the 2 channels together so that it is triggered if there is a signal from either channel.

    Your code was not working for me, and I am not sure why, I will have to take a closer look at it.

    In the mean time, here is the code I used while I was waiting (to show another (very similar) way of doing it)...

    input in1_left, in1_right;
    input in2_left, in2_right;
    output out_left, out_right;

    macs out_left, in2_left, 0, 0;
    macs out_right, in2_right, 0, 0;
    acc3 0, out_left, out_right, 0;
    skip ccr, ccr, 0x100, 2;
    macs out_left, in1_left, 0, 0;
    macs out_right, in1_right, 0, 0;

    To add volume controls, you would just change the first 2 and last 2 instructions to apply the volumes.

    Ok, now let me figure out why your code is not working for me...
     
    Last edited: Feb 21, 2007
  7. Russ

    Russ Well-Known Member

    Joined:
    Jan 17, 2005
    Messages:
    5,722
    Likes Received:
    13
    Trophy Points:
    48
    Ok, I see what the problem is, you have the conditions backwards (those skip instructions can be confusing).

    i.e.

    if (in1 != 0)
    out = in2 // in2 only plays when a signal is at in1
    else
    out = in1 // only gets here if in1 is 0, so nothing plays at all if it gets here

    BTW:
    Why use this:
    -----------
    macs OutL, 0x0, t1, 0x7fffffff;
    macs OutR, 0x0, t2, 0x7fffffff;
    -----------

    instead of:
    -----------
    macs OutL, t1, 0, 0;
    macs OutR, t2, 0, 0;
    -----------

    Not that it really matters, I am just curious...

    <edit>
    One more thing...
    I would swap the positions of your volume controls, such that top slider controls volume for the top inputs, and the bottom slider controls the volume for the bottom inputs. Just because it is what I am used to with plugins like Stereo Mix, GainHQ, etc (I kept adjusting the wrong slider).
    </edit>
     
    Last edited: Feb 21, 2007
  8. Maddogg6

    Maddogg6 Tail Razer

    Joined:
    Jun 21, 2005
    Messages:
    4,027
    Likes Received:
    26
    Trophy Points:
    0
    I fixed the post - Ok - NOW it works - Im positively 100% sure - I think.

    hehe.


    Anyway - I have a question:
    I was wondering why testing this wasn't good?
    ?? - beside the fact you multiplied by zero (which would always = zero, no??)
    (edit: nevermind the above Q - DoH out=in+(0 *0) /end edit)
    But the question is more on why you added an extra instruction for the test - does that reset a value or something.

    Edit - I gotya - My way is ONLY testing RIGHT - your test the combination of L+R...
    Sorry - I dum ....

    But then agian - Im saving an instruction - so - 'I dum like skunk'.
     
    Last edited: Feb 21, 2007
  9. Russ

    Russ Well-Known Member

    Joined:
    Jan 17, 2005
    Messages:
    5,722
    Likes Received:
    13
    Trophy Points:
    48
    MACS instructions takes the form: R = A + (X * Y)
    (order of operations does multiplication before addition)

    MACS R, A, 0, 0; R = A + (0 * 0) or R = A

    MACS R, A, 0, 1; R = A + (0 * 1) or R = A
    The above instruction has the same result as the previous one, the 1 does nothing (1 * 0 = 0) except make it confusing as to what the code is supposed to do when reading it.

    skip out_right, ccr, 0x100, 2;
    Why are you saving the result of the skip instrcution in out_right?
    You do not need to save it at all, and further it is modfying the value of out_right.

    You did the same thing in your code with your tmp variable, so that when t1 is fed to the output, it is the result of the skip instruction instead on the input. You need to fix that.
    Just make it:
    skip ccr, ccr, 0x100, 2;

    Give me a min and I will look at your update and see if there is anything else.
     
  10. Russ

    Russ Well-Known Member

    Joined:
    Jan 17, 2005
    Messages:
    5,722
    Likes Received:
    13
    Trophy Points:
    48
    Ok, the only problem that I see with your new code is with the skip instruction:
    Code:
    skip t1, ccr, 0x100, 2 ; if FXBInL = 0.. then Skip next 2 instructions
    
    Remove 't1' and use 'ccr' instead as I said in my previous post.
    The comment is wrong, should read:
    if FXBInR != 0.. then Skip next 2 instructions
    (note the 'R' and the "!=")

    The rest would just be optimizations to get rid of the temp variables, etc.

    The only problem with such a plugin, is with audio sources that have parts in them that are completely silent (i.e. value of 0). With no noise floor (digital material), such silences can cause it to act up. It would be good to add a timer of some sort to keep it from unmuting the other input during short periods of silence, etc.
     
    Last edited: Feb 21, 2007
  11. Maddogg6

    Maddogg6 Tail Razer

    Joined:
    Jun 21, 2005
    Messages:
    4,027
    Likes Received:
    26
    Trophy Points:
    0
    Ok I tried yur optimizations and I think the FIRST macs that SET output registers are causing them to be set for PLIN then AGAIN for FXB - when signal is present on both... so I think the temp registers are needed.
     
  12. Maddogg6

    Maddogg6 Tail Razer

    Joined:
    Jun 21, 2005
    Messages:
    4,027
    Likes Received:
    26
    Trophy Points:
    0
    Ok - I got it this time - poor Russ, puttin up with my idiotic ways..

    Code:
    input FXBInL, FXBInR, PLInL, PLInR
    output OutL, OutR
    control FXB=1, PL =1
    
    ; code
    
    macs OutL, 0, FXBInL, FXB ; OutL = 0 + PLInL * PL
    macs OutR, 0, FXBInR, FXB ; OutR = 0 + PLInR * PL
    
    acc3 0, FXBInL, FXBInR,0 ; Add BOTH inputs to test BOTH L & R for any signal
    skip ccr, ccr, 0x100, 2 ; If FXBInL+FXBInR != 0.. then Skip next 2 instructions
    macs OutL, 0, PLInL, PL ; OutL = 0 + PLInL * PL
    macs OutR, 0, PLInR, PL ; OutR = 0 + PLInR * PL
    I should have beed using headphones for test this whole time to more accurately hear what was happening.

    Anyway - its working 100% now - no really - it is...

    Thanks again Russ for your patients and suggestions - I'll find that cliff right away... Now did you say I should leap forwards or backwards ?? lolz

    edit: I added your suggested ACC3 - as it clicks less durring fade outs when signal id onFXBIn.

    Now - 1 more Q - I'm thinking of using iTram (say 10 samples) and adding FXBIn's and sending the sum to that iTram, and adding that as well to the ACC3 instruction - to get a sort of delay in muting - to reduce the artifacts - as we're always crossing 0)

    An I still being dum with this idea??
     
    Last edited: Feb 21, 2007
  13. Russ

    Russ Well-Known Member

    Joined:
    Jan 17, 2005
    Messages:
    5,722
    Likes Received:
    13
    Trophy Points:
    48
    I am not sure what you mean, I would have to see how you coded it. It works for me (except my code mutes in1 when a signal is presnt at in2).

    <edit>
    Just saw your last post... that looks better :)
    </edit>
     
    Last edited: Feb 21, 2007
  14. Russ

    Russ Well-Known Member

    Joined:
    Jan 17, 2005
    Messages:
    5,722
    Likes Received:
    13
    Trophy Points:
    48
    Sounds ok to me... Give it a try, that is part of the fun with making your own plugins, trying out ideas and seeing if/how well they work.
     
  15. Maddogg6

    Maddogg6 Tail Razer

    Joined:
    Jun 21, 2005
    Messages:
    4,027
    Likes Received:
    26
    Trophy Points:
    0
    Something like this...
    Code:
    itramsize 10
    ; xtramsize 0
    
    input FXBInL, FXBInR, PLInL, PLInR
    output OutL, OutR
    control FXB=1, PL =1
    
    ; code
    idelay write dw at 0x0
    macs OutL, 0, FXBInL, FXB ; t1 = T1 + PLInL * PL
    macs OutR, 0, FXBInR, FXB ; t2 = T2 + PLInR * PL
    
    acc3 0, FXBInL, FXBInR, dw
    skip ccr, ccr, 0x100, 2 ; FXBInR != 0.. then Skip next 2 instructions
    macs OutL, 0, PLInL, PL ; t1 = T1 + PLInL * PL
    macs OutR, 0, PLInR, PL ; t2 = T2 + PLInR * PL
    So far seems to work
     
  16. Maddogg6

    Maddogg6 Tail Razer

    Joined:
    Jun 21, 2005
    Messages:
    4,027
    Likes Received:
    26
    Trophy Points:
    0
    Seems alot of trouble is NON OPTIMAL testing methods...

    But yes - that definitly seems to have helped smooth out fades.
     
  17. Russ

    Russ Well-Known Member

    Joined:
    Jan 17, 2005
    Messages:
    5,722
    Likes Received:
    13
    Trophy Points:
    48
    Are you sure?
    You have no read address, so all you are doing is writing to iTram.
    (err, actually you are not even doing that :)... to write to iTram, the write address needs to be the R register in one of the instructions).

    Yeah, good testing methods would help.

    <edit>
    You would need to do something like this:

    iDelay read dr at 10
    ...
    acc3 dw, in1l, in1r, 0;
    acc3 0, in1l, in1r, dr;
    skip...

    But if you have a sound that is less than 10 samples long, then this could cause problems too...
    </edit>
     
    Last edited: Feb 21, 2007
  18. Lex Nahumury

    Lex Nahumury DH Senior Member

    Joined:
    Jan 5, 2003
    Messages:
    1,944
    Likes Received:
    6
    Trophy Points:
    0
    I don't mean to spoil the fun but,
    Russ, you are making the same mistake as with your Noise gate.
    Use average of control signal. Never per sample!

    What you guys are doing now is abruptly switching channel_B on *every*
    zero crossing of the signal present on channel_A.

    The proper way to do such 'channel switching' without introducing distortion/pops&clicks etc, is to design a proper Gate.
    So you really can't do without some form of EnvelopeFollower,attack,release + VCA.
    (If this plugin has to be any good that is)

    HTH,

    /Lex.

    PS:
    Russ, Just noticed your 'itram' attempt.
    Go for a 'real' Gate,..trust me:cool:
     
  19. Russ

    Russ Well-Known Member

    Joined:
    Jan 17, 2005
    Messages:
    5,722
    Likes Received:
    13
    Trophy Points:
    48
    Yup, you are right....
     
  20. Maddogg6

    Maddogg6 Tail Razer

    Joined:
    Jun 21, 2005
    Messages:
    4,027
    Likes Received:
    26
    Trophy Points:
    0
    Hey lex... I have no doubts having the conventional gating would be better,
    But I came up with this that works pretty good for my needs.
    Its low on resources and all DANE... which is what I was after - I do, on occasion hear some clicking - but this is for TV/DVD watching so its not a big deal

    (I can now easily use the same DSP config now for AC3 or DSP upmix - and not have doubled sounds )

    Thanks for all the input, suggestions etc etc - Oh, I found that cliff btw Russ :D
     

Share This Page

visited