MIDI AND OSC for onPC – Part III: Encoders, Faders, Feedback

There is an update/FAQ available for this video! Please check that!

More:    Top Page        Part I         Part II

On this page:        Groups/Presets        Modified files        Feedback & Syncing       Manage pages

This episode deals with how to map midi encoders to encoders of GrandMA3 onPC, how to use the executor faders, and how to send feedback to the motor faders of the X-Touch.
Here is some supplemental stuff and background to the video.

How to select fixtures, groups or presets in Chataigne

If you want to map a button or key on the midi device to select a group in onPC or to fire up a preset you can do that like this:
From the grandMA3 mapping select „Send command“ and add one of the options below as parameters:
      select a group:group 1“ or „selfix group 1
      select fixtures:selfix 101 103 105 201 202 203
      activate dimmer presets:at preset 1.3
      activate position presets:at preset 2.1
      activate „all“ presets:at preset 21.4
You can download my (not yet complete) example X-Touch2grandMA3 Chataigne file.

Modified Chataigne files

Some of the Chataigne support files for grandMA3 must be tweaked a little bit. The original files are by yastefan, and are made with true endless encoders in mind. So each turn would add or substract a defined value from the attribute. However, the encoders of X-Touch send increasing (absolute) values between 0 and 127. We therefore must adjust the range and also switch from relative to absolute in the grandMA encoders.

On a Mac the files can be found at
On Windows the path is a little bit different but you may find it.

Please replace the „Turn Encoder“ section with the code below. Note that we added two new devices „Blower“ and „Hazer“.
The main modification is the range of the slider. We allow negative values that are necessary for Pan and Tilt.

 "Turn Encoder":
          "type":"Enum", "options": 
            "Dimmer": "Dimmer",
            "Pan": "Pan",
            "Tilt": "Tilt",
            "Color1": "Color1",
            "ColorRGB_R": "ColorRGB_R",
            "ColorRGB_G": "ColorRGB_G",
            "ColorRGB_B": "ColorRGB_B",
            "ColorRGB_W": "ColorRGB_W",
            "ColorRGB_WW": "ColorRGB_WW",
            "ColorRGB_CW": "ColorRGB_CW",
            "ColorRGB_UV": "ColorRGB_UV",
            "Blower1": "Blower1",
            "Haze1": "Haze1"
        "Multiplicator": {"type": "Float", "min":-10, "max":10, "default":1, "description":"Speed of the encoder movement"},
        "Value": {"type": "Float", "ui":"slider", "min":-100, "max":100, "default":0, "mappingIndex": 0}


Please replace function „turnEncoder“ with the code below. The original code used „ at + “ what allows increasing values only. A simple „ at “ is the solution.

function turnEncoder(encoder, multiplicator, value) {
  // script.log("Attribute " + encoder + " at + " + value*multiplicator);
  script.log("Attribute " + encoder + " at " + value*multiplicator);
  // local.send("/cmd", "Attribute " + encoder + " at + " + value*multiplicator);
  local.send("/cmd", "Attribute " + encoder + " at " + value*multiplicator);

Feedback, Syncing
The X-Touch Compact allows the motor faders to be controlled remotely by midi control change commands. The script below is a plugin that sends the current fader values of the onPC towards the X-Touch. Currently, no perfect feedback is possible.
The plugin can be configured to run one time only or to loop a chosen number of times with a certain delay in between. This is not a perfect solution and I prefer the sync on demand option.
I found that when I move a fader slowly in the onPC and have sync set to permanent, the faders of the X-Touch produce a lot of noise, that may disturb less loud scenes.
Download lua script

This plugin reads the executor values from onPC and sends them to TouchOSC by OSC
and to Behringer X-Touch Compact by midi

The plugin does not yet track changes in the faders. You have to call it each time syncing is needed.
Or, you run it in a looop (configure nTimes etc. below)
Or put it as a Cmd in a sequence cue an adjust firing of the cue to your needs.

It is based on code by user "mr-button"

V 0.80


-- adjust the following variables to fit your setting

local OSCchannel=3
local nTimes = 1   -- you can loop the read out. "1" = single shot
local delay = .3   -- sleep between update loops

-- executors to read
local executor_table = {
		201, 202, 203, 204, 205, 206, 207, 208, 
		216, 217, 218, 219, 220, 221, 222, 223

local function main()
	function Read_Fader_Send_OSC_nn(executor_nr)
		local FaderDataStructure = {}
		my_ex_obj_1 = GetExecutor(executor_nr)
		if my_ex_obj_1 == nil then
			-- Echo("Executor not assigned")
			local fader_current_Value = my_ex_obj_1:GetFader(FaderDataStructure);
			local exact = fader_current_Value  / 100
			Cmd("SendOSC 3 \"/Page1/Fader" .. executor_nr .. ",f," .. exact .. "\"")
			local fdr_nr = 0
			-- translate for Bank A of Behringer X-Touch compact
			if executor_nr < 209 then
			    fdr_nr = executor_nr-200
			    -- translate for Bank B
			    fdr_nr = executor_nr-188
			Cmd("SendMidi \"Control\" " ..  fdr_nr .. " " .. fader_current_Value*1.27 )
	for xx=1, nTimes, 1
	    for i, name in ipairs(executor_table) do
	    -- get the GrandMaster value 
	    local val = Root().ShowData.Masters.Grand.Master.NormedValue
	    -- Send GrandMaster value to X-Touch, midify it before
	    Cmd("SendMidi \"Control\" " ..  9 .. " " .. val*1.27 )
	    Cmd("SendMidi \"Control\" " ..  36 .. " " .. val*1.27 )
	    Cmd("SendOSC 3 \"/Master"   .. ",f," .. val/100 .. "\"")
	  coroutine.yield(delay) -- sleep well for a while

return main

Midi feedback must be enabled in onPC.
Menu -> Settings -> onPC Settings -> in and out
There is a video about that on Youtube.

How to manage pages with X-Touch and grandMA3
Some lighting people are used to preparing individual pages for e.g. each song of a show. However, the X-Touch provides only 2 pages and I use one for the 201 to 208 executor faders and the other page for group masters.
My workaround in onPC is, that I store all my pages from page 501 onward.
This means, when I finish editing my page #1, I will copy it to page #501, doing the same for the other pages with 502, 503 etc.
I have two helper macros. One asks for where to copy page #1 to. The other aks which page shall be recalled, i.e. copied to page #1, my actual working-with page.

Macro 1: Copy page xxx to page one, call Plugin 1 that syncs the X-Touch faders

Copy Page (Page - Page 1 will be overwritten!) At 1
Plugin 1

Macro 2: Copy page 1 to page xxx

Copy Page 1 At (Target Page#)

On this page:        Groups/Presets        Modified files        Feedback & Syncing       Manage pages

Modified files Feedback & Syncing