Duplicate Const Var Declaration Problem



  • Hi guys,

    I have 4 dynamics modules in my project that I've split off so that I could have separate gain modules and bypass buttons for each (2 compressors, 1 limiter, 1 noise gate)

    I've made a gain reduction film strip animation for each (which works great if it's just linked to one of them). Once I add the code in for the 2nd one, I'm getting "duplicate const var declaration" errors as I already have references to the same modules further up the code (for the bypass buttons).

    It's not just the name references it's saying are duplicated though, it's understandably some of the other code (getDecibelsForGainFactor, setValue(v) etc), but I'm not sure how to get around this.

    II'll add my 4 lots of code that should work for each if they were on their own, and I'll also add the edit I tried which I thought might work to condense it all into one block (that didn't work as well as I thought. It compiled ok but just linked the 2 animations together and was triggered by only the compressor, not separated between the compressor and limiter)

    Can anyone suggest a way I could get all 4 working so that the gain reduction animations are running from the 4 separate modules and not interfering or linking with each other, or having duplicate declarations please?

    Here are the 4 separate blocks for the 4 separate modules:

    // Create Limiter Gain Reduction Meter
    const var NewLimiter = Synth.getEffect("NewLimiter");
    
    const var LimiterReduction = Content.getComponent("LimiterReduction");
    
    const var t = Engine.createTimerObject();
    t.setTimerCallback(function()
    {
        var v = NewLimiter.getAttribute(NewLimiter.LimiterReduction);
        
        v = Engine.getDecibelsForGainFactor(v);
        
        LimiterReduction.setValue(v);
    });
    
    t.startTimer(30);
    
    // Create Slam Gain Reduction Meter
    
    const var SlamCompressor = Synth.getEffect("SlamCompressor");
    
    const var SlamReduction = Content.getComponent("SlamReduction");
    
    const var t = Engine.createTimerObject();
    t.setTimerCallback(function()
    {
        var v = SlamCompressor.getAttribute(Dynamics.CompressorReduction);
        
        v = Engine.getDecibelsForGainFactor(v);
        
        SlamReduction.setValue(v);
    });
    
    t.startTimer(30);
    
    // Create SSL Gain Reduction Meter
    
    const var SSLCompressor = Synth.getEffect("SSLCompressor");
    
    const var SSLReduction = Content.getComponent("SSLReduction");
    
    const var t = Engine.createTimerObject();
    t.setTimerCallback(function()
    {
        var v = SSLCompressor.getAttribute(Dynamics.CompressorReduction);
        
        v = Engine.getDecibelsForGainFactor(v);
        
        SSLReduction.setValue(v);
    });
    
    t.startTimer(30);
    
    // Create Gate Gain Reduction Meter
    
    const var NoiseGate = Synth.getEffect("NoiseGate");
    
    const var GateReduction = Content.getComponent("GateReduction");
    
    const var t = Engine.createTimerObject();
    t.setTimerCallback(function()
    {
        var v = NoiseGate.getAttribute(Dynamics.GateReduction);
        
        v = Engine.getDecibelsForGainFactor(v);
        
        GateReduction.setValue(v);
    });
    
    t.startTimer(30);
    

    ...and this is what I thought could work adding the first 2 together and condensing it down (which wasn't quite correct)

    const var NewLimiter = Synth.getEffect("NewLimiter");
    
    const var LimiterReduction = Content.getComponent("LimiterReduction");
    
    const var SlamCompressor = Synth.getEffect("SlamCompressor");
    
    const var SlamReduction = Content.getComponent("SlamReduction");
    
    const var t = Engine.createTimerObject();
    t.setTimerCallback(function()
    {
        var v = NewLimiter.getAttribute(Dynamics.LimiterReduction);
         var v = SlamCompressor.getAttribute(Dynamics.CompressorReduction);
        
        v = Engine.getDecibelsForGainFactor(v);
        
        LimiterReduction.setValue(v);
        SlamReduction.setValue(v);
    });
    
    t.startTimer(30);
    


  • The problem is the const variable t. Just rename it to t2 in your second snippet and you should be fine. It's not good style though 🙂



  • @Christoph-Hart Ah! Thanks man. I'll try that in a second.

    I know, my scripting has zero style at the moment 🤣 Getting there though!


Log in to reply
 

8
Online

551
Users

2.1k
Topics

16.1k
Posts