MIDI-MT - Specific MIDI-MT API objects in ChaiScripts

MIDI-MT Documentation in English

Specific MIDI-MT API objects in «ChaiScript»

     The scripting core of MIDI-MT is ChaiScript
     ChaiScript is a typed declarative language with syntax similar to C++, TypeScript and JavaScript.

Objects MIDI-MT API

Basic functions of the MIDI-MT API

Checking the execution cancellation status:

In scripts using loops, be sure to check the script’s cancellation status, example:

   while (!IsCanceled()) {
      // ... long job 1 ...
      if (IsCanceled()) { break; }
      // ... long job 2 ...
      if (IsCanceled()) { break; }
      // ... long job 3 ...
   }
Waiting and handling possible errors in a loop:
   while (!IsCanceled()) {
      try {
          // ... job ...
       } catch (e) {
          print("Oops, found error: " + e.what());
          break;
       }
       if (IsCanceled()) { break; }
       // wait one second 
       sleep(1000);
   }
Set and send a new value for a button:
   var scene = 176;
   var key = 23;

   UpdateControlButton(scene, key);
   // or:
   UpdateControlButton(176, 23);
   // or best practice:
   UpdateControlButton(uint8_t(176), uint8_t(23));
Set and send a new value for the slider:
   var scene = 176;
   var key = 44;
   var value = 42;

   UpdateControlSlider(scene, key, value);
   // or:
   UpdateControlSlider(176, 44, 42);
   // or best practice:
   UpdateControlSlider(uint8_t(176), uint8_t(44), uint8_t(42));
Getting a list of controls from a configuration file:
   // Get all units list, from configuration file
   var list = MidiUnitsList();
   print(list);
   // or:
   for (auto i = 0; i < list.size(); ++i) {
      auto unit = list[i];
      print(unit);
   }
Searching for a control in the configuration:
   var group = uint8_t(176);
   var key = uint8_t(3);
   var slider176_3 = Unit(group, key, uint8_t(42), UnitTypeIndex.SLIDER);

   var find_unit = FindMidiUnit(slider176_3);
   if (!find_unit.empty()) {
      print(find_unit);
   }

Basic MIDI-MT API Objects

MMTConfig

constructor: none
functions:

   MMTConfig.Find(uint8_t)
   MMTConfig.Find(uint8_t, uint8_t)
   MMTConfig.Find(uint8_t, uint8_t, UnitTypeIndex)
   MMTConfig.Find(TargetIndex)
   MMTConfig.Add(MidiUnit)
   MMTConfig.clear()
   MMTConfig.empty()
   MMTConfig.dump()

variables:

   MMTConfig.AutoStart
   MMTConfig.ConfigName
   MMTConfig.BuilderVersion
BaseUnit

constructor: var bu = BaseUnit()
functions:

   BaseUnit.empty()
   BaseUnit.dump()

variables:

   BaseUnit.id
   BaseUnit.key
   BaseUnit.scene
   BaseUnit.target
   BaseUnit.longtarget
   BaseUnit.type
   BaseUnit.value
   BaseUnit.apps
MidiUnit

constructor: var mu = MidiUnit()
functions:

   MidiUnit.Equals(MidiUnit)
   MidiUnit.EqualsGroup(MidiUnit)
   MidiUnit.GetMixerId()
   MidiUnit.GetHash()
   MidiUnit.empty()
   MidiUnit.dump()

variables:

   MidiUnit.id
   MidiUnit.key
   MidiUnit.scene
   MidiUnit.group
   MidiUnit.target
   MidiUnit.type
   MidiUnit.value
   MidiUnit.apps
UnitValue (MidiUnit.value(), MixerUnit.value)

constructor: var uv = UnitValue()
functions:

   UnitValue.empty()
   UnitValue.dump()

variables:

   UnitValue.value
   UnitValue.onoff
   UnitValue.type
MidiData

constructor: var md = MidiData()
functions:

   MidiData.SetData(uint8_t, uint8_t, uint8_t, uint8_t, uint8_t)
   MidiData.SetValue(bool)
   MidiData.GetScene()
   MidiData.GetKey()
   MidiData.GetValue()
   MidiData.GetTarget()
   MidiData.Equals(MidiData)
   MidiData.clear()
   MidiData.empty()
   MidiData.dump()
Unit (Color unit, Macro unit)

constructor: var unit = Unit()
additional constructors:

   Unit(U8Vector, uint8_t)
   Unit(uint8_t, uint8_t, uint8_t)
   Unit(uint8_t, uint8_t, uint8_t, UnitTypeIndex)

functions:

   Unit.GetType()
   Unit.SetValue()
   Unit.GetSene()
   Unit.GetKey()
   Unit.GetValue()
   Unit.empty()
   Unit.dump()
ColorCorrector

constructor: var unit = ColorCorrector(r, g, b, w) color correction value -127 to 127
additional constructors:

   ColorCorrector(8Vector)

functions:

   ColorCorrector.Get()
   ColorCorrector.empty()
   ColorCorrector.dump()
RGBW

constructor: var rgb = RGBW()
additional constructors:

   RGBW(U8Vector, U8Vector, U8Vector)
   RGBW(U8Vector, U8Vector, U8Vector, U8Vector)

functions:

   RGBW.SetColor(uint8_t, uint8_t, uint8_t, uint8_t)   // set RGBW color type
   RGBW.SetColor(uint16_t, uint8_t, uint8_t)           // set HSB/HSV color type
   RGBW.SetColor(ColorsIndex)                          // set RGBW color by index
   RGBW.SetHue(uint16_t)                               // set Hue: 0-359
   RGBW.SetSaturation(uint8_t)                         // set Saturation: 0-99
   RGBW.SetBrightness(uint8_t)                         // set Brightness: 0-99
   RGBW.FadeIn(size_t, size_t, size_t)                 // values -> start: 0-99, end: 0-99, wait: ms.
   RGBW.FadeOut(size_t, size_t, size_t)                // values -> start: 0-99, end: 0-99, wait: ms.
   RGBW.On()
   RGBW.Off()
   RGBW.R()
   RGBW.G()
   RGBW.B()
   RGBW.W()
   RGBW.GetColor(ColorIndex)
   RGBW.GetHue()
   RGBW.GetSaturation()
   RGBW.GetBrightness()
   RGBW.GetGroup()
   RGBW.ApplyValues()
   RGBW.UpdateValues()
   RGBW.empty()
   RGBW.dump()

utilites:

   var group = 176;
   var key_red = 11;
   var key_green = 12;
   var key_blue = 13;
   var key_white = 14;

   auto rgb  = CreateRGB(uint8_t(group), uint8_t(key_red), uint8_t(key_green), uint8_t(key_blue));
   auto rgbw = CreateRGBW(uint8_t(group), uint8_t(key_red), uint8_t(key_green), uint8_t(key_blue), uint8_t(key_white));

An example of using additional constructors:

   var v1 = U8Vector()
   v1.push_back(176)
   v1.push_back(11)

   var v2 = U8Vector()
   v2.push_back(176)
   v2.push_back(12)

   var v3 = U8Vector()
   v3.push_back(176)
   v3.push_back(13)

   var v4 = U8Vector()
   v4.push_back(176)
   v4.push_back(14)

   var color_control = RGBW(v4, v3, v2);

   // <- update values from configuration:
   color_control.UpdateValues();

   print(color_control);

   // color_control.SetColor(ColorsIndex.LIME);
   // or:
   // .SetColor(Hue, Saturation, Brightness);
   color_control.SetColor(180, 50, 99);

   // FadeIn / FadeOut (
   //   initial brightness value,
   //   final brightness value,
   //   delay in milliseconds
   // );
   color_control.FadeIn(0, 100, 200);
   color_control.FadeOut(100, 0, 200);

More about the color scheme “HSB”/“HSV”

Macro

constructor: var macro = Macro()
functions:

   Macro.Add(Unit)  // Unit(uint8_t, uint8_t, uint8_t, UnitTypeIndex)
   Macro.ApplyValues()
   Macro.UpdateValues()
   Macro.clear()
   Macro.empty()
   Macro.dump()

Example of using the Macro object:


   var group = uint8_t(176);
   var key1 = uint8_t(11);
   var key2 = uint8_t(12);
   var key3 = uint8_t(13);
   var key4 = uint8_t(14);

   var macro_group = Macro();

   macro_group.Add(
     Unit(group, key1, uint8_t(0), UnitTypeIndex.BTN)
   );
   macro_group.Add(
     Unit(group, key2, uint8_t(0), UnitTypeIndex.BTN)
   );
   macro_group.Add(
     Unit(group, key3, uint8_t(0), UnitTypeIndex.BTN)
   );
   macro_group.Add(
     Unit(group, key4, uint8_t(42), UnitTypeIndex.SLIDER)
   );

   // real time apply values:
   macro_group.ApplyValues();
   // or, -> update values to configuration:
   macro_group.UpdateValues();
ColorIndex
name group
ColorIndex.RED ColorGroup::RED 0
ColorIndex.GREEN ColorGroup::GREEN 1
ColorIndex.BLUE ColorGroup::BLUE 2
ColorIndex.WHITE ColorGroup::WHITE 3
ColorsIndex
name group
ColorsIndex.OFF ColorsGroup::OFF 0
ColorsIndex.ON ColorsGroup::ON 1
ColorsIndex.RED ColorsGroup::RED 2
ColorsIndex.MAROON ColorsGroup::MAROON 3
ColorsIndex.YELLOW ColorsGroup::YELLOW 4
ColorsIndex.OLIVE ColorsGroup::OLIVE 5
ColorsIndex.LIME ColorsGroup::LIME 6
ColorsIndex.GREEN ColorsGroup::GREEN 7
ColorsIndex.AQUA ColorsGroup::AQUA 8
ColorsIndex.TEAL ColorsGroup::TEAL 9
ColorsIndex.BLUE ColorsGroup::BLUE 10
ColorsIndex.MAGENTA ColorsGroup::MAGENTA 11
ColorsIndex.PURPLE ColorsGroup::PURPLE 12
TargetIndex
name group
TargetIndex.MAV MIDI::Mackie::Target::MAV 0
TargetIndex.MAP MIDI::Mackie::Target::MAP 1
TargetIndex.MAM MIDI::Mackie::Target::MAM 2
TargetIndex.MAS MIDI::Mackie::Target::MAS 3
TargetIndex.JOG MIDI::Mackie::Target::JOG 4
TargetIndex.AV1 MIDI::Mackie::Target::AV1 5
TargetIndex.AV2 MIDI::Mackie::Target::AV2 6
TargetIndex.AV3 MIDI::Mackie::Target::AV3 7
TargetIndex.AV4 MIDI::Mackie::Target::AV4 8
TargetIndex.AV5 MIDI::Mackie::Target::AV5 9
TargetIndex.AV6 MIDI::Mackie::Target::AV6 10
TargetIndex.AV7 MIDI::Mackie::Target::AV7 11
TargetIndex.AV8 MIDI::Mackie::Target::AV8 12
TargetIndex.XV9 MIDI::Mackie::Target::XV9 13
TargetIndex.AP1 MIDI::Mackie::Target::AP1 14
TargetIndex.AP2 MIDI::Mackie::Target::AP2 15
TargetIndex.AP3 MIDI::Mackie::Target::AP3 16
TargetIndex.AP4 MIDI::Mackie::Target::AP4 17
TargetIndex.AP5 MIDI::Mackie::Target::AP5 18
TargetIndex.AP6 MIDI::Mackie::Target::AP6 19
TargetIndex.AP7 MIDI::Mackie::Target::AP7 20
TargetIndex.AP8 MIDI::Mackie::Target::AP8 21
TargetIndex.XP9 MIDI::Mackie::Target::XP9 22
TargetIndex.B11 MIDI::Mackie::Target::B11 23
TargetIndex.B12 MIDI::Mackie::Target::B12 24
TargetIndex.B13 MIDI::Mackie::Target::B13 25
TargetIndex.B14 MIDI::Mackie::Target::B14 26
TargetIndex.B15 MIDI::Mackie::Target::B15 27
TargetIndex.B16 MIDI::Mackie::Target::B16 28
TargetIndex.B17 MIDI::Mackie::Target::B17 29
TargetIndex.B18 MIDI::Mackie::Target::B18 30
TargetIndex.B19 MIDI::Mackie::Target::B19 31
TargetIndex.B21 MIDI::Mackie::Target::B21 32
TargetIndex.B22 MIDI::Mackie::Target::B22 33
TargetIndex.B23 MIDI::Mackie::Target::B23 34
TargetIndex.B24 MIDI::Mackie::Target::B24 35
TargetIndex.B25 MIDI::Mackie::Target::B25 36
TargetIndex.B26 MIDI::Mackie::Target::B26 37
TargetIndex.B27 MIDI::Mackie::Target::B27 38
TargetIndex.B28 MIDI::Mackie::Target::B28 39
TargetIndex.B29 MIDI::Mackie::Target::B29 40
TargetIndex.B31 MIDI::Mackie::Target::B31 41
TargetIndex.B32 MIDI::Mackie::Target::B32 42
TargetIndex.B33 MIDI::Mackie::Target::B33 43
TargetIndex.B34 MIDI::Mackie::Target::B34 44
TargetIndex.B35 MIDI::Mackie::Target::B35 45
TargetIndex.B36 MIDI::Mackie::Target::B36 46
TargetIndex.B37 MIDI::Mackie::Target::B37 47
TargetIndex.B38 MIDI::Mackie::Target::B38 48
TargetIndex.B39 MIDI::Mackie::Target::B39 49
TargetIndex.FUN11 MIDI::Mackie::Target::FUN11 50
TargetIndex.FUN12 MIDI::Mackie::Target::FUN12 51
TargetIndex.FUN13 MIDI::Mackie::Target::FUN13 52
TargetIndex.FUN14 MIDI::Mackie::Target::FUN14 53
TargetIndex.FUN15 MIDI::Mackie::Target::FUN15 54
TargetIndex.FUN16 MIDI::Mackie::Target::FUN16 55
TargetIndex.FUN17 MIDI::Mackie::Target::FUN17 56
TargetIndex.FUN18 MIDI::Mackie::Target::FUN18 57
TargetIndex.FUN21 MIDI::Mackie::Target::FUN21 58
TargetIndex.FUN22 MIDI::Mackie::Target::FUN22 59
TargetIndex.FUN23 MIDI::Mackie::Target::FUN23 60
TargetIndex.FUN24 MIDI::Mackie::Target::FUN24 61
TargetIndex.FUN25 MIDI::Mackie::Target::FUN25 61
TargetIndex.FUN26 MIDI::Mackie::Target::FUN26 62
TargetIndex.FUN27 MIDI::Mackie::Target::FUN27 63
TargetIndex.FUN28 MIDI::Mackie::Target::FUN28 64
TargetIndex.SYS_Rewind MIDI::Mackie::Target::SYS_Rewind 65
TargetIndex.SYS_Forward MIDI::Mackie::Target::SYS_Forward 66
TargetIndex.SYS_Stop MIDI::Mackie::Target::SYS_Stop 67
TargetIndex.SYS_Play MIDI::Mackie::Target::SYS_Play 68
TargetIndex.SYS_Record MIDI::Mackie::Target::SYS_Record 69
TargetIndex.SYS_Up MIDI::Mackie::Target::SYS_Up 70
TargetIndex.SYS_Down MIDI::Mackie::Target::SYS_Down 71
TargetIndex.SYS_Left MIDI::Mackie::Target::SYS_Left 72
TargetIndex.SYS_Right MIDI::Mackie::Target::SYS_Right 73
TargetIndex.SYS_Zoom MIDI::Mackie::Target::SYS_Zoom 74
TargetIndex.SYS_Scrub MIDI::Mackie::Target::SYS_Scrub 75
TargetIndex.VMSCRIPT MIDI::Mackie::Target::VMSCRIPT 249
TargetIndex.LIGHTKEY16B MIDI::Mackie::Target::LIGHTKEY16B 250
TargetIndex.LIGHTKEY8B MIDI::Mackie::Target::LIGHTKEY8B 251
TargetIndex.MQTTKEY MIDI::Mackie::Target::MQTTKEY 252
TargetIndex.MEDIAKEY MIDI::Mackie::Target::MEDIAKEY 253
TargetIndex.VOLUMEMIX MIDI::Mackie::Target::VOLUMEMIX 254
TargetIndex.NOTARGET MIDI::Mackie::Target::NOTARGET 255
UnitTypeIndex
name group
UnitTypeIndex.FADER MIDI::MidiUnitType::FADER 0
UnitTypeIndex.SLIDER MIDI::MidiUnitType::SLIDER 1
UnitTypeIndex.KNOB MIDI::MidiUnitType::KNOB 2
UnitTypeIndex.BTN MIDI::MidiUnitType::BTN 3
UnitTypeIndex.KNOBINVERT MIDI::MidiUnitType::KNOBINVERT 4
UnitTypeIndex.FADERINVERT MIDI::MidiUnitType::FADERINVERT 5
UnitTypeIndex.SLIDERINVERT MIDI::MidiUnitType::SLIDERINVERT 6
UnitTypeIndex.UNITNONE MIDI::MidiUnitType::UNITNONE 255
ClickTypeIndex
name group
ClickTypeIndex.ClickOnce MIDI::Mackie::ClickType::ClickOnce 0
ClickTypeIndex.ClickLong MIDI::Mackie::ClickType::ClickLong 1
ClickTypeIndex.ClickTrigger MIDI::Mackie::ClickType::ClickTrigger 2
ClickTypeIndex.ClickSlider MIDI::Mackie::ClickType::ClickSlider 3
ClickTypeIndex.ClickUnknown MIDI::Mackie::ClickType::ClickUnknown 255
Specific container objects
name specification
UnitVector std::vector<MidiUnit>
U8Vector std::vector<uint8_t>
U16Vector std::vector<uint16_t>
U32Vector std::vector<uint32_t>
I32Vector std::vector<int32_t>
VectorString std::vector<std::string>
VectorWstring std::vector<std::wstring>

ChaiScript documentation and examples

  1. Find out more in documentation and examples on the ChaiScript website.
  2. View more code examples ChaiScript.
  3. ChaiScript language reference.
  4. Getting started with ChaiScript:
  5. Specific MIDI-MT API objects in scripts.
  6. Example MIDI-MT API.
  7. Examples of RGB LED controls:
  8. Other examples:
  9. Useful additions: