Page 1 of 2

what triggers the ruby code boxes to refresh?

PostPosted: Tue Jun 16, 2020 9:43 pm
by MichaelBenjamin
.

Re: what triggers the ruby code boxes to refresh?

PostPosted: Tue Jun 16, 2020 10:15 pm
by tulamide
MichaelBenjamin wrote:for green, it is a trigger, for the codebox it is each sample.
but what triggers the ruby code boxes to refresh?

What do you mean by that?
The code boxes are constantly interpreted, at around 100 Hz.
Inputs are event-driven. No change - no trigger.
Or do you mean a redraw? That's triggered by a MGUI.

Re: what triggers the ruby code boxes to refresh?

PostPosted: Tue Jun 16, 2020 10:24 pm
by nix
you can trigger Ruby with a tick if you'd like

Re: what triggers the ruby code boxes to refresh?

PostPosted: Tue Jun 16, 2020 10:54 pm
by MichaelBenjamin
.

Re: what triggers the ruby code boxes to refresh?

PostPosted: Tue Jun 16, 2020 11:02 pm
by nix
no, you can trigger a Ruby codebox with itself also

Re: what triggers the ruby code boxes to refresh?

PostPosted: Wed Jun 17, 2020 12:58 am
by MichaelBenjamin
.

Re: what triggers the ruby code boxes to refresh?

PostPosted: Wed Jun 17, 2020 2:04 am
by nix
it's a usable precision for slightly humanised timing,
do u want to join the Alpha Michael?
-I could then share with you my attempt at a solid sequencer
Ruby is close enough to sound fine, even at like 480 bpm

Re: what triggers the ruby code boxes to refresh?

PostPosted: Wed Jun 17, 2020 2:27 pm
by trogluddite
A complete answer to this needs to take into account the nature of the code inside the Ruby box.

Type 1: What I call "bare code" (no method definitions)

There is just one or more lines of code which act upon the input values and send one or more output values. This behaves as follows...

- All of the code is executed when an input receives a trigger.
- All of the code is executed when the code is edited (literally every key-stroke!)
- The code may schedule any input to change value at a later time (when the code will again be executed).
- The code may schedule any output to change value at a later time (no code is executed).

These should NOT be executed at startup (the RubyEdit's output values are saved with the schematic, just like most other primitives). However, there seems to be a bug which does cause startup execution sometimes, which can lead to very annoying Ruby errors (more info here).

Type 2: You write a series of method definitions

These normally include a method called "event", which is used to handle incoming green triggers. These behave as follows...

- At startup, the code is parsed to define the methods, then the methods "init" and "loadState" are executed.
- When code is edited, the code is parsed to define the methods, then the "init" method is executed.
- When a green trigger arrives, the "event" method is called.
- The code may schedule any method to be executed at a later time.
- The code may schedule any input to change value at a later time (which will call "event", if present).
- The code may schedule any output to change value at a later time.

In at least some v3.0.x versions, the detection of the kind of code is very crude - it just looks for the string "def" anywhere in the code. This can occasionally lead to bugs where "bare code" is erroneously taken to be a set of method definitions - e.g. if you used the word "default" in a comment or to name a temporary local variable.

Re: what triggers the ruby code boxes to refresh?

PostPosted: Fri Jun 19, 2020 12:11 am
by MichaelBenjamin
.

Re: what triggers the ruby code boxes to refresh?

PostPosted: Fri Jun 19, 2020 6:48 am
by nix
greets!
glad you're still on board, I catch you from time to time here
I sent a pm about the Alpha, nothing like some practical experience,
you can try Ruby if you'd like to compagnon