Home

Awesome

LuaJack: Lua bindings for the JACK Audio Connection Kit

LuaJack is a Lua binding library for the JACK Audio Connection Kit.

It runs on GNU/Linux and requires Lua (>=5.3) and JACK (API >= v0.124.1).

Authored by: Stefano Trettel

Lua logo

License

MIT/X11 license (same as Lua). See LICENSE.

Documentation

See the Reference Manual.

Getting and installing (Ubuntu)

Setup the build environment as described here, then:

$ git clone https://github.com/stetre/luajack
$ cd luajack
luajack$ make
luajack$ sudo make install

Example

The example below creates a JACK client that simply copies samples from an input port to an output port. Other examples can be found in the examples/ directory contained in the release package.

-- Script: example.lua
jack = require("luajack")

-- Open a JACK client:
c = jack.client_open("myclient")

-- Create two ports:
p_in = jack.input_audio_port(c, "port_in")
p_out = jack.output_audio_port(c, "port_out")

-- Load the 'process' chunk:
jack.process_load(c, [[
c, p_in, p_out = table.unpack(arg)

function process(nframes)
   -- Copy the samples from the input port to the output port:
   jack.get_buffer(p_in)
   jack.get_buffer(p_out)
   jack.copy(p_out, p_in) 
end

-- Register the (rt) process callback:
jack.process_callback(c, process)
]], c, p_in, p_out)

-- Register a non-rt callback:
jack.shutdown_callback(c, function() error("shutdown from server") end)

-- Activate the client:
jack.activate(c)

-- Sleep, waiting for JACK to call back: 
jack.sleep()

The script can be executed at the shell prompt with the standard Lua interpreter:

$ lua example.lua

See also