Updated 2015-01-09 09:11:14 by lm


TclJACK is a Tcl C extension I've been working on for interacting with a JACK audio server via its libjack interface. It's my first attempt at writing a C extension, and is hardly polished or well-written, but it exists and I've found it useful.

Example Use

% # Basic setup:
% package require TclJACK

% jack register
tcljack: JACK sampling frequency changed to 44100 Hz.
tcljack: JACK buffer size changed to 256.

% # Basic info:
% jack samplerate

% jack cpuload

% # Port information:
% jack ports
system:playback_1 system:playback_2 tcljack:input tcljack:midi_input {MPlayer [3182]:out_0} {MPlayer [3182]:out_1}

% foreach port [jack ports] {puts "$port: [jack porttype $port], [jack portflags $port]"}
system:playback_1: 32 bit float mono audio, input physical terminal
system:playback_2: 32 bit float mono audio, input physical terminal
tcljack:input: 32 bit float mono audio, input
tcljack:midi_input: 8 bit raw midi, input
MPlayer [3182]:out_0: 32 bit float mono audio, output
MPlayer [3182]:out_1: 32 bit float mono audio, output

% # You can analyse sound levels via TclJACK's audio input.
% jack connect {MPlayer [3182]:out_0} tcljack:input
% jack meter
0.2430237382650375 0.1043709889054298 0.0000897496938705 -0.0210323482751846
% # Output values are: abs peak, numeric RMS (cf. AES-17!), abs trough (smallest non-zero value), and DC offset (average) for the window (simply the last buffer processed).

% # Transport control uses sample frames for positioning, but you can easily derive more user-friendly representations.
% jack timecode
% jack transport start
% jack timecode
% jack transport stop
% jack transport locate 1000000
% jack timecode

% jack deregister

The git repository includes JACKManager, a compact Tcl/Tk-based control panel for JACK that uses TclJACK. I wanted something like QJackCtl that was a bit more compact and could be docked away into a statusbar or dock so it was always visible and accessible. I also found the conventional way of drawing patch connections as lines or splines difficult to read with more than a few connections, so have started implementing a matrix patchbay window for these.

Future Refinements

  • Finish implementing the matrix patchbay.
  • Generalise the audio metering in TclJACK and JACKManager to allow any number of meters (somehow create and destroy them).
  • Add commands for generating MIDI notes and control data (and have a play with procedurally-generated music) and reading MIDI note data (for implementing MIDI filters). Being able to store, retrieve and edit patch settings from external hardware via SysEx could be handy.
  • Producing and consuming actual audio in Tcl. It doesn't seem like the best language for this sort of task, but I would be interested in building a DAW that used JACK for audio I/O and see how well Tcl's channels would handle the disk I/O. I would imagine needing some C routines for audio mixing, but many of the effects could simply be farmed out to LADSPA plugins, which can be hosted within the JACK server process itself, IIUC. It would be natural to implement a new type of channel for JACK audio, although I have no idea how to do that!

lm2015-01-08 : Thanks for the work ! Do you thing at the end it could be possible to write a software like , say , Live !, Cubase or LMMS ? It seems your extension can record MIDI, audio (with gain management), but could it playback several tracks at the same time ? And a naive question : what about VST/VSTi plugins ?