News:

Simutrans Sites
Know our official sites. Find tools and resources for Simutrans.

New music backend for Simutrans: fluidsynth

Started by Roboron, August 29, 2020, 07:56:10 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Roboron

Quote from: TurfIt on February 07, 2021, 03:52:12 AMAlternatively, a Msys2 package is available, mingw-w64-x86_64-fluidsynth, however it's only setup for dynamic linking

Since fluidsynth 2.2.2 (released half a year ago), fluidsynth export static libraries, and mingw-w64-x86_64-fluidsynth can now be used for static linking, not requiring manually compiling fluidsynth any-more. I just tested today.

mirror176

  I can add that I ran into an issue with fluidsynth built without sdl backend on FreeBSD by default. It is normally built with jack (=no output on my system) and oss. To play a midi on command line it required by default `fluidsynth -s -a oss -m oss /usr/local/share/sounds/sf2/FluidR3_GM.sf2 file.midi`. I found a typo on -m leads to "fluidsynth: error: Couldn't find the requested midi driver." and then plays audio while excluding it does not (presume it defaults to jack).
  It would be useful to be able to select the driver through Simutrans options (say I want to pass it through jack for more specific program connections and mixing, or default just didn't work) so I don't need to patch+recompile Simutrans to change it; if there is a way to change fluidsynth default sound such as a config file then I didn't figure out how best to go about it. If Simutrans is going to control fluidsynth options, then it is best to make those options controllable by the user. If I recall, there are other options that can impact how it sounds that could be beneficial to expose to the user too.
  Another beneficial change would be modifying the sound dialog to state why midi is disabled (driver initialization, no font, etc.) instead of just that it is disabled; there was a lot in the logs to skim through until finding the sdl initialization failure and I had to find things like this thread to have a better idea what I was looking for. Popup errors could do it but may be annoying for users who don't care about audio working compared to a statement in a settings dialog box.
  Seems a working sound setup retains mute/unmute status. Breaking it will mute the setting next run and fixing it does not unmute it on its own.
  If game loads with music muted, first track is main theme instead of randomized. Randomizing works on launches already in an unmuted state. Maybe play theme on loading until options screen is closed or when on the new game setups and such if its undesired for general game play listening?
  /usr/local/share/simutrans/simutrans.tab makes reference to ~/simutrans and comparable statement was found in simutrans/readme.txt though the only folder in my user area is ~/.simutrans. Is the lack of a dot something that changed over time or refers to a different folder and the one I have will never be read for simutrans.tab? Copying it to ~/.simutrans/ seemed like it worked where I set frames_per_second to 1 because it got more sluggish but was definitely still faster than 1fps.
  Comment #54 says to see readme.txt and has quoted text which I implied said to set soundfont_filename to be able to give a full path to a soundfont but could not currently find "soundfont_filename" present when grepping against the extracted download of simutrans-src-123-0-1.zip. Looks like the readme files could benefit from a bit of a content rework.
  Another goal for another day will be looking into if I can drive midi directly but don't have space for my electric piano near my PC currently.
  FreeBSD falls under the category of soundfont not being installed by default, "/usr/local/share/sounds/sf2" is where FluidR3_GM installs to (all third party packages end up in /usr/local with very few exceptions) after installing the port "audio/fluid-soundfont" and doing so does not create a symlink to /usr/local/share/soundfonts/default.sf2 (not that Simutrans looks for it there). As sinutrans looks only in /usr/local/share/simutrans/music/ but doesn't include its own, I agree it would be nice to at least probe a few common possible Linux/UNIX system install locations for them. If not, it would be nice if ~/.simutrans/music or similar user home directory could be used so it is easy to adjust without requiring admin level work once again. Checking many locations could be avoided by either providing a setting to the user or a compile time setting that contains a path where all fonts are stored and looked for since Simutrans currently uses its own proprietary locaton while it also does not include any soundfont in it.
  If timidity(++) is an option, I have not yet figured out what steps are necessary to get that going with Simutrans.
  Presume the excluded 'disturbing' midi is what is currently listed as '53-Where-Thomassons-Lie.mid'. If so, it seems to use more of a 20th century nontonal music style if my memory serves. Been over 15 years since I had music theory so I may be wrong in timeframe/description but basically it goes into styles that move away from the usual use of harmonic keys and chords. Didn't notice the game telling me 'there is another file, but it was excluded' though the GUI could be changed to provide music either by folders (and user expandable/customizable) or use some other categorization so individual/groups (such of types) of songs could be enabled/disabled from the playlist.
  If concerned about the size of a good soundfont being several hundred megs, preprocessed midi could be easily fit in <150MB space. Midi has the advantages of small files, easy editing of the composition (though I'd still prefer a different source to compose it in), variations with supplying different sounds per track, and processing can be offloaded to separate dedicated hardware. If I recall, timidity started from a developer wanting to make a game with dynamically composed music so it could be altered relative to the content without just having to fade/cut from one to the next. If Simutrans just wants it to be a radio playing and not game content aware then maybe that could be skipped. Midi in games/programs still leaves some cool potential for what can be done. Midi or not, there is still the option of music is lowered for certain other content to play; doubt an engine startup would be as desired as a voice talking for such task, but it is doable too.
  Thank you for efforts to minimize layered library dependencies and improve stability+compatibility.

Roboron

Simutrans does look in more than one place for soundfonts, it is just a matter of adding the FreeBSD path, see https://github.com/simutrans/simutrans/blob/master/src/simutrans/music/fluidsynth.cc#L29

The suggestion to be able to choose the audio driver seems reasonable. I'll try to add an option, at least to simuconf.