How to find out if changes come from BWS or a controller?

Post Reply New Topic
RELATED
PRODUCTS

Post

Hey,

I currently work on a script for a controller with motorised faders and I wonder what the best way would be to find out if parameter changes in a callback come from the controller or from mouse or automation in the DAW, so that I do not send the data to the faders that just came from there.
I did this in the past in relatively clumsy ways, by setting a variable in the onMidi function to "true" when data came in that way, then in the observer checking that variable and not sending the data back when it's true and at the same time resetting it to false - rinse and repeat.
Now I wonder if there is a better way or even something built into the API?

Thanks for any ideas and hints!

Thanks,

Tom
"Out beyond the ideas of wrongdoing and rightdoing, there is a field. I’ll meet you there." - Rumi
ScreenDream Instagram Mastodon

Post

Midi callbacks are set separately for each midi channel - so you can have different ones for input and output.

As for parameter change callback try this:

1. For each parameter have a variable in your script that remember it's value, for example if it's channel 1 volume let's call it channelVol[1]
2. When your controller sends midi from your motorised fader set your channelVol[1] to the new value AND send that value to Bitwig with getVolume().set(X)
3. When you get a callback for the volume fader check if the value you receive is equal to channelVol[1], if it is not, then the change comes from Bitwig, not the controller, and you need to move the motorised fader and update channelVol[1], if it's equal than everything is already in order

Post

Thanks Netsu,

yeah, that may be a better solution, my way always felt a bit random.
Do you implement a certain delta in which you accept the data as valid or do you do 1:1 comparisons?

Back in the day I tried to talk the devs into implementing a flag on each callback that differentiates between those, but it never was important enough.

Thanks and cheers,

Tom
"Out beyond the ideas of wrongdoing and rightdoing, there is a field. I’ll meet you there." - Rumi
ScreenDream Instagram Mastodon

Post

Depends on the type of data. For addRawValueObserver(callback) you will receive a floating point value so there should be some small margin of error. For addValueObserver(range, callback) the callback will get an integer number so 1:1 comparisons will be fine.

There might be some corner cases when you send a few consecutive getVolume().set(X) from the controller before you get any callbacks - don't know how the engine times those events exactly. If that would be the case, implementing a slightly larger margin of error might help, even for the integer case.

Post

Ok, will do some testing.
Currently the main problem is, that Remote Controls are completely broken in 2.0, so I'm stuck anyway.

Thanks and cheers!

Tom
"Out beyond the ideas of wrongdoing and rightdoing, there is a field. I’ll meet you there." - Rumi
ScreenDream Instagram Mastodon

Post

(reply deleted)

Post Reply

Return to “Controller Scripting”