Boxer icon indicating copy to clipboard operation
Boxer copied to clipboard

Feature request: Additional audio options (e.g. Sound fonts, GUS)

Open PatTheMav opened this issue 10 years ago • 42 comments

Adding to the amazing work done for MT-32 support in Boxer, I'd very much like to see a possibility to also configure additional audio options, e.g.:

  • Selection of Sound fonts - Core Audio is able to use SF2 sound font files, DOSBOX supposedly supports this in OS X natively (see http://sourceforge.net/p/dosbox/patches/242/)
  • Global configuration for Gravis Ultrasound - if given an ULTRASND folder, it would be awesome if this folder could be dropped on the config window just like the MT-32 ROMs which would enable GUS for all games and "mount" the folder properly (setting the "ultradir" config variable accordingly).

A bit of an explanation for this: Even though many games tout MT-32 support (and have appropriate drivers) not all of them have been composed using an MT-32 (or their MT-32 tracks haven't). Case in point: X-Wing's floppy version has a MT-32 sound track, it's General Midi sound track was converted from the MT-32 version. X-Wing's CD Rom version however sports only the General Midi tracks (even for the MT-32). TIE Fighter was composed on a Roland SC-55 which is a General Midi device, so it's MT-32 track is also just a converted General Midi soundtrack.

So while one might want to use MT-32 for - say - Monkey Island (which truly shines using it), TIE Fighter or Dark Forces will sound better using General Midi and a proper modern sound font.

As Boxer passes General Midi music to core audio (bypassing its internal MT-32 support), it could use an available sound font. Configuring this "out of the box" on OS X has become quite cumbersome ever since Quicktime X and requires outdated software (often requiring Rosetta) or doing a full install of Xcode to acquire needed programs.

Edit: Looking at the repository it seems that the underlying system is able to load a user-specified sound font, so the UI exposing that feature is "just" missing.

PatTheMav avatar Nov 01 '14 16:11 PatTheMav

If it exists, Boxer should access a database and select the "best" choice for the user. Possibly the most frustrating part of setting up a new game in Boxer is optimizing the audio options.

getaaron avatar Nov 03 '14 03:11 getaaron

Edit: Looking at the repository it seems that the underlying system is able to load a user-specified sound font, so the UI exposing that feature is "just" missing.

That's correct: this is a hidden feature with no UI. I have toyed with the idea of exposing this, either as a global preference or as a per-game setting on a future "Audio" panel in the inspector, but to be honest: unlike MT-32 support, it's a niche option that to me doesn't justify the UI space.

For now in any case, you can specify a soundfont path using the following Terminal command: defaults write net.washboardabs.boxer MIDISoundFontPath -string "/absolute/path/to/my/soundfont.sf2"

Should you later wish to switch back to OS X's default soundfont, you can undo the setting with the following command: defaults delete net.washboardabs.boxer MIDISoundFontPath


Aside from this, I should note that the sound quality from OS X's default soundfont was quite good up until 10.6, then got markedly worse in 10.7: certain instruments are now incorrectly mapped or use the wrong reverb settings. Strangely, when using a custom soundfont I found that the sound output from both OS X versions was identical: this is despite the fact that OS X's default soundfont is identical in both versions, so I'm unable to explain the difference in output when using the default soundfont. I've thought about addressing this by bundling a small soundfont with known quality into Boxer, but haven't found any that are both free-use and not frickin enormous.


Now, as to GUS support: Boxer has the original GUS patches built-in, and no configuration is needed in order to use Gravis Ultrasound out-of-the-box. I assume you're aware of this though, and wish to globally override these with custom GUS patches instead.

Currently it is possible to do this by dumping the custom patches into the gamebox and overriding the ULTRADIR path. Like with soundfonts, I consider overriding the patches to be an advanced feature and not something I want to dedicate UI space to right now. If I do introduce support for globally overriding the GUS patches, it would probably be in the form of "if you put patch files in ~/Application Support/Boxer/Ultrasound Patches, we'll automatically use them instead of the built-in patches."

To explain my philosophy on this: UI for features like these would be fairly compact, but would still require a lot of code to wire it all up that then needs to be tested and maintained and allotted space in the UI design forever after. Each feature that's exposed to the user is a small but significant tax on UI space, maintenance time and the user's own attention span. Boxer is what it is in part because I said "no" to as many settings as possible.

alinebee avatar Nov 03 '14 09:11 alinebee

getaaron: Boxer is simply unable to automate DOS game installers such that it can choose options for you. There are almost as many kinds of DOS installer as there are DOS games, and Boxer has no insight into their inner workings: they're just pixels on a screen as far as it knows. This is why Boxer can only tell you which music options are good and which settings to pick when you're asked.

The other approach would be for Boxer to bypass the installer altogether, by instead copying the files itself and replacing whichever files the game puts its sound/video settings in with preconfigured versions of those files. Maintaining such a resource is far beyond my means, and it would ultimately just be a messier and more error-prone equivalent to providing prepackaged versions of the games themselves: which is what companies like GOG.com are already doing for you.

alinebee avatar Nov 03 '14 09:11 alinebee

@alunbestor Thanks for the defaults hint, will try that for the time being.


You are right that OSX' built-in Midi capabilities have been diminishing for some time now - before Lion it was possible to configure this out of the box. But ever since Quicktime X was introduced, OS X seemed to have refocused on supporting external USB Midi devices instead. In my personal opinion sound fonts such as "FluidR3_GM" sound better and have a "fuller" sound (yet being comparatively "small" at 140MB).


As for the GUS support, I wasn't aware that it has the patches built-in already (at least that's not how I understood the help file), but it's good to know.

I'm with you on the UI question - it's Boxer's strong suit that its UI is simple and straight forward (especially the inspector for a given game). As such I'd be totally ok with a properly documented drop-in support inside the Application Support folder (similar to how the MT-32 ROM files are placed there):

Have a "Ultrasound" and "Soundfont" folder in there and any power user can place his files there. This would be a global setting (so any game uses the specified ULTRASND folder and uses the given sound font for General MIDI playback).

As much as I would like another "drop" area for these patches, they don't make sense from a UI point of view (the MT-32 interface is already quite gratuitous), so I'd consider this feature as "complete" once the Application Support-folders are supported (I haven't put enough thought about implications for the standalone Boxer builds though).

PatTheMav avatar Nov 03 '14 10:11 PatTheMav

There is a hack you can do on your computer to replace the default soundfont. If you wish. Download any .sf2 file convert it to .dls format, (good luck with this as the only tools I know that can do this are not free and windows), and move it to /System/Library/Components/CoreAudio.component/Resources and rename it to gs_instruments.dls. (be sure to rename the old gs_instruments.dls file so you don't delete it)

I replaced mine with the beta of Timbres of Heaven 2.03. https://groups.yahoo.com/neo/groups/midkar/conversations/topics/38503 It is, by far, better then anything else out there. (And I know Fluid_R3 and Arachno soundfonts very well) On top of sounding phenomenal all around, the samples are properly normalized and balanced with each other. With General Midi, it also supports Yamaha XG and Roland GS (sound canvas) midi extensions. (great for games that support them) 2.02 Is available and supports this as well, but the next version, which will be out hopefully soon, is just amazing. Definitely leaves behind the standard midi synth. Alun be sure to give it a try! I'm sure you won't think it so niche :)

JoshuaPettus avatar Nov 29 '14 05:11 JoshuaPettus

@darklord42 as you already mentioned, converting the SF2 sound fonts to DLS is quite expensive (as only a handful of windows programs seem to be able to do this).

Alas I couldn't get Boxer to use the SF2 files properly using the method explained by alun. I've set the defaults using the absolute path to my SF2 file, yet Midi music sounds the same no matter which setting I'm using (I even copied the sound font to my root folder to exclude the possibility of a path error).

PatTheMav avatar Nov 29 '14 11:11 PatTheMav

Pat: if your soundfont path contains spaces, make sure that the spaces are EITHER escaped using \ OR the whole path is wrapped in "" (not both, or Terminal will treat the \ escapes as part of the actual path).

I got caught by that while testing just now, because I copy-pasted the path from Finder into the terminal and then blithely wrapped it in quotes without noticing that the spaces were already escaped.

With the correctly-formatted path, the soundfont feature does work - at least testing with the soundfont linked by darklord42 above. (Bear in mind that the SF2 file you're testing with may be incompatible with CoreAudio in some way, in which case there's nothing Boxer can do.)

alinebee avatar Nov 29 '14 12:11 alinebee

Yah, Core Audio incompatibility is possible, though I have not noticed any big issues. There is also option 3 - install fluidsynth via macports, run it through command line (you can create a bash script to do this for you later) and use mididevice command in boxer to select the right device. It's been a while since I did this, but I believe it's by a number with coremidi. I might try it again to see if there is any difference.

JoshuaPettus avatar Nov 29 '14 16:11 JoshuaPettus

Sorry, that's the midiconfig command. (told you it's been a while :) ) 0 is default 1 is the next device available most likely fluidsynth unless you have something else already there.

JoshuaPettus avatar Nov 29 '14 16:11 JoshuaPettus

It has been a while...I forgot you had to do quite a bit for fluidsynth. After launching fluidsynth with the soundfont as an argument, go to /Applications/Utilities/Audio Midi Setup. Click on Show Midi Studio. Click on IAC Driver, make sure it's active. Then go to Network, Create a new session, Under live routings, select IAC Driver as output and Fluidsynth as Input. Then in boxer you need to set mididevice coremidi and midiconfig 1, If you don't hear anything keep changing numbers till you do :) I found it on 2 for my system. In short, go with Boxer's sound font selection if you can XD

JoshuaPettus avatar Nov 29 '14 17:11 JoshuaPettus

I'm using FluidR3 usually, so now I've tried "Timbres of Heaven". I copied the file to my user folder and added it to the defaults:

➜ defaults write net.washboardabs.boxer MIDISoundFontPath -string "/Users/PatTheMav/Timbres.sf2"

I then went ahead and checked the MIDI output using the "Dark Forces" IMUSE config tool, yet it sounds the same with or without an SF2-file being set.

Any game in particular that might be better for checking this?

PatTheMav avatar Nov 29 '14 17:11 PatTheMav

defaults write net.washboardabs.boxer MIDISoundFontPath "/Users/PatTheMav/Timbers.sf2" I believe no -string In fact, you may not need the quotation marks

JoshuaPettus avatar Nov 29 '14 17:11 JoshuaPettus

Thanks, tried that with Timbres and FluidR3 respectively, restarting Boxer each time I've changed the settings, but General Midi sounds the same in all three cases (no sound font, FluidR3, Timbres of Heaven).

Games I used for testing: Star Wars Dark Forces, Star Wars TIE Fighter and Tyrian 2000.

Edit: As people using vanilla Dosbox with Timbres and FluidR3 don't seem to have issues, I take it that both sound fonts are compatible with Core Audio (as that's what Dosbox is using on OS X).

PatTheMav avatar Nov 29 '14 18:11 PatTheMav

Well vanilia dosbox doesn't support soundfonts directly. There is Taewong's build which has a lot of patches and extra features, one of which has fluidsynth built in. I'm not sure how that works though. I'll give boxers default a try myself and see what I come up with

JoshuaPettus avatar Nov 29 '14 18:11 JoshuaPettus

Ok I was wrong you do need -strings but loose the quotation marks

defaults write net.washboardabs.boxer MIDISoundFontPath -string /Applications\ Music/midi/Timbres\ Of\ Heaven\ GM_GS_XG_SFX\ V\ 2.0.3\ Beta\ 3.2/Timbres\ Of\ Heaven\ GM_GS_XG_SFX\ V\ 2.0.3\ Beta\ 3.2.sf2

was my setup and worked for me. (Notice how spaces are handled with a backslash preceding each space.) To double make sure something is there type

defaults read net.washboardabs.boxer

and if within the wall of text you find MIDISoundFontPath = none then it didn't work.

JoshuaPettus avatar Nov 29 '14 19:11 JoshuaPettus

@darklord42 actually the quotation marks shouldn't make a difference (you either need to quote the path or escape spaces and other non-standard letters in the given path) and in both cases the setting was set as a "string".

I've put the sound fonts in my user dir and renamed them so I don't need any kind of escaping (to avoid any of those issues), yet the midi test in TIE fighter sounds the same, no matter my setting.

➜ defaults write net.washboardabs.boxer MIDISoundFontPath -string /Users/PatTheMav/Fluid.sf2 
➜ defaults read net.washboardabs.boxer | grep MIDI
    MIDISoundFontPath = "/Users/PatTheMav/Fluid.sf2";

➜ defaults write net.washboardabs.boxer MIDISoundFontPath -string /Users/PatTheMav/Timbres.sf2
➜ defaults read net.washboardabs.boxer | grep MIDI
    MIDISoundFontPath = "/Users/PatTheMav/Timbres.sf2";

PatTheMav avatar Nov 30 '14 01:11 PatTheMav

Well default read says it's there, so that's a good sign. The difference is quite noticeable in Tie fighter and any game supporting GM. I don't think you would get the end result confused. Really stupid question, but I'm out of ideas. You sure you don't have the game set to use adlib, gravismidi or something other then GM?

JoshuaPettus avatar Nov 30 '14 01:11 JoshuaPettus

If it just were that easy ;) I'm testing directly using the iMuse setup tool, it's always "General Midi" on port 330.

PatTheMav avatar Nov 30 '14 01:11 PatTheMav

I just realized, one more stupid question. Are you using boxer 1.3.2 or a version of 2.0 beta you compiled yourself? I'm pretty sure the soundfont feature doesn't exist in 1.3.2. It was put in after. Either way, I'd be happy go give you a .dls version of the soundfonts. Can't really guarantee their accuracy, but it's better then fluidsynth. :) I actually haven't noticed any issues with that method.

JoshuaPettus avatar Nov 30 '14 04:11 JoshuaPettus

Here are .dls versions of Fluid and ToH. They go to replace /System/Library/Components/CoreAudio.component/Resources/gs_instruments.dls (Make sure to rename or move the old one)

FluidR3 https://www.dropbox.com/s/fygv4xg4x53vw76/FluidR3.7z?dl=0 ToH2.0.3B3.2 https://www.dropbox.com/s/bz6t85kak9op6kv/ToH2.0.3B3.2.7z?dl=0

JoshuaPettus avatar Nov 30 '14 05:11 JoshuaPettus

DLS or SF2 should make no difference, CoreAudio supports both and definitely the original SF2 version of ToH works for me (in 10.10). And the userdefaults setting is definitely correct, so Boxer should be picking up on the soundfont.

(One thing you haven't mentioned yet is which OS X version you're using? This shouldn't matter - the soundfont support should work on 10.5 thru 10.10 - but it could nevertheless be a factor.)

In commit I added some debug messages for the loading. If you're able to build Boxer from source, please do the following:

  1. Build and run Boxer from within XCode.
  2. Launch a game like Dark Forces that's set up for General MIDI, and get to a point where MIDI music starts playing.
  3. Once music is playing, check the console output in the bottom panel of the XCode window. Below a bunch of other nonsense, you should see one of the following messages:
    • "Successfully loaded soundfont: [path to soundfont]"
    • "Error when loading soundfont: [error information]"
    • "No soundfont specified, using default OS X soundfont."

Copy-paste the contents of the message in here; or if you don't see any of those messages, let me know.

alinebee avatar Nov 30 '14 07:11 alinebee

I just realized, one more stupid question. Are you using boxer 1.3.2 or a version of 2.0 beta you compiled yourself? I'm pretty sure the soundfont feature doesn't exist in 1.3.2. It was put in after. Either way, I'd be happy go give you a .dls version of the soundfonts. Can't really guarantee their accuracy, but it's better then fluidsynth. :) I actually haven't noticed any issues with that method.

Urm, well - yeah we should've cleared that up front.. I'm using the last official build (1.3.2), been looking forward to 2.0 but haven't compiled it myself.

PatTheMav avatar Nov 30 '14 12:11 PatTheMav

Oh okay, that explains it - yeah the soundfont-loading code is not actually wired up in 1.3.2. You'll need to build from source if you want to use soundfonts, or else switch to using FluidSynth and redirecting MIDI output to that.

alinebee avatar Nov 30 '14 12:11 alinebee

@alunbestor "I've thought about addressing this by bundling a small soundfont with known quality into Boxer, but haven't found any that are both free-use and not frickin enormous."

I think the musescore people may have the solution for this. For distribution purposes in musescore 2, they compress all the samples in a soundfont into ogg vorbis format, and dubbed the soundfont ".sf3" they then patched an internal timidity player to read this new format. This brought their bundled FluidR3 synth from 150mb to just 14!

JoshuaPettus avatar Dec 01 '14 18:12 JoshuaPettus

Just my 2¢: I have an MT32 and a SoundCanvas. The MT32 is automatically detected (thanks for the compliment :P ) but the SoundCanvas only works if the .conf file is altered to select coremidi as the sound server instead of the default coreaudio.

lavadrop avatar Feb 21 '15 02:02 lavadrop

Just FYI - switching the gs_Instruments.dls with alternative ones does not work anymore with OSX El Capitan in the new "rootless" mode, as all write access to the /System/ folder is prohibited.

Also haven't found a way to make the system use a CoreAudio.component in an alternative folder (e.g. /Library/ yet.

PatTheMav avatar Aug 29 '15 19:08 PatTheMav

To my knowledge, Boxer shouldn’t need to write to the gs_instrument.dls file. Read access, yes, but not write.

On Aug 29, 2015, at 1:45 PM, PatTheMav [email protected] wrote:

Just FYI - switching the gs_Instruments.dls with alternative ones does not work anymore with OSX El Capitan in the new "rootless" mode, as all write access to the /System/ folder is prohibited.

Also I haven't found a way to make the system use a CoreAudio.component in an alternative folder (e.g. /Library/ yet.

— Reply to this email directly or view it on GitHub https://github.com/alunbestor/Boxer/issues/47#issuecomment-136033338.

MaddTheSane avatar Aug 29 '15 20:08 MaddTheSane

To my knowledge, Boxer shouldn’t need to write to the gs_instrument.dls file. Read access, yes, but not write.

You're absolutely right; this was more intended as an update to the "fix" @JoshuaPettus suggested which made Boxer games use Timbres of Heaven or FluidR3 as sound fonts through modifying the system's gs_instruments file (as "native" sound font support is not built into the currently released version).

PatTheMav avatar Aug 29 '15 20:08 PatTheMav

This could be a significant issue for people using soft synths and not just limited to Boxer, but all current Core Audio apps like GarageBand

El El sáb, 29 de agosto de 2015 a la(s) 15:07, PatTheMav < [email protected]> escribió:

To my knowledge, Boxer shouldn’t need to write to the gs_instrument.dls file. Read access, yes, but not write.

You're absolutely right; this was more intended as an update to the "fix" @JoshuaPettus https://github.com/JoshuaPettus suggested which made Boxer games use Timbres of Heaven or FluidR3 as sound fonts through modifying the system's gs_instruments file (as "native" sound font support is not built into the currently released version).

— Reply to this email directly or view it on GitHub https://github.com/alunbestor/Boxer/issues/47#issuecomment-136037279.

lavadrop avatar Aug 29 '15 20:08 lavadrop

This could be a significant issue for people using soft synths and not just limited to Boxer, but all current Core Audio apps like GarageBand

As far as I understood the "rootless" specifications, Apple signed installers are still able to write to these folders - like the rest of Apple's encroaching walled garden approach to OSX, you can either a) disable rootless yourself (at the cost of losing this "security feature") or shell out money for a developer certificate and sign your installers.

PatTheMav avatar Aug 29 '15 20:08 PatTheMav