Page 1 of 1

FluidSynth music driver

Posted: 16 Oct 2011 13:32
by jmak
Hi,

I implemented a basic music driver using FluidSynth, which seems to be more maintained than libTimidity. It should be also a cleaner solution than extmidi.

A patch to OpenTTD trunk is attached.

The driver has two options - "driver" and "soundfont", by default it uses alsa for output, and /usr/share/sounds/sf2/FluidR3_GM.sf2 as the sound font.

Example usage: openttd -m fluidsynth:driver=pulseaudio,soundfont=/opt/soundfont/SGM-V2.01.sf

Re: FluidSynth music driver

Posted: 16 Oct 2011 16:56
by planetmaker
Looks nice and clean so far. I haven't yet tested it, but a note on twothree minor things:
- could you add doxygen comments to the single functions and methods, please?
- very short statements like if (a == b) Foo() go into one line, otherwise use braces and separate lines.

EDIT: And

Code: Select all

+class MusicDriver_FluidSynth: public MusicDriver {
(...)
+	/* virtual */ const char *GetName() const { return "libtimidity"; }
+};
+
+/** Factory for the libtimidity driver. */
looks like a copy&paste error for the return value and the following comment in the last quoted line

Cheers,
pm

Re: FluidSynth music driver

Posted: 16 Oct 2011 18:54
by jmak
Thanks for comments, here is an updated version.

Re: FluidSynth music driver

Posted: 16 Oct 2011 21:08
by planetmaker
Seems to work well for me with coreaudio - but only after I found out that I also have to get some soundfont from somewhere ;-) In conjunction with Jack it doesn't work for me, but that seems to be rather a Jack issue.

Is there some default soundfont which comes with packages or default locations where it should look for them? To make it easily usable for people, it'd be nice, if it found automatically a soundfont - though that might be out of scope of this patch. But having no default sound font could mean to reduce the 'ranking' of this sound driver.

Anyhow, comparing to the usual cocoa music driver I use, I can say: sounds nice. Sounds are slightly different with the SoundFont which I got, though, but definitely not worse, rather better.

Re: FluidSynth music driver

Posted: 16 Oct 2011 21:27
by jmak
planetmaker wrote:Seems to work well for me with coreaudio - but only after I found out that I also have to get some soundfont from somewhere ;-) In conjunction with Jack it doesn't work for me, but that seems to be rather a Jack issue.

Is there some default soundfont which comes with packages or default locations where it should look for them? To make it easily usable for people, it'd be nice, if it found automatically a soundfont - though that might be out of scope of this patch. But having no default sound font could mean to reduce the 'ranking' of this sound driver.

Anyhow, comparing to the usual cocoa music driver I use, I can say: sounds nice. Sounds are slightly different with the SoundFont which I got, though, but definitely not worse, rather better.
The default path in the source corresponds to the fluid-soundfont-gm package distributed with Debian. I prefer larger SGM-2.01 ( http://www.geocities.jp/shansoundfont/ ) though. One could certainly add a list of files to try, that's rather easy.

Re: FluidSynth music driver

Posted: 16 Oct 2011 21:43
by jmak
Updated version with a soundfont list.

Re: FluidSynth music driver

Posted: 17 Oct 2011 07:42
by jmak
Added comments with rationale for defaults + Fedora linux support.

Re: FluidSynth music driver

Posted: 25 Oct 2011 07:17
by jmak
Removed error messages when looking for default soundfont.

Re: FluidSynth music driver

Posted: 13 Nov 2011 21:04
by jmak
Bump. Any chance for this patch to be included in trunk, possibly with lower driver priority setting to avoid surprises for the users?

Re: FluidSynth music driver

Posted: 14 Nov 2011 10:45
by planetmaker
Hm, yes, thanks for the reminder :-)

We discussed it a bit, but became distracted ;-) The problem with sound fonts, as you also know / said, is that there's no default font or location for them really. Would you care to add a setting in the config file / adv. settings which allows the user to configure a sound font in the config file? That might be the better alternative to hard-coding a few sound fonts with fixed paths for three OS :-) (yes, I know, these change requests suck ;-) ).

Re: FluidSynth music driver

Posted: 14 Nov 2011 10:56
by jmak
The soundfont path can be set in the config file, see the first post in this thread.

If you want to have it settable in the GUI, I can give it a try, but I have no experience with openttd GUI coding so far.

Re: FluidSynth music driver

Posted: 14 Nov 2011 10:57
by planetmaker
jmak wrote:The soundfont path can be set in the config file, see the first post in this thread.

If you want to have it settable in the GUI, I can give it a try, but I have no experience with openttd GUI coding so far.
Oh, I missed that then. I read the last posting ;-) IMHO a gui setting for that is not required. I'll have another look.

Re: FluidSynth music driver

Posted: 12 Feb 2012 20:07
by jmak
Ping :)

Re: FluidSynth music driver

Posted: 16 Feb 2012 15:12
by orudge
Small thing I've noticed - "wether" should be "whether" (line 283 of the patch)

In theory this should work on Windows too, it seems. I may experiment later. :)

Re: FluidSynth music driver

Posted: 07 Feb 2019 02:52
by njn
By the way, libtimidity has actually seen some activity in the past year or so:
* https://sourceforge.net/projects/libtimidity/
* https://github.com/sezero/libtimidity