First project - KDE Widget for Jack Transport

Programming applications for making music on Linux.

Moderators: MattKingUSA, khz

Post Reply
User avatar
Largos
Established Member
Posts: 617
Joined: Mon Oct 05, 2020 12:21 pm
Has thanked: 70 times
Been thanked: 179 times

First project - KDE Widget for Jack Transport

Post by Largos »

To say I don't really know what I am doing is putting it mildly. I have created the UI for a widget so that the play stop and skip controls for jack transport can be in the panel of a plasma desktop. What I don't know is how to send the commands and to what to have them actually working (small detail, I know). I have actually spent a good bit of time on this because I had to learn all the qml stuff.

I created a gitlab page for it here https://gitlab.com/a7534/jacktransportwidget

If you want to install it, you download it and move the jacktransportwidget folder to ~/.local/share/plasma/plasmoids You might have to restart plasma. It doesn't do anything at the moment, though.

What I want it to do is, detect in the background when JACK is running and connect to it. There is an indicator button on the widget, which I want to light up when it's connected. The buttons are skip forward and back, play/pause and stop. I copied the buttons off Catia. My idea for this was to move those buttons on the panel because that would be convenient.

Those are my first goals. If I can get that working, I'll see if I can do other things for jack from the panel.

What I am looking for is any advice and/or information to help with how I go about getting this to work because I haven't had any joy finding information on this.
User avatar
SpotlightKid
Established Member
Posts: 250
Joined: Sun Jul 02, 2017 1:24 pm
Has thanked: 48 times
Been thanked: 54 times

Re: First project - KDE Widget for Jack Transport

Post by SpotlightKid »

Do you want to write the main program logic in C++ or Python? In latter case, check out jackclient-python.

This example shows how to connect to a running JACK server and query and manipulate the transport state:

https://github.com/spatialaudio/jackcli ... sporter.py
User avatar
marbangens
Established Member
Posts: 56
Joined: Fri Nov 16, 2018 8:39 pm
Been thanked: 6 times

Re: First project - KDE Widget for Jack Transport

Post by marbangens »

If you like to detect jack in the background with c++ you probably need to create a thread with the lowest priority and just check for something simple and fast and then sleep kind of loop. Its a bit advanced for fist project, but you learn the most when you just go into the fun stuff from the start :D
There is the docs
https://jackaudio.org/api/group__TransportControl.html

You may need to use those, test what you need to use and what works for you and you're code :D

Code: Select all

jack_client_open()
// To change position, use jack_transport_reposition() and jack_transport_locate()
jack_transport_start()
jack_transport_stop()
Look at others code also, take things apart and test everything
User avatar
Largos
Established Member
Posts: 617
Joined: Mon Oct 05, 2020 12:21 pm
Has thanked: 70 times
Been thanked: 179 times

Re: First project - KDE Widget for Jack Transport

Post by Largos »

A little update on my progress, I decided to go with Python as I found the documentation for the jack api good to understand. Documentation for plasmoids is not so good, so I am making a standalone python/qml app instead. It has all the plasma integration, so the icons will change with plasma theme change. It won't be on the panel but obviously can be set for always on top for a similar effect.

I managed to find a video which told me how to get the qml to talk to the python so I have a working play button. The other buttons should hopefully be fairly straight forward, I'll do some tweaks to the qml and that will hopefully be ready.

I am not doing the indicator and auto detect that I want to do with plasmoid, as I don't think that will need that function. I don't know how to do that yet anyway.

I also spent an hour earlier shouting at the screen because I forgot I needed to start it with python3 not python and I kept using the up arrow in terminal to constantly repeat my mistake.
User avatar
Largos
Established Member
Posts: 617
Joined: Mon Oct 05, 2020 12:21 pm
Has thanked: 70 times
Been thanked: 179 times

Re: First project - KDE Widget for Jack Transport

Post by Largos »

https://gitlab.com/Largos/jack-transport-for-plasma

That's the page for the stand alone application. It's usable now though has a few faults.

The stop button breaks the animation of the play/pause button and the play/pause button is not synced with other jack apps. Not figured out how to get the background to follow theming so it's a neutral gray. You can change the "color" field in the qml file to whatever you want easily though, even transparent..
User avatar
SpotlightKid
Established Member
Posts: 250
Joined: Sun Jul 02, 2017 1:24 pm
Has thanked: 48 times
Been thanked: 54 times

Re: First project - KDE Widget for Jack Transport

Post by SpotlightKid »

Nice. You probably shouldn't create the jack client at the module level, but only if your main.py is actually run as the main script (i.e. after line 74f.).
Largos wrote: Sat Jan 29, 2022 5:42 pm The play/pause button is not synced with other jack apps.
You should probably use a QTimer to periodically poll `client.transport_state`.
User avatar
Largos
Established Member
Posts: 617
Joined: Mon Oct 05, 2020 12:21 pm
Has thanked: 70 times
Been thanked: 179 times

Re: First project - KDE Widget for Jack Transport

Post by Largos »

SpotlightKid wrote: Sun Feb 06, 2022 3:58 pm
Nice. You probably shouldn't create the jack client at the module level, but only if your main.py is actually run as the main script (i.e. after line 74f.).
Why would this be bad? There is only the one python script being used.
You should probably use a QTimer to periodically poll `client.transport_state`.
Thanks, I will give this a try.
User avatar
SpotlightKid
Established Member
Posts: 250
Joined: Sun Jul 02, 2017 1:24 pm
Has thanked: 48 times
Been thanked: 54 times

Re: First project - KDE Widget for Jack Transport

Post by SpotlightKid »

Largos wrote: Mon Feb 07, 2022 12:01 pm Why would this be bad? There is only the one python script being used.
It's just a suggestion as a matter of principle. As it is, it doesn't hurt. But should you ever want to import your main.py as a module* or maybe you'll refactor your code along the way and put the JACK connection establishment in another module, it shouldn't trigger the connection at import time.

* for example, when you package your project as a Python package and define a command line script entry point in setup.py / setup.cfg, it will need to import main.py.
Post Reply