My project was crashed by Vu Meter Script
-
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);
-
@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 asreg
- 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 }
- Move
-
@ustk Thank you Bro!
-
@ustk This work like a charm, Thank Bro again!