arc4all
script laptop and arc integration using lua
I love Lua. It’s so comfortable to use when programming little scripts for norns or little plugins for neovim. The other weekend I wanted to use the arc to control some shader parameters in a TouchDesigner patch. It took me a bit to figure out how OSC works in TouchDesigner and decided it would be nice to have a little command-line utility that discovers what port your Arc is listening on and handles that connection for you. The result is a little piece of code that I felt like sharing in the spirit of threads like Norns for laptops: hopefully if you’re like me and enjoy writing Lua to interact with the Arc more than wrangling Max/MSP, this can be inspiring. Soon I’d like to rewrite it to be a little more robust and friendly.
Requirements
Arc, Lua with luasocket and losc, serialosc.
Installation
To use, you’ll need Lua installed on your laptop, as well as the packages luasocket
and losc
,
which you can install with LuaRocks by invoking
luarocks install luasocket
luarocks install losc
You’ll also need serialosc.
Usage
Plug in your arc and then open a terminal.
Usage is
lua /path/to/arc4all.lua '/relative/path/to/handler-script'
For example, if your terminal instance is in the folder containing arc4all,
and you want to run the example touchdesigner script, you would invoke
lua arc4all.lua 'examples/touchdesigner'
At the time of this writing, arc4all
is a blocking process until interrupted with CTRL+C (you might need to hit this twice).
Arc4all optionally broadcasts OSC data on port 9000 in the form of the following messages:
/val1 f
/val2 f
/val3 f
/val4 f
At the moment, arc4all listens for the following messages on port 8000:
/redraw n f
where n
is the ring number (1-indexed) and f
is a float to be interpreted by the handler script. The ring number can also be absorbed into the message address, for example
/redraw1 f
It also listens for
/configure
and forwards the (arbitrary) message contents to the handler script.
Handlers
The handler script is require
d by arc4all and is expected to return a Lua table
with the following three functions: delta
, redraw
and configure
.
If delta
returns a float, that float will be broadcast on port 9000.
The redraw
function is called with a ring number and a float and is expected to return an array of 64 integers 0–15 to represent the states of the arc LEDs.
The configure
function allows the behavior of the script to be altered over OSC.
As an example, the touchdesigner.lua
handler script imagines the arc as 4 configurable knobs
that send their current value when turned. The max, min and step size of these values is configurable over OSC.
Download
v0.1 – Github