Ticket #8476: midi-gain.diff

File midi-gain.diff, 7.2 KB (added by eriktorbjorn, 17 years ago)

Patch against an October 25 CVS snapshot

  • NEWS

    RCS file: /cvsroot/scummvm/scummvm/NEWS,v
    retrieving revision 1.132
    diff -u -r1.132 NEWS
     
    2121   - Added FluidSynth MIDI driver.
    2222   - Added GUI for the "soundfont" setting. (Currently only used by the
    2323     CoreAudio and FluidSynth MIDI drivers.)
     24   - Added "MIDI gain" setting. (Currently only used by the FluidSynth MIDI
     25     driver.)
    2426   - The MPEG player could hang if the sound ended prematurely.
    2527   - Improved autoscaling GUI, which takes full advantage of your screen.
    2628   - Fixes for GCC 4.
  • README

    RCS file: /cvsroot/scummvm/scummvm/README,v
    retrieving revision 1.339
    diff -u -r1.339 README
     
    834834---- ----------------------------------------------
    835835If ScummVM was build with libfluildsynth support it will be able to play MIDI
    836836music through the FluidSynth driver. You will have to specify a SoundFont to
    837 use, however.
     837use, however. Depending on the SoundFont, you may also have to adjust the MIDI
     838gain setting.
    838839
    839840NOTE: The processor requirements for FluidSynth can be fairly high in some
    840841cases. A fast CPU is recommended.
  • base/gameDetector.cpp

    RCS file: /cvsroot/scummvm/scummvm/base/gameDetector.cpp,v
    retrieving revision 1.126
    diff -u -r1.126 gameDetector.cpp
     
    132132        ConfMan.registerDefault("multi_midi", false);
    133133        ConfMan.registerDefault("native_mt32", false);
    134134        ConfMan.registerDefault("enable_gs", false);
     135        ConfMan.registerDefault("midi_gain", 150);
    135136//      ConfMan.registerDefault("music_driver", ???);
    136137
    137138        ConfMan.registerDefault("cdrom", 0);
  • 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
     
    88
    99If ScummVM was build with libfluildsynth support it will be able to play MIDI
    1010music through the FluidSynth driver. You will have to specify a SoundFont to
    11 use, however.
     11use, however. Depending on the SoundFont, you may also have to adjust the MIDI
     12gain setting.
    1213
    1314\textbf{NOTE:} The processor requirements for FluidSynth can be fairly high in
    1415some cases. A fast CPU is recommended.
  • gui/options.cpp

    RCS file: /cvsroot/scummvm/scummvm/gui/options.cpp,v
    retrieving revision 1.99
    diff -u -r1.99 options.cpp
     
    6060        kSfxVolumeChanged               = 'sfvc',
    6161        kSpeechVolumeChanged    = 'vcvc',
    6262        kChooseSoundFontCmd             = 'chsf',
     63        kMIDIGainChanged                = 'migc',
    6364        kChooseSaveDirCmd               = 'chos',
    6465        kChooseExtraDirCmd              = 'chex'
    6566};
     
    159160
    160161                // GS extensions setting
    161162                _enableGSCheckbox->setState(ConfMan.getBool("enable_gs", _domain));
     163
     164                char buf[10];
     165                int gain = ConfMan.getInt("midi_gain", _domain);
     166                sprintf(buf, "%.2f", (double)gain / 100.0);
     167                _midiGainSlider->setValue(gain);
     168                _midiGainLabel->setLabel(buf);
    162169        }
    163170
    164171
     
    232239                                ConfMan.set("multi_midi", _multiMidiCheckbox->getState(), _domain);
    233240                                ConfMan.set("native_mt32", _mt32Checkbox->getState(), _domain);
    234241                                ConfMan.set("enable_gs", _enableGSCheckbox->getState(), _domain);
     242                                ConfMan.set("midi_gain", _midiGainSlider->getValue(), _domain);
    235243                        } else {
    236244                                ConfMan.removeKey("multi_midi", _domain);
    237245                                ConfMan.removeKey("native_mt32", _domain);
    238246                                ConfMan.removeKey("enable_gs", _domain);
     247                                ConfMan.removeKey("midi_gain", _domain);
    239248                        }
    240249                }
    241250
     
    247256}
    248257
    249258void OptionsDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 data) {
     259        char buf[10];
     260
    250261        switch (cmd) {
    251262        case kMusicVolumeChanged:
    252263                _musicVolumeLabel->setValue(_musicVolumeSlider->getValue());
     
    260271                _speechVolumeLabel->setValue(_speechVolumeSlider->getValue());
    261272                _speechVolumeLabel->draw();
    262273                break;
     274        case kMIDIGainChanged:
     275                sprintf(buf, "%.2f", (double)_midiGainSlider->getValue() / 100.0);
     276                _midiGainLabel->setLabel(buf);
     277                _midiGainLabel->draw();
     278                break;
    263279        case kOKCmd:
    264280                setResult(1);
    265281                close();
     
    295311        _multiMidiCheckbox->setEnabled(enabled);
    296312        _mt32Checkbox->setEnabled(enabled);
    297313        _enableGSCheckbox->setEnabled(enabled);
     314        _midiGainSlider->setEnabled(enabled);
     315        _midiGainLabel->setEnabled(enabled);
    298316}
    299317
    300318void OptionsDialog::setVolumeSettingsState(bool enabled) {
     
    411429        }
    412430
    413431        // SoundFont
    414         _soundFontButton = addButton(boss, x, yoffset, "SoundFont: ", kChooseSoundFontCmd, 0, ws);
     432        _soundFontButton = addButton(boss, x, yoffset, "SoundFont:", kChooseSoundFontCmd, 0, ws);
    415433        _soundFont = new StaticTextWidget(boss, x + buttonWidth + 20, yoffset + 3, _w - (x + buttonWidth + 20) - 10, kLineHeight, "None", kTextAlignLeft, ws);
    416434        yoffset += buttonHeight + 2 * spacing;
    417435
     
    427445        _enableGSCheckbox = addCheckbox(boss, x, yoffset, "Enable Roland GS Mode", 0, 0, ws);
    428446        yoffset += _enableGSCheckbox->getHeight() + spacing;
    429447
     448        const char *label = "MIDI gain:";
     449        int textwidth = g_gui.getStringWidth(label);
     450
     451        new StaticTextWidget(boss, x, yoffset + 2, textwidth, kLineHeight, label, kTextAlignLeft, ws);
     452        _midiGainSlider = addSlider(boss, x + textwidth + 15, yoffset, kMIDIGainChanged, ws);
     453        _midiGainLabel = new StaticTextWidget(boss, x + textwidth + 15 + _midiGainSlider->getWidth() + 10, yoffset + 2, 40, kLineHeight, "100%", kTextAlignLeft, ws);
     454
     455        _midiGainSlider->setMinValue(0);
     456        _midiGainSlider->setMaxValue(1000);
     457        _midiGainLabel->setFlags(WIDGET_CLEARBG);
     458
     459        yoffset += _midiGainSlider->getHeight() + 4;
     460
    430461        _enableMIDISettings = true;
    431462
    432463        return yoffset;
  • gui/options.h

    RCS file: /cvsroot/scummvm/scummvm/gui/options.h,v
    retrieving revision 1.34
    diff -u -r1.34 options.h
     
    104104
    105105        SliderWidget *_speechVolumeSlider;
    106106        StaticTextWidget *_speechVolumeLabel;
     107
     108        SliderWidget *_midiGainSlider;
     109        StaticTextWidget *_midiGainLabel;
    107110};
    108111
    109112
  • sound/softsynth/fluidsynth.cpp

    RCS file: /cvsroot/scummvm/scummvm/sound/softsynth/fluidsynth.cpp,v
    retrieving revision 1.7
    diff -u -r1.7 fluidsynth.cpp
     
    114114
    115115        _settings = new_fluid_settings();
    116116
    117         // The default gain setting is ridiculously low, but we can't set it
    118         // too high either or sound will be clipped. This may need tuning...
     117        double gain = (double)ConfMan.getInt("midi_gain") / 100.0;
    119118
    120         setNum("synth.gain", 2.1);
     119        setNum("synth.gain", gain);
    121120        setNum("synth.sample-rate", _outputRate);
    122121
    123122        _synth = new_fluid_synth(_settings);