In this third tutorial about score, we will start exploring the interactive possibilities available to the score author.
There are two main ways to have temporal interactivity :
- Interactive triggering
A condition means that a part of the score will only happen if some condition is true.
For instance, such a condition could be :
an:/osc/address == 100
Triggers are a more complex version of conditions.
They are a way of saying : “WHEN something happens, THEN do something”.
The format of the expressions is the same.
Creation of a condition
First, create two Time Intervals following each other, like we saw before :
Now, select the middle blue dot (a State).
Now, hit the C button on the top
this will create (actually, enable) a condition for this event.
By default, the condition is true.
This means that there is no condition, execution will just go on.
One can choose what kind of condition (<=, !=, >, etc.) he wants by clicking on the selector in the condition’s inspector.
The fields are as follows :
- (Optional) First one is to select a boolean operator when there are multiple expressions : “a:/b == 1 and c:/d == 2”.
- Second one is to put an OSC address
- Third one is to put a comparator or action
- Fourth one is to put a value or another address to compare with
For instance, given this tree :
One can input this condition :
Upon pressing validation (by clicking outside or pressing Enter / Return), the score becomes as follows :
If the value of OSCdevice:/my_node is unchanged, at 0, upon pressing play, the second interval is not executed :
The state also won’t run as shown by its red color : it only happens if the condition is true.
Else, if the value is changed to something >= 12, everything will play.
The condition is checked exactly when execution reaches its point.
An interesting capacity of score is conditional branching.
It is a pattern in which you can write : “IF A happens THEN do X, ELSE IF B happens THEN do Y, ELSE IF C happen THEN do nothing…”
The Events allow for branching.
Click on the middle State, go into creation mode, and drag your mouse a bit : a new interval will be created :
As you can guess, the condition will apply on both following time intervals, which will either both happen in parallel, or both not happen at all.
It is possible to do branching even without condition : it will just run the parts of the score in parallel, like tracks in an audio sequencer.
To allow conditional branching, we have to split the event.
For this, you’ll have to create a new Event – this is easily achieved by alt-dragging from the little + widget that appears when selecting a state.
As you can see, there is a thin dark line : this line is called a sync, and is what allows synchronization.
Now, what happens is that the condition (materialized by the yellow C) only matters for the topmost interval. The bottom one will execute regardless during execution.
Then, the same procedure than before can be applied in order to have multiple different synchronized conditions.