Attached find my POC of your idea.
I implemented it on my Traktor Kontrol F1 which also allows to set the colors of the buttons. This does exactly what you want. The POC supports 1 knob only and did not use a map to hold the displayed value (see above). My binding is the Pre Gain of the selected track.
How does it work?
There are 2 events per control/binding: mOnProcessValueChange and mOnDisplayValueChange
mOnProcessValueChange is called whenever the control has changed and mOnDisplayValueChange is called whenever the value on the UI changes. In pickup mode mOnDisplayValueChange is called only when the control has really picked up the value.
When the state of the control doesn’t match with the UI value, it is not called until the UI value changes. Which happens when the control reached the corresponding position.
These events are also called when the bound host values change. E.g. by switching mapping pages or the selected channel changes. I use this to hold the target UI value in a global variable. This I compare in the controller event to set the colors accordingly. Unfortunately, the UI value is the exact UI value. Meaning it is a string and in the case of the Pre Gain has the unit as well. E.g. -2.5dB. I convert this to 0.0…1.0 as the controller event value is always normalized to 0.0…1.0. This prevents a pure generic implementation…. It would be great to get the normalized value.
@Jochen_Trappe How can we find out what GetState accepts for the keys? What is the key for GetState(‘key) to read the current pre grain value?
Unfortunately, the mOnProcessValueChange is also called when the user changes the UI value. This prevents to update the colors on the controller when the user changes a host value by e.g. the mouse. There is no way to reliably distinguish between a controller event and a event trigged by the user in the UI.
Hope this helps.
Native Instruments_F1.zip (1.9 KB)