Internal Messages Language (IML)

:!: do not translate

This chapter is only for advanced users, and only if you want to create/modify patches dynamically.

Since the v4.1 Usine provides a powerful internal language to create patch dynamically.

The background idea is very simple: you send messages to the internal messages manager by several ways:

  1. use the Send Internal Messages module
  2. use the SendInternalMsg in Scripting Language or in the SDK.

Of course, commands can be sent over the network with OSC modules.

Global variables

TARGET_PATCH : contains the patch designed as the target patch, in other word it’s the patch that executes the commands.

SENDER_PATCH : contains the patch which actually sending the messages. This variable is automatically set by Usine.

MOUSE_X : contains the current X coordinate of the mouse. This variable is automatically set by Usine.

MOUSE_Y : contains the current Y coordinate of the mouse. This variable is automatically set by Usine.

SHIFT_PRESSED : its value is 1 if the user is pressing the [shift] key, 0 otherwise.

CONTROL_PRESSED : its value is 1 if the user is pressing the [control] key, 0 otherwise.

ALT_PRESSED : its value is 1 if the user is pressing the [Alt] key, 0 otherwise.

LAST_CREATED_MODULE_NAME : Contain the name of the last created module by the command CREATE_MODULE. This variable is automatically set by Usine.

ON_WIRE: its value is 1 if the user has dropped a file on a wire.

BUSES_LIST_DATA:contains the list of all available DATA buses for the current patch.

BUSES_LIST_AUDIO:contains the list of all available AUDIO buses for the current patch.

BUSES_LIST_MIDI:contains the list of all available MIDI buses for the current patch.

Templates variables

The following variables are automatically set by Usine when the user try to create a new wire in a patch. They are used in the Templates Engine.

SRC_TERM_IN_OUT none=0,in=1,out=2

SRC_TERM_FLOW_TYPE None=0, Audio=1 InternText=2 Data=3 MIDI=4 Array=5 User=6 EvtText=7 Pointer=8 Intern=9 Other=maxInt

SRC_TERM_DISPLAY_FLOW_TYPE Text=0 gainFader=1 Directory=2 Switch=3 Button=4 IntegerFader=5 FloatFader=6 SelectColorFader=7 ListBox=8 Array=9 IPAddress=10 Smpte=11 FileName=12 MidiNote=13

SRC_SCALE Linear=0 Log=1 Exp=2 Other=maxint

SRC_MIN min value of the selected terminal

SRC_MAX max value of the selected terminal

SRC_TERM_NAME name of the selected terminal

SRC_TERM_NUM num (order) of the selected terminal

SRC_SYMBOL symbol string of the selected terminal

SRC_FORMAT format string of the selected terminal

SRC_MODULE selected module

SRC_MODULE_ID selected module ID

DROP_FILENAME full name of the dropped file

DROP_SHORT_FILENAME short name of the dropped file

DROP_FILEEXT extension of the dropped file

SRC_COMMATEXT string which contains all the items of the list box separated by commas

SRC_NB_COMMATEXT_ITEMS number of items in the list box

SRC_VALUE value of the terminal

SRC_DEFAULT_VALUE default value of the terminal

SRC_PRECISION_INDEX number of digits displayed of the terminal

SRC_VALUE_STRING value as a string format (for text terminals)

Procedures

Names between brackets [] are optional

SET_VAR name value [value2]

Set a variable value

SET_VAR pi 3.14
SET_VAR HelloString 'Hello guys'

for strings optional value2 is concatenated

SET_VAR newName 'hello-' DROP_FILENAME 
// new name will be the concatenation of 'hello-' and the DROP_FILENAME variable

CREATE_MODULE modulename id x y [filename]

Create a new module at the position x y in the patch.

The module type is set by the parameter id (see the list of id’s bellow). Then the module is renamed with the modulename.

For sub-patches modules (id=6) you must specify the filename of the sub-patch.

CREATE_MODULE vol 4 100 100 // creates an audio volume module
CREATE_MODULE gate 6 100 100 'c:UsineGate.pat' // add the Gate.pat sub-patch
CREATE_MODULE matrix 95 100 100 'Matrix.usr' // create the Matrix.usr User module 

CREATE_PLUGIN modulename x y [plug_filename] Usine V6 only Create a new plugin module (for example VST) at the position x y in the patch.

CREATE_PLUGIN myplug 100 100 'C:Program filesSteinbergVstpluginsReaktor.dll' 

RENAME_MODULE oldmodulename [newmodulename]

Change the name of the module. If the newmodule name parameter is missing, the module name is set to nothing (blank).

DELETE_MODULE modulename

Deletes the modulename module.

SET_TARGET_PATCH patch

Define the target patch which will receive Internal Messages

SET_TARGET_PATCH SENDER_PATCH // the active patch is the current patch

SET_TARGET_PATCH subpatchname

Defines the target subpatch that will receive Internal Messages.

SET_TARGET_PATCH SENDER_PATCH // the active patch is the current patch
CREATE_MODULE wd1 6 MOUSE_X MOUSE_Y 'wave+pitch+gain.pat'
SET_TARGET_PATCH wd1

SET_VALUE modulename terminalname value

Set the terminalname value of the modulename module

CREATE_MODULE MyMidiCreate 78 100 100 // create a “Create Midi note” module
SET_VALUE MyMidiCreate create 1 // set the ‘create’ inlet of the ‘MyMidiCreate’ module value to 1
...
CREATE_MODULE MyDelay 54 100 100 // create a Delay module
SET_VALUE MyDelay delay 100 // set the delay inlet of the ‘MyDelay’ module value to 100ms

SET_STRING_VALUE modulename terminalname stringvalue

Same as the SET_VALUE above but for strings values.

SET_STRING_VALUE fader1 Caption “I love you”

SET_COMMATEXT modulename terminalname commatext

Set the values of a listbox items. A comma text is a list of possible values separated by commas.

SET_COMMATEXT Listbox1 list “delay, flanger, filter”

GET_COMMATEXT modulename terminalname destvariable

Get the values of a listbox items and store it in destvariable. A comma text is a list of possible values separated by commas.

GET_COMMATEXT Listbox1 list value

GET_VALUE modulename terminalname destvariable

Retrieve the value of a terminal and store it in a destvariable variable.

GET_INDEX modulename terminalname destvariable

Retrieve the index of a terminal and store it in a destvariable variable.

GET_CAPTION modulename terminalnum destvariable

Retrieve the caption of a terminal and store it in a destvariable variable.

GET_STRING_VALUE modulename terminalname destvariable

Retrieve the value of a string terminal and store it in a destvariable variable.

CREATE_LINK moduleSrcOut terminalSrcOut moduleDestIn terminalDestIn

CREATE_LINK moduleSrcOut termSrcOutNum moduleDestIn termDestOuNum

Add a new link (wire) between two modules. Always from out to in.

CREATE_LINK Step1 out Delay1 delay

The CREATE_LINK command can also be used with Terminal order number instead of terminal names. Typically, the SRC_TERM_NUM gives the order of the target inlet. The following example comes from a template (see p226).

CREATE_LINK in1 in SRC_MODULE SRC_TERM_NUM

DELETE_LINK moduleSrcOut terminalSrcOut moduleDestIn terminalDestIn

Delete a link (wire)

DELETE_LINK Step1 out Delay1 delay

AS above the DELETE_LINK command can also be used with Terminal order number instead of terminal names.

CLEAR_PATCH

Clear the target patch. No prompt is made.

STORE_FOR_UNDO

Store Undo information’s. So the user will be able to cancel the last operation.

For example, if you send the single command

CLEAR_PATCH

Then no undo is possible…

Now, if you send

STORE_FOR_UNDO
CLEAR_PATCH

The user will be able to undo the Clear patch operation.

UNDO_PATCH

Executes an undo on the target patch

REDO_PATCH

Executes a redo on the target patch

LOAD_PATCH filename

Load a new patch in the target patch. Be careful, no prompt for save is done…

SAVE_PATCH filename

Save the target patch as a new name

RELOAD_PATCH

Reload the current Target patch.

RENAME_PATCH newfilename

Rename the target patch without saving it.

ADD_GROUP filename X Y

Open a patch and add new modules to the actual patch (without clear it before).

INPUT_QUERY_VALUE textToDisplay VarName DefaultValue

Ask the user to enter a numerical value and stores the result in VarName.

SET_TARGET_PATCH SENDER_PATCH
INPUT_QUERY_VALUE 'Enter the fader value' FADER_VALUE 50
SET_VALUE FA1 fader FADER_VALUE

INPUT_QUERY_STRING textToDisplay VarName DefaultValue

Ask the user to enter a string and stores the result in VarName.

SET_TARGET_PATCH SENDER_PATCH
INPUT_QUERY_STRING 'Input items, separated by commas' COMMATEXT 'a,b,c,d'
SET_COMMATEXT LB1 list COMMATEXT

INPUT_QUERY_LIST WindowTitle Question List ResultStringVariableName ResultIndexVariableName(optional)

Ask the user to select an item in a List. Stores the selected string result in ResultStringVariableName and the selected item index in ResultIndexVariableName. The last parameter is optional.

Generally used with the following variables:

  • BUSES_LIST_DATA
  • BUSES_LIST_AUDIO
  • BUSES_LIST_MIDI
SET_TARGET_PATCH SENDER_PATCH
INPUT_QUERY_LIST 'Get from Audio Bus' 'Select Bus' BUSES_LIST_AUDIO BUSNAME
CREATE_MODULE data1 284 MOUSE_X MOUSE_Y 
CREATE_LINK data1 'get bus' SRC_MODULE SRC_TERM_NUM
SET_STRING_VALUE data1 name BUSNAME

PROMPT_FOR_SAVE

Ask the user to save the target patch if it has been modified.

Can be used before a CLEAR_PATCH or a LOAD_PATCH operation.

PROMPT_FOR_SAVE
CLEAR_PATCH

LOAD_WORKSPACE filename

Load a new workspace. Be careful, no prompt is done…

SAVE_WORKSPACE filename

Save the current workspace as a new name. If no filename is specified it saves the workspace with its current file name.

EXECUTE_SCRIPT scriptfilename Compile and execute once a script

SET_TARGET_PATCH SENDER_PATCH
EXECUTE_SCRIPT 'create-patch.script'

CREATE_USER_CURVE name Create a user curve module from SRC_MODULE and SRC_TERM_NUM in the TARGET_PATCH.

SET_CTRL_POS modulename left top autosize(optional) Set the position , in the control panel or IB, of the associated control of the module.

Provides an automatic control panel resizing by default. Set autosize to false to disable the control panel resizing.

SET_CTRL_POS BUTTON1 100 100  // the control panel is resized
SET_CTRL_POS BUTTON1 100 100 false // the control panel is not resized

SET_CTRL_POS_PC modulename left(%) top(%) Set the position , in the control panel or IB, of the associated control of the module with left and top defined in percent ([0..1]) of the parent panel size.

No automatic control panel resizing is done. SET_CTRL_POS_PC BUTTON1 0.2 0.56

SET_CTRL_SIZE modulename width height autosize(optional) Set the size of the associated control of the module.

Provides an automatic control panel resizing by default. Set autosize to false to disable the control panel resizing.

SET_CTRL_SIZE BUTTON1 100 20  // the control panel is resized
SET_CTRL_SIZE BUTTON1 100 20 false // the control panel is not resized

SET_CTRL_SIZE_PC modulename width(%) height(%) Set the size of the associated control of the module with values in percent ([0..1]) of the parent panel size.

No automatic control panel resizing is done.

SET_CTRL_SIZE BUTTON1 0.1 0.1 

SET_LAYOUT modulename layoutFieldName value Set the LayoutFieldName value of the modulename

This function is CPU hungry if you use it in a script.

SET_LAYOUT TheFader "border width" 12 

CREATE_UID variable Creates an Unique Identifier (UID) and store it in variable

PAUSE Pause and process queued Usine messages

SELECT_MODULE modulename Selects the modulename module.

Modules ID’s

Here is the list of modules ID’s used in the CREATE_MODULE message.

Fader   = 3
AudioOut= 2
AudioIn = 1
Volume  = 4
MidiIn  = 5
subPatch= 6
Vst     = 7
Button  = 8
Switch  = 9
Trace Value = 10
Sin     = 11
Cos     = 12
LN      = 13
LOG     = 14
EXP     = 15
1 / X   = 16
SQRT    = 17
ABS     = 18
-X      = 19
DataIn  = 20
DataOut = 21
MIDIOut = 22
Round   = 23
Trunc   = 24
Variable= 25
ArcSin  = 26
ArcCos  = 27
Pi      = 28
Const   = 29
TimeMs  = 30
TimeSec = 31
Random         = 32
Keyboard = 34
A+B      = 35
A-B      = 36
A/B      = 37
A*B      = 38
A div B  = 39
A mod B  = 40
>        = 41
<        = 42
>=       = 43
<=       = 44
<>       = 45
Min      = 46
Max      = 47
Power    = 48
Equal    = 49
And      = 50
Or       = 51
Xor      = 52
Not             = 53
DelayAudio      = 54
EnvelopFollower = 55
RandomDATA      = 57
PeakFollower    = 58
Presetx8        = 60
Step            = 61
Separator       = 62
Granular        = 65
Delta           = 66
Selector        = 67
ComboBox        = 68
Panner4         = 69
SmoothData      = 70
Wait1           = 71
XY Pad          = 72
A*X+B           = 73
Mouse           = 74
StopEvent       = 75
FreezeEvent     = 76
MidiFilter      = 77
CreateMidi      = 78
Text            = 79
MidiTransformer = 80
VuMeter      = 81
AdditionalIn = 82
RangeFader   = 83
Lfo          = 84
CrossFadeMono    = 85
NoteToFreq       = 86
FreqToNote       = 87
Current Rack Num = 88
EmptyModule      = 89
On Initialization= 90
CookFilter  = 91
ArrayDisplay= 92
FFT         = 93
FFTInv      = 94
User        = 95
WaveDisplay = 96
CoeffTodb   = 97
dbToCoeff   = 98
SeqSwitch   = 99
StepMidi    = 100
RandomMidi     = 101
SeqLines       = 102
On Activation  = 103
CheckBoxLed    = 104
HasChanged     = 106
ZeroCrossing   = 107
Oscilloscope   = 108
SetGlobVar   = 113
GetGlobVar   = 114
AdditionalOut= 115
SetMidiBus   = 118
GetMidiBus   = 119
VolumeMono   = 120
LoadWkp      = 121
LoadPatch    = 122
SysExEditor  = 125
Dispatch     = 126
OSCReceive32 = 127
OSCSend1     = 128
OSCSend2     = 129
OSCSend8     = 130
OSCSend4     = 131
MaxArray     = 132
MinArray     = 133
GrainSampler = 134
OSCSend16    = 135
QueueData    = 136
SortArray    = 137
SwapArray    = 138
ArrayElementValueGet= 139
ArrayElementValueSet= 140
SumArray     = 141
MeanArray    = 142
StdDevArray  = 143
Bloc Size    = 144
Sample Rate  = 145
PowerScale   = 146
ExpScale     = 147
MultipleVar  = 148
ArraySize    = 149
MapperCurve  = 150
MapperData   = 151
ArrayEditor  = 152
Master Panel = 153
PianoRoll    = 154
ConcatArray  = 155
OnlyIfHasChanged = 156
PassEventFlow    = 157
OSCReceive1      = 158
OSCReceive2      = 159
OSCReceive4      = 160
OSCReceive8      = 161
OSCReceive16     = 162
OSCSend32        = 163
TextField        = 164
ConcatStrings    = 165
InArray          = 166
OutArray         = 167
OSCSendTxt       = 168
Patch On Off     = 169
OSCSendOnlyTxt   = 170
VuMeterVert      = 171
FaderVert        = 172
Image            = 174
Knob             = 175
PreciseTimeMs    = 176
ListBox          = 177
Synchro          = 179
LocalSynchro     = 180
GetSMPTEpos      = 181
VstLite          = 184
Sampler1         = 187
Sampler4         = 188
Sampler8         = 189
Sampler16        = 190
GrainSampler1    = 191
Shell command    = 194
Ramp old version = 200
GrainSampler4    = 202
GrainSampler8    = 203
GrainSampler16   = 204
WavePlayer16     = 205
ShiftArray       = 207
WhatTimeIsIt     = 209
MaxArrayPos      = 210
VideoPlayer      = 211
ListBoxBtn       = 212
WaveShaper       = 213
Crusher          = 214
Phaser           = 215
From0To1         = 219
From1To0         = 220
Toggle           = 221
FaderMidiNote    = 222
Color Chooser    = 223
MinArrayPos      = 224
PolarToCart      = 225
CartToPolar      = 226
ArrayMinMaxRange = 227
ArrayGate        = 228
SetArraySize     = 229
ExpandArray      = 230
FillArray        = 231
SetSMPTEpos      = 232
IntToStr         = 234
DataMixer        = 235
AudioMixer       = 236
Wiimote          = 237
PointCurve       = 238
DblClickPatch    = 239
FillRampArray    = 240
ADSR             = 241
Preset16         = 242
Device           = 243
DrawObject       = 244
ConcatArray3     = 245
ExtractArray     = 246
ConcatArray4     = 247
Send internal msg  = 248
OSCReceiveBytes    = 249

Current_Patch_Name    = 250
Get_Buses_List        = 251
output_Usine_MIDI     = 252
Quadratic_Distance_2D = 253
Battery_Level         = 254
Comment               = 257
Sampler               = 258 (Query)
Grain_Sampler         = 259 (Query)
Array_display         = 260 (Query)
Volume_audio          = 261 (Query)
XY                    = 262 (Query)
DrawPanel             = 263 (Query)
Popup                 = 264
Selector              = 265 (Query)
Dispatch              = 266 (Query)
Audio_Mixer           = 267 (Query)
Data_Mixer            = 268 (Query)
Step                  = 269 (Query)
Lines                 = 270 (Query)
Points_Curve          = 271 (Query)
Sequenced_Switch      = 272 (Query)
Fast_Script           = 273
Step_Midi             = 274 (Query)
PianoRoll             = 275 (Query)
Preset manager        = 276 (Query)
OSC_Send              = 277 (Query)
OSCReceive            = 278 (Query)
Float_To_String       = 279
Send_Mouse_Msg        = 282
Video_Detect          = 283
Get_From_Audio_bus    = 284
Send_to_Audio_bus     = 285

FaderColor            = 289
1-X                   = 290
X+1                   = 291
Current_Voice_Num     = 293
SubPatch_Polyphony    = 294
Mapper_Data           = 295 (Query)
Midi_Voice_Dispatcher = 296
Draw Panel New        = 297
X-1                   = 298
Bloc Duration         = 299
DBAP_2D               = 300
ArcTan                = 301
Open Dialog           = 302
Formant Filter        = 303
Ramp                  = 304
Cross_Fade            = 305
Setup Panel           = 308
Web Browser           = 309
Sign                  = 310
Selector_string       = 312
Additional_Audio_Input= 313
Thru                  = 314
Osc Lister            = 315
ParamEQ               = 316
Soft_Clipping         = 318
Crusher               = 323
WaveShaper            = 324
Phaser                = 325
Filter                = 326
Filter_24db           = 327
Delay_audio           = 328
FormantFilter         = 329
AudioInDevice         = 330
AudioOutDevice        = 331
Linkwitz_Rileyfilter  = 332
OscLister             = 333
Shape                 = 334
Path                  = 335
Compressor            = 336
Gate                  = 337
Oscillator            = 338
Sequenced_Button      = 339
Random_Midi           = 340
Grid_settings         = 341
Selector_color        = 342
Panner                = 343
Sample_Player_Recorder= 344
Grid Section Settings = 345
Sampler_Basic         = 346
Sample_Player         = 347
Grain_Sampler_Basic   = 348
Grain_Sample_Player   = 349
Grain_Sample_Player_Recorder  = 350
Sensors               = 351
Rack_Settings         = 352
Midi_Multi_Filter     = 353
Kalman_Filter         = 354
FastScript            = 355
Quantize Panel        = 356
ListManager           = 357
FileLister            = 358
Current_Workspace_Settings = 359
CLOCK                 = 360
Count_MS              = 361
Change_Scale          = 362
Counter               = 363
Odd                   = 364
Quantize_Data         = 365
Quantize_Button       = 366
Quantize_Midi         = 367
Array_Difference      = 368
Array_Delete          = 369
TimeLine              = 370
Spot                  = 371
VLC                   = 372
VideoPlayer           = 373
SmoothAttackRelease   = 374
UsineColorToRGB       = 375
RGBtoUsineColor       = 376
3D_to_MatrixArray        = 381
3D_Transform_Translation = 382
3D_Transform_RotationZ   = 383
3D_Transform_RotationX   = 384
3D_Transform_RotationY   = 385
3D_Transform_Scaling     = 386
MatrixArray_to_3D        = 387
Set_Array_nb_lines       = 388
Get_Array_nb_lines       = 389
Set_Array_nb_rows        = 390
Get_Array_nb_rows        = 391
3D_Set_Point             = 392
3D_Get_Point             = 393
Quadratic_Distance_3D    = 394
DBAP_3D                  = 395
Equal_String             = 396
ClearChannelDMX          = 397
fMod                     = 398
Color Palette            = 399
int power                = 400
sqr                      = 401
Load_Rack                = 402
Dispatch_audio           = 403
Random_Array             = 404
Dispatch_String          = 405
Midi_Sampler             = 406
Master_DMX_Panel         = 407
Smooth_Color             = 408
Color_Mixer              = 409
LanguageID               = 410
SystemLanguageID         = 411
Patch_Bypass             = 412
Direct_DMX_array         = 413
Joystick                 = 414