Index: NEWS
===================================================================
RCS file: /cvsroot/scummvm/scummvm/NEWS,v
retrieving revision 1.132
diff -u -r1.132 NEWS
--- NEWS	11 Oct 2005 11:27:18 -0000	1.132
+++ NEWS	24 Oct 2005 09:18:50 -0000
@@ -21,6 +21,8 @@
    - Added FluidSynth MIDI driver.
    - Added GUI for the "soundfont" setting. (Currently only used by the
      CoreAudio and FluidSynth MIDI drivers.)
+   - Added "MIDI gain" setting. (Currently only used by the FluidSynth MIDI
+     driver.)
    - The MPEG player could hang if the sound ended prematurely.
    - Improved autoscaling GUI, which takes full advantage of your screen.
    - Fixes for GCC 4.
Index: README
===================================================================
RCS file: /cvsroot/scummvm/scummvm/README,v
retrieving revision 1.339
diff -u -r1.339 README
--- README	23 Oct 2005 10:03:24 -0000	1.339
+++ README	24 Oct 2005 09:18:52 -0000
@@ -834,7 +834,8 @@
 ---- ----------------------------------------------
 If ScummVM was build with libfluildsynth support it will be able to play MIDI
 music through the FluidSynth driver. You will have to specify a SoundFont to
-use, however.
+use, however. Depending on the SoundFont, you may also have to adjust the MIDI
+gain setting.
 
 NOTE: The processor requirements for FluidSynth can be fairly high in some
 cases. A fast CPU is recommended.
Index: base/gameDetector.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/base/gameDetector.cpp,v
retrieving revision 1.126
diff -u -r1.126 gameDetector.cpp
--- base/gameDetector.cpp	18 Oct 2005 19:05:22 -0000	1.126
+++ base/gameDetector.cpp	24 Oct 2005 09:18:54 -0000
@@ -132,6 +132,7 @@
 	ConfMan.registerDefault("multi_midi", false);
 	ConfMan.registerDefault("native_mt32", false);
 	ConfMan.registerDefault("enable_gs", false);
+	ConfMan.registerDefault("midi_gain", 150);
 //	ConfMan.registerDefault("music_driver", ???);
 
 	ConfMan.registerDefault("cdrom", 0);
Index: doc/07_02b.tex
===================================================================
RCS file: /cvsroot/scummvm/scummvm/doc/07_02b.tex,v
retrieving revision 1.1
diff -u -r1.1 07_02b.tex
--- doc/07_02b.tex	10 Apr 2005 14:35:11 -0000	1.1
+++ doc/07_02b.tex	24 Oct 2005 09:18:55 -0000
@@ -8,7 +8,8 @@
 
 If ScummVM was build with libfluildsynth support it will be able to play MIDI
 music through the FluidSynth driver. You will have to specify a SoundFont to
-use, however.
+use, however. Depending on the SoundFont, you may also have to adjust the MIDI
+gain setting.
 
 \textbf{NOTE:} The processor requirements for FluidSynth can be fairly high in
 some cases. A fast CPU is recommended.
Index: gui/options.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gui/options.cpp,v
retrieving revision 1.99
diff -u -r1.99 options.cpp
--- gui/options.cpp	18 Oct 2005 01:30:18 -0000	1.99
+++ gui/options.cpp	24 Oct 2005 09:18:55 -0000
@@ -60,6 +60,7 @@
 	kSfxVolumeChanged		= 'sfvc',
 	kSpeechVolumeChanged	= 'vcvc',
 	kChooseSoundFontCmd		= 'chsf',
+	kMIDIGainChanged		= 'migc',
 	kChooseSaveDirCmd		= 'chos',
 	kChooseExtraDirCmd		= 'chex'
 };
@@ -159,6 +160,12 @@
 
 		// GS extensions setting
 		_enableGSCheckbox->setState(ConfMan.getBool("enable_gs", _domain));
+
+		char buf[10];
+		int gain = ConfMan.getInt("midi_gain", _domain);
+		sprintf(buf, "%.2f", (double)gain / 100.0);
+		_midiGainSlider->setValue(gain);
+		_midiGainLabel->setLabel(buf);
 	}
 
 
@@ -232,10 +239,12 @@
 				ConfMan.set("multi_midi", _multiMidiCheckbox->getState(), _domain);
 				ConfMan.set("native_mt32", _mt32Checkbox->getState(), _domain);
 				ConfMan.set("enable_gs", _enableGSCheckbox->getState(), _domain);
+				ConfMan.set("midi_gain", _midiGainSlider->getValue(), _domain);
 			} else {
 				ConfMan.removeKey("multi_midi", _domain);
 				ConfMan.removeKey("native_mt32", _domain);
 				ConfMan.removeKey("enable_gs", _domain);
+				ConfMan.removeKey("midi_gain", _domain);
 			}
 		}
 
@@ -247,6 +256,8 @@
 }
 
 void OptionsDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 data) {
+	char buf[10];
+
 	switch (cmd) {
 	case kMusicVolumeChanged:
 		_musicVolumeLabel->setValue(_musicVolumeSlider->getValue());
@@ -260,6 +271,11 @@
 		_speechVolumeLabel->setValue(_speechVolumeSlider->getValue());
 		_speechVolumeLabel->draw();
 		break;
+	case kMIDIGainChanged:
+		sprintf(buf, "%.2f", (double)_midiGainSlider->getValue() / 100.0);
+		_midiGainLabel->setLabel(buf);
+		_midiGainLabel->draw();
+		break;
 	case kOKCmd:
 		setResult(1);
 		close();
@@ -295,6 +311,8 @@
 	_multiMidiCheckbox->setEnabled(enabled);
 	_mt32Checkbox->setEnabled(enabled);
 	_enableGSCheckbox->setEnabled(enabled);
+	_midiGainSlider->setEnabled(enabled);
+	_midiGainLabel->setEnabled(enabled);
 }
 
 void OptionsDialog::setVolumeSettingsState(bool enabled) {
@@ -411,7 +429,7 @@
 	}
 
 	// SoundFont
-	_soundFontButton = addButton(boss, x, yoffset, "SoundFont: ", kChooseSoundFontCmd, 0, ws);
+	_soundFontButton = addButton(boss, x, yoffset, "SoundFont:", kChooseSoundFontCmd, 0, ws);
 	_soundFont = new StaticTextWidget(boss, x + buttonWidth + 20, yoffset + 3, _w - (x + buttonWidth + 20) - 10, kLineHeight, "None", kTextAlignLeft, ws);
 	yoffset += buttonHeight + 2 * spacing;
 
@@ -427,6 +445,19 @@
 	_enableGSCheckbox = addCheckbox(boss, x, yoffset, "Enable Roland GS Mode", 0, 0, ws);
 	yoffset += _enableGSCheckbox->getHeight() + spacing;
 
+	const char *label = "MIDI gain:";
+	int textwidth = g_gui.getStringWidth(label);
+
+	new StaticTextWidget(boss, x, yoffset + 2, textwidth, kLineHeight, label, kTextAlignLeft, ws);
+	_midiGainSlider = addSlider(boss, x + textwidth + 15, yoffset, kMIDIGainChanged, ws);
+	_midiGainLabel = new StaticTextWidget(boss, x + textwidth + 15 + _midiGainSlider->getWidth() + 10, yoffset + 2, 40, kLineHeight, "100%", kTextAlignLeft, ws);
+
+	_midiGainSlider->setMinValue(0);
+	_midiGainSlider->setMaxValue(1000);
+	_midiGainLabel->setFlags(WIDGET_CLEARBG);
+
+	yoffset += _midiGainSlider->getHeight() + 4;
+
 	_enableMIDISettings = true;
 
 	return yoffset;
Index: gui/options.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gui/options.h,v
retrieving revision 1.34
diff -u -r1.34 options.h
--- gui/options.h	18 Oct 2005 01:30:18 -0000	1.34
+++ gui/options.h	24 Oct 2005 09:18:55 -0000
@@ -104,6 +104,9 @@
 
 	SliderWidget *_speechVolumeSlider;
 	StaticTextWidget *_speechVolumeLabel;
+
+	SliderWidget *_midiGainSlider;
+	StaticTextWidget *_midiGainLabel;
 };
 
 
Index: sound/softsynth/fluidsynth.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sound/softsynth/fluidsynth.cpp,v
retrieving revision 1.7
diff -u -r1.7 fluidsynth.cpp
--- sound/softsynth/fluidsynth.cpp	18 Oct 2005 01:30:24 -0000	1.7
+++ sound/softsynth/fluidsynth.cpp	24 Oct 2005 09:18:56 -0000
@@ -114,10 +114,9 @@
 
 	_settings = new_fluid_settings();
 
-	// The default gain setting is ridiculously low, but we can't set it
-	// too high either or sound will be clipped. This may need tuning...
+	double gain = (double)ConfMan.getInt("midi_gain") / 100.0;
 
-	setNum("synth.gain", 2.1);
+	setNum("synth.gain", gain);
 	setNum("synth.sample-rate", _outputRate);
 
 	_synth = new_fluid_synth(_settings);
