Raspberry pi 4 setup - getting crazy with jack

Trying to setup latest mod software on a raspberry pi 4 on raspberry OS 64 bit. And really need some help :neutral_face:

If I keep the jack.service mod-host.service in this way all is ok , can use mod and enjoy the wonderful plugins built with plugin builder for modduox.

[Unit]
Description=JACK2 Audio Server
#After=sound.target

[Service]
Environment=LV2_PATH=/home/sound/.lv2
Environment=JACK_NO_AUDIO_RESERVATION=1
Environment=JACK_PROMISCUOUS_SERVER=jack
LimitRTPRIO=99
LimitMEMLOCK=infinity
ExecStart=/usr/bin/jackd -t 2000 -R -P 99 -d alsa -d hw:pisound -r 48000 -p 128 -n default -X seq -s -S
Restart=always
RestartSec=1

[Install]
WantedBy=multi-user.target

The problem comes when I want to run this services as my regular user, in order to add other software to the equation . Puredata , Carla and patchage for instance , to route audio/midi here and there to and from mod etc.

When I do add this modifications to the .service’s files

User=sound
Group=audio

mod-ui fails , complaining about jack

jack server is not running or cannot be started JackShmReadWritePtr

then I tried to remove the user and group from mod-ui and it works , but I get mod without inputs and outputs , and the jack servers tells me there it was an error adding clients.

If I run the services as root it works well , but I cant use other software at the same time and every software I run cant seem to access the jack server , even with Environment=JACK_PROMISCUOUS_SERVER=jack

I’m quite sure I had this working in the past and would love to play with mod routing audio/midi from other apps for sequencing etc .
Its very clear that I don’t know what I’m doing, but I would suspect that jack and mod services should run as a separated user and not as root maybe ?

other modifications Ive made include adding JACK_PROMISCUOUS_SERVER=jack to /etc/environment. Adding my current USER to an audio group in /etc/security/limits.d/audio.conf following guides on jack realtime setup and so on

@audio   -  rtprio     99
@audio   -  memlock    unlimited

thanks for any hints, Im aware that this is not officially supported but Im sure someone here was in a similar situation or knows where the problem could be .

Its so much fun to run mod along other apps like Giada or pd

3 Likes

If you rely on jackd from debian repositiories to work on a scenario like this, yeah you are going to have a bad time.
Unless you get your hands dirty, compiling stuff on your own, expect pain :scream:

The same setup we use for jack and other tools wont work on generic distributions.
As you likely already saw, dealing with DBus on such a service is a pain, and I guess debian jack2 builds are also missing the systemd integration, not to mention being quite outdated by now.
Oh, and running as root can be a problem, the metadata fix required for it was made a few releases ago, debian is still on a version before that.

A lot of tinkering is needed to get things working just right, and stuff will break when you eventually update as newer kernel or systemd versions tend to change little details here and there.

and to be honest, I feel a bit dirty trying to guide such efforts… :roll_eyes:

4 Likes

No worries , you just gave me a good hint to go and try to build jack from sources. Thanks

1 Like

I compiled jack2 from git and went all smooth .
Everything looks quite similar . When adding the User and Group to mod-host & mod-ui, mod-host is ok with it , mod-ui isnt.
If I run manually mod-ui I get :

=/usr/local/bin/mod-ui
ERROR: Failed to open HMI serial port, error was:
__init__() got an unexpected keyword argument 'writeTimeout'
Using FakeHMI => <mod.development.FakeHMI object at 0x7f918fdd60>
cc start socket missing
PermissionError: [Errno 13] Permission denied
jack client deactivated NOT

pretty much like before I guess.

Then I changed just mod-ui service to run as before without the user and group. Got it without input and output port BUT voilá , somehow I got what I wanted , sacrificing some functionality

Can somehow live with this . Thanks a lot Falk for suggesting to compile the jackd2 even tho it might not be related its good to know to keep apt to date.
Will continue from here and try to enjoy the toy now

3 Likes

thanks to my friend DatanoiseTV , he found out about mod-ui service needing

AmbientCapabilities=CAP_NET_BIND_SERVICE 

in order to get the web UI going as the regular user .
Im updating the repository in case someone wants to experiment

Finally have mod latest with in and outs working !

3 Likes

So after asking the mod mods I’ve reconsidered my position. Since this post had a happy ending and I wrongly assumed I should delete the instructions for others to try.

Install scripts for latest Mod software

And for building plugings on your own here the notes I took when doing so using a VM. Handy for mod hardware users too given the plugin store situation. My notes are for the mod plugin builder for raspberrypi4 64 bit target but you can replace and build for any mod device. I’ve tried adding a few plugins from github like bolliedelay xt and worked but with others I’ve failed.

Btw the microtonal autotune is so much fun!

6 Likes

Thank you for the install scripts! I was able to set everything up on a Pi 4 running Bullseye. However, when I try running them on a Bookworm system, the build process requires me to use the --break-system-packages flag for all of the Python library installs. Also, once everything is built, the MOD host doesn’t start at all. Have you had any success using it on Bookworm?

1 Like

Hey @KAOSS, tbh it has been some time since I’ve last updated or played with that.

That pip issue is somewhat a recent change and it shouldn’t be hard to append to every pip install line the --break-system-packages.

Maybe is not the way to go about it but before I get time to play with virtual envs etc, it might be worth trying.

I’m adding the flag to the script, you can try again and let me know, but its not tested on an actual pi

Thanks for the update @DrKoma! I’d be interested to know if you were able to get it running on Bookworm. Everything works fine on Bullseye.

But while the install process goes fine after adding the aforementioned flag to the pip lines, I couldn’t get the MOD host and web UI to actually run on Bookworm. Note that I’m using a Behringer UMC202HD interface. I’ve tried the process on both Pi 4 and 5, but the result is the same.

I could use MODEP from Blokas, but the reason I’m interested in this is that there’s a CPU usage issue on startup as explained here. My workaround for the issue ends up taking twice as long to get playing after booting up the Pi.

I dont remember the exact version at the time. You could always try the version from the original creator, mine is just a fork of his with some tweaks and I got it with regular raspberry OS at the time but dont remember exact version.

You should check the services status or run the commands manually and post the output either here or in a gh issue and I will check at some point.

I understand you could cloning and compiling from upstream was always better for me than modep

I just noticed that somebody had posted an issue on @micahvdm’s repo that had you forked from, asking if it was possible to run it on Bookworm. They weren’t able to get mod-host and mod-ui running either.

they also dont provide any logs or meaningful information

Finally got around to reinstalling Bookworm Lite on an SD card and trying the install on a Pi 5. Here’s what I got from journalctl:

Sep 03 07:55:12 modlel systemd[1]: mod-host.service: Main process exited, code=exited, status=1/FAILURE
Sep 03 07:55:12 modlel systemd[1]: mod-host.service: Failed with result 'exit-code'.
Sep 03 07:55:12 modlel jackd[955]: jackdmp 1.9.22
Sep 03 07:55:12 modlel jackd[955]: Copyright 2001-2005 Paul Davis and others.
Sep 03 07:55:12 modlel jackd[955]: Copyright 2004-2016 Grame.
Sep 03 07:55:12 modlel jackd[955]: Copyright 2016-2023 Filipe Coelho.
Sep 03 07:55:12 modlel jackd[955]: jackdmp comes with ABSOLUTELY NO WARRANTY
Sep 03 07:55:12 modlel jackd[955]: This is free software, and you are welcome to redistribute it
Sep 03 07:55:12 modlel jackd[955]: under certain conditions; see the file COPYING for details
Sep 03 07:55:12 modlel jackd[955]: JACK server starting in realtime mode with priority 99
Sep 03 07:55:12 modlel jackd[955]: self-connect-mode is "Don't restrict self connect requests"
Sep 03 07:55:12 modlel jackd[955]: creating alsa driver ... hw:U192k|hw:U192k|128|2|48000|0|0|nomon|swmeter|soft-mode|3>
Sep 03 07:55:12 modlel jackd[955]: configuring for 48000Hz, period = 128 frames (2.7 ms), buffer = 2 periods
Sep 03 07:55:12 modlel jackd[955]: ALSA: final selected sample format for capture: 32bit integer little-endian
Sep 03 07:55:12 modlel jackd[955]: ALSA: use 2 periods for capture
Sep 03 07:55:12 modlel jackd[955]: ALSA: final selected sample format for playback: 32bit integer little-endian
Sep 03 07:55:12 modlel jackd[955]: ALSA: use 2 periods for playback
Sep 03 07:55:12 modlel jackd[955]: port created: Midi Through:Port 0 (capture)
Sep 03 07:55:12 modlel jackd[955]: port created: Midi Through:Port 0 (playback)
Sep 03 07:55:12 modlel jackd[955]: port created: Pico:CircuitPython usb_midi por (capture)
Sep 03 07:55:12 modlel jackd[955]: port created: Pico:CircuitPython usb_midi por (playback)
Sep 03 07:55:12 modlel mod-ui[958]: Traceback (most recent call last):
Sep 03 07:55:12 modlel mod-ui[958]:   File "/usr/local/bin/mod-ui", line 33, in <module>
Sep 03 07:55:12 modlel mod-ui[958]:     sys.exit(load_entry_point('mod==0.99.8', 'console_scripts', 'mod-ui')())
Sep 03 07:55:12 modlel mod-ui[958]:              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Sep 03 07:55:12 modlel mod-ui[958]:   File "/usr/local/bin/mod-ui", line 25, in importlib_load_entry_point
Sep 03 07:55:12 modlel mod-ui[958]:     return next(matches).load()
Sep 03 07:55:12 modlel mod-ui[958]:            ^^^^^^^^^^^^^^^^^^^^
Sep 03 07:55:12 modlel mod-ui[958]:   File "/usr/lib/python3.11/importlib/metadata/__init__.py", line 202, in load
Sep 03 07:55:12 modlel mod-ui[958]:     module = import_module(match.group('module'))
Sep 03 07:55:12 modlel mod-ui[958]:              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Sep 03 07:55:12 modlel mod-ui[958]:   File "/usr/lib/python3.11/importlib/__init__.py", line 126, in import_module
Sep 03 07:55:12 modlel mod-ui[958]:     return _bootstrap._gcd_import(name[level:], package, level)
Sep 03 07:55:12 modlel mod-ui[958]:            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Sep 03 07:55:12 modlel mod-ui[958]:   File "<frozen importlib._bootstrap>", line 1206, in _gcd_import
Sep 03 07:55:12 modlel mod-ui[958]:   File "<frozen importlib._bootstrap>", line 1178, in _find_and_load
Sep 03 07:55:12 modlel mod-ui[958]:   File "<frozen importlib._bootstrap>", line 1149, in _find_and_load_unlocked
Sep 03 07:55:12 modlel mod-ui[958]:   File "<frozen importlib._bootstrap>", line 690, in _load_unlocked
Sep 03 07:55:12 modlel mod-ui[958]:   File "<frozen importlib._bootstrap_external>", line 940, in exec_module
Sep 03 07:55:12 modlel mod-ui[958]:   File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
Sep 03 07:55:12 modlel mod-ui[958]:   File "/usr/local/lib/python3.11/dist-packages/mod/webserver.py", line 17, in <mod>
Sep 03 07:55:12 modlel mod-ui[958]:     from tornado import gen, iostream, web, websocket
Sep 03 07:55:12 modlel mod-ui[958]:   File "/usr/local/lib/python3.11/dist-packages/tornado/web.py", line 85, in <modul>
Sep 03 07:55:12 modlel mod-ui[958]:     from tornado import httputil
Sep 03 07:55:12 modlel mod-ui[958]:   File "/usr/local/lib/python3.11/dist-packages/tornado/httputil.py", line 101, in >
Sep 03 07:55:12 modlel mod-ui[958]:     class HTTPHeaders(collections.MutableMapping):
Sep 03 07:55:12 modlel mod-ui[958]:                       ^^^^^^^^^^^^^^^^^^^^^^^^^^
Sep 03 07:55:12 modlel mod-ui[958]: AttributeError: module 'collections' has no attribute 'MutableMapping'
Sep 03 07:55:12 modlel systemd[1]: mod-ui.service: Main process exited, code=exited, status=1/FAILURE
Sep 03 07:55:12 modlel systemd[1]: mod-ui.service: Failed with result 'exit-code'.
Sep 03 07:55:14 modlel systemd[1]: mod-host.service: Scheduled restart job, restart counter is at 1.
Sep 03 07:55:14 modlel systemd[1]: Stopped mod-ui.service - MOD-UI.
Sep 03 07:55:14 modlel systemd[1]: Stopped mod-host.service - MOD-host.
Sep 03 07:55:14 modlel systemd[1]: Starting mod-host.service - MOD-host...
Sep 03 07:55:14 modlel mod-host[964]: Forking... child PID: 965
Sep 03 07:55:14 modlel systemd[1]: Started mod-host.service - MOD-host.
Sep 03 07:55:14 modlel systemd[1]: Started mod-ui.service - MOD-UI.
Sep 03 07:55:14 modlel mod-host[965]: mod-host ready!
Sep 03 07:55:14 modlel mod-ui[966]: Traceback (most recent call last):
Sep 03 07:55:14 modlel mod-ui[966]:   File "/usr/local/bin/mod-ui", line 33, in <module>
Sep 03 07:55:14 modlel mod-ui[966]:     sys.exit(load_entry_point('mod==0.99.8', 'console_scripts', 'mod-ui')())
Sep 03 07:55:14 modlel mod-ui[966]:              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Sep 03 07:55:14 modlel mod-ui[966]:   File "/usr/local/bin/mod-ui", line 25, in importlib_load_entry_point
Sep 03 07:55:14 modlel mod-ui[966]:     return next(matches).load()
Sep 03 07:55:14 modlel mod-ui[966]:            ^^^^^^^^^^^^^^^^^^^^
Sep 03 07:55:14 modlel mod-ui[966]:   File "/usr/lib/python3.11/importlib/metadata/__init__.py", line 202, in load
Sep 03 07:55:14 modlel mod-ui[966]:     module = import_module(match.group('module'))
Sep 03 07:55:14 modlel mod-ui[966]:              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Sep 03 07:55:14 modlel mod-ui[966]:   File "/usr/lib/python3.11/importlib/__init__.py", line 126, in import_module
Sep 03 07:55:14 modlel mod-ui[966]:     return _bootstrap._gcd_import(name[level:], package, level)
Sep 03 07:55:14 modlel mod-ui[966]:            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Sep 03 07:55:14 modlel mod-ui[966]:   File "<frozen importlib._bootstrap>", line 1206, in _gcd_import
Sep 03 07:55:14 modlel mod-ui[966]:   File "<frozen importlib._bootstrap>", line 1178, in _find_and_load
Sep 03 07:55:14 modlel mod-ui[966]:   File "<frozen importlib._bootstrap>", line 1149, in _find_and_load_unlocked
Sep 03 07:55:14 modlel mod-ui[966]:   File "<frozen importlib._bootstrap>", line 690, in _load_unlocked
Sep 03 07:55:14 modlel mod-ui[966]:   File "<frozen importlib._bootstrap_external>", line 940, in exec_module
Sep 03 07:55:14 modlel mod-ui[966]:   File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
Sep 03 07:55:14 modlel mod-ui[966]:   File "/usr/local/lib/python3.11/dist-packages/mod/webserver.py", line 17, in <mod>
Sep 03 07:55:14 modlel mod-ui[966]:     from tornado import gen, iostream, web, websocket
Sep 03 07:55:14 modlel mod-ui[966]:   File "/usr/local/lib/python3.11/dist-packages/tornado/web.py", line 85, in <modul>
Sep 03 07:55:14 modlel mod-ui[966]:     from tornado import httputil
Sep 03 07:55:14 modlel mod-ui[966]:   File "/usr/local/lib/python3.11/dist-packages/tornado/httputil.py", line 101, in >
Sep 03 07:55:14 modlel mod-ui[966]:     class HTTPHeaders(collections.MutableMapping):
Sep 03 07:55:14 modlel mod-ui[966]:                       ^^^^^^^^^^^^^^^^^^^^^^^^^^
Sep 03 07:55:14 modlel mod-ui[966]: AttributeError: module 'collections' has no attribute 'MutableMapping'

Note that I’m using a Behringer UMC202HD as my audio interface, however everything works without any issues on Bullseye.

Thanks. I’ll try on my own some time soon. It looks like python versions of God knows what libraries

Because mod got more development and I have the libs with a specific version that used to work in the old fork

hey @KAOSS
I managed to get it running again yay! , however some manual intervention is still required. There is a dependency issue that would trigger a message complaining about the collections import , replacing the import with collections.abc and in other places where it fails did the job. Is some sort of new change in the lib.

Im not sure if I will get the time to properly test the script from a fresh install soon, but I followed again step by step from the latest repos from mod and it all went well, might throw another virtual env for browsepy at somepoint but need to find the time for it

mod-PiSound

Any testing is appreatiated in the meanwhile
Cheers

the file is this one or similar path ( In the newer version I tried on a fresh install is $HOME/.local/lib/python…etc)

so this file has to be edited

"class HTTPHeaders(collections.abc.MutableMapping):

and the import the same way import collections.abc on the top of the file.

Great to hear @DrKoma! I’ll try it out on a fresh Bookworm install as soon as I get the chance.