diff options
Diffstat (limited to 'attic/muse2-oom/muse2/synti/fluid')
| -rw-r--r-- | attic/muse2-oom/muse2/synti/fluid/CMakeLists.txt | 95 | ||||
| -rw-r--r-- | attic/muse2-oom/muse2/synti/fluid/fluid.cpp | 594 | ||||
| -rw-r--r-- | attic/muse2-oom/muse2/synti/fluid/fluid.h | 84 | ||||
| -rw-r--r-- | attic/muse2-oom/muse2/synti/fluid/fluidgui.cpp | 81 | ||||
| -rw-r--r-- | attic/muse2-oom/muse2/synti/fluid/fluidgui.h | 33 | ||||
| -rw-r--r-- | attic/muse2-oom/muse2/synti/fluid/fluidguibase.ui | 112 | 
6 files changed, 999 insertions, 0 deletions
diff --git a/attic/muse2-oom/muse2/synti/fluid/CMakeLists.txt b/attic/muse2-oom/muse2/synti/fluid/CMakeLists.txt new file mode 100644 index 00000000..1367436a --- /dev/null +++ b/attic/muse2-oom/muse2/synti/fluid/CMakeLists.txt @@ -0,0 +1,95 @@ +#============================================================================= +#  MusE +#  Linux Music Editor +#  $Id:$ +# +#  Copyright (C) 2002-2006 by Werner Schweer and others +# +#  This program is free software; you can redistribute it and/or modify +#  it under the terms of the GNU General Public License version 2. +# +#  This program is distributed in the hope that it will be useful, +#  but WITHOUT ANY WARRANTY; without even the implied warranty of +#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the +#  GNU General Public License for more details. +# +#  You should have received a copy of the GNU General Public License +#  along with this program; if not, write to the Free Software +#  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +#============================================================================= + +## +## Expand Qt macros in source files +## +QT4_WRAP_CPP ( fluid_mocs +      fluidgui.h +      ) + +## +## UI files +## +file (GLOB fluid_ui_files +      fluidguibase.ui +      ) +QT4_WRAP_UI ( fluid_uis ${fluid_ui_files} ) + +## +## List of source files to compile +## +file (GLOB fluid_source_files +      fluid.cpp  +      fluidgui.cpp +      ) + +## +## Define target +## +add_library ( fluid SHARED  +      ${fluid_source_files} +      ${fluid_mocs} +      ${fluid_uis} +      ) + +## +## Append to the list of translations +## +set (FILES_TO_TRANSLATE +      ${FILES_TO_TRANSLATE} +      ${fluid_source_files} +      ${fluid_ui_files} +      CACHE INTERNAL "" +      ) + +## +## Compilation flags and target name +## +# - tell cmake to name target fluid.so instead of  +#   libfluid.so +# - use precompiled header files +# +set_target_properties ( fluid +      PROPERTIES PREFIX "" +      COMPILE_FLAGS "-fvisibility=hidden -include ${PROJECT_BINARY_DIR}/all-pic.h" +      LINK_FLAGS "${FLUIDSYN_LDFLAGS}"   # "-lfluidsynth" +      ) + +## +## Linkage +## +target_link_libraries(fluid +      synti +      ${QT_LIBRARIES} +      # Can't do this. FLUIDSYN_LIBRARIES = fluidsynth, which is the name  +      # of our fluidsynth.so shared synthesizer library. +      # This caused ../fluidsynth/fluidsynth.so to appear in the link line. +      # ${FLUIDSYN_LIBRARIES} +      # Try giving full path: Nope, path is empty! +      # ${FLUIDSYN_LIBRARY_DIRS}/${FLUIDSYN_LIBRARIES} +      ) + +## +## Install location +## +install( TARGETS fluid  +      DESTINATION ${MusE_SYNTHI_DIR} +      ) diff --git a/attic/muse2-oom/muse2/synti/fluid/fluid.cpp b/attic/muse2-oom/muse2/synti/fluid/fluid.cpp new file mode 100644 index 00000000..d1802354 --- /dev/null +++ b/attic/muse2-oom/muse2/synti/fluid/fluid.cpp @@ -0,0 +1,594 @@ +//========================================================= +//  MusE +//  Linux Music Editor +//  $Id: fluid.cpp,v 1.18.2.8 2009/12/06 10:05:00 terminator356 Exp $ +// +//  This file is derived from fluid Synth and modified +//    for MusE. +//  Parts of fluid are derived from Smurf Sound Font Editor. +//  Parts of Smurf Sound Font Editor are derived from +//    awesfx utilities +//  Smurf:  Copyright (C) 1999-2000 Josh Green +//  fluid:  Copyright (C) 2001 Peter Hanappe +//  MusE:   Copyright (C) 2001 Werner Schweer +//  awesfx: Copyright (C) 1996-1999 Takashi Iwai +//========================================================= + +#include <stdlib.h> +#include <stdio.h> +#include <string.h> +#include <unistd.h> +#include <stdarg.h> +#include <errno.h> +#include <pthread.h> +#include <cmath> +#include <sys/mman.h> +#include <sys/time.h> +#include <sched.h> + +#include "muse/midictrl.h" + +#include "muse/midi.h" +#include "fluid.h" +#include "fluidgui.h" + +//--------------------------------------------------------- +//   instantiate +//--------------------------------------------------------- + +class QWidget; + +static Mess* instantiate(int sr, QWidget*, QString* /* projectPathPtr */, const char* name) +      { +      ISynth* synth = new ISynth(); +      synth->setSampleRate(sr); +      if (synth->init(name)) { +            delete synth; +            synth = 0; +            } +      return synth; +      } + +//--------------------------------------------------------- +//    MESS +//--------------------------------------------------------- + +extern "C" { +      static MESS descriptor = { +            "fluid", +            "fluid soundfont loader by Werner Schweer",    +            "0.1",      // fluid version string +            MESS_MAJOR_VERSION, MESS_MINOR_VERSION, +            instantiate, +            }; +      // We must compile with -fvisibility=hidden to avoid namespace +      // conflicts with global variables. +      // Only visible symbol is "mess_descriptor". +      // (TODO: all plugins should be compiled this way) +   +      __attribute__ ((visibility("default"))) +      const MESS* mess_descriptor() { return &descriptor; } +      } + +//--------------------------------------------------------- +//   ISynth +//--------------------------------------------------------- + +ISynth::ISynth() +   : Mess(2) +      { +      _busy       = false; +      sfont       = 0; +      _gmMode     = false;     // General Midi Mode +      _fluidsynth = 0; +      initBuffer  = 0; +      initLen     = 0; +      fontId      = -1; +      } + +//--------------------------------------------------------- +//   playNote +//    return true if busy +//--------------------------------------------------------- + +bool ISynth::playNote(int channel, int pitch, int velo) +      { +      if (_busy) { +//            printf("fluid: playNote(): busy!\n"); +            return true; +            } +      if (velo) { +            int err = fluid_synth_noteon(_fluidsynth, channel, pitch, velo); +            if (err) { +                  printf("ISynth: noteon error, channel %d pitch %d<%s>\n", +                     channel, pitch, fluid_synth_error(_fluidsynth)); +			} +            } +      else +            fluid_synth_noteoff(_fluidsynth, channel, pitch); +      return false; +      } + +//--------------------------------------------------------- +//   setController +//    return true if busy +//--------------------------------------------------------- + +bool ISynth::setController(int ch, int ctrl, int val) +      { +      if (_busy) { +//            printf("fluid: setController(): busy!\n"); +            return true; +            } +      switch(ctrl) { +            case CTRL_PROGRAM: +                  { +                  int hbank = (val & 0xff0000) >> 16; +                  int lbank = (val & 0xff00) >> 8; +                  if (hbank > 127)  // map "dont care" to 0 +                        hbank = 0; +                  if (lbank > 127) +                        lbank = 0; +                  if (lbank == 127 || ch == 9)       // drum HACK +                        lbank = 128; +                  int prog  = val & 0x7f; +                  fluid_synth_program_select(_fluidsynth, ch, +                     hbank, lbank, prog); +                  } +                  break; + +            case CTRL_PITCH: +                  fluid_synth_pitch_bend (_fluidsynth, ch, val); +                  break; + +            default: +// printf("controller %x val %x\n", ctrl & 0x3fff, val); +                  fluid_synth_cc(_fluidsynth, ch, ctrl & 0x3fff, val); +                  break; +            } +      return false; +      } + +//--------------------------------------------------------- +//   sysex +//    7e 7f 09 01          GM on +//    7e 7f 09 02          GM off +//    7f 7f 04 01 ll hh    Master Volume (ll-low byte, hh-high byte) +//    7c 00 01 nn ...      replace Soundfont (nn-ascii char of path +//    7c 00 02 nn ...      add Soundfont +//    7c 00 03 nn ...      remove Soundfont +// +//    return true if busy +//--------------------------------------------------------- + +bool ISynth::sysex(int len, const unsigned char* data) +      { +      if (_busy) { +//            printf("fluid: sysex(): busy!\n"); +            return true; +            } +      if (len >= 4) { +            //--------------------------------------------- +            //  Universal Non Realtime +            //--------------------------------------------- + +            if (data[0] == 0x7e) { +                  if (data[1] == 0x7f) {  // device Id +                        if (data[2] == 0x9) {   // GM +                              if (data[3] == 0x1) { +                                    gmOn(true); +                                    return false; +                                    } +                              else if (data[3] == 0x2) { +                                    gmOn(false); +                                    return false; +                                    } +                              } +                        } +                  } + +            //--------------------------------------------- +            //  Universal Realtime +            //--------------------------------------------- + +            else if (data[0] == 0x7f) { +                  if (data[1] == 0x7f) {  // device Id +                        if ((data[2] == 0x4) && (data[3] == 0x1)) { +                              float v = (data[5]*128 + data[4])/32767.0; +                              fluid_synth_set_gain(_fluidsynth, v); +                              return false; +                              } +                        } +                  } + +            //--------------------------------------------- +            //  MusE Soft Synth +            //--------------------------------------------- + +            else if (data[0] == 0x7c) { +                  int n = len - 3; +                  if (n < 1) { +                        printf("fluid: bad sysEx:\n"); +                        return false; +                        } +                  char buffer[n+1]; +                  memcpy(buffer, (char*)data+3, n); +                  buffer[n] = 0; +                  if (data[1] == 0) {     // fluid +                        if (data[2] == 1) {  // load sound font +                              sysexSoundFont(SF_REPLACE, buffer); +                              return false; +                              } +                        else if (data[2] == 2) {  // load sound font +                              sysexSoundFont(SF_ADD, buffer); +                              return false; +                              } +                        else if (data[2] == 3) {  // load sound font +                              sysexSoundFont(SF_REMOVE, buffer); +                              return false; +                              } +                        } +                  } +            else if (data[0] == 0x41) {   // roland +                  if (data[1] == 0x10 && data[2] == 0x42 && data[3] == 0x12 +                     && data[4] == 0x40 && data[5] == 00 && data[6] == 0x7f +                     && data[7] == 0x41) { +                        // gs on +                        gmOn(true); +                        return false; +                        } +                  } +            } +      printf("fluid: unknown sysex received, len %d:\n", len); +      for (int i = 0; i < len; ++i) +            printf("%02x ", data[i]); +      printf("\n"); +      return false; +      } + +//--------------------------------------------------------- +//   gmOn +//--------------------------------------------------------- + +void ISynth::gmOn(bool flag) +      { +      _gmMode = flag; +      allNotesOff(); +      } + +//--------------------------------------------------------- +//   allNotesOff +//    stop all notes +//--------------------------------------------------------- + +void ISynth::allNotesOff() +      { +      for (int ch = 0; ch < 16; ++ch) { +            fluid_synth_cc(_fluidsynth, ch, 0x7b, 0);  // all notes off +            } +      } + +//--------------------------------------------------------- +//   guiVisible +//--------------------------------------------------------- + +bool ISynth::guiVisible() const +      { +      return gui->isVisible(); +      } + +//--------------------------------------------------------- +//   showGui +//--------------------------------------------------------- + +void ISynth::showGui(bool flag) +      { +      gui->setVisible(flag); +      } + +//--------------------------------------------------------- +//   ~ISynth +//--------------------------------------------------------- + +ISynth::~ISynth() +      { +      // TODO delete settings +      if (_fluidsynth) +            delete_fluid_synth(_fluidsynth); +      if (initBuffer) +            delete [] initBuffer; +      } + +//--------------------------------------------------------- +//   processMessages +//   Called from host always, even if output path is unconnected. +//--------------------------------------------------------- + +void ISynth::processMessages() +{ +  //Process messages from the gui +  if (!_busy)  +  { +    // +    //  get and process all pending events from the +    //  synthesizer GUI +    // +    while (gui->fifoSize()) +          processEvent(gui->readEvent()); +  } +} +   +//--------------------------------------------------------- +//   process +//   Called from host, ONLY if output path is connected. +//--------------------------------------------------------- + +void ISynth::process(float** ports, int offset, int n) +      { +      if (!_busy) { +            /* +            // +            //  get and process all pending events from the +            //  synthesizer GUI +            // +            while (gui->fifoSize()) +                  processEvent(gui->readEvent()); +            */       +            fluid_synth_write_float(_fluidsynth, n, ports[0], +               offset, 1, ports[1], offset, 1); +            } +      // printf("%f %f\n", *ports[0], *(ports[0]+1)); +      } + +//--------------------------------------------------------- +//   processEvent +//    All events from the sequencer go here +//--------------------------------------------------------- +bool ISynth::processEvent(const MidiPlayEvent& ev) +      { +      switch(ev.type()) { +            case ME_CONTROLLER: +                  setController(ev.channel(), ev.dataA(), ev.dataB()); +                  return true; +            case ME_NOTEON: +                  return playNote(ev.channel(), ev.dataA(), ev.dataB()); +            case ME_NOTEOFF: +                  return playNote(ev.channel(), ev.dataA(), 0); +            case ME_SYSEX: +                  return sysex(ev.len(), ev.data()); +            case ME_PITCHBEND: +                setController(ev.channel(), CTRL_PITCH, ev.dataA()); +                break;             +            case ME_PROGRAM: +                setController(ev.channel(), CTRL_PROGRAM, ev.dataA()); +                break;    +            default: +                break; +            } +      return false; +      } + +//--------------------------------------------------------- +//   getPatchName +//--------------------------------------------------------- + +const char* ISynth::getPatchName(int /*ch*/, int val, int, bool /*drum*/) const +      { +      int prog =   val & 0xff; +      if(val == CTRL_VAL_UNKNOWN || prog == 0xff) +            return "<unknown>"; +      prog &= 0x7f; +       +      int hbank = (val & 0xff0000) >> 16; +      int lbank = (val & 0xff00) >> 8; +      if (hbank > 127) +            hbank = 0; +      if (lbank > 127) +            lbank = 0; +      if (lbank == 127)       // drum HACK +            lbank = 128; +      const char* name = "<unknown>"; + +      if (_busy) { +            printf("fluid: getPatchName(): busy!\n"); +            return name; +            } +      fluid_font = fluid_synth_get_sfont_by_id(_fluidsynth, hbank); +      if (fluid_font) { +            fluid_preset_t* preset = (*fluid_font->get_preset)(fluid_font, lbank, prog); +            if (preset) +                  name = (*preset->get_name)(preset); +            else +                  fprintf(stderr, "no fluid preset for bank %d prog %d\n", +                     lbank, prog); +            } +      else +            fprintf(stderr, "ISynth::getPatchName(): no fluid font id=%d found\n", hbank); +      return name; +      } + +//--------------------------------------------------------- +//   getNextPatch +//--------------------------------------------------------- + +const MidiPatch* ISynth::getPatchInfo(int ch, const MidiPatch* p) const +      { +      if (_busy) { +            printf("fluid: getPatchInfo(): busy!\n"); +            return 0; +            } +      if (p == 0) { +            // get font at font stack index 0 +            fluid_font = fluid_synth_get_sfont(_fluidsynth, 0); +            if (fluid_font == 0) +                  return 0; +            (*fluid_font->iteration_start)(fluid_font); +            } +      fluid_preset_t preset; + +      while ((*fluid_font->iteration_next)(fluid_font, &preset)) { +            patch.hbank = fluid_sfont_get_id(fluid_font); +            int bank = (*preset.get_banknum)(&preset); +            if (ch == 9 && bank != 128) // show only drums for channel 10 +                  continue; +            if (bank == 128) +                  bank = 127; +            patch.typ   = 0; +            patch.name  = (*preset.get_name)(&preset); +            patch.lbank = bank; +            patch.prog  = (*preset.get_num)(&preset); +            return &patch; +            } +      return 0; +      } + +//--------------------------------------------------------- +//   getInitData +//    construct an initialization string which can be used +//    as a sysex to restore current state +//--------------------------------------------------------- + +void ISynth::getInitData(int* len, const unsigned char** data) +      { +      if (sfont == 0) { +            *len = 0; +            return; +            } +      int n = 4 + strlen(sfont); +      if (n > initLen) { +            if (initBuffer) +                  delete [] initBuffer; +            initBuffer = new unsigned char[n]; +            } +      initBuffer[0] = 0x7c; +      initBuffer[1] = 0x00; +      initBuffer[2] = SF_REPLACE; +      strcpy((char*)(initBuffer+3), sfont); +      *len = n; +      *data = initBuffer; +      } + +//--------------------------------------------------------- +//   sysexSoftfont +//--------------------------------------------------------- + +void ISynth::sysexSoundFont(SfOp op, const char* data) +      { +      char c = 'x'; +      allNotesOff(); +      switch(op) { +            case SF_REMOVE: +                  break; +            case SF_REPLACE: +            case SF_ADD: +                  if (sfont && (strcmp(sfont, data) == 0)) { +                        fprintf(stderr, "fluid: font already loaded\n"); +                        break; +                        } +                  if (_busy) { +                        fprintf(stderr, "fluid: busy!\n"); +                        break; +                        } +                  _busy = true; +                  if (sfont) +                        delete[] sfont; +                  sfont = new char[strlen(data)+1]; +                  strcpy(sfont, data); +                  _busy = true; +                  write(writeFd, &c, 1); +                  break; +            } +      } + +//--------------------------------------------------------- +//   fontLoad +//    helper thread to load soundfont in the +//    background +//--------------------------------------------------------- + +static void* helper(void* t) +      { +      ISynth* is = (ISynth*) t; +      is->noRTHelper(); +      pthread_exit(0); +      } + +//------------------------------------ +//   noRTHelper +//--------------------------------------------------------- + +void ISynth::noRTHelper() +      { +      for (;;) { +            char c; +            int n = read(readFd, &c, 1); +            if (n != 1) { +                  perror("ISynth::read ipc failed\n"); +                  continue; +                  } +            int id = getFontId(); +            if (id != -1) { +                  fprintf(stderr, "ISynth: unload old font\n"); +                  fluid_synth_sfunload(synth(), (unsigned)id, true); +                  } +            int rv = fluid_synth_sfload(synth(), getFont(), true); +            if (rv == -1) { +                  fprintf(stderr, "ISynth: sfload %s failed\n", +                     fluid_synth_error(synth())); +                  } +            else { +                  setFontId(rv); +                  fprintf(stderr, "ISynth: sfont %s loaded as %d\n ", +                     getFont(), rv); +                  } +            fluid_synth_set_gain(synth(), 1.0);  //? +            _busy = false; +            } +      } + +//--------------------------------------------------------- +//   init +//    return true on error +//--------------------------------------------------------- + +bool ISynth::init(const char* name) +      { +      fluid_settings_t* settings; +      settings = new_fluid_settings(); +      fluid_settings_setnum(settings, (char*) "synth.sample-rate", float(sampleRate())); + +      _fluidsynth = new_fluid_synth(settings); + +      //--------------------------------------- +      //    create non realtime helper thread +      //    create message channels +      // +      int filedes[2];         // 0 - reading   1 - writing +      if (pipe(filedes) == -1) { +            perror("ISynth::thread:creating pipe"); +            return true; +            } +      readFd  = filedes[0]; +      writeFd = filedes[1]; + +      pthread_attr_t* attributes = (pthread_attr_t*) malloc(sizeof(pthread_attr_t)); +      pthread_attr_init(attributes); +      if (pthread_create(&helperThread, attributes, ::helper, this)) +            perror("creating thread failed:"); +      pthread_attr_destroy(attributes); + +      char* p = getenv("DEFAULT_SOUNDFONT"); +      if (p) { +            sfont = new char[strlen(p)+1]; +            strcpy(sfont, p); +            char c = 'x'; +            _busy = true; +            write(writeFd, &c, 1); +            } + +      gui = new FLUIDGui; +      gui->setWindowTitle(QString(name)); +      gui->show(); +      return false; +      } + diff --git a/attic/muse2-oom/muse2/synti/fluid/fluid.h b/attic/muse2-oom/muse2/synti/fluid/fluid.h new file mode 100644 index 00000000..c1669846 --- /dev/null +++ b/attic/muse2-oom/muse2/synti/fluid/fluid.h @@ -0,0 +1,84 @@ +//========================================================= +//  MusE +//  Linux Music Editor +//  $Id: fluid.h,v 1.7.2.4 2009/11/19 04:20:33 terminator356 Exp $ +// +//  This file is derived from fluid Synth and modified +//    for MusE. +//  Parts of fluid are derived from Smurf Sound Font Editor. +//  Parts of Smurf Sound Font Editor are derived from +//    awesfx utilities +//  Smurf:  Copyright (C) 1999-2000 Josh Green +//  fluid:   Copyright (C) 2001 Peter Hanappe +//  MusE:   Copyright (C) 2001 Werner Schweer +//  awesfx: Copyright (C) 1996-1999 Takashi Iwai +//========================================================= + +#ifndef _SYNTH_H +#define _SYNTH_H + +#include <list> +#include <fluidsynth.h> +#include "libsynti/mess.h" + +enum SfOp { SF_REPLACE = 1, SF_ADD, SF_REMOVE }; +class FLUIDGui; + +//--------------------------------------------------------- +//   ISynth +//--------------------------------------------------------- + +class ISynth : public Mess { +      bool _busy; +      bool _gmMode; + +      unsigned char* initBuffer; +      int initLen; + +      fluid_synth_t* _fluidsynth; +      char* sfont; +      mutable fluid_sfont_t* fluid_font; +      int fontId; + +      int readFd, writeFd; + +      mutable MidiPatch patch; + +      pthread_t helperThread; +      FLUIDGui* gui; + +      void gmOn(bool); +      void sysexSoundFont(SfOp op, const char* data); + +      void allNotesOff(); +      void resetAllController(int); + +      virtual void processMessages(); +      virtual void process(float**, int, int); +      virtual bool playNote(int channel, int pitch, int velo); +	virtual bool setController(int, int, int); +      virtual bool sysex(int len, const unsigned char* p); +     +      virtual bool processEvent(const MidiPlayEvent&); +      virtual const char* getPatchName (int, int, int, bool) const; +      virtual const MidiPatch* getPatchInfo(int, const MidiPatch *) const; +      virtual void getInitData(int*, const unsigned char**); + +      virtual bool guiVisible() const; +      virtual void showGui(bool); +      virtual bool hasGui() const { return true; } + +   public: +      ISynth(); +      ~ISynth(); + +      fluid_synth_t* synth() { return _fluidsynth; } +      const fluid_synth_t* synth() const { return _fluidsynth; } +      char* getFont() const  { return sfont; } +      void setFontId(int id)  { fontId = id; } +      int getFontId() const   { return fontId; } +      bool init(const char* name); +      void noRTHelper(); +      }; + +#endif  /* _SYNTH_H */ diff --git a/attic/muse2-oom/muse2/synti/fluid/fluidgui.cpp b/attic/muse2-oom/muse2/synti/fluid/fluidgui.cpp new file mode 100644 index 00000000..3ba70aff --- /dev/null +++ b/attic/muse2-oom/muse2/synti/fluid/fluidgui.cpp @@ -0,0 +1,81 @@ +//========================================================= +//  MusE +//  Linux Music Editor +//  $Id: fluidgui.cpp,v 1.6.2.1 2009/08/12 20:47:01 spamatica Exp $ +// +//    This is a simple GUI implemented with QT for +//    fluid software synthesizer. +// +//  (C) Copyright 2001-2004 Werner Schweer (ws@seh.de) +//========================================================= + +#include <unistd.h> +#include <stdlib.h> + +#include <QFileDialog> +#include <QFileInfo> +#include <QMessageBox> + +#include "fluidgui.h" +#include "muse/midi.h" +#include "muse/icons.h" + +//--------------------------------------------------------- +//   FLUIDGui +//--------------------------------------------------------- + +FLUIDGui::FLUIDGui() +   : QDialog(0, Qt::Window), MessGui() +      { +      setupUi(this); +      fdialogButton->setIcon(QIcon(*openIcon)); +      connect(fdialogButton, SIGNAL(clicked()), SLOT(soundFontFileDialog())); +      connect(loadButton, SIGNAL(clicked()), SLOT(loadFont())); + +      // work around for probable QT/WM interaction bug. +      // for certain window managers, e.g xfce, this window is +      // is displayed although not specifically set to show(); +      // bug: 2811156  	 Softsynth GUI unclosable with XFCE4 (and a few others) +      show(); +      hide(); +      } + +//--------------------------------------------------------- +//   loadFont +//    sysex f0 lenH lenM lenL 7c 00 01 name +//--------------------------------------------------------- + +void FLUIDGui::loadFont() +      { +      if (pathEntry->text().isEmpty()) +            return; +      QFileInfo fi(pathEntry->text()); +      if (!fi.exists()) { +            QString s = QString("SoundFont ") + pathEntry->text() + QString(" does not exists"); +            QMessageBox::critical(this, tr("FLUID: open Soundfile"), s); +            return; +            } +      QByteArray ba = pathEntry->text().toLatin1(); +      const char* path = ba.constData(); +      int len     = strlen(path) + 1 + 3; +      unsigned char buffer[len]; +      int k       = 0; +      buffer[k++] = 0x7c; +      buffer[k++] = 0x00;       // fluid +      buffer[k++] = 0x01;       // load sound font +      strcpy((char*)(&buffer[k]), path); +      sendSysex(buffer, len); +      } + +//--------------------------------------------------------- +//   soundFontFileDialog +//--------------------------------------------------------- + +void FLUIDGui::soundFontFileDialog() +      { +      QString s = QFileDialog::getOpenFileName(this, QString(), QString(), QString("*.[Ss][Ff]2")); +      if (!s.isEmpty()) { +            pathEntry->setText(s); +            } +      } + diff --git a/attic/muse2-oom/muse2/synti/fluid/fluidgui.h b/attic/muse2-oom/muse2/synti/fluid/fluidgui.h new file mode 100644 index 00000000..3e564538 --- /dev/null +++ b/attic/muse2-oom/muse2/synti/fluid/fluidgui.h @@ -0,0 +1,33 @@ +//========================================================= +//  MusE +//  Linux Music Editor +//  $Id: fluidgui.h,v 1.2 2004/02/12 17:32:29 wschweer Exp $ +// +//  (C) Copyright 2001 Werner Schweer (ws@seh.de) +//========================================================= + +#ifndef __GUI_H__ +#define __GUI_H + +#include "ui_fluidguibase.h" +#include "libsynti/gui.h" + +class QDialog; + +//--------------------------------------------------------- +//   FLUIDGui +//--------------------------------------------------------- + +class FLUIDGui : public QDialog, public Ui::FLUIDGuiBase, public MessGui { + +      Q_OBJECT + +   private slots: +      void soundFontFileDialog(); +      void loadFont(); + +   public: +      FLUIDGui(); +      }; + +#endif diff --git a/attic/muse2-oom/muse2/synti/fluid/fluidguibase.ui b/attic/muse2-oom/muse2/synti/fluid/fluidguibase.ui new file mode 100644 index 00000000..1abbf49c --- /dev/null +++ b/attic/muse2-oom/muse2/synti/fluid/fluidguibase.ui @@ -0,0 +1,112 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>FLUIDGuiBase</class> + <widget class="QDialog" name="FLUIDGuiBase"> +  <property name="geometry"> +   <rect> +    <x>0</x> +    <y>0</y> +    <width>248</width> +    <height>94</height> +   </rect> +  </property> +  <property name="windowTitle"> +   <string>Form1</string> +  </property> +  <layout class="QVBoxLayout"> +   <property name="spacing"> +    <number>6</number> +   </property> +   <property name="margin"> +    <number>11</number> +   </property> +   <item> +    <layout class="QHBoxLayout"> +     <property name="spacing"> +      <number>6</number> +     </property> +     <property name="margin"> +      <number>0</number> +     </property> +     <item> +      <widget class="QLabel" name="TextLabel1"> +       <property name="text"> +        <string>Soundfont</string> +       </property> +       <property name="wordWrap"> +        <bool>false</bool> +       </property> +      </widget> +     </item> +     <item> +      <widget class="QLineEdit" name="pathEntry"/> +     </item> +     <item> +      <widget class="QToolButton" name="fdialogButton"> +       <property name="text"> +        <string/> +       </property> +      </widget> +     </item> +    </layout> +   </item> +   <item> +    <spacer name="Spacer2"> +     <property name="orientation"> +      <enum>Qt::Vertical</enum> +     </property> +     <property name="sizeType"> +      <enum>QSizePolicy::Expanding</enum> +     </property> +     <property name="sizeHint" stdset="0"> +      <size> +       <width>20</width> +       <height>20</height> +      </size> +     </property> +    </spacer> +   </item> +   <item> +    <layout class="QHBoxLayout"> +     <property name="spacing"> +      <number>6</number> +     </property> +     <property name="margin"> +      <number>0</number> +     </property> +     <item> +      <widget class="QPushButton" name="loadButton"> +       <property name="sizePolicy"> +        <sizepolicy hsizetype="Preferred" vsizetype="Fixed"> +         <horstretch>0</horstretch> +         <verstretch>0</verstretch> +        </sizepolicy> +       </property> +       <property name="text"> +        <string>Load</string> +       </property> +      </widget> +     </item> +     <item> +      <spacer name="Spacer1"> +       <property name="orientation"> +        <enum>Qt::Horizontal</enum> +       </property> +       <property name="sizeType"> +        <enum>QSizePolicy::Expanding</enum> +       </property> +       <property name="sizeHint" stdset="0"> +        <size> +         <width>20</width> +         <height>20</height> +        </size> +       </property> +      </spacer> +     </item> +    </layout> +   </item> +  </layout> + </widget> + <resources/> + <connections/> +</ui>  | 
