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 » 16 Oct 2011 13:32

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 151 times

User avatar
planetmaker
OpenTTD Developer
OpenTTD Developer
Posts: 9271
Joined: 07 Nov 2007 22:44
Location: Sol d

Re: FluidSynth music driver

Post by planetmaker » 16 Oct 2011 16:56

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 » 16 Oct 2011 18:54

Thanks for comments, here is an updated version.
Attachments
0001-fluidsynth-support.patch
(10.44 KiB) Downloaded 152 times

User avatar
planetmaker
OpenTTD Developer
OpenTTD Developer
Posts: 9271
Joined: 07 Nov 2007 22:44
Location: Sol d

Re: FluidSynth music driver

Post by planetmaker » 16 Oct 2011 21:08

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 » 16 Oct 2011 21:27

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 » 16 Oct 2011 21:43

Updated version with a soundfont list.
Attachments
0001-fluidsynth-support.patch
(10.85 KiB) Downloaded 101 times

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

Re: FluidSynth music driver

Post by jmak » 17 Oct 2011 07:42

Added comments with rationale for defaults + Fedora linux support.
Attachments
0001-fluidsynth-support.patch
(11.02 KiB) Downloaded 137 times

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

Re: FluidSynth music driver

Post by jmak » 25 Oct 2011 07:17

Removed error messages when looking for default soundfont.
Attachments
0001-fluidsynth-support.patch
(11.11 KiB) Downloaded 131 times

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

Re: FluidSynth music driver

Post by jmak » 13 Nov 2011 21:04

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: 9271
Joined: 07 Nov 2007 22:44
Location: Sol d

Re: FluidSynth music driver

Post by planetmaker » 14 Nov 2011 10:45

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 » 14 Nov 2011 10:56

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: 9271
Joined: 07 Nov 2007 22:44
Location: Sol d

Re: FluidSynth music driver

Post by planetmaker » 14 Nov 2011 10:57

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 » 12 Feb 2012 20:07

Ping :)

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

Re: FluidSynth music driver

Post by orudge » 16 Feb 2012 15:12

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: 11
Joined: 11 Jan 2019 03:03
Location: New York, NY
Contact:

Re: FluidSynth music driver

Post by njn » 07 Feb 2019 02:52

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 4 guests