Using timidity++ as a daemon

D

Deleted member 67862

Guest
Greetings fellow Beastie followers,

I want to integrate MIDI into the sound system for my desktop environment. The settings allow me to select a MIDI device and I usually used audio/timidity++ as an auto-starting daemon on Linux systems to get this functionality, but I can't figure out how to launch timidity++ as a daemon on FreeBSD. I believe on Linux the command used is timidity -iA but I use FreeBSD's native sound so no ALSA (which this flag uses). I've tested timidity++ and it works just fine on its own, I have it mapped to an .sf2 file from audio/fluid-soundfont.

I simply can't get it to launch as a daemon and work. The man page is very hard to read, but timidity -h has the following:

Code:
Available interfaces (-i, --interface option):
  -in          ncurses interface
  -iT          vt100 interface
  -id          dumb interface
  -ir          remote interface

None of these interfaces are close to what I'm looking for. Is it even possible to use timidity++ as a daemon for OSS and if so, how? I'd love to find at least some kind of midi mapper daemon that will work with the native sound system. Thanks.
 
I also asked questions about MIDI but nobody answered with a solution. For example audio/bristol is software synth but no matter what I tried with OSS/sndio nothing works.

Bristol and every other MIDI program looks for /dev/midi, which is not present. Bristol supports JACK so that is the only way to get it working. And eventually I did make it work. Fire up JACK, run bristol and audacity, wire Bristol’s output to audacity’s input and it works fine.
 
I only need playback. What a shame.
 
I don't have experience with timidity++ but what are you trying to achieve exactly?
Can you give a concrete example of a usecase where you'd like to have it running as a daemon?

This program has a funny option, but not meant for us despite the name :)
Code:
       -e, --evil
              Make TiMidity++ evil.  For the Win32 version, this increases the task priority by one.  It can give better playback when you switch tasks at the expense
              of slowing all other tasks down.

Fire up JACK
In the broken manpages of this venerable program (some list of possible values aren't located where they should, next to the description of the corresponding option) I also noticed:
Code:
       -O mode, --output-mode=mode
              -Oj    JACK
... unfortunately not available in our version:
$ timidity -Oj
Playmode `j' is not compiled in.
Try timidity -h for help
I don't know why JACK support is disabled, unless it's broken upstream it should be possible to modify the FreeBSD port to enable it.
 
I tried to enable jack in ports(maintainer disabled it with a reason yea xD) so this is what i got, i currently don't have enough time to see what is the problem in code, working in the first shift tomorrow. But this doesn't seem to be big problem, linker cannot find some functions.

2022-05-03-212249_599x713_scrot.png
 
Feel free to contact the maintainer, I didn't notice this port had one.

I also asked questions about MIDI but nobody answered with a solution.
Didn't https://forums.freebsd.org/threads/virtual-midi-port.83482/#post-552333 work for you?

By the way, this also could be of interest to you hunter0one.
Since thanks to hselasky@ we now have audio/alsa-seq-server, it may be possible to enable the ALSA backend in timidity++ and use it the way you're used to on Linux.
 
I don't have experience with timidity++ but what are you trying to achieve exactly?
Can you give a concrete example of a usecase where you'd like to have it running as a daemon?
Not sure if KDE still has their equivalent kmid but I use TDE which still has good MIDI support with tdemid which can integrate with arTs to play midi files, however I don't have a MIDI device to set for aRts so I have to use something like timidity++ to simulate one. This is possible because I've done it on Debian, but FreeBSD is a whole new ballgame.

As for why I'm trying to integrate and play MIDI files in 2022, its just for fun :)
 
KMid is abandoned:
This app is unmaintained and no longer released by the KDE community.
The latest stable release is 2.4.0, published on August 15th, 2010.
Still downloadable at https://sourceforge.net/projects/kmid2/files/OldFiles/

integrate with arTs
Analog Real Time Synthesizer. Another one that's long gone from KDE. Not knowing what this program was about, I had a hard time finding relevant information on the web from the name alone. A web search returns tons of results related to artistic practices, but that's obviously not what I'm looking for. Search engines being case insensitive, developers should avoid giving such a common name to a piece of software, and rather express some artistic creativity :)

As for why I'm trying to integrate and play MIDI files in 2022, its just for fun :)
Nothing special here, I play MIDI files too!
I use audio/fluidsynth.

I found an interesting page:
It's meant for people using OSS on Linux but there is still valuable information:

Midi applications​

  • To merely play MIDI files, software synthesizers (like timidity and fluidsynth) will work fine (They can play MIDI files directory to OSS output.)
  • Other applications wishing to play MIDI which are not synthesizers themselves (like scummvm or tuxguitar) should be set to use (lib)fluidsynth or timidity.
  • You may decide to load ALSA's sequencer modules. As long as modules which touch the hardware or modules which emulate oss (snd-mixer-oss, snd-pcm-oss) are not loaded, this is safe. Than you could load timidity or fluidsynth as ALSA midi sequencers, and have the apps use these. This is not needed to make libfluidsynth or timidity's server mode work though.

scummvm​

  • scummvm works fine, but midi output may need tuning.
  • scummvm 0.11.0 supports midi output via timidity and also via fluidsynth.
  • Start timidity -Od -ir 7777 and then run scummvm. Select "TiMidity" as a music driver.
  • Alternately, if fluidsynth is compiled, you can select it as music driver. You need to add a soundfont entry to ~/.scummvmrc .
... this may be applicable to your case too. Did you try option -ir?
Code:
              -ir    Launch TiMidity++ as MIDI server.
If you run timidity -ir 7777, are you able to select it as an output in aRts?
 
Analog Real Time Synthesizer. Not knowing what this program was about, I had a hard time finding relevant information on the web. A web search returns tons of results related to artistic practices, but that's obviously not what I'm looking for. Search engines being case insensitive, developers should avoid giving such a common name to a piece of software, and rather express some artistic creativity :)
Oh yeah, it's relatively unheard of nowadays since KDE dropped it with KDE4/Plasma. I actually quite like it, it was a competitor to pulseaudio but pulseaudio won (probably because it was more compatible outside of KDE). Its still used in TDE for notifications and native TDE applications, including TDEMid so it lives on. :)

I found an interesting page:
It's meant for people using OSS on Linux but there is still valuable information:

... this may be applicable to your case too. Did you try option -ir?
Code:
              -ir    Launch TiMidity++ as MIDI server.
If you run timidity -ir 7777, are you able to select it as an output in aRts?

I forgot to mention but I have tried that flag beforehand. I just tried -Od -ir (though I think -Od is used by default) like the wiki says and it still doesn't create any valid MIDI devices for aRts.

Even though this worked with ALSA, I would rather just not have MIDI using OSS v4 than have to use ALSA. FreeBSD is the only operating system that I can actually use OSS on - I couldn't even get Gentoo to use it. With ALSA I had unsolvable popping that couldn't be fixed with any configuration, but this is entirely absent with OSS v4 (at least FreeBSD's implementation).
 
Running audio/alsa-seq-server doesn't mean running ALSA! You can't use ALSA natively on FreeBSD, it's just a MIDI sequencer, you'll still be using OSS for audio.

I installed games/scummvm to test with timidity++ but in fact you can select the corresponding option even without timidity running, so nothing valuable to learn from it.

I can't experiment with aRts myself for obvious reasons but it's probable it expects nothing else than ALSA MIDI ports. You should try with alsa-seq-server and fluidsynth (whose port has an option to enable ALSA support). If it works, then it may be worth to have a look at the timidity++ port to enable ALSA there too.

$ fluidsynth -s -a oss -m alsa_seq /path/to/your/soundfont.sf2

it's relatively unheard of nowadays since KDE dropped it with KDE4/Plasma
Definitely! I first used KDE (and Linux) when it was in its transition from 3 to 4, so I haven't used KDE3 much. Actually the first Linux system I installed came with both KDE 4.0 and 3.5.
I should try Trinity one day, never done so far.
 
Running audio/alsa-seq-server doesn't mean running ALSA! You can't use ALSA natively on FreeBSD, it's just a MIDI sequencer, you'll still be using OSS for audio.
That'll be great, I wanted to try this but -iA isn't compiled into timidity and I couldn't find the build option for it in the port.

I can't experiment with aRts myself for obvious reasons but it's probable it expects nothing else than ALSA MIDI ports. You should try with alsa-seq-server and fluidsynth (whose port has an option to enable ALSA support). If it works, then it may be worth to have a look at the timidity++ port to enable ALSA there too.
It gives you the option of choosing a MIDI device or use a MIDI mapper. I typically could start timidity and MIDI ports would appear inside the box for MIDI devices. This is in the Control Center -> Sound & Multimedia -> Sound System's hardware tab.

$ fluidsynth -s -a oss -m alsa_seq /path/to/your/soundfont.sf2
I'll try this since timidity doesn't have an ALSA option.

I should try Trinity one day, never done so far.
It's great, but it has to be installed from the Trinity team themselves via third-party means almost everywhere because it uses Qt3 which they have forked and kept updated as TQt3. The FreeBSD port can be a hassle to install but I've updated the wiki page for R14.0.12, and in this release it fixed one of the major bugs with the FreeBSD port. https://wiki.trinitydesktop.org/FreeBSD_Trinity_Installation_Instructions
 
-iA isn't compiled into timidity and I couldn't find the build option for it in the port
Indeed, that's why I suggested to try with fluidsynth first :)
Enabling ALSA in timidity++ should be possible but will require a modification of the port, which is best to be discussed with its maintainer directly.

The FreeBSD port can be a hassle to install but I've updated the wiki page for R14.0.12
Nice, thank you for maintaining this!
 
So I got audio/alsa-seq-server and audio/fluidsynth and I just realized a detrimental problem: I compiled aRts / akode without ALSA support.

Pertaining to alsa-seq-server & fluidsynth themselves, I can't run fluidsynth -s -a oss -m alsa_seq /usr/local/share/sounds/sf2/FLuidR3_GM.sf2 without this error, for some reason it can't load audio/fluid-soundfont and I don't have a /dev/snd directory for ALSA compatibility.

Code:
FluidSynth runtime version 2.2.6
Copyright (C) 2000-2022 Peter Hanappe and others.
Distributed under the LGPL license.
SoundFont(R) is a registered trademark of Creative Technology Ltd.

fluidsynth: error: fluid_is_soundfont(): fopen() failed: 'File does not exist.'
Parameter '/usr/local/share/sounds/sf2/FLuidR3_GM.sf2' not a SoundFont or MIDI file or error occurred identifying it.
fluidsynth: error: fluid_sfloader_load(): Failed to open '/usr/local/share/soundfonts/default.sf2': File does not exist.
fluidsynth: error: Unable to open file '/usr/local/share/soundfonts/default.sf2'
fluidsynth: error: Failed to load SoundFont "/usr/local/share/soundfonts/default.sf2"
ALSA lib seq_hw.c:466:(snd_seq_hw_open) open /dev/snd/seq failed: No such file or directory
fluidsynth: error: Error opening ALSA sequencer
Failed to create the MIDI thread; no MIDI input
will be available. You can access the synthesizer
through the console.
Type 'help' for help topics.

> fluidsynth: warning: Failed to set thread to high priority

Nice, thank you for maintaining this!
You're welcome but I only update the wiki, I would thank Slavek B. who is currently over the project for maintaining all the bells and whistles of the FreeBSD port itself. I've considered maintaining it myself but I am very inexperienced with ports/makefiles. It takes a lot to uphold an entire desktop environment.
 
FLuidR3_GM.sf2
FluidR3_GM.sf2 without a capital L should work :)

I don't have a /dev/snd directory for ALSA compatibility
How do you run alsa-seq-server?
I need to run it as root, otherwise it can't access cuse(3). Don't forget to load that kernel module, by the way.
$ alsa-seq-server
alsa-seq-server: Could not connect to cuse module
With it running as root, fluidsynth doesn't complain:
$ fluidsynth -s -a oss -m alsa_seq /usr/local/share/sounds/sf2/FluidR3_GM.sf2
FluidSynth runtime version 2.2.6
Copyright (C) 2000-2022 Peter Hanappe and others.
Distributed under the LGPL license.
SoundFont(R) is a registered trademark of Creative Technology Ltd.

Type 'help' for help topics.
fluidsynth: warning: Failed to set thread to high priority
fluidsynth: warning: Failed to set thread to high priority

>
I'll further investigate how to run this without requiring root access.
 
FluidR3_GM.sf2 without a capital L should work :)


How do you run alsa-seq-server?
I need to run it as root, otherwise it can't access cuse(3). Don't forget to load that kernel module, by the way.

With it running as root, fluidsynth doesn't complain:

I'll further investigate how to run this without requiring root access.
Oof, I didn't even notice the typo. Alright, with that out of the way, I've launched alsa-seq-server as root and loaded the cuse module. I now have a /dev/snd/seq device, alsa-seq-server is running as a daemon with -B, and I can run fluidsynth -s -a oss -m alsa_seq /usr/local/share/sounds/sf2/FluidR3_GM.sf2 with the same output you have. There is still no MIDI devices appearing in the settings menu.

I just realized something major. I built aKode without ALSA support (akode is a framework that arts uses to decode audio). Let me try to re-build it with support and see what happens.
 
Even with ALSA support enabled in aKode, it doesn't show any devices unfortunately.
 
Strange.

$ aconnect -l (from audio/alsa-utils) gives me:
Code:
client 1: 'FLUID Synth (97866)' [type=User]
    0 'Synth input port (97866:0)'
Do you get it too?
If the port is there, I don't understand why your software can't see it. Maybe ALSA support is still missing in yet another TDE component?

I tried to connect a keyboard to fluidsynth that way, using # alsa-seq-server -F umidi so that umidi devices are automatically connected to the sequencer:
$ aconnect -l
Code:
client 1: 'BEHRINGER UMX 49' [type=Kernel]
    0 'port-0          '
client 2: 'FLUID Synth (68698)' [type=User]
    0 'Synth input port (68698:0)'
$ aconnect 1:0 2:0 successfully connects the keyboard to the synthesizer and I can play music.
 
I have to launch aconnect -l from another terminal since fluidsynth -s -a oss -m alsa_seq doesn't seem to just start the process (it opens fluidsynth's prompt), but I do indeed have that same output:

Code:
client 1: 'FLUID Synth (98619)' [type=user]
    0 'Synth input port (98619:0)'
 
Back
Top