Simple Jack MIDI Client in C++?

Programming applications for making music on Linux.

Moderators: MattKingUSA, khz

Post Reply
suprafly
Established Member
Posts: 4
Joined: Thu Jan 27, 2011 12:41 am

Simple Jack MIDI Client in C++?

Post by suprafly »

I am just getting started with Jack and linux-based audio. Currently working on a project in C++ where I am going to need to build Jack MIDI clients, however, the Jack API seems to be for C.

I have used JackCPP header wrappers for creating audio clients, however, they are only for the audio i/o libraries.

Is there anything out there for using Jack's midiport.h in C++? Or, any other way to create a MIDI client to talk to Jack?

Thanks!
User avatar
autostatic
Established Member
Posts: 1994
Joined: Wed Dec 09, 2009 5:26 pm
Location: Beverwijk, The Netherlands
Has thanked: 32 times
Been thanked: 104 times
Contact:

Re: Simple Jack MIDI Client in C++?

Post by autostatic »

suprafly wrote:I am just getting started with Jack and linux-based audio. Currently working on a project in C++ where I am going to need to build Jack MIDI clients, however, the Jack API seems to be for C.
Hello suprafly, did you also take a look at Jack2? That implementation is written in C++ instead of C.
suprafly wrote:Is there anything out there for using Jack's midiport.h in C++? Or, any other way to create a MIDI client to talk to Jack?
You could take a look at RtMidi: http://www.music.mcgill.ca/~gary/rtmidi/

Best,

Jeremy
brummer

Re: Simple Jack MIDI Client in C++?

Post by brummer »

you could use jack headers in C or C++ independent if you use jackd or jackdmp, because:

Code: Select all

 #ifdef __cplusplus
extern "C" {
#endif
If you like you could have a look at our implementation here :
http://sourceforge.net/apps/trac/guitar ... x_jack.cpp
Isn't a simple client, but maybe it's helpful for you.
And here is our midi engine:
http://sourceforge.net/apps/trac/guitar ... e_midi.cpp
suprafly
Established Member
Posts: 4
Joined: Thu Jan 27, 2011 12:41 am

Re: Simple Jack MIDI Client in C++?

Post by suprafly »

Thanks for the help guys. I have a follow up question, probably very simple.

I am taking midisine.c from the example clients and attempting to compile it in C++. It creates the object file but when it comes to compiling the executable it gives me this:

Code: Select all

simple.o: In function `process(unsigned int, void*)':
simple.cpp:(.text+0xca): undefined reference to `jack_port_get_buffer'
simple.cpp:(.text+0xe2): undefined reference to `jack_port_get_buffer'
simple.cpp:(.text+0xf9): undefined reference to `jack_midi_get_event_count'
simple.cpp:(.text+0x135): undefined reference to `jack_midi_event_get'
simple.cpp:(.text+0x17f): undefined reference to `jack_midi_event_get'
simple.cpp:(.text+0x22d): undefined reference to `jack_midi_event_get'
simple.o: In function `main':
simple.cpp:(.text+0x395): undefined reference to `jack_client_open'
simple.cpp:(.text+0x3d9): undefined reference to `jack_get_sample_rate'
simple.cpp:(.text+0x417): undefined reference to `jack_set_process_callback'
simple.cpp:(.text+0x42d): undefined reference to `jack_set_sample_rate_callback'
simple.cpp:(.text+0x464): undefined reference to `jack_port_register'
simple.cpp:(.text+0x48c): undefined reference to `jack_port_register'
simple.cpp:(.text+0x49f): undefined reference to `jack_activate'
Any ides why I am getting an undefined reference?
User avatar
raboof
Established Member
Posts: 1865
Joined: Tue Apr 08, 2008 11:58 am
Location: Deventer, NL
Has thanked: 52 times
Been thanked: 80 times
Contact:

Re: Simple Jack MIDI Client in C++?

Post by raboof »

suprafly wrote:simple.cpp:(.text+0xca): undefined reference to `jack_port_get_buffer'[/code]

Any ides why I am getting an undefined reference?
I'm guessing you failed to link in libjack. How are you building this binary?
suprafly
Established Member
Posts: 4
Joined: Thu Jan 27, 2011 12:41 am

Re: Simple Jack MIDI Client in C++?

Post by suprafly »

A simple Makefile which compiles the binary with g++. What is the line for linking libjack?
User avatar
raboof
Established Member
Posts: 1865
Joined: Tue Apr 08, 2008 11:58 am
Location: Deventer, NL
Has thanked: 52 times
Been thanked: 80 times
Contact:

Re: Simple Jack MIDI Client in C++?

Post by raboof »

suprafly wrote:A simple Makefile which compiles the binary with g++. What is the line for linking libjack?
Could you paste the Makefile? iirc something like '-ljack' while linking should do it.
brummer

Re: Simple Jack MIDI Client in C++?

Post by brummer »

try this one

Code: Select all

g++ `pkg-config --libs jack` midisine.c -o midisine
regards brummer
suprafly
Established Member
Posts: 4
Joined: Thu Jan 27, 2011 12:41 am

Re: Simple Jack MIDI Client in C++?

Post by suprafly »

Thanks Brummer! That was the line I was missing.
Post Reply