User Tools

Site Tools


events

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
events [2019/01/17 13:29]
admin [Using Global Variables as Parameter]
events [2019/01/17 13:47] (current)
admin [Using Global Variables as Parameter]
Line 91: Line 91:
 If we cant use the Value parameter, we have to create 100 Events. Event 1 checs if Value = 1, Event 2 checks if Value = 2 etc. Of course nobody will use this. But there is an elegant way to do this with only one Event, one Task and one global variable. If we cant use the Value parameter, we have to create 100 Events. Event 1 checs if Value = 1, Event 2 checks if Value = 2 etc. Of course nobody will use this. But there is an elegant way to do this with only one Event, one Task and one global variable.
  
-First we need a global variable that is used to store the volume level. See [[scriptsgeneral#​Global Variables|Global Variables Section]] ​+First we need a global variable that is used to store the volume level. See [[scriptsgeneral#​Global Variables|Global Variables Section]] ​if you don't know how to create a global variable. Now we can create the Event: 
 + 
 +{{ ::​eventparameter.png |}} 
 + 
 +The Event Script 
 + 
 +<​code>​ 
 +//If onControllerChange = then Condition = true 
 +Dim onControllerChange as Variant 
 +onControllerChange = GetDeviceVar("​MIDI","​onControllerChange"​) 
 +Dim v as string 
 +v = NthField(onControllerChange,":",​3) 
 +SetGlobalVar("​Volume",​v) 
 +Condition = true 
 +</​code>​ 
 + 
 +First notice the last line, '​Condition = true'. Here we define that the condition is allways true, no matter what controller change message is received. If you expect controller change messages from other controllers than controller 1 on channel 1 you have to change this. e.g. 
 +<​code>​ 
 +dim Controller, Channel as string 
 +controller = NthField(onControllerChange,":",​1) 
 +channel = NthField(onControllerChange,":",​2) 
 +if Controller = "​0"​ and Channel = "​0"​ then Condition is true 
 +</​code>​ 
 + 
 +Now lets look how we extract the volume level and use it as parameter:​ 
 +<​code>​ 
 +Dim v as string 
 +v = NthField(onControllerChange,":",​3) 
 +SetGlobalVar("​Volume",​v) 
 +</​code>​ 
 +the variable v receives the volume level. This level is the strored in the global variable Volume. 
 + 
 +Make sure that the 'After Fired Block for ms' value is set to 0 to allow quick volume changes. 
 +{{ ::​blockafterfired.png |}} 
 + 
 +Now we link the Event to a script. 
 +{{ ::​eventparameter2.png |}} 
 + 
 +This script simply reads the global Volume variable and inserts it in an OSC Command 
 ===== Calendar Events ===== ===== Calendar Events =====
  
events.1547731785.txt.gz · Last modified: 2019/01/17 13:29 by admin