Related


Links

Am I free?


Social bookmarking

Delicious Bookmark this on Delicious


Tweets
Flickr randomness


Badges and junk

Support The Commons

Valid HTML 4.01 Strict
Valid CSS!













Along with all the useful clients given as examples, such as jack_metro and jack_lsp, there is a file called simple_client.c. I've had a look through it, and it appears that all this client does is take its input and pass it as output, but to be sure, lets try it out.

Before we compile it and try it, lets just make a minor change. The simple client only runs for 10 seconds - here's the snippet of code that causes this to happen:

.
...
	sleep (10);
	jack_client_close (client);
	exit (0);
}

So, after all of the setting up is done, the client sleeps for 10 seconds before telling JACK it's finished and quitting. A sensible question at this point is "How can it do anything while it's asleep?", and here's the answer: JACK (at least, as far as this example goes) works with callbacks. It is JACK that requests us to do something by calling a function that it was given, rather than it being our job to do some processing and hand the output to JACK. Is that clear? If not, don't worry - we'll see how this works later on.

Back to our minor change: we don't want to quit until we kill the client, so we have time to experiment. Remove the sleep(10); line and replace it with something like:

	for(;;)
	  sleep (1);

Which will cause the simple client to run until we kill it (C-c). Now compile your modified simple client:

$gcc -o simple `pkg-config --cflags --libs jack` simple_client.c
$

No errors - always a good sign.

Now to test the simple client. The easiest way to do this is to run something with output (I used the metronome again) as well as the simple client that we just compiled and connect them together. Here's how I did it:

$./simple aaa &
[1] 31205
the sample rate is now 48000/sec
engine sample rate: 48000

$jack_metro -b 120 &
[2] 31222

$jack_lsp
alsa_pcm:capture_1
alsa_pcm:capture_2
alsa_pcm:playback_1
alsa_pcm:playback_2
aaa:input
aaa:output
metro:120_bpm

$jack_connect metro:120_bpm aaa:input
engine sample rate: 48000

And we have the (single speaker) beeping again, but this time going through our simple client.

A few notes before we go any further:

To stop the beeping, we need to bring the commands back into the foreground and kill them (there are plenty of other ways, but this is how I'm doing it):

$fg
jack_metro -b 120
[C-c]
$fg
./simple aaa
[C-c]
$

Groovy. Actually typing control-c doesn't show up, so I've put it in as [C-c].

top - Previous - Next