custom peak meter.
-
Hello to all,
I am currently trying to implement a custom peak meter. I used this snippet as a basis:
HiseSnippet 3040.3oc6a8taabbD+nktfP53Dam+0OUrfenfxQlhGojkUUcL0enrUrjEAohRcCBDVd2Rxy53sL2cT1JFFHnH.8K8MnepOI0u.EnOBsuAoOAsyr2+163IIJFWa0fH3fnc1Ylcleyr6MydmZ5v0YttbGkb42+jgLkbumZ6Sr85uQeposx1apj6Zp6r1VGdvWtKyi4nr9ICottLCkb4l4AHK4xOqh3me79qSsn15rXRJJGvM0Y6XNvzKlZy5OxzxZKpAaeyARbuX8s041avs3i.yYF0JJCo5GQ6wdLEY6JpJ4dmFFldbm1dTOlqRtYWmabR697mY6y+AltlcrX3.Mk1fh7IuE2x.sXjpxF8MsLZF51tJJ4TaFCBy3CBej5tlFlQziAiqKlfDKgLdj6JIMuYRXdZxlWEIyKCSJmjIMquIcC015NlC8hmAsmqptsMDV5RAXW1T74U4J+tOQcCNvgsW4AziXa4.ChjnTsJUlmrXkJysZgB.z65Qr35VGZQ6RtGITNcGF3N6v0oV6v4GslswVLlUITlPtK6v5Y5BZcqQ15dlb6REMbnOqE2i5bRaKSClSw4IcCmr27DdmmNWgWTnvBKPNf43YBJmrioMirC6XlEQjqQ1BRSJPL6RJArW1i8bOx8tGoXSF8HACnjHOEmiTfPH4eQg7GScHTv3QAnfguJNAAo1g64wGrOnjATmdl1.SUhm0quo9Q1.tBjqtZ9H5GCKwPtafFOlZMh8Xty.pk42wLVEXpP9BEx2qrKy6ANTCS.vPKpzWira5wF3mNWcdBfzzut12HbcoYzhlgbaIq31jRHsaGQYtaEXJeybq5ujcg0oEejMjZ2ho6Qs6YwJ80gJ6VjRZfVxvpmC4n52DvGvy4wOvJlgjGPk7uD9O7emcfqI2DywJPXVtryI.Fv6a4XHxKA7P+PoenIxn8GhPv4g5SVHLL.DMChvk07CrBTFA4BuD2hg+.X8ZFF.6LxWtMogEa.jl4FtkEcw0evgMo1.9GuskZXHHUpX3jEEoZXnLjGvUgi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XrmqN3rH1ImqzbjkKSrKPSVvXxUkI+PpiADWzOqy+lcxN+6b9T9dmK2eJeQOGbMmgrd8LEvJZKuuLkjIou1dPgzMr7gm10Qr9HOO3rB+Vo8sh.RotYj.0cN53ZpsXtLuKrJjpi8CDmdfki5SKkRVo9jnjqphZPXKSmUbcgBZej4oXF+38mD3.zB2w6QrSb+ofHfyLjwDur7zJ32LNZb8.E.061guN+4BUbS01rucDCNqKh7j6PRlx0T8OEqE0tGa57l7ps6OpaWK1zkgcUU+Cq12jcVtvr9J3lIV+lT8iDJ4i.3Xf49P6.RSjVa+MC7l2x8mUw2d+kieTlbG7.lEWGdf+j6fc+r0Wqb4UdzlkKWaTy2NimXG7lp6vr640+zcuaUOU76Hb4d5CgkqYWX4Ju7Zv3C9BXb4mhiKiy+vsgwGaiiafiKGO96P9cvw0333uBmeSTekY33d33thw+AbbGw3Gfq2.z8NJg6cV6VugZPoPsYVL7klLAaVyTQep5di7FNx60j5tg5tMazFeiFAJbrsvS3wQe.pnF1FmhZpTeRNI3cTeHTaPFmhb4uc9D0HjOzF86UsAzAoEGnD1dTW5HKuPpIKUXWtMeXetsYhJsZwfxv60ikn.tLcn077vcNQT9n5sfTDpKS9ucC7i8l5.3DaJwBsK7e5CYFu9Up9lKAKBm7+uWCyL+r9ZXl7cePOHWtihvomt5UIhPI4sSr7MQi0uIViATcG9g59Gpia5eWAEvusE+odkWcWbLQK73bU0Jkqf2Ws4g55X95sg1+xVlpSgL0lBYVbJjYooPl6LExr7THycOSYvVkWajGefeNOPnYCwqhNWtFgWtetYT9u.Iz0wVC
I have several layers in my plug-in, which is why I need several peak meters.
Basically everything works. However, there seems to be a data leak, because the peak meters for layer B also receive data from layer A and vice versa.
Is it perhaps because I am using namespaces here? Unfortunately, I cannot find the error. Maybe one of you has an idea.
Thank you very much
OliHISE Snippet:
HiseSnippet 1997.3oc6as0baabEFPRHIT4lSG2j73FM8AnTEIRYq33ISR3cUMgzlCohS83wimUfKI2JvcQAVJKMcxL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YJO5w4kikBTGBqqZv+CdEtXA4XyvEKLdw4Uk7AV57ejZkafIpCXXprvtFEuORKduOflxHJnSkj8opwneFeBAsOgQ7kB94gn9eu7yR9wNB33OzGyB73AIXbGxP5gPsjAIRrMfT2m72aKc9SjYMG6m5R+9OTGtjoRSGrXjuJJZ5Lqeag0mkx6UYUv2tyW5JAB9JFl+BTM+tYUye6sZ9q3TpxprOqx9kfJ6uzk2kkp7OOr9m9expxOqJ+rp7ypx+Fi06Mqh+KcQ8hT8+tYU+ujT8+RVJxY4Zsv4Zs7.kea4LFhc74uvQ+q6RFE+dpY.cKS8uidNqlxwnBFpewWw8iFBQvuvwIIqlgvcWTBu2hR38WTB2aQI7qWTBevhR3275ITBvVZjfOTCKXXzrUM0OQNSS82viJBz3+CTXiU3J
Script:
var fillColourLayA = Colours.withAlpha("0x5E59C970", 0.2); var fillColourLayB = Colours.withAlpha("0x8439A1D7", 0.2); //PEAK LEFT LAYER A--------------------------------------------------------------------------------------------------------------------------------------------------------------------------- namespace peakLeftLayA { const var Gain = Synth.getEffect("PanModSynthGrp1"); //Current Values var curLevelLM_Fill = 0.0; var curLevelRS_Fill = 0.0; const var MeterL = Content.getComponent("peakLeftLayA"); MeterL.setPaintRoutine(function(g) { var a = this.getLocalBounds(0); g.setColour(fillColourLayA); g.fillRect([a[0], a[1] + a[3], a[2], ((this.getValue() * 3) * a[3]) * (-1)]); }); // Decay Time const var DECAY_RATE_Fill = 0.75; //Timer Callback const var t1 = Engine.createTimerObject(); t1.setTimerCallback(function() { //Module Values var LevelLM_Fill = Gain.getCurrentLevel(1); var LevelRS_Fill = Gain.getCurrentLevel(0); //LM Peak Module Values var peakLevelLM_Fill = Math.max(LevelLM_Fill, LevelLM_Fill); if (peakLevelLM_Fill > curLevelLM_Fill) curLevelLM_Fill = peakLevelLM_Fill; else curLevelLM_Fill *= DECAY_RATE_Fill; //RS Peak Module Values var peakLevelRS_Fill = Math.max(LevelRS_Fill, LevelRS_Fill); if (peakLevelRS_Fill > curLevelRS_Fill) curLevelRS_Fill = peakLevelRS_Fill; else curLevelRS_Fill *= DECAY_RATE_Fill; //Decibel Conversion LevelLM_Fill = curLevelLM_Fill; //Set Values MeterL.setValue(LevelLM_Fill); MeterL.repaint(); }); t1.startTimer(50); } //PEAK RIGHT LAYER A--------------------------------------------------------------------------------------------------------------------------------------------------------------------------- namespace peakRightLayA { const var Gain = Synth.getEffect("PanModSynthGrp1"); //Current Values var curLevelLM_Fill = 0.0; var curLevelRS_Fill = 0.0; const var MeterR = Content.getComponent("peakRightLayA"); MeterR.setPaintRoutine(function(g) { var a = this.getLocalBounds(0); g.setColour(fillColourLayA); g.fillRect([a[0], a[1] + a[3], a[2], ((this.getValue() * 3) * a[3]) * (-1)]); }); // Decay Time const var DECAY_RATE_Fill = 0.75; //Timer Callback const var t1 = Engine.createTimerObject(); t1.setTimerCallback(function() { //Module Values var LevelLM_Fill = Gain.getCurrentLevel(1); var LevelRS_Fill = Gain.getCurrentLevel(0); //LM Peak Module Values var peakLevelLM_Fill = Math.max(LevelLM_Fill, LevelLM_Fill); if (peakLevelLM_Fill > curLevelLM_Fill) curLevelLM_Fill = peakLevelLM_Fill; else curLevelLM_Fill *= DECAY_RATE_Fill; //RS Peak Module Values var peakLevelRS_Fill = Math.max(LevelRS_Fill, LevelRS_Fill); if (peakLevelRS_Fill > curLevelRS_Fill) curLevelRS_Fill = peakLevelRS_Fill; else curLevelRS_Fill *= DECAY_RATE_Fill; //Decibel Conversion LevelRS_Fill = curLevelRS_Fill; //Set Values MeterR.setValue(LevelRS_Fill); MeterR.repaint(); }); t1.startTimer(50); } //PEAK LEFT LAYER B--------------------------------------------------------------------------------------------------------------------------------------------------------------------------- namespace peakLeftLayB { const var Gain = Synth.getEffect("PanModSynthGrp2"); //Current Values var curLevelLM_Fill = 0.0; var curLevelRS_Fill = 0.0; const var MeterL = Content.getComponent("peakLeftLayB"); MeterL.setPaintRoutine(function(g) { var a = this.getLocalBounds(0); g.setColour(fillColourLayB); g.fillRect([a[0], a[1] + a[3], a[2], ((this.getValue() * 3) * a[3]) * (-1)]); }); // Decay Time const var DECAY_RATE_Fill = 0.75; //Timer Callback const var t1 = Engine.createTimerObject(); t1.setTimerCallback(function() { //Module Values var LevelLM_Fill = Gain.getCurrentLevel(1); var LevelRS_Fill = Gain.getCurrentLevel(0); //LM Peak Module Values var peakLevelLM_Fill = Math.max(LevelLM_Fill, LevelLM_Fill); if (peakLevelLM_Fill > curLevelLM_Fill) curLevelLM_Fill = peakLevelLM_Fill; else curLevelLM_Fill *= DECAY_RATE_Fill; //RS Peak Module Values var peakLevelRS_Fill = Math.max(LevelRS_Fill, LevelRS_Fill); if (peakLevelRS_Fill > curLevelRS_Fill) curLevelRS_Fill = peakLevelRS_Fill; else curLevelRS_Fill *= DECAY_RATE_Fill; //Decibel Conversion LevelLM_Fill = curLevelLM_Fill; //Set Values MeterL.setValue(LevelLM_Fill); MeterL.repaint(); }); t1.startTimer(50); } //PEAK RIGHT LAYER B--------------------------------------------------------------------------------------------------------------------------------------------------------------------------- namespace peakRightLayB { const var Gain = Synth.getEffect("PanModSynthGrp2"); //Current Values var curLevelLM_Fill = 0.0; var curLevelRS_Fill = 0.0; const var MeterR = Content.getComponent("peakRightLayB"); MeterR.setPaintRoutine(function(g) { var a = this.getLocalBounds(0); g.setColour(fillColourLayB); g.fillRect([a[0], a[1] + a[3], a[2], ((this.getValue() * 3) * a[3]) * (-1)]); }); // Decay Time const var DECAY_RATE_Fill = 0.75; //Timer Callback const var t1 = Engine.createTimerObject(); t1.setTimerCallback(function() { //Module Values var LevelLM_Fill = Gain.getCurrentLevel(1); var LevelRS_Fill = Gain.getCurrentLevel(0); //LM Peak Module Values var peakLevelLM_Fill = Math.max(LevelLM_Fill, LevelLM_Fill); if (peakLevelLM_Fill > curLevelLM_Fill) curLevelLM_Fill = peakLevelLM_Fill; else curLevelLM_Fill *= DECAY_RATE_Fill; //RS Peak Module Values var peakLevelRS_Fill = Math.max(LevelRS_Fill, LevelRS_Fill); if (peakLevelRS_Fill > curLevelRS_Fill) curLevelRS_Fill = peakLevelRS_Fill; else curLevelRS_Fill *= DECAY_RATE_Fill; //Decibel Conversion LevelRS_Fill = curLevelRS_Fill; //Set Values MeterR.setValue(LevelRS_Fill); MeterR.repaint(); }); t1.startTimer(50); }
-
@Oli-Ullmann said in custom peak meter.:
data leak
I haven't looked in detail at the code, but don't use
var
unless that's the only choice in the situation. -
@Oli-Ullmann said in custom peak meter.:
var curLevelLM_Fill = 0.0;
var curLevelRS_Fill = 0.0;sorry im not an expert, I see these are the same for the 4 meters, I renamed the ones for the blue meter and that meter not move but the other one kept working, maybe something on the naming could be
-
@Oli-Ullmann If you register these vars with "reg" instead of "var" it will work.
var curLevelLM_Fill = 0.0; var curLevelRS_Fill = 0.0;
As David said, avoid using var if you can.
-