Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

script and send() function #355

Closed
cyberic99 opened this issue Aug 29, 2018 · 13 comments

Comments

Projects
None yet
3 participants
@cyberic99
Copy link
Contributor

commented Aug 29, 2018

I tried to use the send() function inside a script but I failed...

I have a widget named text_1

the script condition is 1

the script content is:

#{
send("self", "/text_1", 99);
}

I tried with ip:port too, but my text widget is not modified

See attached session file

2018-08-29_20-38.json.txt

@jean-emmanuel

This comment has been minimized.

Copy link
Owner

commented Aug 29, 2018

The script is only evaluated when it receives a value and send() will only work if the event is supposed to trigger osc messages (ie user interaction or /SET command)

@cyberic99

This comment has been minimized.

Copy link
Contributor Author

commented Aug 29, 2018

Oh OK, I thought that the send() would send an OSC message on the network

@jean-emmanuel

This comment has been minimized.

Copy link
Owner

commented Aug 30, 2018

Yes, that's what it does, but the script itself needs specific conditions to run otherwise you wouldn't be able to control when these are sent.

@cyberic99

This comment has been minimized.

Copy link
Contributor Author

commented Aug 30, 2018

After reading the docs, I thought the script would be run each time a value was received and if the condition was evaluated to true

@jean-emmanuel

This comment has been minimized.

Copy link
Owner

commented Aug 30, 2018

Everytime the script widget receives a value, it does run the script, but the send() only sends when it should which is in case of user interaction or /SET command.

@jean-emmanuel

This comment has been minimized.

Copy link
Owner

commented Aug 30, 2018

Btw, in the next release, the script widget will have a value property too, it might also help choosing how the widget receives values.

@cyberic99

This comment has been minimized.

Copy link
Contributor Author

commented Aug 30, 2018

Thx for these explainations and additions to o-s-c

@super-frais

This comment has been minimized.

Copy link

commented Mar 12, 2019

Everytime the script widget receives a value, it does run the script, but the send() only sends when it should which is in case of user interaction or /SET command.

This is unclear to me. As cyberic99 mentioned, the docs seem to imply that send() will fire when there is an incoming value, and the condition property is true.

You mention that "send() only sends when it should which is in case of user interaction." ...but user interaction with what? Do you mean interaction with the widget that triggered the value update? This is the part that I am unclear about - I set the send() command up the same way that cyberic99 did and I am unable to get it to fire under any condition. I tried debugging by referencing the current state of the script widget, but it appears self-reference (e.g. "@this" inheritance) for this widget is undefined.

Right now I am assuming that the "incoming value" mentioned in the script widget docs can be any of these:
--same id as another widget, which triggers ripple update
--shared link_id
--explicit .value trigger from another object
--incoming OSC in address property (this one I am unsure about.)

BTW I'm having a lot of fun with O-S-C - if I could get some multiline OSC messages using the script widget, I would be the happiest kid on the block ;)

@super-frais

This comment has been minimized.

Copy link

commented Mar 12, 2019

Oooookaaay - as it turns out, relative commands work, e.g.:

send(false, "/position", "+");

But absolute commands, especially if they're the same number being sent repeatedly, like:

send(false, "/track/2/volume", 64);

...don't work. Actually, they work once, and then never work again.

Spamming the same number from a normal control works, but not from the script widget. I'm beginning to suspect it's deliberate data thinning, possibly by the OSC API of my host (Bitwig), unless anyone has any other bright ideas :)

[p.s. sorry for posting into a closed issue]

@jean-emmanuel

This comment has been minimized.

Copy link
Owner

commented Mar 13, 2019

Yo !

You mention that "send() only sends when it should which is in case of user interaction." ...but user interaction with what

I mean direct interaction with o-s-c's user interface, excluding same id updates that don't trigger message sending (see (see http://osc.ammd.net/widgets-reference/#id)

incomming value

It is triggered when one of the following happens:

  • a linked widget (via linkId) value updates (even if the value didn't change)
  • the script's value property changes when it contains a reference to another widget's value that changed

The subtle thing here is that value references in the script's value property must actually change to trigger the execution, where linked widgets via linkId can submit the same value over and over and trigger the execution, hence the problem you mention. This should be added to the docs.

The script widget was kind of a hack on top of the property/value inheritance feature, I must say I'm not fully satisfied with it. When I have the need for these features I prefer writing a custom module.

@super-frais

This comment has been minimized.

Copy link

commented Mar 13, 2019

The subtle thing here is that value references in the script's value property must actually change to trigger the execution

AHA - Ça y est! I would never have figured that out, merci bien ;)

I generally agree about using a custom module instead of a widget. (When I have need for more complex behavior I tend to do it in Bitwig's API, which also uses .js modules). It is however nice to be able to create complex behavior in o-s-c using only the GUI, especially when you're prototyping 30 different controls and aren't sure what you need yet...I feel the Script widget does have a positive use.

Many thanks for this amazing application!

@jean-emmanuel

This comment has been minimized.

Copy link
Owner

commented Mar 13, 2019

Thank you :)

@cyberic99

This comment has been minimized.

Copy link
Contributor Author

commented Mar 13, 2019

It is however nice to be able to create complex behavior in o-s-c using only the GUI

I second that.

To me, adding small pieces of code thanks to the script widget feels more integrated than a custom module.

And you do everything with the same tool (the editor)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.