making a custom patchbay

Programming applications for making music on Linux.

Moderators: MattKingUSA, khz

Post Reply
tatch
Established Member
Posts: 662
Joined: Fri Nov 16, 2012 3:18 pm

making a custom patchbay

Post by tatch »

I want to write a patchbay app that will connect ports from different applications in a specific way. I want to connect clients with the same name together in a predetermined chain; my particular use case would be to eg connect all clients with "bass" in their names in the order of

bass-rack (carla)-> bass-sc (carla) -> bass (non-mixer)
voice-rack (carla)-> voice-sc (carla) -> voice (non-mixer)

etc. My plan is to have the logic go something like this:

Code: Select all

track_names = [bass, pad, main, voice, drums]
track_order = [rack, sc, non-mixer]

on init:
    clients = get(all_jack_clients)
    for track_name in track_names:
        for track_client in track_order:
            track = track_name + track_client
        if track in clients:
            connect_to_next_client(track)

connect_to_next_client would connect rack to sc (or non-mixer if sc isn't available) and sc to non-mixer. I was thinking of having this run in the background but for now I wouldn't mind just executing it manually.

I've never written an application for JACK before so I'm not really sure where to start but I think I might be able to work with JACKPatch since it's relatively small and reads all the jack ports. I guess I would probably have to rethink my pseudocode in terms of ports (and c++, i think I can handle that) but it should still be fine I think. Well even though I said it's small I'm still a little daunted and don't know what each of these functions do/which ones i need to read all the ports. Could someone give me a hand in figuring this out? https://github.com/original-male/non/bl ... ackpatch.c thanks!
User avatar
noedig
Established Member
Posts: 239
Joined: Wed Feb 12, 2014 4:39 am
Location: South Africa
Has thanked: 9 times
Been thanked: 54 times

Re: making a custom patchbay

Post by noedig »

Hi

Firstly, the Jack API documentation is a good reference to keep handy: http://jackaudio.org/files/docs/html/index.html

Secondly, here is a list of example Jack clients: http://jackit.sourceforge.net/cgi-bin/l ... e-clients/
The connect.c example connects or disconnects two ports.

Thirdly, here is a short intro to writing a Jack application: http://dis-dot-dat.net/index.cgi?item=j ... /starting/


To summarize, the basics steps are:
Include <jack/jack.h>.
Become a client with the jack_client_new() function.
Once you are a client, you can list all the ports with jack_get_ports().
If you want to perform a function automatically every time a port is connected, for instance, you have to create a callback function and give it to jack_set_port_connect_callback().
(There are a few other callbacks too).
Before you can actually start doing something (like connecting ports, etc.), you have to activate your client with jack_activate().
When building, use pkg-config (discribed in the third link above).

You will see some of the above points in the connect.c example and in the JACKPatch source.

Hope this puts you on the right track.
Post Reply