Interface: JACK Audio Connection Kit

The Arrp compiler can generate C++ code for a Jack client using the option --interface jack.

CMake helps automate the process of generating this C++ code and further compiling it into an executable.


This example demonstrates how to create a Jack client from simple Arrp code that outputs a sine wave at 440 Hz.



Place the following files into the same directory:


input samplerate : int;
output y : [~]real64;

y = osc(440.0, 0.0);

osc(freq, init_ph) =
  sin(ph * 2 * pi) where
    ph = phase(freq, init_ph);

phase(freq, init) = p where
    p[0] = init;
    p[n] = wrap(p[n-1] + freq[n-1] / samplerate);

wrap(x) = x - floor(x);

pi = atan(1) * 4;


cmake_minimum_required(VERSION 3.0)


# Uncomment and adjust the following line
# to specify non-standard location of the Arrp compiler
# set(CMAKE_PREFIX_PATH "path where Arrp is installed")

find_package(Arrp REQUIRED)

arrp_to_jack(osc-jack osc.arrp)

Procedure (Linux, Mac OS)

  1. In the directory containing the above files, run the following commands to generate a Jack client executable osc-jack.

     mkdir build
     cd build
     cmake -D CMAKE_BUILD_TYPE=Release ..
     make osc-jack

    Note: If you want machine code that's easier to debug, replace the cmake command with:

     cmake -D CMAKE_BUILD_TYPE=Debug ..
  2. With the Jack server running, execute osc-jack.

  3. A sine wave at 440 Hz will now be playing on the first default Jack output channel.