Ticket #8413: fluidsynth4.diff

File fluidsynth4.diff, 40.3 KB (added by eriktorbjorn, 20 years ago)

Patch against an April 9 CVS snapshot

  • README

    diff -urN ScummVM-cvs20050409/README ScummVM-cvs20050409+hack/README
    old new  
    3131 * 6.1 Autosaves
    32327.0) Music and Sound
    3333 * 7.1 Adlib emulation
    34  * 7.2 MT-32 emulation
    35  * 7.3 MIDI emulation
    36  * 7.4 Native MIDI support
    37  * 7.5 UNIX native & ALSA sequencer support
    38  * 7.6 Using compressed audiofiles (MP3, Ogg Vorbis, Flac)
    39  * 7.7 Output sample rate
     34 * 7.2 FluidSynth MIDI emulation
     35 * 7.3 MT-32 emulation
     36 * 7.4 MIDI emulation
     37 * 7.5 Native MIDI support
     38 * 7.6 UNIX native & ALSA sequencer support
     39 * 7.7 Using compressed audiofiles (MP3, Ogg Vorbis, Flac)
     40 * 7.8 Output sample rate
    40418.0) Configuration Files
    41429.0) Compiling
    4243
     
    369370  --platform=WORD          Specify version of game (allowed values: amiga,
    370371                           atari, fmtowns, mac, pc, windows)
    371372  --savepath=PATH          Path to where savegames are stored
     373  --soundfont=FILE         Select the SoundFont for MIDI playback. (Only
     374                           supported by some MIDI drivers.)
    372375  --multi-midi             Enable combination of Adlib and native MIDI
    373376  --native-mt32            True Roland MT-32 (disable GM emulation)
    374377  --output-rate=RATE       Select output sample rate in Hz (e.g. 22050)
     
    705708manual configuration. If you ARE using MIDI, you have several different
    706709choices of output, depending on your operating system and configuration.
    707710       
    708         null      - Null output. Don't play any music.
     711        null       - Null output. Don't play any music.
    709712
    710         adlib     - Internal Adlib emulation (default)
    711         mt32      - Internal MT-32 emulation
    712         pcjr      - Internal PCjr emulation
    713         pcspk     - Internal PC Speaker emulation
    714         towns     - Internal FM-TOWNS YM2612 emulation
    715 
    716         alsa      - Output using ALSA sequencer device. See below.
    717         amidi     - Use the MorphOS MIDI system, for MorphOS users
    718         core      - CoreAudio sound, for Mac OS X users.
    719         qt        - Quicktime sound, for Macintosh users.
    720         seq       - Use /dev/sequencer for MIDI, *nix users. See below.
    721         windows   - Windows MIDI. Uses built-in sequencer, for Windows users
     713        adlib      - Internal Adlib emulation (default)
     714        fluidsynth - FluidSynth MIDI emulation
     715        mt32       - Internal MT-32 emulation
     716        pcjr       - Internal PCjr emulation
     717        pcspk      - Internal PC Speaker emulation
     718        towns      - Internal FM-TOWNS YM2612 emulation
     719
     720        alsa       - Output using ALSA sequencer device. See below.
     721        amidi      - Use the MorphOS MIDI system, for MorphOS users
     722        core       - CoreAudio sound, for Mac OS X users.
     723        qt         - Quicktime sound, for Macintosh users.
     724        seq        - Use /dev/sequencer for MIDI, *nix users. See below.
     725        windows    - Windows MIDI. Uses built-in sequencer, for Windows users
    722726
    723727To select a sound driver, pass its name via the '-e' option to scummvm,
    724728for example:
     
    732736as sampled waves. This is the default mode for most games, and offers the
    733737best compatibility between machines and games.
    734738
    735 7.2) Playing sound with MT-32 emulation:
     739
     7407.2) Playing sound with FluildSynth MIDI emulation:
     741---- ----------------------------------------------
     742If ScummVM was build with libfluildsynth support it will be able to play MIDI
     743music through the FluidSynth driver. You will have to specify a SoundFont to
     744use, however.
     745
     746NOTE: The processor requirements for FluidSynth can be fairly high in some
     747cases. A fast CPU is recommended.
     748
     749
     7507.3) Playing sound with MT-32 emulation:
    736751---- -----------------------------------
    737752Some games which contain MIDI music data also have improved tracks designed
    738753for the MT-32 sound module. ScummVM can now emulate this device, however you
     
    749764NOTE: The processor requirements for the emulator are quite high; a fast CPU is
    750765strongly recommended.
    751766
    752 7.3) Playing sound with MIDI emulation:
     767
     7687.4) Playing sound with MIDI emulation:
    753769---- ----------------------------------
    754770Some games (such as Sam and Max) only contain MIDI music data.  This once
    755771prevented music for these games from working on platforms that do not support
    756772MIDI, or soundcards that do not provide MIDI drivers (e.g, many soundcards will
    757773not play MIDI under Linux). ScummVM can now emulate MIDI mode using sampled
    758 waves and Adlib or MT-32 emulation using the -eadlib or -emt32 options
    759 respectively.  However, if you are capable of using native MIDI, we recommend
    760 using one of the MIDI modes below for best sound.
     774waves and Adlib, FluidSynth MIDI emulation or MT-32 emulation using the
     775-eadlib, -efluidsynth or -emt32 options respectively.  However, if you are
     776capable of using native MIDI, we recommend using one of the MIDI modes below
     777for best sound.
    761778
    762779
    763 7.4) Playing sound with Native MIDI:
     7807.5) Playing sound with Native MIDI:
    764781---- -------------------------------
    765782Use the appropriate -e<mode> command line option from the list above to
    766783select your preferred MIDI device. For example, if you wish to use the
    767784Windows MIDI driver, use the -ewindows option.
    768785
    769786
    770 7.5.0) Playing sound with Sequencer MIDI:                        [UNIX ONLY]
     7877.6.0) Playing sound with Sequencer MIDI:                        [UNIX ONLY]
    771788------ ----------------------------------
    772789If your soundcard driver supports a sequencer, you may set the environment
    773790variable "SCUMMVM_MIDI" to your sequencer device - e.g., /dev/sequencer
     
    780797sequencer support does not work, you can always fall back on Adlib emulation.
    781798
    782799
    783 7.5.1) Playing sound with ALSA sequencer:                        [UNIX ONLY]
     8007.6.1) Playing sound with ALSA sequencer:                        [UNIX ONLY]
    784801------ ----------------------------------
    785802If you have installed the ALSA driver with the sequencer support, then
    786803set the environment variable SCUMMVM_PORT or the config file parameter
     
    829846Once either TiMidity or FluidSynth are running, use the 'aconnect -o -l'
    830847command as described earlier in this section.
    831848
    832 7.6.0) Using MP3 files for CD audio:
     8497.7.0) Using MP3 files for CD audio:
    833850------ -----------------------------
    834851Use LAME or some other MP3 encoder to rip the cd audio tracks to files. Name
    835852the files track1.mp3 track2.mp3 etc. ScummVM must be compiled with MAD support
     
    840857  lame -t -q 0 -b 96 track1.wav track1.mp3
    841858
    842859
    843 7.6.1) Using Ogg Vorbis files for CD audio:
     8607.7.1) Using Ogg Vorbis files for CD audio:
    844861------ ------------------------------------
    845862Use oggenc or some other vorbis encoder to encode the audio tracks to files.
    846863Name the files track1.ogg track2.ogg etc. ScummVM must be compiled with vorbis
     
    851868  oggenc -q 5 track1.wav
    852869
    853870
    854 7.6.2) Using Flac files for CD audio:
     8717.7.2) Using Flac files for CD audio:
    855872------ ------------------------------------
    856873Use flac or some other flac encoder to encode the audio tracks to files.
    857874Name the files track1.flac track2.flac etc. In your filesystem only allows
     
    866883affect the encoding time and resulting filesize.
    867884
    868885
    869 7.6.3) Compressing MONSTER.SOU with MP3:
     8867.7.3) Compressing MONSTER.SOU with MP3:
    870887------ ---------------------------------
    871888You need LAME, and our compress_scumm_sou util from the scummvm-tools package
    872889to perform this task, and ScummVM must be compiled with MAD support.
     
    877894to your game directory. You can safely remove the monster.sou file.
    878895
    879896
    880 7.6.4) Compressing MONSTER.SOU with Ogg Vorbis:
     8977.7.4) Compressing MONSTER.SOU with Ogg Vorbis:
    881898------ ----------------------------------------
    882899As above, but ScummVM must be compiled with OGG support. Run:
    883900
     
    888905than MP3, so have a good book handy.
    889906
    890907
    891 7.6.5) Compressing MONSTER.SOU with Flac:
     9087.7.5) Compressing MONSTER.SOU with Flac:
    892909------ ----------------------------------------
    893910As above, but ScummVM must be compiled with Flac support. Run:
    894911
     
    902919to read the encoder documentation before you use other values.
    903920
    904921
    905 7.6.6) Compressing sfx/speech in Simon the Sorcerer 1 and 2
     9227.7.6) Compressing sfx/speech in Simon the Sorcerer 1 and 2
    906923------ ----------------------------------------------------
    907924Use our compress_simon util from the scummvm-tools package to perform this
    908925task. You can choose between multiple target formats, but note that you can
     
    929946Eventually you will have a much smaller *.mp3, *.ogg or *.fla file, copy this
    930947file to your game dir. You can safely remove the old file.
    931948
    932 7.6.7) Compressing speech/music in Broken Sword 1
     9497.7.7) Compressing speech/music in Broken Sword 1
    933950------ ------------------------------------------
    934951The compress_sword1 tool from the scummvm-tools package can encode music and
    935952speech to MP3 as well as Ogg Vorbis.
     
    945962Use "compress_sword1 --help" to get a full list of the options.
    946963
    947964
    948 7.6.8) Compressing speech/music in Broken Sword 2
     9657.7.8) Compressing speech/music in Broken Sword 2
    949966------ ------------------------------------------
    950967Use our compress_sword2 util from the scummvm-tools package to perform this
    951968task. You can choose between multiple target formats, but note  that you can
     
    970987nor will it work with the speech files from Broken Sword 1.
    971988
    972989
    973 7.7) Output sample rate:
     9907.8) Output sample rate:
    974991---- -------------------
    975992The output sample rate tells ScummVM how many sound samples to play per channel
    976993per second. There is much that could be said on this subject, but most of it
     
    10871104        music_volume    number   The music volume setting (0-255)
    10881105        multi_midi      bool     If true, enable combination Adlib and native
    10891106                                 MIDI.
     1107        soundfont       string   The SoundFont to use for MIDI playback. (Only
     1108                                 supported by some MIDI drivers.)
    10901109        native_mt32     bool     If true, disable GM emulation and assume that
    10911110                                 there is a true Roland MT-32 available.
    10921111        sfx_volume      number   The sfx volume setting (0-255)
  • backends/fs/fs.h

    diff -urN ScummVM-cvs20050409/backends/fs/fs.h ScummVM-cvs20050409+hack/backends/fs/fs.h
    old new  
    131131        virtual FSList listDir(ListMode mode = kListDirectoriesOnly) const = 0;
    132132
    133133        /**
    134          * Compare the name of this node to the name of another.
     134         * Compare the name of this node to the name of another. Directories
     135         * go before normal files.
    135136         */
    136137        virtual bool operator< (const AbstractFilesystemNode& node) const
    137138        {
     139                if (isDirectory() && !node.isDirectory())
     140                        return true;
     141                if (!isDirectory() && node.isDirectory())
     142                        return false;
    138143                return scumm_stricmp(displayName().c_str(), node.displayName().c_str()) < 0;
    139144        }
    140145
  • base/gameDetector.cpp

    diff -urN ScummVM-cvs20050409/base/gameDetector.cpp ScummVM-cvs20050409+hack/base/gameDetector.cpp
    old new  
    9292        "  --platform=WORD          Specify version of game (allowed values: amiga,\n"
    9393        "                           atari, fmtowns, nes, mac, pc, windows)\n"
    9494        "  --savepath=PATH          Path to where savegames are stored\n"
     95        "  --soundfont=FILE         Select the SoundFont for MIDI playback. (Only\n"
     96        "                           supported by some MIDI drivers.)\n"
    9597        "  --multi-midi             Enable combination Adlib and native MIDI\n"
    9698        "  --native-mt32            True Roland MT-32 (disable GM emulation)\n"
    9799        "  --output-rate=RATE       Select output sample rate in Hz (e.g. 22050)\n"
    98100        "  --aspect-ratio           Enable aspect ratio correction\n"
    99101        "  --render-mode=MODE       Enable additional render modes (cga, ega, hercGreen,\n"
    100     "                           hercAmber, amiga)\n"
     102        "                           hercAmber, amiga)\n"
    101103        "  --force-1x-overlay       Make inner GUI 320x200\n"
    102104        "\n"
    103105#if !defined(DISABLE_SKY) || !defined(DISABLE_QUEEN)
     
    472474                                ConfMan.set("platform", option, kTransientDomain);
    473475                        END_OPTION
    474476
     477                        DO_LONG_OPTION("soundfont")
     478                                ConfMan.set("soundfont", option, kTransientDomain);
     479                        END_OPTION
     480
    475481                        DO_LONG_OPTION_BOOL("multi-midi")
    476482                                ConfMan.set("multi_midi", cmdValue, kTransientDomain);
    477483                        END_OPTION
  • configure

    diff -urN ScummVM-cvs20050409/configure ScummVM-cvs20050409+hack/configure
    old new  
    2020_alsa=auto
    2121_zlib=auto
    2222_mpeg2=auto
     23_fluidsynth=auto
    2324_mt32emu=yes
    2425# default option behaviour yes/no
    2526_build_scumm=yes
     
    294295  --with-mpeg2-prefix=DIR  Prefix where libmpeg2 is installed (optional)
    295296  --disable-mpeg2          disable mpeg2 codec for cutscenes [autodetect]
    296297
     298  --with-fluidsynth-prefix=DIR  Prefix where libfluidsynth is installed (optional)
     299  --disable-fluidsynth     disable fluidsynth MIDI driver [autodetect]
     300
    297301  --with-sdl-prefix=DIR    Prefix where the sdl-config script is installed (optional)
    298302
    299303  --with-nasm-prefix=DIR   Prefix where nasm executable is installed (optional)
     
    338342      --enable-nasm)            _nasm=yes       ;;
    339343      --disable-nasm)           _nasm=no        ;;
    340344      --disable-mpeg2)          _mpeg2=no       ;;
     345      --disable-fluidsynth)     _fluidsynth=no  ;;
    341346      --enable-plugins)         _build_plugins=yes ;;
    342347      --enable-mt32emu)         _mt32emu=yes    ;;
    343348      --disable-mt32emu)        _mt32emu=no     ;;
     349      --with-fluidsynth-prefix=*)
     350        _prefix=`echo $ac_option | cut -d '=' -f 2`
     351        FLUIDSYNTH_CFLAGS="-I$_prefix/include"
     352        FLUIDSYNTH_LIBS="-L$_prefix/lib"
     353        ;;
    344354      --with-mpeg2-prefix=*)
    345355        _prefix=`echo $ac_option | cut -d '=' -f 2`
    346356        MPEG2_CFLAGS="-I$_prefix/include"
     
    9911001rm -f $TMPC $TMPO$EXEEXT
    9921002
    9931003#
     1004# Check for libfluidsynth
     1005#
     1006echocheck "libfluidsynth"
     1007if test "$_fluidsynth" = auto ; then
     1008        _fluidsynth=no
     1009        cat > $TMPC << EOF
     1010#include <fluidsynth.h>
     1011int main(void) { return 0; }
     1012EOF
     1013        cc_check $LDFLAGS $CXXFLAGS $FLUIDSYNTH_CFLAGS $FLUIDSYNTH_LIBS -lfluidsynth && _fluidsynth=yes
     1014fi
     1015if test "$_fluidsynth" = yes ; then
     1016        _def_fluidsynth='#define USE_FLUIDSYNTH'
     1017        LIBS="$LIBS $FLUIDSYNTH_LIBS -lfluidsynth"
     1018        INCLUDE="$INCLUDES $FLUIDSYNTH_CFLAGS"
     1019else
     1020        _def_fluidsynth='#undef USE_FLUIDSYNTH'
     1021fi
     1022echo "$_fluidsynth"
     1023rm -f $TMPC $TMPO$EXEEXT
     1024
     1025#
    9941026# Check for nasm
    9951027#
    9961028if test "$_have_x86" = yes ; then
     
    11261158$_def_alsa
    11271159$_def_zlib
    11281160$_def_mpeg2
     1161$_def_fluidsynth
    11291162$_def_mt32emu
    11301163
    11311164/* Whether we should use i386 assembly routines */
  • doc/05_01.tex

    diff -urN ScummVM-cvs20050409/doc/05_01.tex ScummVM-cvs20050409+hack/doc/05_01.tex
    old new  
    3636                          &atari, fmtowns, mac, pc, windows)\\
    3737  --savepath=PATH         &Path to where savegames are stored\\
    3838  --multi-midi            &Enable combination of Adlib and native MIDI\\
     39  --soundfont             &Select the SoundFont for MIDI playback. (Only\\
     40                          &supported by some MIDI drivers.)\\
    3941  --native-mt32           &True Roland MT-32 (disable GM emulation)\\
    4042  --output-rate=RATE      &Select output sample rate in Hz (e.g. 22050)\\
    4143  --aspect-ratio          &Enable aspect ratio correction\\
  • doc/07.tex

    diff -urN ScummVM-cvs20050409/doc/07.tex ScummVM-cvs20050409+hack/doc/07.tex
    old new  
    1111choices of output, depending on your operating system and configuration.
    1212
    1313\begin{tabular}[h]{ll}
    14   adlib     & Uses internal Adlib Emulation (default)\\
    15   mt32      & Uses internal MT-32 Emulation\\
    16   pcjr      & Uses internal PCjr Emulation \\
    17   pcspk     & Uses internal PC Speaker Emulation\\
    18   towns     & Uses FM-TOWNS YM2612 Emulation\\
    19   windows   & Windows MIDI. Uses built-in sequencer, for Windows users\\
    20   seq       & Uses /dev/sequencer for MIDI, *nix users. See below.\\
    21   qt        & Quicktime sound, for Macintosh users.\\
    22   core      & CoreAudio sound, for MacOS X users.\\
    23   amidi     & Uses the MorphOS MIDI system, for MorphOS users\\
    24   alsa      & Output using ALSA sequencer device. See below.\\
    25   null      & Null output. Don't play any music.\\
     14  adlib      & Uses internal Adlib Emulation (default)\\
     15  fluidsynth & Uses FluidSynth MIDI Emulation\\
     16  mt32       & Uses internal MT-32 Emulation\\
     17  pcjr       & Uses internal PCjr Emulation \\
     18  pcspk      & Uses internal PC Speaker Emulation\\
     19  towns      & Uses FM-TOWNS YM2612 Emulation\\
     20  windows    & Windows MIDI. Uses built-in sequencer, for Windows users\\
     21  seq        & Uses /dev/sequencer for MIDI, *nix users. See below.\\
     22  qt         & Quicktime sound, for Macintosh users.\\
     23  core       & CoreAudio sound, for MacOS X users.\\
     24  amidi      & Uses the MorphOS MIDI system, for MorphOS users\\
     25  alsa       & Output using ALSA sequencer device. See below.\\
     26  null       & Null output. Don't play any music.\\
    2627\end{tabular}
    2728
    2829To select a sound driver, pass its name via the '-e' option to scummvm,
     
    3233\end{verbatim}
    3334
    3435\input {07_01.tex}
     36\input {07_02b.tex}
    3537\input {07_02a.tex}
    3638\input {07_02.tex}
    3739\input {07_03.tex}
  • doc/07_02b.tex

    diff -urN ScummVM-cvs20050409/doc/07_02b.tex ScummVM-cvs20050409+hack/doc/07_02b.tex
    old new  
     1
     2%%% Local Variables:
     3%%% mode: latex
     4%%% TeX-master: "readme"
     5%%% End:
     6
     7\subsection{Playing sound with FluidSynth MIDI emulation}
     8
     9If ScummVM was build with libfluildsynth support it will be able to play MIDI
     10music through the FluidSynth driver. You will have to specify a SoundFont to
     11use, however.
     12
     13\textbf{NOTE:} The processor requirements for FluidSynth can be fairly high in
     14some cases. A fast CPU is recommended.
  • doc/08.tex

    diff -urN ScummVM-cvs20050409/doc/08.tex ScummVM-cvs20050409+hack/doc/08.tex
    old new  
    9898        music\_volume   &number   The music volume setting (0-255)\\
    9999        multi\_midi     &bool     If true, enable combination Adlib and native\\
    100100                        &         MIDI.\\
     101        soundfont       &string   The SoundFont to use for MIDI playback. (Only\\
     102                        &         supported by some MIDI drivers.)\\
    101103        native\_mt32    &bool     If true, disable GM emulation and assume that\\
    102104                        &         there is a true Roland MT-32 available.\\
    103105        sfx\_volume     &number   The sfx volume setting (0-255)\\
  • gui/browser.cpp

    diff -urN ScummVM-cvs20050409/gui/browser.cpp ScummVM-cvs20050409+hack/gui/browser.cpp
    old new  
    3434 * other operating systems.
    3535 */
    3636
    37 BrowserDialog::BrowserDialog(const char *title)
     37DirBrowserDialog::DirBrowserDialog(const char *title)
    3838        : Dialog(20, 10, 320 -2 * 20, 200 - 2 * 10) {
    3939        _titleRef = CFStringCreateWithCString(0, title, CFStringGetSystemEncoding());
    4040}
    4141
    42 BrowserDialog::~BrowserDialog() {
     42DirBrowserDialog::~DirBrowserDialog() {
    4343        CFRelease(_titleRef);
    4444}
    4545
    46 int BrowserDialog::runModal() {
     46int DirBrowserDialog::runModal() {
    4747        NavDialogRef dialogRef;
    4848        WindowRef windowRef = 0;
    4949        NavDialogCreationOptions options;
     
    125125        kGoUpCmd = 'GoUp'
    126126};
    127127
    128 BrowserDialog::BrowserDialog(const char *title)
     128DirBrowserDialog::DirBrowserDialog(const char *title)
    129129        : Dialog(20, 10, 320 -2 * 20, 200 - 2 * 10)
    130130        {
    131131
     
    150150        addButton(_w - (kButtonWidth+10), _h - 24, "Choose", kChooseCmd, 0);
    151151}
    152152
    153 void BrowserDialog::open() {
     153void DirBrowserDialog::open() {
    154154        // If no node has been set, or the last used one is now invalid,
    155155        // go back to the root/default dir.
    156156        if (!_node.isValid()) {
     
    164164        Dialog::open();
    165165}
    166166
    167 void BrowserDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 data) {
     167void DirBrowserDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 data) {
    168168        switch (cmd) {
    169169        case kChooseCmd: {
    170170                        // If nothing is selected in the list widget, choose the current dir.
     
    193193        }
    194194}
    195195
    196 void BrowserDialog::updateListing() {
     196void DirBrowserDialog::updateListing() {
    197197        // Update the path display
    198198        _currentPath->setLabel(_node.path());
    199199
     
    216216
    217217#endif  // MACOSX
    218218
     219FileBrowserDialog::FileBrowserDialog(const char *title)
     220        : Dialog(20, 10, 320 -2 * 20, 200 - 2 * 10)
     221        {
     222
     223        _fileList = NULL;
     224        _currentPath = NULL;
     225
     226        // Headline - TODO: should be customizable during creation time
     227        new StaticTextWidget(this, 10, 8, _w - 2 * 10, kLineHeight, title, kTextAlignCenter);
     228
     229        // Current path - TODO: handle long paths ?
     230        _currentPath = new StaticTextWidget(this, 10, 20, _w - 2 * 10, kLineHeight,
     231                                                                "DUMMY", kTextAlignLeft);
     232
     233        // Add file list
     234        _fileList = new ListWidget(this, 10, 34, _w - 2 * 10, _h - 34 - 24 - 10);
     235        _fileList->setNumberingMode(kListNumberingOff);
     236        _fileList->setEditable(false);
     237
     238        // Buttons
     239        addButton(10, _h - 24, "Go up", kGoUpCmd, 0);
     240        addButton(_w - 2 * (kButtonWidth + 10), _h - 24, "Cancel", kCloseCmd, 0);
     241        addButton(_w - (kButtonWidth+10), _h - 24, "Choose", kChooseCmd, 0);
     242}
     243
     244void FileBrowserDialog::open() {
     245        // If no node has been set, or the last used one is now invalid,
     246        // go back to the root/default dir.
     247        if (!_node.isValid()) {
     248                _node = FilesystemNode();
     249        }
     250
     251        // Alway refresh file list
     252        updateListing();
     253       
     254        // Call super implementation
     255        Dialog::open();
     256}
     257
     258void FileBrowserDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 data) {
     259        switch (cmd) {
     260        case kChooseCmd: {
     261                        int selection = _fileList->getSelected();
     262                        if (selection < 0)
     263                                break;
     264                        if (_nodeContent[selection].isDirectory()) {
     265                                _node = _nodeContent[selection];
     266                                updateListing();
     267                        } else {
     268                                _choice = _nodeContent[selection];
     269                                setResult(1);
     270                                close();
     271                        }
     272                }
     273                break;
     274        case kGoUpCmd:
     275                _node = _node.getParent();
     276                updateListing();
     277                break;
     278        case kListItemActivatedCmd:
     279        case kListItemDoubleClickedCmd:
     280                if (_nodeContent[data].isDirectory()) {
     281                        _node = _nodeContent[data];
     282                        updateListing();
     283                } else {
     284                        _choice = _nodeContent[data];
     285                        setResult(1);
     286                        close();
     287                }
     288                break;
     289        default:
     290                Dialog::handleCommand(sender, cmd, data);
     291        }
     292}
     293
     294void FileBrowserDialog::updateListing() {
     295        // Update the path display
     296        _currentPath->setLabel(_node.path());
     297
     298        // Read in the data from the file system
     299        _nodeContent = _node.listDir(AbstractFilesystemNode::kListAll);
     300        _nodeContent.sort();
     301
     302        // Populate the ListWidget
     303        Common::StringList list;
     304        int size = _nodeContent.size();
     305        int i;
     306
     307        for (i = 0; i < size; i++) {
     308                if (_nodeContent[i].isDirectory())
     309                        list.push_back(_nodeContent[i].displayName() + "/");
     310                else
     311                        list.push_back(_nodeContent[i].displayName());
     312        }
     313
     314        _fileList->setList(list);
     315        _fileList->scrollTo(0);
     316
     317        // Finally, redraw
     318        draw();
     319}
     320
    219321} // End of namespace GUI
  • gui/browser.h

    diff -urN ScummVM-cvs20050409/gui/browser.h ScummVM-cvs20050409+hack/gui/browser.h
    old new  
    3434class ListWidget;
    3535class StaticTextWidget;
    3636
    37 class BrowserDialog : public Dialog {
     37// TODO: Common parent class for DirBrowserDialog and FileBrowserDialog
     38
     39class DirBrowserDialog : public Dialog {
    3840        typedef Common::String String;
    3941        typedef Common::StringList StringList;
    4042public:
    41         BrowserDialog(const char *title);
     43        DirBrowserDialog(const char *title);
    4244
    4345#ifdef MACOSX
    44         ~BrowserDialog();
     46        ~DirBrowserDialog();
    4547        virtual int runModal();
    4648#else
    4749        virtual void open();
     
    5052
    5153        const FilesystemNode    &getResult() { return _choice; }
    5254
    53 
    5455protected:
    5556#ifdef MACOSX
    5657        CFStringRef             _titleRef;
    5758#else
    5859        ListWidget              *_fileList;
    59         StaticTextWidget*_currentPath;
     60        StaticTextWidget        *_currentPath;
    6061        FilesystemNode  _node;
    6162        FSList                  _nodeContent;
    6263#endif
     
    6768#endif
    6869};
    6970
     71// TODO: MACOSX version
     72
     73class FileBrowserDialog : public Dialog {
     74        typedef Common::String String;
     75        typedef Common::StringList StringList;
     76public:
     77        FileBrowserDialog(const char *title);
     78
     79        virtual void open();
     80        virtual void handleCommand(CommandSender *sender, uint32 cmd, uint32 data);
     81
     82        const FilesystemNode &getResult() { return _choice; }
     83
     84protected:
     85        ListWidget *_fileList;
     86        StaticTextWidget *_currentPath;
     87        FilesystemNode _node;
     88        FSList _nodeContent;
     89        FilesystemNode _choice;
     90
     91        void updateListing();
     92};
     93
    7094} // End of namespace GUI
    7195
    7296#endif
  • gui/launcher.cpp

    diff -urN ScummVM-cvs20050409/gui/launcher.cpp ScummVM-cvs20050409+hack/gui/launcher.cpp
    old new  
    349349
    350350        // Change path for the game
    351351        case kCmdGameBrowser: {
    352                 BrowserDialog *_browser = new BrowserDialog("Select additional game directory");
     352                DirBrowserDialog *_browser = new DirBrowserDialog("Select additional game directory");
    353353                if (_browser->runModal() > 0) {
    354354                        // User made his choice...
    355355                        FilesystemNode dir(_browser->getResult());
     
    366366
    367367        // Change path for extra game data (eg, using sword cutscenes when playing via CD)
    368368        case kCmdExtraBrowser: {
    369                 BrowserDialog *_browser = new BrowserDialog("Select additional game directory");
     369                DirBrowserDialog *_browser = new DirBrowserDialog("Select additional game directory");
    370370                if (_browser->runModal() > 0) {
    371371                        // User made his choice...
    372372                        FilesystemNode dir(_browser->getResult());
     
    377377        }
    378378        // Change path for stored save game (perm and temp) data
    379379        case kCmdSaveBrowser: {
    380                 BrowserDialog *_browser = new BrowserDialog("Select directory for saved games");
     380                DirBrowserDialog *_browser = new DirBrowserDialog("Select directory for saved games");
    381381                if (_browser->runModal() > 0) {
    382382                        // User made his choice...
    383383                        FilesystemNode dir(_browser->getResult());
     
    449449        updateButtons();
    450450
    451451        // Create file browser dialog
    452         _browser = new BrowserDialog("Select directory with game data");
     452        _browser = new DirBrowserDialog("Select directory with game data");
    453453}
    454454
    455455void LauncherDialog::selectGame(const String &name) {
  • gui/launcher.h

    diff -urN ScummVM-cvs20050409/gui/launcher.h ScummVM-cvs20050409+hack/gui/launcher.h
    old new  
    2828
    2929namespace GUI {
    3030
    31 class BrowserDialog;
     31class DirBrowserDialog;
    3232class ListWidget;
    3333
    3434class LauncherDialog : public Dialog {
     
    4747        Widget                  *_removeButton;
    4848        StringList              _domains;
    4949        GameDetector    &_detector;
    50         BrowserDialog   *_browser;
     50        DirBrowserDialog        *_browser;
    5151
    5252        void updateListing();
    5353        void updateButtons();
  • gui/options.cpp

    diff -urN ScummVM-cvs20050409/gui/options.cpp ScummVM-cvs20050409+hack/gui/options.cpp
    old new  
    5050namespace GUI {
    5151
    5252// TODO - allow changing options for:
    53 // - the save path (use _browser!)
     53// - the save path (use _dirBrowser!)
    5454// - music & graphics driver (but see also the comments on EditGameDialog
    5555//   for some techincal difficulties with this)
    5656// - default volumes (sfx/speech/music)
     
    6060        kMusicVolumeChanged             = 'muvc',
    6161        kSfxVolumeChanged               = 'sfvc',
    6262        kSpeechVolumeChanged    = 'vcvc',
     63        kChooseSoundFontCmd             = 'chsf',
    6364        kChooseSaveDirCmd               = 'chos',
    6465        kChooseExtraDirCmd              = 'chex'
    6566};
     
    343344                _midiPopUp->appendEntry(md->description, md->id);
    344345                md++;
    345346        }
     347
     348        // SoundFont
     349        new ButtonWidget(boss, x, yoffset, kButtonWidth + 14, 16, "SoundFont: ", kChooseSoundFontCmd, 0);
     350        _soundFont = new StaticTextWidget(boss, x + kButtonWidth + 20, yoffset + 3, _w - (x + kButtonWidth + 20) - 10, kLineHeight, "None", kTextAlignLeft);
     351
     352        yoffset += 18;
    346353       
    347354        // Multi midi setting
    348355        _multiMidiCheckbox = new CheckboxWidget(boss, x, yoffset, w, 16, "Mixed Adlib/MIDI mode");
    349         yoffset += 16;
     356        yoffset += 15;
    350357       
    351358        // Native mt32 setting
    352359        _mt32Checkbox = new CheckboxWidget(boss, x, yoffset, w, 16, "True Roland MT-32 (disable GM emulation)");
    353         yoffset += 16;
     360        yoffset += 15;
    354361
    355362        // Subtitles on/off
    356363        _subCheckbox = new CheckboxWidget(boss, x, yoffset, w, 16, "Display subtitles");
    357         yoffset += 16;
     364        yoffset += 15;
    358365       
    359366        _enableAudioSettings = true;
    360367
     
    448455        addButton(_w - 2 * (kButtonWidth + 10), _h - 24, "Cancel", kCloseCmd, 0);
    449456        addButton(_w - (kButtonWidth + 10), _h - 24, "OK", kOKCmd, 0);
    450457
    451         // Create file browser dialog
    452         _browser = new BrowserDialog("Select directory for savegames");
     458        // Create file browser dialogs
     459        _dirBrowser = new DirBrowserDialog("Select directory for savegames");
     460        _fileBrowser = new FileBrowserDialog("Select SoundFont");
    453461
    454462#ifdef _WIN32_WCE
    455463        _keysDialog = new CEKeysDialog();
     
    457465}
    458466
    459467GlobalOptionsDialog::~GlobalOptionsDialog() {
    460         delete _browser;
     468        delete _dirBrowser;
     469        delete _fileBrowser;
    461470
    462471#ifdef _WIN32_WCE
    463472        delete _keysDialog;
     
    471480        // Set _savePath to the current save path
    472481        Common::String dir(ConfMan.get("savepath", _domain));
    473482        Common::String extraPath(ConfMan.get("extrapath", _domain));
     483        Common::String soundFont(ConfMan.get("soundfont", _domain));
    474484
    475485        if (!dir.isEmpty()) {
    476486                _savePath->setLabel(dir);
     
    486496        } else {
    487497                _extraPath->setLabel(extraPath);
    488498        }
     499
     500        if (soundFont.isEmpty() || !ConfMan.hasKey("soundfont", _domain)) {
     501                _soundFont->setLabel("None");
     502        } else {
     503                _soundFont->setLabel(soundFont);
     504        }
    489505#endif
    490506}
    491507
     
    497513                String extraPath = _extraPath->getLabel();
    498514                if (!extraPath.isEmpty() && (extraPath != "None"))
    499515                        ConfMan.set("extrapath", extraPath, _domain);
     516
     517                String soundFont = _soundFont->getLabel();
     518                if (!soundFont.isEmpty() && (soundFont != "None"))
     519                        ConfMan.set("soundfont", soundFont, _domain);
    500520        }
    501521        OptionsDialog::close();
    502522}
     
    504524void GlobalOptionsDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 data) {
    505525        switch (cmd) {
    506526        case kChooseSaveDirCmd:
    507                 if (_browser->runModal() > 0) {
     527                if (_dirBrowser->runModal() > 0) {
    508528                        // User made his choice...
    509                         FilesystemNode dir(_browser->getResult());
     529                        FilesystemNode dir(_dirBrowser->getResult());
    510530                        _savePath->setLabel(dir.path());
    511531                        // TODO - we should check if the directory is writeable before accepting it
    512532                }
    513533                break;
    514534        case kChooseExtraDirCmd:
    515                 if (_browser->runModal() > 0) {
     535                if (_dirBrowser->runModal() > 0) {
    516536                        // User made his choice...
    517                         FilesystemNode dir(_browser->getResult());
     537                        FilesystemNode dir(_dirBrowser->getResult());
    518538                        _extraPath->setLabel(dir.path());
    519539                }
    520540                break;
     541        case kChooseSoundFontCmd:
     542                if (_fileBrowser->runModal() > 0) {
     543                        // User made his choice...
     544                        FilesystemNode file(_fileBrowser->getResult());
     545                        _soundFont->setLabel(file.path());
     546                }
     547                break;
    521548#ifdef _WIN32_WCE
    522549        case kChooseKeyMappingCmd:
    523550                _keysDialog->runModal();
  • gui/options.h

    diff -urN ScummVM-cvs20050409/gui/options.h ScummVM-cvs20050409+hack/gui/options.h
    old new  
    3232
    3333namespace GUI {
    3434
    35 class BrowserDialog;
     35class DirBrowserDialog;
     36class FileBrowserDialog;
    3637class CheckboxWidget;
    3738class PopUpWidget;
    3839class SliderWidget;
     
    5556        /** Config domain this dialog is used to edit. */
    5657        String _domain;
    5758       
     59        StaticTextWidget *_soundFont;
     60
    5861        int addGraphicControls(GuiObject *boss, int yoffset);
    5962        int addMIDIControls(GuiObject *boss, int yoffset);
    6063        int addVolumeControls(GuiObject *boss, int yoffset);
     
    109112        void handleCommand(CommandSender *sender, uint32 cmd, uint32 data);
    110113
    111114protected:
    112         BrowserDialog *_browser;
     115        DirBrowserDialog *_dirBrowser;
     116        FileBrowserDialog *_fileBrowser;
    113117#ifdef _WIN32_WCE
    114118        CEKeysDialog *_keysDialog;
    115119#endif
  • sound/mididrv.cpp

    diff -urN ScummVM-cvs20050409/sound/mididrv.cpp ScummVM-cvs20050409+hack/sound/mididrv.cpp
    old new  
    5858        {"towns", "FM Towns", MD_TOWNS},
    5959        {"pcspk", "PC Speaker", MD_PCSPK},
    6060        {"pcjr", "IBM PCjr", MD_PCJR},
     61#ifdef USE_FLUIDSYNTH
     62        {"fluidsynth", "FluidSynth", MD_FLUIDSYNTH},
     63#endif
    6164#ifdef USE_MT32EMU
    6265        {"mt32", "MT-32", MD_MT32},
    6366#endif
     
    172175        // driver.
    173176        case MD_ADLIB:     return NULL;
    174177
     178#ifdef USE_FLUIDSYNTH
     179        case MD_FLUIDSYNTH:     return MidiDriver_FluidSynth_create(g_engine->_mixer);
     180#endif
    175181#ifdef USE_MT32EMU
    176182        case MD_MT32:      return MidiDriver_MT32_create(g_engine->_mixer);
    177183#endif
  • sound/mididrv.h

    diff -urN ScummVM-cvs20050409/sound/mididrv.h ScummVM-cvs20050409+hack/sound/mididrv.h
    old new  
    4848        MD_TOWNS = 13,
    4949        MD_YPA1 = 14, // PalmOS
    5050        MD_ZODIAC = 15, // PalmOS
    51         MD_MT32 = 16
     51        MD_MT32 = 16,
     52        MD_FLUIDSYNTH = 17
    5253};
    5354
    5455enum MidiDriverType {
     
    195196extern MidiDriver *MidiDriver_ETUDE_create();
    196197extern MidiDriver *MidiDriver_ALSA_create();
    197198extern MidiDriver *MidiDriver_YM2612_create(SoundMixer *mixer);
     199#ifdef USE_FLUIDSYNTH
     200extern MidiDriver *MidiDriver_FluidSynth_create(SoundMixer *mixer);
     201#endif
    198202#ifdef USE_MT32EMU
    199203extern MidiDriver *MidiDriver_MT32_create(SoundMixer *mixer);
    200204#endif
  • sound/module.mk

    diff -urN ScummVM-cvs20050409/sound/module.mk ScummVM-cvs20050409+hack/sound/module.mk
    old new  
    1818        sound/wave.o \
    1919        sound/softsynth/adlib.o \
    2020        sound/softsynth/ym2612.o \
     21        sound/softsynth/fluidsynth.o \
    2122        sound/softsynth/mt32.o \
    2223
    2324MODULE_DIRS += \
  • sound/softsynth/fluidsynth.cpp

    diff -urN ScummVM-cvs20050409/sound/softsynth/fluidsynth.cpp ScummVM-cvs20050409+hack/sound/softsynth/fluidsynth.cpp
    old new  
     1/* ScummVM - Scumm Interpreter
     2 * Copyright (C) 2001-2005 The ScummVM project
     3 *
     4 * This program is free software; you can redistribute it and/or
     5 * modify it under the terms of the GNU General Public License
     6 * as published by the Free Software Foundation; either version 2
     7 * of the License, or (at your option) any later version.
     8 *
     9 * This program is distributed in the hope that it will be useful,
     10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
     11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     12 * GNU General Public License for more details.
     13 *
     14 * You should have received a copy of the GNU General Public License
     15 * along with this program; if not, write to the Free Software
     16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
     17 *
     18 * $Header$
     19 */
     20
     21#if defined(HAVE_CONFIG_H)
     22#include "config.h"
     23#endif
     24
     25#ifdef USE_FLUIDSYNTH
     26
     27#include "stdafx.h"
     28#include "common/config-manager.h"
     29#include "sound/mpu401.h"
     30#include "sound/softsynth/emumidi.h"
     31
     32#include <fluidsynth.h>
     33
     34class MidiDriver_FluidSynth : public MidiDriver_Emulated {
     35private:
     36        MidiChannel_MPU401 _midiChannels[16];
     37        fluid_settings_t *_settings;
     38        fluid_synth_t *_synth;
     39        int _soundFont;
     40        int _outputRate;
     41        SoundHandle _handle;
     42
     43protected:
     44        // Because GCC complains about casting from const to non-const...
     45        void setInt(const char *name, int val);
     46        void setNum(const char *name, double num);
     47        void setStr(const char *name, const char *str);
     48
     49        void generateSamples(int16 *buf, int len);
     50
     51public:
     52        MidiDriver_FluidSynth(SoundMixer *mixer);
     53
     54        int open();
     55        void close();
     56        void send(uint32 b);
     57
     58        MidiChannel *allocateChannel();
     59        MidiChannel *getPercussionChannel();
     60
     61        // AudioStream API
     62        bool isStereo() const { return true; }
     63        int getRate() const { return _outputRate; }
     64};
     65
     66// MidiDriver method implementations
     67
     68MidiDriver_FluidSynth::MidiDriver_FluidSynth(SoundMixer *mixer)
     69        : MidiDriver_Emulated(mixer) {
     70
     71        for (int i = 0; i < ARRAYSIZE(_midiChannels); i++) {
     72                _midiChannels[i].init(this, i);
     73        }
     74
     75        // It ought to be possible to get FluidSynth to generate samples at
     76        // lower
     77
     78        _outputRate = _mixer->getOutputRate();
     79        if (_outputRate < 22050)
     80                _outputRate = 22050;
     81        else if (_outputRate > 96000)
     82                _outputRate = 96000;
     83}
     84
     85void MidiDriver_FluidSynth::setInt(const char *name, int val) {
     86        char *name2 = strdup(name);
     87
     88        fluid_settings_setint(_settings, name2, val);
     89        free(name2);
     90}
     91
     92void MidiDriver_FluidSynth::setNum(const char *name, double val) {
     93        char *name2 = strdup(name);
     94
     95        fluid_settings_setnum(_settings, name2, val);
     96        free(name2);
     97}
     98
     99void MidiDriver_FluidSynth::setStr(const char *name, const char *val) {
     100        char *name2 = strdup(name);
     101        char *val2 = strdup(val);
     102
     103        fluid_settings_setstr(_settings, name2, val2);
     104        free(name2);
     105        free(val2);
     106}
     107
     108int MidiDriver_FluidSynth::open() {
     109        if (_isOpen)
     110                return MERR_ALREADY_OPEN;
     111
     112        if (!ConfMan.hasKey("soundfont"))
     113                error("FluidSynth recquires a 'soundfont' setting");
     114
     115        _settings = new_fluid_settings();
     116
     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...
     119
     120        setNum("synth.gain", 2.1);
     121        setNum("synth.sample-rate", _outputRate);
     122
     123        _synth = new_fluid_synth(_settings);
     124
     125        // In theory, this ought to reduce CPU load... but it doesn't make any
     126        // noticeable difference for me, so disable it for now.
     127
     128        // fluid_synth_set_interp_method(_synth, -1, FLUID_INTERP_LINEAR);
     129        // fluid_synth_set_reverb_on(_synth, 0);
     130        // fluid_synth_set_chorus_on(_synth, 0);
     131
     132        const char *soundfont = ConfMan.get("soundfont").c_str();
     133
     134        _soundFont = fluid_synth_sfload(_synth, soundfont, 1);
     135        if (_soundFont == -1)
     136                error("Failed loading custom sound font '%s'", soundfont);
     137
     138        MidiDriver_Emulated::open();
     139
     140        // The MT-32 emulator uses kSFXSoundType here. I don't know why.
     141        _mixer->playInputStream(SoundMixer::kMusicSoundType, &_handle, this, -1, 255, 0, false, true);
     142        return 0;
     143}
     144
     145void MidiDriver_FluidSynth::close() {
     146        if (!_isOpen)
     147                return;
     148        _isOpen = false;
     149
     150        _mixer->stopHandle(_handle);
     151
     152        if (_soundFont != -1)
     153                fluid_synth_sfunload(_synth, _soundFont, 1);
     154
     155        delete_fluid_synth(_synth);
     156        delete_fluid_settings(_settings);
     157}
     158
     159void MidiDriver_FluidSynth::send(uint32 b) {
     160        //byte param3 = (byte) ((b >> 24) & 0xFF);
     161        uint param2 = (byte) ((b >> 16) & 0xFF);
     162        uint param1 = (byte) ((b >>  8) & 0xFF);
     163        byte cmd    = (byte) (b & 0xF0);
     164        byte chan   = (byte) (b & 0x0F);
     165
     166        switch (cmd) {
     167        case 0x80:      // Note Off
     168                fluid_synth_noteoff(_synth, chan, param1);
     169                break;
     170        case 0x90:      // Note On
     171                fluid_synth_noteon(_synth, chan, param1, param2);
     172                break;
     173        case 0xA0:      // Aftertouch
     174                break;
     175        case 0xB0:      // Control Change
     176                fluid_synth_cc(_synth, chan, param1, param2);
     177                break;
     178        case 0xC0:      // Program Change
     179                fluid_synth_program_change(_synth, chan, param1);
     180                break;
     181        case 0xD0:      // Channel Pressure
     182                break;
     183        case 0xE0:      // Pitch Bend
     184                fluid_synth_pitch_bend(_synth, chan, (param2 << 7) | param1);
     185                break;
     186        case 0xF0:      // SysEx
     187                // We should never get here! SysEx information has to be
     188                // sent via high-level semantic methods.
     189                warning("MidiDriver_FluidSynth: Receiving SysEx command on a send() call");
     190                break;
     191        default:
     192                warning("MidiDriver_FluidSynth: Unknown send() command 0x%02X", cmd);
     193                break;
     194        }
     195}
     196
     197MidiChannel *MidiDriver_FluidSynth::allocateChannel() {
     198        for (int i = 0; i < ARRAYSIZE(_midiChannels); i++) {
     199                if (i != 9 && _midiChannels[i].allocate())
     200                        return &_midiChannels[i];
     201        }
     202        return NULL;
     203}
     204
     205MidiChannel *MidiDriver_FluidSynth::getPercussionChannel() {
     206        return &_midiChannels[9];
     207}
     208
     209MidiDriver *MidiDriver_FluidSynth_create(SoundMixer *mixer) {
     210        return new MidiDriver_FluidSynth(mixer);
     211}
     212
     213void MidiDriver_FluidSynth::generateSamples(int16 *data, int len) {
     214        fluid_synth_write_s16(_synth, len, data, 0, 2, data, 1, 2);
     215}
     216
     217#endif