HISE Logo Forum
    • Categories
    • Register
    • Login

    My project was crashed by Vu Meter Script

    Scheduled Pinned Locked Moved General Questions
    4 Posts 2 Posters 287 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.
    • T.B.GuangT
      T.B.Guang
      last edited by

      Any suggestion for this, please help! My project was crashed by Vu Meter Script, eveything compile OK, but just a few thousand year later, it was crashed.

      const var LevelMeterL = Content.getComponent("LevelMeterL");
      const var LevelMeterR = Content.getComponent("LevelMeterR");
      const var LevelMeterLock = Content.getComponent("LevelMeterLock");
      
      // show values as well, via label with whole integer db values.
      const var Label_MeterValue = Content.getComponent("Label_MeterValue"); // the peak of the strongest channel. 
      const var Label_MeterValue_L = Content.getComponent("Label_MeterValue_L");
      const var Label_MeterValue_R = Content.getComponent("Label_MeterValue_R");
      
      
      
      // ------------
      
      const var knbPan = Content.getComponent("knbPan");
      
      const var SimpleGain = Synth.getEffect("Simple Gain");
      
      //Decay Rate
      const var DECAY_RATE = 0.93;
      
      //Current Values
      var curLevelL = 0.0;
      var curLevelR = 0.0;
      var curLevelM = 0.0;
      
      //Timer Callback
      const var t = Engine.createTimerObject();
      
      t.setTimerCallback(function()
      {
      //Synth Values
        var LevelL = SimpleGain.getCurrentLevel(1);  
        var LevelR = SimpleGain.getCurrentLevel(0);
        
      //Peak Synth Values  
        var peakLevelL = Math.max(LevelL, LevelL);  
        var peakLevelR = Math.max(LevelR, LevelR);
        
        var peakLevelMax = Math.max(LevelL, LevelR);
      
      //Kick Left  
      //-----------------------------------------------------------------------------  
        if (peakLevelL > curLevelL)
          {
            curLevelL = peakLevelL;
          }
        else
          {
            curLevelL *= DECAY_RATE;
          }
      
      //Kick Right  
      //-----------------------------------------------------------------------------     
        if (peakLevelR > curLevelR)
          {
            curLevelR = peakLevelR;
          }
        else
          {
            curLevelR *= DECAY_RATE;
          }
          
      //Kick Max peak for mono out or label with max peak for strongest channel.
      //-----------------------------------------------------------------------------     
        if (peakLevelMax > curLevelM)
          {
            curLevelM = peakLevelMax;
          }
        else
          {
            curLevelM *= DECAY_RATE;
          }
      
        
      //Decibel Conversion  
      //-----------------------------------------------------------------------------   
        LevelL = Engine.getDecibelsForGainFactor(curLevelL);  
        LevelR = Engine.getDecibelsForGainFactor(curLevelR);
        
        var LevelMax = Engine.getDecibelsForGainFactor(curLevelM);
        
      //Set Values  
      //-------------------------------------------------------------------------------  
        LevelMeterL.setValue(LevelL);  
        LevelMeterR.setValue(LevelR);
        
        Label_MeterValue.set("text", (LevelMax >= -99) ? Math.round(LevelMax) : -100); // use Math.round (round up) for all except minimum value, -100. 
        Label_MeterValue_L.set("text", (LevelL >= -99) ? Math.round(LevelL) : -100); // use Math.round (round up) for all except minimum value, -100. 
        Label_MeterValue_R.set("text", (LevelR >= -99) ? Math.round(LevelR) : -100); // use Math.round (round up) for all except minimum value, -100. 
      
        
      });
      
      t.startTimer(30);
      
      
      ustkU 1 Reply Last reply Reply Quote 0
      • ustkU
        ustk @T.B.Guang
        last edited by ustk

        @T-B-Guang The code seems clean...

        If it crashes consistently (even if it happens after x minutes...), then try one (or all) of these things:

        • Move var declarations outside the function as reg
        • Move everything in an inline function that is called from this timer function
        • Stop the timer and restart it at the end so you are sure it isn't called before all that is inside is really done
        t.setTimerCallback(function()
        {
            this.stopTimer();
        
            // do your things in between
            // or call updateMeters()
        
            this.startTimer(30);
        });
        
        t.startTimer(30);
        
        inline function updateMeters()
        {
           // put your meter code here
            // so you can declare local instead of var
        }
        
        

        Can't help pressing F5 in the forum...

        T.B.GuangT 2 Replies Last reply Reply Quote 0
        • T.B.GuangT
          T.B.Guang @ustk
          last edited by

          @ustk Thank you Bro!

          1 Reply Last reply Reply Quote 0
          • T.B.GuangT
            T.B.Guang @ustk
            last edited by

            @ustk This work like a charm, Thank Bro again!

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

            50

            Online

            1.7k

            Users

            11.7k

            Topics

            102.1k

            Posts