Do something only when automating?
-
Is it possible to know when a parameter is being automated by the DAW, and only execute it's callback then? Ideally, with some simple logic like:
Not automated - do something
Automated - do something else
Thank you!
-
@tomekslesicki You can attach a mouse broadcaster to the UI knob that will track whether you actually interact with it while changing parameters. In Pseudocode:
broadcaster.attachListener(function() { IS_AUTOMATED = !event.clicked; } onKnob1Control(component, value) { if(!IS_AUTOMATED) { // whatever... } }
-
@Christoph-Hart clever, thank you!
-
As a precautionary method: what are you trying to achieve here? Whenever people start making this distinction, it's usually a warning sign for a underlying design flaw.
Oh and another way of checking this (which also covers the case where you have assigned a MIDI controller to a knob) is to check the actual thread where this might happen from:
inline function onKnob1Control(component, value) { if(Threads.getCurrentThread() == Threads.Audio) { Console.print("Plugin Parameter / MIDI controlled"); } else { Console.print("UI Interaction"); } }; Content.getComponent("Knob1").setControlCallback(onKnob1Control);
Although that might not be 100% robust because I know that some hosts are calling the plugin parameters on a different thread (IIRC Protools does that).
-
@Christoph-Hart thanks! In this case, I have a bunch of buttons that control stuff - isPluginParameter is disabled for them. I want to add a slider, which would be plugin parameter enabled, and would set these buttons depending on it’s value (slider at 0 - button 0 on, slider at 1, button 1 on, etc.).
The end user never sees the slider, it’s only there to automate the button states. The buttons are displayed on the interface, though, and they should update the slider’s value when they’re interacted with - button 0 on, slider value set to 0.
What I actually want to achieve is to prevent creating a loop where the button state fires its callback, and changes the slider’s value - which then changes the button’s value, and fires the callback again, and so on. So my idea is:
-
button pressed on the interface a fire button callback, and set the slider’s value
-
slider automated - change button state, but don’t set the slider’s value again (and don’t call it at init)
-
-
I just figured out I can actually do this by checking the button’s value on the knob’s callback and just if it from there, which would be a much simpler solution I guess
-
@tomekslesicki yes there are plenty of other solutions
- just not calling changed() in the slider would prevent the infinite loop
- writing a custom panel instead of the buttons that store its value and is assigned to a plugin parameter would also work.
- you could even get away with just styling the slider with a laf and make it look like a few buttons but that‘s advanced hackery and might not work with you design.