FluidSynth MIDI driver

Here you can discuss the development of patches.

FluidSynth MIDI driver

Postby mgiuca » 2012-3-07 @ 05:32

Hi,

I was getting sick of having to manually start up FluidSynth and connect DOSBox to it (through ALSA, on Linux, for example). So I got around to writing a FluidSynth driver for DOSBox, so it can directly send MIDI commands to FluidSynth via its own API. For those who don't know what this is, it's a MIDI synthesiser that turns DOSBox's MPU-401 MIDI commands into sound.

Its usage is pretty simple, you just set this in the [midi] section:
Code: Select all
mididevice=fluidsynth
midiconfig=audio_driver:soundfont

for example, on Linux, I might have:
Code: Select all
mididevice=fluidsynth
midiconfig=pulseaudio:/usr/share/sounds/sf2/FluidR3_GM.sf2


Then, all DOSBox MPU-401 games will automatically produce sound without having to start up any extra software. (I don't have many MPU-401 games, but King's Quest VII requires some external MIDI synth, and this works for that game.)

I have found a year-old forum post here with a similar patch, that doesn't appear to have been accepted. So perhaps I am wasting my time, but since I wrote my patch, I may as well post it here. My patch looks simpler than that one -- it doesn't create a whole event structure, it just passes the messages directly to FluidSynth API calls. The whole driver is 137 lines.

I am maintaining the patch in a Bazaar branch on Launchpad here. The full patch is here: download. I am also attaching the patch to this post.

I am not sure how hard it is to get MIDI games working in DOSBox under Windows -- perhaps someone can explain what the process is like. But under Linux, it is quite a pain if you don't have a hardware synth, requiring that you set up a separate MIDI synth. Hopefully, this patch will make it much easier to get MIDI games working. Unfortunately, it still requires that the user configure the driver name and specify the path to the soundfont, but at least that can be done on a once-off basis.
You do not have the required permissions to view the files attached to this post.
mgiuca
Newbie
 
Posts: 4
Joined: 2011-4-27 @ 23:21

Re: FluidSynth MIDI driver

Postby mgiuca » 2012-3-07 @ 05:52

A quick update: made it so the FluidSynth driver is tried LAST, instead of FIRST.

This page will always contain a link to the up-to-date patch.
You do not have the required permissions to view the files attached to this post.
mgiuca
Newbie
 
Posts: 4
Joined: 2011-4-27 @ 23:21

Re: FluidSynth MIDI driver

Postby Dominus » 2012-3-07 @ 06:54

Thanks for your effort. If I had any say in Dosbox I'd accept this patch ;)
User avatar
Dominus
DOSBox Moderator
 
Posts: 7644
Joined: 2002-10-03 @ 09:54
Location: Ludwigsburg

Re: FluidSynth MIDI driver

Postby ykhwong » 2012-3-07 @ 08:56

Thanks for the patch. :)
ykhwong
Oldbie
 
Posts: 627
Joined: 2004-3-17 @ 15:35

Re: FluidSynth MIDI driver

Postby mgiuca » 2012-7-29 @ 06:17

Bump -- did anybody take a look at this patch? Is there a reason it was rejected that I can address, or is it just not appropriate for integration into DOSBox?
mgiuca
Newbie
 
Posts: 4
Joined: 2011-4-27 @ 23:21

Re: FluidSynth MIDI driver

Postby VileRancour » 2012-7-30 @ 02:15

I wouldn't assume that it was rejected, as there hasn't been an official DOSBox release since you put up the patch.

Don't know why it wasn't moved to the patches forum, though - would be nice to have it where more people would notice and get the chance to test.

EDIT: ah, there it is. :)
User avatar
VileRancour
Oldbie
 
Posts: 1648
Joined: 2003-5-14 @ 22:11
Location: 1-01-80 0:00a

Re: FluidSynth MIDI driver

Postby Ocean112 » 2012-8-01 @ 18:50

I've been using ykhwong's build of dosbox which I'm assuming includes this patch. Is there anyway to set the gain of fluidsynth in the config options? Looking at the code on the lauchpad I can't see it. If it isn't, adding in an option to set the gain in the conf file with the rest of the midi options would be great. Especially as all soundfonts aren't recorded at the same level. If I'm being an idiot and a gain option is already included, please inform me as to how. I saw in one of the old fluidsynth topics where a setting might have been implemented as synth.gian=* but I tried that to no success. Short of re-doing the soundfont I would like to use and upping the base magnitude all around I don't see any other way to go about it, other than a volume control attached to the entire midi section.
Ocean112
Newbie
 
Posts: 3
Joined: 2012-7-30 @ 23:52

Re: FluidSynth MIDI driver

Postby Dominus » 2012-8-01 @ 20:06

The patch doesn't mention gain in any way, so...
User avatar
Dominus
DOSBox Moderator
 
Posts: 7644
Joined: 2002-10-03 @ 09:54
Location: Ludwigsburg

Re: FluidSynth MIDI driver

Postby ykhwong » 2012-8-02 @ 07:48

viewtopic.php?t=27831&highlight=fluidsynth

If you increase the gain, however, you will get extremely distorted output with some soundfonts.
ykhwong
Oldbie
 
Posts: 627
Joined: 2004-3-17 @ 15:35

Re: FluidSynth MIDI driver

Postby Ocean112 » 2012-8-09 @ 03:40

That's to be expected really, as most soundfonts, while having a common recording amplitude inside each "font", they can differ greatly between them. Each soundfont would have a different "best" gain setting associated with it (to match the volume of the emulated digital audio). It just depends on how and who sourced the samples. (and how they prepared them for the pack) Thanks for the help though.

EDIT: As a side-note though, I had to make the 20120701 build large address aware for the SGM and Crisis soundfonts that I tried work. Probably something everyone's already aware of but if you don't well, there you are.
Ocean112
Newbie
 
Posts: 3
Joined: 2012-7-30 @ 23:52


Return to DOSBox Patches

Who is online

Users browsing this forum: No registered users and 2 guests