how to correctly install fluidsynth as a service?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
JPT
Reply | Threaded
Open this post in threaded view
|

how to correctly install fluidsynth as a service?

JPT
Hi,

I installed fluidsynth as a service on kubuntu according to this guide:
https://blog.geierb.de/debian-fluidsynth-als-systemd-service/
(adding DISPLAY=:0 to the config)

now after startup there are two processes:
fluidsy+  20   0  625032  16652  13068 S  14,9  0,2   1:56.71 pulseaudio
fluidsy+  20   0  909016 196852   8440 S  10,2  2,4   1:23.55 fluidsynth

But...

A) The first problem is, that there is an additional pulseaudio spawned
for the fluidsynth user which collides with the user's pulseaudio and
thus sometimes midi works and the other audio doesn't or vice versa
depending who got the audio device.

Should I run fluidsynth for the current user?
Is there any other way to install fluidsynth to the background?
why doesn't it connect to the user's pulsaudio?

B) the next problem is that sometimes (no idea about the likeliness)
after boot-up these two processes consume 100% of a single core each.
manually restarting the service solved it.

any idea?

find below my config.

thanks.

JPT

ps. did not allow real-time priority that's why there are error messages.


$ cat /etc/default/fluidsynth
SOUND_FONT="/usr/share/sounds/sf2/FluidR3_GM.sf2"
AUDIO_DRIVER=pulseaudio
OTHER_OPTS='-m alsa_seq -r 48000 -o synth.cpu-cores=2 --chorus no
--reverb no'
DISPLAY=:0

$ cat /etc/systemd/system/fluidsynth.service
[Unit]
Description=FluidSynth Daemon
After=sound.target

[Service]
ExecStart=/usr/bin/fluidsynth -is -a $AUDIO_DRIVER $OTHER_OPTS ${SOUND_FONT}
EnvironmentFile=/etc/default/fluidsynth
User=fluidsynth

[Install]
WantedBy=multi-user.target

$ systemctl status fluidsynth.service
● fluidsynth.service - FluidSynth Daemon
   Loaded: loaded (/etc/systemd/system/fluidsynth.service; enabled;
vendor preset: enabled)
   Active: active (running) since Tue 2020-03-10 14:36:49 CET; 19min ago
 Main PID: 17946 (fluidsynth)
    Tasks: 10 (limit: 4915)
   CGroup: /system.slice/fluidsynth.service
           ├─17946 /usr/bin/fluidsynth -is -a pulseaudio -m alsa_seq -r
48000 -o synth.cpu-cores 2 --chorus no reverb no
/usr/share/sounds/sf2/FluidR3_GM.sf2
           ├─17950 /usr/bin/pulseaudio --start --log-target=syslog
           └─17957 /usr/lib/x86_64-linux-gnu/pulse/gconf-helper

Mär 10 14:36:51 AFLL pulseaudio[17950]: [pulseaudio] server-lookup.c:
Unable to contact D-Bus: org.freedesktop.DBus.Error.Spawn.ExecFailed:
/usr/bin/dbus-launch terminated abnormally w
Mär 10 14:36:51 AFLL pulseaudio[17950]: [pulseaudio] server-lookup.c:
Autolaunch error: X11 initialization failed.
Mär 10 14:36:51 AFLL pulseaudio[17950]: [pulseaudio] main.c: Unable to
contact D-Bus: org.freedesktop.DBus.Error.Spawn.ExecFailed:
/usr/bin/dbus-launch terminated abnormally with the f
Mär 10 14:36:51 AFLL pulseaudio[17950]: [pulseaudio] main.c: Autolaunch
error: X11 initialization failed.
Mär 10 14:36:51 AFLL pulseaudio[17950]: [pulseaudio] bluez5-util.c:
GetManagedObjects() failed: org.freedesktop.DBus.Error.AccessDenied:
Rejected send message, 2 matched rules; type="m
Mär 10 14:36:51 AFLL fluidsynth[17946]: fluidsynth: Using PulseAudio driver
Mär 10 14:36:51 AFLL fluidsynth[17946]: fluidsynth: warning: Failed to
set thread to high priority
Mär 10 14:36:51 AFLL fluidsynth[17946]: No protocol specified
Mär 10 14:36:51 AFLL fluidsynth[17946]: xcb_connection_has_error()
returned true
Mär 10 14:36:51 AFLL fluidsynth[17946]: fluidsynth: warning: Failed to
set thread to high priority


_______________________________________________
fluid-dev mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/fluid-dev
Reply | Threaded
Open this post in threaded view
|

Re: how to correctly install fluidsynth as a service?

fluid-dev mailing list
Regarding A), it would be worth to run fluidsynth for the current user, rather than an extra user.

> why doesn't it connect to the user's pulsaudio?

You can tell fluidsynth via the setting audio.pulseaudio.server which server to connect to. This setting receives a string which will then be passed as "Server name" to pa_simple_new()[1].

Apparently pulse audio's default behaviour is to spawn a new server for every user. To set up pulseaudio system-wide, it should be started as root with the --system command line argument, see [2].

Regarding B), the only real option you have here is to start gdb, attach to the fluidsynth process and provide a stack trace of the two running threads.

[1] https://freedesktop.org/software/pulseaudio/doxygen/simple_8h.html#add9a7dce4e15955d4296726c26206689
[2] https://www.freedesktop.org/wiki/Software/PulseAudio/Documentation/User/SystemWide/


Tom



_______________________________________________
fluid-dev mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/fluid-dev
JPT
Reply | Threaded
Open this post in threaded view
|

Re: how to correctly install fluidsynth as a service?

JPT


Am 13.03.20 um 13:51 schrieb Tom M.:
> Regarding A), it would be worth to run fluidsynth for the current user, rather than an extra user.

In case anybody is searching for a clean solution.
I did so and it works fine.

I added the below file to KDE auto-start.
Keep in mind that this is not perfect and might need some adjustment.
you can test it be starting from the KDE menu.

cat ~/.local/share/applications/fluidsynth.desktop

[Desktop Entry]
Type=Application
Version=1.0
GenericName=Midi Synthesizer
Name=Fluidsynth
TryExec=/usr/bin/fluidsynth
Exec=/usr/bin/fluidsynth --no-shell --server --audio-driver=pulseaudio
--midi-driver=alsa_seq --sample-rate 44100 -o synth.cpu-cores=2
/usr/share/sounds/sf3/FluidR3Mono_GM.sf3
# for debug add --dump remove --no-shell
# if you need more midi channels, add --midi-channels=
# for less background CPU use add --chorus 0 --reverb 0
# check the soundfont exists
Categories=Multimedia;System;
StartupNotify=false
X-GNOME-Autostart-Delay=60
Terminal=false
#for debug: true



_______________________________________________
fluid-dev mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/fluid-dev