FluidSynth music driver
Moderator: OpenTTD Developers
FluidSynth music driver
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
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 338 times
- planetmaker
- OpenTTD Developer
- Posts: 9432
- Joined: 07 Nov 2007 22:44
- Location: Sol d
Re: FluidSynth music driver
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
looks like a copy&paste error for the return value and the following comment in the last quoted line
Cheers,
pm
- 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. */
Cheers,
pm
OpenTTD: manual | online content | translations | Wanted contributions and patches
#openttdcoop: blog | wiki | public server | DevZone | NewGRF web translator
DevZone - home of the free NewGRFs: OpenSFX | OpenMSX | OpenGFX | Swedish Rails | OpenGFX+ Trains|RV|Industries|Airports|Landscape | NML
Re: FluidSynth music driver
Thanks for comments, here is an updated version.
- Attachments
-
- 0001-fluidsynth-support.patch
- (10.44 KiB) Downloaded 374 times
- planetmaker
- OpenTTD Developer
- Posts: 9432
- Joined: 07 Nov 2007 22:44
- Location: Sol d
Re: FluidSynth music driver
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.

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.
OpenTTD: manual | online content | translations | Wanted contributions and patches
#openttdcoop: blog | wiki | public server | DevZone | NewGRF web translator
DevZone - home of the free NewGRFs: OpenSFX | OpenMSX | OpenGFX | Swedish Rails | OpenGFX+ Trains|RV|Industries|Airports|Landscape | NML
Re: FluidSynth music driver
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.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 somewhereIn 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
Updated version with a soundfont list.
- Attachments
-
- 0001-fluidsynth-support.patch
- (10.85 KiB) Downloaded 278 times
Re: FluidSynth music driver
Added comments with rationale for defaults + Fedora linux support.
- Attachments
-
- 0001-fluidsynth-support.patch
- (11.02 KiB) Downloaded 349 times
Re: FluidSynth music driver
Removed error messages when looking for default soundfont.
- Attachments
-
- 0001-fluidsynth-support.patch
- (11.11 KiB) Downloaded 363 times
Re: FluidSynth music driver
Bump. Any chance for this patch to be included in trunk, possibly with lower driver priority setting to avoid surprises for the users?
- planetmaker
- OpenTTD Developer
- Posts: 9432
- Joined: 07 Nov 2007 22:44
- Location: Sol d
Re: FluidSynth music driver
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
).

We discussed it a bit, but became distracted



OpenTTD: manual | online content | translations | Wanted contributions and patches
#openttdcoop: blog | wiki | public server | DevZone | NewGRF web translator
DevZone - home of the free NewGRFs: OpenSFX | OpenMSX | OpenGFX | Swedish Rails | OpenGFX+ Trains|RV|Industries|Airports|Landscape | NML
Re: FluidSynth music driver
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.
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.
- planetmaker
- OpenTTD Developer
- Posts: 9432
- Joined: 07 Nov 2007 22:44
- Location: Sol d
Re: FluidSynth music driver
Oh, I missed that then. I read the last postingjmak 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.

OpenTTD: manual | online content | translations | Wanted contributions and patches
#openttdcoop: blog | wiki | public server | DevZone | NewGRF web translator
DevZone - home of the free NewGRFs: OpenSFX | OpenMSX | OpenGFX | Swedish Rails | OpenGFX+ Trains|RV|Industries|Airports|Landscape | NML
- orudge
- Administrator
- Posts: 25218
- Joined: 26 Jan 2001 20:18
- Skype: orudge
- Location: Banchory, UK
- Contact:
Re: FluidSynth music driver
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.
In theory this should work on Windows too, it seems. I may experiment later.

Re: FluidSynth music driver
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
* https://sourceforge.net/projects/libtimidity/
* https://github.com/sezero/libtimidity
Who is online
Users browsing this forum: No registered users and 11 guests