Before we get to the code, lets make sure we can compile the example clients. I'll start with the metronome:
$gcc -o metronome metro.c /tmp/cc2hi1P0.o(.text+0x33): In function `process_silence': : undefined reference to `jack_port_get_buffer' /tmp/cc2hi1P0.o(.text+0x6f): In function `process_audio': : undefined reference to `jack_port_get_buffer' /tmp/cc2hi1P0.o(.text+0x15a): In function `process': : undefined reference to `jack_get_transport_info' /tmp/cc2hi1P0.o(.text+0x55d): In function `main': : undefined reference to `jack_client_new' /tmp/cc2hi1P0.o(.text+0x5ac): In function `main': : undefined reference to `jack_set_process_callback' /tmp/cc2hi1P0.o(.text+0x5d8): In function `main': : undefined reference to `jack_port_register' /tmp/cc2hi1P0.o(.text+0x5ea): In function `main': : undefined reference to `jack_get_sample_rate' /tmp/cc2hi1P0.o(.text+0x848): In function `main': : undefined reference to `sin' /tmp/cc2hi1P0.o(.text+0x89a): In function `main': : undefined reference to `jack_activate' collect2: ld returned 1 exit status
That didn't work too well. Why? Because we need to link the JACK libraries. All we need to do now is find out which ones we need and where they are. But wait! The FAQ has some info on this. JACK uses pkg-config to set the necessary flags, so we should use:
$ gcc -o metronome `pkg-config --cflags --libs jack` metro.c
to compile. The version installed with JACK is called jack_metro, so we'll cal ours metronome to avoid confusion.
If you don't have pkg-config, then do what it says in the FAQ - get a package for your distribution or get the source from http://freedesktop.org/software/pkgconfig/.
pkg-config is a nifty utility that sorts out the necessary compile and link flags for the given library. Lets see what flags this actually gives:
$pkg-config --cflags --libs jack -ljack -lpthread -ldl -lrt
So, we need to link to 4 libraries (jack, pthread, dl and rt), although this could possibly be different on your system. Good thing we have pkg-config, eh?
Now lets try compiling the metronome again.
$gcc -o metronome `pkg-config --cflags --libs jack` metro.c $
No messages. That's almost always a good sign.
If this worked, then you should be able to use the compiled file (metronome) like this:
$./metronome -b 120
and then connect it to your output (either with jack_connect from the command-line or with something graphical like qjackconnect). If none of this means anything to you, then you need to go back to the JACK site and find out what JACK is all about, make sure you have it installed and try out the example clients before you start writing your own applications. Here's how I did it (I have the jack server running under one shell, the metronome under another and the this was entered into the third:
$jack_lsp alsa_pcm:capture_1 alsa_pcm:capture_2 alsa_pcm:playback_1 alsa_pcm:playback_2 metro:120_bpm $jack_connect metro:120_bpm alsa_pcm:playback_1
And hey presto! We have a beep coming out of the speakers at 120 bpm (beeps per minute :). In case you haven't come across it before (although you should have, this tutorial is meant for people who have used JACK already), jack_lsp lists the available ports. In my case, I have the main playback and capture ports, and the metronome output. All I needed to do was connect the metronome output to one of the playback ports.
Notice that the beep comes out of one speaker only? That's because playback_1 and playback_2 are for left and right. If you want stereo beeping, connect the metronome output to the second playback port too.
The beeping is getting on my nerves now, so lets kill the metronome. C-c (control and C) will do the job. Lovely.
If this didn't work for you, make sure you are using the version of the example clients that came with your version of JACK.Top - Previous - Next