Hi, I made some c++ classes which wrap the Jack audio io api and lock-free ring buffer. Works with Linux and OSX (thanks to Will Wolcott for OSX testing and example/test file comments).


This code is licensed with version 3 of the GPL license and is intended for use with in open source projects.

How to get it

I have created a github project where you can find the source code. There you can use git to download the code or use github's handy 'download' link.


View the doxygen generated documentation here: doc


Below is a simple c++ example program that uses this api. A more in depth example is included in the download.

#include "jackaudioio.hpp"
#define MIN(x,y) ((x) < (y) ? (x) : (y))

class TestJack: public JackCpp::AudioIO {
    // Your audio callback. All audio processing goes in this function.
    virtual int audioCallback(jack_nframes_t nframes, 
        audioBufVector inBufs,
        audioBufVector outBufs){
      for(unsigned int i = 0; i < MIN(inBufs.size(),outBufs.size()); i++){
        // A simple example: copy the input to the output.
        for(unsigned int j = 0; j < nframes; j++)
          outBufs[i][j] = inBufs[i][j];
      //0 on success
      return 0;
    TestJack() :
      JackCpp::AudioIO("jackcpp-test", 2,2){

int main(){
  // initial ports from constructor created here.
  TestJack * t = new TestJack;
  t->start();  // activate the client

  //connect our ports to physical ports
  t->connectToPhysical(0,0);    // connects this client out port 0 to physical destination port 0
  t->connectToPhysical(1,1);    // connects this client out port 1 to physical destination port 1
  t->connectFromPhysical(0,0);  // connects this client in port 0 to physical source port 0
  t->connectFromPhysical(1,1);  // connects this client in port 1 to physical source port 1

  sleep(20);    // sleep to allow the callback to run for 20 seconds.
  t->close();  // stop client.
  delete t;  // always clean up after yourself.