Transport Tycoon Forums

The place to talk about Transport Tycoon
It is currently Thu Dec 14, 2017 2:25 am

All times are UTC




Post new topic  Reply to topic  [ 14 posts ] 
Author Message
 Post subject: FluidSynth music driver
PostPosted: Sun Oct 16, 2011 1:32 pm 
Offline
Engineer
Engineer

Joined: Sun Oct 16, 2011 1:26 pm
Posts: 9
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:
File comment: FluidSynth music driver patch
0001-fluidsynth-support.patch [9.21 KiB]
Downloaded 101 times
Top
   
PostPosted: Sun Oct 16, 2011 4:56 pm 
Offline
OpenTTD Developer
OpenTTD Developer
User avatar

Joined: Wed Nov 07, 2007 10:44 pm
Posts: 9025
Location: Sol d
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:
+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

_________________
Image
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


Top
   
PostPosted: Sun Oct 16, 2011 6:54 pm 
Offline
Engineer
Engineer

Joined: Sun Oct 16, 2011 1:26 pm
Posts: 9
Thanks for comments, here is an updated version.


Attachments:
0001-fluidsynth-support.patch [10.44 KiB]
Downloaded 98 times
Top
   
PostPosted: Sun Oct 16, 2011 9:08 pm 
Offline
OpenTTD Developer
OpenTTD Developer
User avatar

Joined: Wed Nov 07, 2007 10:44 pm
Posts: 9025
Location: Sol d
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.

_________________
Image
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


Top
   
PostPosted: Sun Oct 16, 2011 9:27 pm 
Offline
Engineer
Engineer

Joined: Sun Oct 16, 2011 1:26 pm
Posts: 9
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.


Top
   
PostPosted: Sun Oct 16, 2011 9:43 pm 
Offline
Engineer
Engineer

Joined: Sun Oct 16, 2011 1:26 pm
Posts: 9
Updated version with a soundfont list.


Attachments:
0001-fluidsynth-support.patch [10.85 KiB]
Downloaded 61 times
Top
   
PostPosted: Mon Oct 17, 2011 7:42 am 
Offline
Engineer
Engineer

Joined: Sun Oct 16, 2011 1:26 pm
Posts: 9
Added comments with rationale for defaults + Fedora linux support.


Attachments:
0001-fluidsynth-support.patch [11.02 KiB]
Downloaded 101 times
Top
   
PostPosted: Tue Oct 25, 2011 7:17 am 
Offline
Engineer
Engineer

Joined: Sun Oct 16, 2011 1:26 pm
Posts: 9
Removed error messages when looking for default soundfont.


Attachments:
0001-fluidsynth-support.patch [11.11 KiB]
Downloaded 83 times
Top
   
PostPosted: Sun Nov 13, 2011 9:04 pm 
Offline
Engineer
Engineer

Joined: Sun Oct 16, 2011 1:26 pm
Posts: 9
Bump. Any chance for this patch to be included in trunk, possibly with lower driver priority setting to avoid surprises for the users?


Top
   
PostPosted: Mon Nov 14, 2011 10:45 am 
Offline
OpenTTD Developer
OpenTTD Developer
User avatar

Joined: Wed Nov 07, 2007 10:44 pm
Posts: 9025
Location: Sol d
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 ;-) ).

_________________
Image
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


Top
   
PostPosted: Mon Nov 14, 2011 10:56 am 
Offline
Engineer
Engineer

Joined: Sun Oct 16, 2011 1:26 pm
Posts: 9
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.


Top
   
PostPosted: Mon Nov 14, 2011 10:57 am 
Offline
OpenTTD Developer
OpenTTD Developer
User avatar

Joined: Wed Nov 07, 2007 10:44 pm
Posts: 9025
Location: Sol d
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.

_________________
Image
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


Top
   
PostPosted: Sun Feb 12, 2012 8:07 pm 
Offline
Engineer
Engineer

Joined: Sun Oct 16, 2011 1:26 pm
Posts: 9
Ping :)


Top
   
PostPosted: Thu Feb 16, 2012 3:12 pm 
Offline
Administrator
Administrator
User avatar

Joined: Fri Jan 26, 2001 8:18 pm
Posts: 23816
Skype: orudge
Location: Banchory, UK
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. :)

_________________
Owen Rudge
owenrudge.net | Owen's Transport Tycoon Station | Owen's Locomotion Depot | The Transport Tycoon Wiki


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic  [ 14 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000-2017 phpBB Limited

Copyright © Owen Rudge/The Transport Tycoon Forums 2001-2017.
Hosted by Zernebok Hosting.