Example Scripts

You can simply copy'n'paste the example scripts into a text file and upload them.

  1. Hello, world
  2. Failover 1
  3. Failover 2
  4. Autoroute

Hello, world

..what else did you expect? :)

Example

-- @name Hello world
-- @desc Check the log file to see the output
-- @fg #308d1d
-- @bg #ffffff

print("Hello, world!")

Failover 1

Imagine two consoles at MADI inputs 3/4 and 5/6 and an output path to 8/9. By the push of a button we want to create a port routing from 5/6 to 8/9.

Example

-- @name Failover 1
-- @desc Create port routing from 5/6 to 8/9
-- @fg #308d1d
-- @bg #ffffff

bulkbegin()
for idx=1,128 do
 setaudioxp(64*4+idx, 64*7+idx, 0)
end
bulkend()

Failover 2

Same situation as in Failover 1, but this time we don't want to create a simple 1:1 routing, instead we want to copy the routing currently active from 3/4 to 8/9.

Example

-- @name Failover 2
-- @desc Copy port routing from 3/4->8/9 to 5/6->8/9
-- @fg #308d1d
-- @bg #ffffff

bulkbegin()
for idx=1,128 do
 src=getaudioxp(64*2+idx, 0)
 if (src==-1) then
  setaudioxp(-1, 64*7+idx, 0)
 else
  setaudioxp(src+128, 64*7+idx, 0)
 end
end
bulkend()

Autoroute

Automatically route all not already connected channels from two input ports to two output ports.

Example

-- @name Auto routing
-- @desc Route all not already routed inputs from 1/2 to 7/8
-- @fg #eef6ff
-- @bg #122356


srcmin, srcmax = 1, 128 -- input channels 1..128
dstmin, dstmax = 385, 512 -- output channels 385..512

function is_connected(src)
 for i=dstmin,dstmax do
  if (xps[i]==src) then
   return true
  end
 end
 return false
end

src = srcmin
xps = getaudioxps(0)

bulkbegin()
for dst=dstmin,dstmax do
 if ((xps[dst]<srcmin) or (xps[dst]>srcmax)) then
  -- channel dst has no connection from [srcmin,srcmax], so
  -- find first unconnected channel from [srcmin,srcmax]..

  while (is_connected(src)) do
   src = src+1
  end
  -- ..and connect it
  setaudioxp(src, dst, 0)
  src = src+1
 end
end
bulkend()
Text and images © 2017 DirectOut Technologies, 07.02.2017