alinebee / Boxer

The DOS game emulator that's fit for your Mac.
http://boxerapp.com/
770 stars 139 forks source link

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

Open PatTheMav opened 9 years ago

PatTheMav commented 9 years ago

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.:

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.

getaaron commented 9 years ago

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.

alinebee commented 9 years ago

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 commented 9 years ago

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.

PatTheMav commented 9 years ago

@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).

JoshuaPettus commented 9 years ago

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 :)

PatTheMav commented 9 years ago

@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).

alinebee commented 9 years ago

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.)

JoshuaPettus commented 9 years ago

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 commented 9 years ago

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 commented 9 years ago

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

PatTheMav commented 9 years ago

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?

JoshuaPettus commented 9 years ago

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

PatTheMav commented 9 years ago

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).

JoshuaPettus commented 9 years ago

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 commented 9 years ago

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.

PatTheMav commented 9 years ago

@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";
JoshuaPettus commented 9 years ago

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?

PatTheMav commented 9 years ago

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

JoshuaPettus commented 9 years ago

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 commented 9 years ago

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

alinebee commented 9 years ago

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.

PatTheMav commented 9 years ago

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.

alinebee commented 9 years ago

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.

JoshuaPettus commented 9 years ago

@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!

lavadrop commented 9 years ago

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.

PatTheMav commented 8 years ago

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.

MaddTheSane commented 8 years ago

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 notifications@github.com 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.

PatTheMav commented 8 years ago

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).

lavadrop commented 8 years ago

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 < notifications@github.com> 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.

PatTheMav commented 8 years ago

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.

Goi-Yaas-Dinn commented 8 years ago

Dropbox links are dead.

kode54 commented 7 years ago

Further alternative MIDI options: Audio Unit picker, to allow one to use things such as the extremely overpriced Roland Sound Canvas VA. It also has an internal API, but that shall not be discussed here, since it goes deeper than the level at which they implemented the processing-expensive software licensing system that happens to add over 10 seconds to the startup time.

almeath commented 6 years ago

I have tried pointing Boxer 2 alpha to a few different SF2 sound fonts using the specified terminal command. It generally works very well. My only problem is the volume of some fonts is way too loud and can sometimes drown out the voice and sound effects in various games. Some games allow for independent music volume control, but others just have one master volume control.

Is there a way to adjust the volume at which Boxer plays the MIDI music, independently of the master volume slider?

Goi-Yaas-Dinn commented 6 years ago

@almeath Dead project.

almeath commented 6 years ago

@Goi-Yaas-Dinn There are active discussions taking place on the issues tracker for this "dead project". We all know that Boxer has not been substantively updated by the developer for a number of years. It does not make my question any less valid. The app continues to work well in the current release of macOS. There is also an active fork being worked on. I was not expecting an answer from the developer, and if there is no solution available in Boxer's current state, then so be it.

Goi-Yaas-Dinn commented 6 years ago

There is also an active fork being worked on.

@almeath ...Eh? Link? I know it's been forked several times, (including by an OpenEmu contributor), but was completely unaware any were actually "active".

almeath commented 6 years ago

I say "active" in the sense that they have been updated in the last couple of years since official development of Boxer stopped. This one has been updated in the last two weeks, incorporating updates from the DOSBox SVN.

https://github.com/MaddTheSane/Boxer/tree/updateDosBox

I have not had time to test this out, but it just goes to show that there is continued interest in keeping Boxer alive as long as possible.

almeath commented 6 years ago

I used the defaults write command to point Boxer 2 alpha to a custom sound font, and that works fine. However, when I use Boxer Bundler to create a standalone app (obviously using the Boxer 2 alpha code) I notice that the resulting apps do not recognize this re-pointing and they default to the built in DLS midisynth in macOS.

Is there a way to point these standalone Boxer Bundler apps to sound fonts, or does it only work with the main Boxer app itself?

almeath commented 6 years ago

I know I could convert an .sf2 sound font to .dls with the right software, and entirely replace my system level sound font.

But that seems like overkill if there is a simpler way to do this.

MaddTheSane commented 6 years ago

I am fairly certain CoreAudio can use both .sf2 and .dls sound fonts. The sample code in this project should help, particularly the -b flag.

almeath commented 6 years ago

Yes, I think there has always been an ability in macOS to override the in-built GM instrument set with sound fonts (either sf2 or DLS) but it needs to be set on a per-application basis, such as within QuickTime or GarageBand etc. I cannot find a way in macOS High Sierra to force the use of an SF2 sound font system-wide across all apps, otherwise my problem would be solved.

Alun provided the terminal command to point Boxer 2 alpha to a corresponding sound font and override the default core audio instruments. SVN DOSBox achieves the same thing by using the core audio or core midi setting and pointing to the soundfont in the configuration file.

However, for various reasons, I want to use standalone Boxer applications constructed with Boxer Bundler. These standalone apps ignore the terminal command used with the main Boxer application, so the individual Boxer apps fall back on the in-built GM instruments. Unlike DOSBox, I cannot manually point to the sound font in the configuration file.

So, I assumed that unless these standalone apps can be made to follow the re-direct command noted by Alun, then the only way I can see to force the use of the preferred sound font is to replace the GM instruments at the system level.

I also thought of using FluidSynth and having the MIDI output redirected through that, similar to when using MUNT, but there are no decent FluidSynth setups for newer versions of macOS of which I am aware.

Anyway, I’ll keep researching this.

kode54 commented 6 years ago

In case anyone wants to look at my Gists, there's a SoundFont List loader, which supports both flat file lists (v1), and JSON based lists (v2), and nesting the lists. It currently is designed to auto load SoundFonts with BASSMIDI, but it could be adapted to load with FluidSynth, or any other synthesizer that supports multiple SoundFont (or DLS) banks per instance, and also picking out individual presets from these banks, and setting a volume override on them. It also has a feature that depends on the synthesizer, which can load presets for specific MIDI channels, which just requires the synthesizer to support that somehow. For BASSMIDI, I implement that using the bank LSB control.

E: Ah, here it is: https://gist.github.com/kode54/a7bb01a0db3f2e996145b77f0ca510d5