Peak-based Action
-
const var TimPan = Content.getComponent("TimPan"); TimPan.setTimerCallback(function() { var Peak = Engine.getMasterPeakLevel("L"); if (Peak > 0.1) { Sat1.set("visible", false); Sat2.set("visible", true); } else { Sat1.set("visible", true); Sat2.set("visible", false); } }); TimPan.startTimer(50);I have written the code above, trying to switch between two graphics based on the output peak. I think it worked for oscillators in hise, but I want it to react to the sound coming from the DAW. (it's an effects-plugin)
Any ideas if and how I could achieve something like that.
ps. it would be good if something like that would be possible with low performance cost -
@VorosMusic That code looks like it should work. You could reduce it a bit
TimPan.setTimerCallback(function() { var state = Engine.getMasterPeakLevel("L") > 0.1; Sat1.set("visible", !state); Sat2.set("visible", state); }); -
@VorosMusic I would go for a glibal_cable instead of a timer so the callback only fires when the value changed.
Even better, it allows you to place the logic on the DSP side so the script callback we really just fire when necessary.That been said this is still a lightweight job for the script, but when I can prevent a timer for running all the time, I do…