FluidSynth music driver

Forum for technical discussions regarding development. If you have a general suggestion, problem or comment, please use one of the other forums.

Moderator: OpenTTD Developers

Post Reply
jmak
Engineer
Engineer
Posts: 9
Joined: 16 Oct 2011 13:26

FluidSynth music driver

Post 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
Attachments
0001-fluidsynth-support.patch
FluidSynth music driver patch
(9.21 KiB) Downloaded 283 times
User avatar
planetmaker
OpenTTD Developer
OpenTTD Developer
Posts: 9432
Joined: 07 Nov 2007 22:44
Location: Sol d

Re: FluidSynth music driver

Post 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
jmak
Engineer
Engineer
Posts: 9
Joined: 16 Oct 2011 13:26

Re: FluidSynth music driver

Post by jmak »

Thanks for comments, here is an updated version.
Attachments
0001-fluidsynth-support.patch
(10.44 KiB) Downloaded 323 times
User avatar
planetmaker
OpenTTD Developer
OpenTTD Developer
Posts: 9432
Joined: 07 Nov 2007 22:44
Location: Sol d

Re: FluidSynth music driver

Post 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.
jmak
Engineer
Engineer
Posts: 9
Joined: 16 Oct 2011 13:26

Re: FluidSynth music driver

Post 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.
jmak
Engineer
Engineer
Posts: 9
Joined: 16 Oct 2011 13:26

Re: FluidSynth music driver

Post by jmak »

Updated version with a soundfont list.
Attachments
0001-fluidsynth-support.patch
(10.85 KiB) Downloaded 227 times
jmak
Engineer
Engineer
Posts: 9
Joined: 16 Oct 2011 13:26

Re: FluidSynth music driver

Post by jmak »

Added comments with rationale for defaults + Fedora linux support.
Attachments
0001-fluidsynth-support.patch
(11.02 KiB) Downloaded 281 times
jmak
Engineer
Engineer
Posts: 9
Joined: 16 Oct 2011 13:26

Re: FluidSynth music driver

Post by jmak »

Removed error messages when looking for default soundfont.
Attachments
0001-fluidsynth-support.patch
(11.11 KiB) Downloaded 292 times
jmak
Engineer
Engineer
Posts: 9
Joined: 16 Oct 2011 13:26

Re: FluidSynth music driver

Post 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?
User avatar
planetmaker
OpenTTD Developer
OpenTTD Developer
Posts: 9432
Joined: 07 Nov 2007 22:44
Location: Sol d

Re: FluidSynth music driver

Post 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 ;-) ).
jmak
Engineer
Engineer
Posts: 9
Joined: 16 Oct 2011 13:26

Re: FluidSynth music driver

Post 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.
User avatar
planetmaker
OpenTTD Developer
OpenTTD Developer
Posts: 9432
Joined: 07 Nov 2007 22:44
Location: Sol d

Re: FluidSynth music driver

Post 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.
jmak
Engineer
Engineer
Posts: 9
Joined: 16 Oct 2011 13:26

Re: FluidSynth music driver

Post by jmak »

Ping :)
User avatar
orudge
Administrator
Administrator
Posts: 25134
Joined: 26 Jan 2001 20:18
Skype: orudge
Location: Banchory, UK
Contact:

Re: FluidSynth music driver

Post 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. :)
User avatar
njn
Engineer
Engineer
Posts: 13
Joined: 11 Jan 2019 03:03
Location: New York, NY
Contact:

Re: FluidSynth music driver

Post 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
Post Reply

Return to “OpenTTD Development”

Who is online

Users browsing this forum: No registered users and 12 guests