JacktLab- Jack Audio in Matlab®

JacktLab is a very simple interface to connect the Jack Audio server to Matlab®. This MEX file brings low-latency, high resolution, multi-channel audio capture to Matlab®. Jack is a low-latency interprocess audio server that runs on Mac OS X and Linux. Matlab® is a particularly popular wrapper for FFTW and LAPACK. Octave® users: check out Jacktave.

Features

  1. Sampling rate set by Jack Server (can be > 44100)
  2. Arbitrary number of receive ports.
  3. 32-bit float precision for input samples.

Limitations

  1. Capture only.
  2. Always creates a client named "Matlab"; only one instance can be run.
  3. Ports named sequentially, "input0", "input1", ...
  4. Does not auto-connect to send ports, use jack_connect or JackPilot.

Installation

  1. Install Jack, including the jack server and development files.
  2. Start the Jack server.
  3. Download the MEX file, open Matlab® and run:

    mex -ljack /Path/to/the/file/jack.c

Usage

This creates a single function jack; to start a jack client call this function with three scalar arguments:

jack(channels, frame_width, fifo_size)

A frame is a matrix with one column of consecutive samples for each channel. Each column will contain frame_width samples. The FIFO will hold at least fifo_size frames, but possibly more.

jack()

Calling jack with no arguments now returns a frame:

A = jack();

This call will always return the oldest frame in the FIFO. If the FIFO fills, new data will not be written to it until the next read is complete. If a read is attempted while the FIFO is empty, an error will be thrown.

jack(k)

Calling jack with a single scalar argument controls the FIFO and allows frames to be skipped. If the scalar is less than or equal to zero, only the current number of frames is returned, e.g.:

jack(0)
jack(-1)
jack(-2)
...

All the above calls simply return the number of frames in the FIFO. If the scalar argument is positive, frames will be removed from the FIFO:

jack(1)

will attempt to remove one frame from the FIFO, and return the number of frames still remaining. Combining these two functions, we have:

jack(jack(0))

which will always clear the FIFO entirely and:

jack(jack(0)-1)

which will leave one frame in the FIFO, or zero if the FIFO is empty.

jack('close')

Calling jack with the string 'close' closes and deallocates the client.

jack('close');

For now, the behavior of jack called with other arguments is left unspecified.

Please send patches, and bug reports to the email at the bottom of the page.