Page 1 of 1

Alternatives to 'has changed'?

Posted: 04 Dec 2024, 18:48
by woodslanding
I have a recurring type of small bug in my wkp. This happens when I set an object's value, and that value happens to be the same value it was before, so hasChanged doesn't see it... but the user has changed the next thing in line in the meantime, so now the two objects are out of sync. I'm contrasting this with the way max operates, where you have discreet events that can always trigger the next thing in line. Is there a way to model this with usine's signal paradigm?

I get around this most times by using a mousedown to actually trigger the next thing, so it happens regardless whether there has been a change in value. But when I set a value by object, that doesn't happen. This is especially an issue in scripts that need to do some kind of refresh.

I guess I can have my recall of the object fake a mouse click. But maybe there's a less awkward way to do it? Is there any way that a control can know that its value has been set via usine objects, if the value doesn't actually change?

Another option I guess is to adjust my recall script to also change whatever is downstream from the main object, so the object doesn't have to do it. That might be a better solution.... or maybe there is a better alternative to hasChanged, that I don't know about?

Thanks as always!
-eric

Re: Alternatives to 'has changed'?

Posted: 26 May 2025, 21:46
by sm_jamieson
The answer is to have an event that does change. A Usine event can be any size but to use cleverly you need to use the sdk. You make the event with an extra word, and increment that each time. At the other end the extra word is ignored. This should create a message that always triggers. Not tried it except on a custom event that might not be compatible with all modules.

Re: Alternatives to 'has changed'?

Posted: 27 May 2025, 19:49
by woodslanding
well, I've not tried using the SDK, but I'll keep that in mind.

Re: Alternatives to 'has changed'?

Posted: 29 May 2025, 12:09
by oli_lab
Hi,
I did something like this for Arduino talking to Usine in OSC :
each time a value is sent (generally a character from a keyboard) the micro-controller send an OSC message with the char.value and a random 16bit integer.
On Usine side, the second value will go to a "has change" module to trigger the inserting of the character in the string.

because you need 2 informations : the value of you data (the Char) AND the information that it should be taken into account (the trig)

Re: Alternatives to 'has changed'?

Posted: 31 May 2025, 18:42
by woodslanding
I was just thinking along these lines, oli! My values are text strings, and I was thinking I could add a character at the beginning or end, that gets stripped out later. If the character is different when the data comes from the UI vs. when it is read off disk, that will trigger the hasChanged, even if the two strings are the same.

It's a bit complicted, but I will try that.