HISE Logo Forum
    • Categories
    • Register
    • Login

    Duplicate Const Var Declaration Problem

    Scheduled Pinned Locked Moved General Questions
    3 Posts 2 Posters 186 Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • SteveRiggsS
      SteveRiggs
      last edited by SteveRiggs

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

      www.anarchyaudioworx.com

      www.facebook.com/groups/audioworx/

      1 Reply Last reply Reply Quote 0
      • Christoph HartC
        Christoph Hart
        last edited by

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

        SteveRiggsS 1 Reply Last reply Reply Quote 1
        • SteveRiggsS
          SteveRiggs @Christoph Hart
          last edited by

          @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!

          www.anarchyaudioworx.com

          www.facebook.com/groups/audioworx/

          1 Reply Last reply Reply Quote 0
          • First post
            Last post

          43

          Online

          1.7k

          Users

          11.7k

          Topics

          101.8k

          Posts