How do you use Timidity on Ubuntu 18.04?
Timidity is available in the default repo via sudo apt install timidity, which includes a service daemon. However, this daemon appears to be broken out of the box, as Timidity produces no sound and service timidity status shows several errors interacting with pulseaudio:
● timidity.service - LSB: start and stop timidity Loaded: loaded (/etc/init.d/timidity; generated) Active: active (exited) since Sun 2020-05-10 14:27:02 EDT; 1s ago Docs: man:systemd-sysv-generator(8) Process: 2407 ExecStop=/etc/init.d/timidity stop (code=exited, status=0/SUCCESS) Process: 2416 ExecStart=/etc/init.d/timidity start (code=exited, status=0/SUCCESS)
May 10 14:27:02 caius systemd[1]: Starting LSB: start and stop timidity...
May 10 14:27:02 caius timidity[2416]: * Starting TiMidity++ ALSA midi emulation...
May 10 14:27:02 caius timidity[2416]: ...done.
May 10 14:27:02 caius systemd[1]: Started LSB: start and stop timidity.
May 10 14:27:02 caius pulseaudio[2448]: [autospawn] core-util.c: Home directory not accessible: Permission denied
May 10 14:27:02 caius pulseaudio[2448]: [autospawn] lock-autospawn.c: Cannot access autospawn lock.
May 10 14:27:02 caius pulseaudio[2448]: [pulseaudio] main.c: Failed to acquire autospawn lockHow do you fix this?
2 Answers
Just trying this in 20.04, and it seems the timidity package no longer includes a service file. I tried some of kyodake's answer and it worked nicely, but you don't need any sudo!
This might also work to solve the original poster's problem, as it seems that whichever user is trying to run timidity does not have access to whichever home directory timidity wants to put a file into (perhaps the package has set up a service user without a home directory). This method makes the current user the user that starts the service, and whose home directory is used.
Firstly, add a new file ~/.config/systemd/user/timidity.service and edit it to include kyodake's contents:
[Unit]
Description=TiMidity++ Daemon
After=sound.target
[Service]
ExecStart=/usr/bin/timidity -iA -Os
[Install]
WantedBy=default.targetNow you can simply start the server like this:
systemctl --user start timidityand ensure that it starts up at user login like this:
systemctl --user enable timidityno sudo required.
To minimally fix your actual problem (and if you want timidity to start on boot and be present for all users); check if you have a /etc/systemd/system/timidity.service file. If you do, check for a line beginning User=; this will tell you which user is trying to start the service. Let's say it says User=timidityuser.
Now you want to find out if timidityuser has a home directory, so:
grep ^timidityuser: /etc/passwdThe last-but-one field returned will be the home directory. You can check that this directory exists and has the correct owner and permissions, or you can create a new one like this:
sudo usermod -md /home/timidityuser timidityuserHope that helps!
Try this:
First you should add yourself to the audio group.
sudo gpasswd -a <user> audioSecond install Freepats, the Freepats project provides a set of instrument samples.
sudo apt update
sudo apt install freepatsThird to use Freepats with TiMidity:
sudo nano /etc/timidity++/timidity.cfgAdd the following lines to timidity.cfg:
soundfont /usr/share/soundfonts/freepats-general-midi.sf2If you are using PulseAudio, that may not work.
To start TiMidity in daemon mode once, you can use the following command:
timidity -iATo do so, write a timidity.service file in ~/.config/systemd/user/ like that one :
sudo nano /etc/systemd/user/timidity.serviceAdd the following lines to timidity.service
[Unit]
Description=TiMidity++ Daemon
After=sound.target
[Service]
ExecStart=/usr/bin/timidity -iA -Os
[Install]
WantedBy=default.targetThen enable the service with:
sudo systemctl --user enable timidity.serviceSource: 1
1