diff options
| author | Florian Jung <flo@windfisch.org> | 2011-04-11 14:46:12 +0000 | 
|---|---|---|
| committer | Florian Jung <flo@windfisch.org> | 2011-04-11 14:46:12 +0000 | 
| commit | 384e0d2f6d77ab107268921511dd91464d4accb3 (patch) | |
| tree | f361808b7af39d0d28188e5efb0140b3e01ab8a1 /muse2/muse | |
| parent | 51eda45715625b6da768e670388510c91b01ff5c (diff) | |
| parent | c8a651f88b5728e246cb46599521ce981f0f4cfb (diff) | |
cosmetic stuff: made many functions static, improved pixmap loading
synced with current trunk
Diffstat (limited to 'muse2/muse')
31 files changed, 818 insertions, 290 deletions
| diff --git a/muse2/muse/app.cpp b/muse2/muse/app.cpp index 00af02e9..58de4584 100644 --- a/muse2/muse/app.cpp +++ b/muse2/muse/app.cpp @@ -1744,6 +1744,7 @@ void MusE::loadProjectFile1(const QString& name, bool songTemplate, bool loadAll              if (!fi.isReadable()) {                    QMessageBox::critical(this, QString("MusE"),                       tr("Cannot read template")); +                  QApplication::restoreOverrideCursor();                    return;                    }              project.setFile("untitled"); @@ -2087,17 +2088,19 @@ void MusE::closeEvent(QCloseEvent* event)              n = QMessageBox::warning(this, appName,                 tr("The current Project contains unsaved data\n"                 "Save Current Project?"), -               tr("&Save"), tr("&Skip"), tr("&Abort"), 0, 2); +               tr("&Save"), tr("&Skip"), tr("&Cancel"), 0, 2);              if (n == 0) {                    if (!save())      // dont quit if save failed                    {                          event->ignore(); +                        QApplication::restoreOverrideCursor();                          return;                    }                          }              else if (n == 2)              {                    event->ignore(); +                  QApplication::restoreOverrideCursor();                    return;              }                    } diff --git a/muse2/muse/arranger/tlist.cpp b/muse2/muse/arranger/tlist.cpp index b13f2ab0..b907b555 100644 --- a/muse2/muse/arranger/tlist.cpp +++ b/muse2/muse/arranger/tlist.cpp @@ -602,28 +602,48 @@ void TList::oportPropertyPopupMenu(Track* t, int x, int y)          SynthI* synth = (SynthI*)t;          QMenu* p = new QMenu; -        QAction* act = p->addAction(tr("Show Gui")); -        act->setCheckable(true); +        //QAction* act = p->addAction(tr("Show Gui")); +        QAction* gact = p->addAction(tr("show gui")); +        //act->setCheckable(true); +        gact->setCheckable(true);          //printf("synth hasgui %d, gui visible %d\n",synth->hasGui(), synth->guiVisible()); -        act->setEnabled(synth->hasGui()); -        act->setChecked(synth->guiVisible()); +        //act->setEnabled(synth->hasGui()); +        //act->setChecked(synth->guiVisible()); +        gact->setEnabled(synth->hasGui()); +        gact->setChecked(synth->guiVisible()); +   +        QAction* nact = p->addAction(tr("show native gui")); +        //act->setCheckable(true); +        nact->setCheckable(true); +        //printf("synth hasgui %d, gui visible %d\n",synth->hasGui(), synth->guiVisible()); +        //act->setEnabled(synth->hasGui()); +        //act->setChecked(synth->guiVisible()); +        nact->setEnabled(synth->hasNativeGui()); +        nact->setChecked(synth->nativeGuiVisible());          // If it has a gui but we don't have OSC, disable the action.          #ifndef OSC_SUPPORT          #ifdef DSSI_SUPPORT          if(dynamic_cast<DssiSynthIF*>(synth->sif()))          { -          act->setChecked(false); -          act->setEnabled(false); +          //act->setChecked(false); +          //act->setEnabled(false); +          nact->setChecked(false); +          nact->setEnabled(false);          }            #endif          #endif          QAction* ract = p->exec(mapToGlobal(QPoint(x, y)), 0); -        if (ract == act) { +        //if (ract == act) { +        if (ract == gact) {                bool show = !synth->guiVisible();                audio->msgShowInstrumentGui(synth, show);                } +        else if (ract == nact) { +              bool show = !synth->nativeGuiVisible(); +              audio->msgShowInstrumentNativeGui(synth, show); +              }          delete p;          return;        } @@ -635,29 +655,46 @@ void TList::oportPropertyPopupMenu(Track* t, int x, int y)        MidiPort* port = &midiPorts[oPort];        QMenu* p = new QMenu; -      QAction* act = p->addAction(tr("Show Gui")); -      act->setCheckable(true); +      //QAction* act = p->addAction(tr("Show Gui")); +      QAction* gact = p->addAction(tr("show gui")); +      //act->setCheckable(true); +      gact->setCheckable(true);        //printf("synth hasgui %d, gui visible %d\n",port->hasGui(), port->guiVisible()); -      act->setEnabled(port->hasGui()); -      act->setChecked(port->guiVisible()); - +      //act->setEnabled(port->hasGui()); +      //act->setChecked(port->guiVisible()); +      gact->setEnabled(port->hasGui()); +      gact->setChecked(port->guiVisible()); + +      QAction* nact = p->addAction(tr("show native gui")); +      nact->setCheckable(true); +      //printf("synth hasgui %d, gui visible %d\n",synth->hasGui(), synth->guiVisible()); +      nact->setEnabled(port->hasNativeGui()); +      nact->setChecked(port->nativeGuiVisible()); +                // If it has a gui but we don't have OSC, disable the action.        #ifndef OSC_SUPPORT        #ifdef DSSI_SUPPORT        MidiDevice* dev = port->device();        if(dev && dev->isSynti() && (dynamic_cast<DssiSynthIF*>(((SynthI*)dev)->sif())))        { -        act->setChecked(false); -        act->setEnabled(false); +        //act->setChecked(false); +        //act->setEnabled(false); +        nact->setChecked(false); +        nact->setEnabled(false);        }          #endif        #endif        QAction* ract = p->exec(mapToGlobal(QPoint(x, y)), 0); -      if (ract == act) { +      //if (ract == act) { +      if (ract == gact) {              bool show = !port->guiVisible();              audio->msgShowInstrumentGui(port->instrument(), show);              } +      else if (ract == nact) { +            bool show = !port->nativeGuiVisible(); +            audio->msgShowInstrumentNativeGui(port->instrument(), show); +            }        delete p;        } diff --git a/muse2/muse/audio.cpp b/muse2/muse/audio.cpp index f541a10c..a4b04436 100644 --- a/muse2/muse/audio.cpp +++ b/muse2/muse/audio.cpp @@ -65,6 +65,7 @@ const char* seqMsgList[] = {        "SEQM_SET_AUX",        "SEQM_UPDATE_SOLO_STATES",        "MIDI_SHOW_INSTR_GUI", +      "MIDI_SHOW_INSTR_NATIVE_GUI",        "AUDIO_RECORD",        "AUDIO_ROUTEADD", "AUDIO_ROUTEREMOVE", "AUDIO_REMOVEROUTES",        "AUDIO_VOL", "AUDIO_PAN", @@ -736,6 +737,9 @@ void Audio::processMsg(AudioMsg* msg)              case MIDI_SHOW_INSTR_GUI:                    midiSeq->msgUpdatePollFd();                    break; +            case MIDI_SHOW_INSTR_NATIVE_GUI:   // p4.0.20 +                  midiSeq->msgUpdatePollFd(); +                  break;              case SEQM_ADD_TEMPO:              case SEQM_REMOVE_TEMPO:              case SEQM_SET_GLOBAL_TEMPO: diff --git a/muse2/muse/audio.h b/muse2/muse/audio.h index ba188f8a..58f399e3 100644 --- a/muse2/muse/audio.h +++ b/muse2/muse/audio.h @@ -58,6 +58,7 @@ enum {        SEQM_SET_AUX,        SEQM_UPDATE_SOLO_STATES,        MIDI_SHOW_INSTR_GUI, +      MIDI_SHOW_INSTR_NATIVE_GUI,        AUDIO_RECORD,        AUDIO_ROUTEADD, AUDIO_ROUTEREMOVE, AUDIO_REMOVEROUTES,        AUDIO_VOL, AUDIO_PAN, @@ -218,6 +219,7 @@ class Audio {        void msgAddSig(int tick, int z, int n, bool doUndoFlag = true);        void msgRemoveSig(int tick, int z, int n, bool doUndoFlag = true);        void msgShowInstrumentGui(MidiInstrument*, bool); +      void msgShowInstrumentNativeGui(MidiInstrument*, bool);        void msgPanic();        void sendMsg(AudioMsg*);        bool sendMessage(AudioMsg* m, bool doUndo); diff --git a/muse2/muse/audiotrack.cpp b/muse2/muse/audiotrack.cpp index 28020caf..98e74331 100644 --- a/muse2/muse/audiotrack.cpp +++ b/muse2/muse/audiotrack.cpp @@ -12,6 +12,7 @@  #include <QMessageBox> +#include "globaldefs.h"  #include "track.h"  #include "event.h"  #include "song.h" @@ -20,6 +21,8 @@  #include "xml.h"  #include "plugin.h"  #include "audiodev.h" +#include "synth.h" +#include "dssihost.h"  bool AudioAux::_isVisible=true;  bool AudioInput::_isVisible=true; @@ -983,7 +986,8 @@ bool AudioTrack::readProperties(Xml& xml, const QString& tag)              //  controls would all be set to zero.              // But we will allow for the (unintended, useless) possibility of a controller               //  with no matching plugin control. -            PluginI* p = 0; +            //PluginI* p = 0; +            PluginIBase* p = 0;                   bool ctlfound = false;              int m = l->id() & AC_PLUGIN_CTL_ID_MASK;              int n = (l->id() >> AC_PLUGIN_CTL_BASE_POW) - 1; @@ -993,6 +997,25 @@ bool AudioTrack::readProperties(Xml& xml, const QString& tag)                if(p && m < p->parameters())                    ctlfound = true;              } +            // Support a special block for dssi synth ladspa controllers. p4.0.20 +            else if(n == MAX_PLUGINS && type() == AUDIO_SOFTSYNTH)     +            { +              SynthI* synti = dynamic_cast < SynthI* > (this); +              if(synti) +              { +                SynthIF* sif = synti->sif(); +                if(sif) +                { +                  DssiSynthIF* dsif = dynamic_cast < DssiSynthIF* > (sif); +                  if(dsif) +                  { +                    p = dsif; +                    if(p && m < p->parameters()) +                        ctlfound = true; +                  } +                } +              } +            }              iCtrlList icl = _controller.find(l->id());              if (icl == _controller.end()) @@ -1128,7 +1151,7 @@ void AudioTrack::mapRackPluginsToControllers()      }      } -  // The loop is a safe way to delete while iterating 'non-linear' lists. +  // FIXME: The loop is a safe way to delete while iterating lists.    bool loop;    do    { @@ -1142,7 +1165,28 @@ void AudioTrack::mapRackPluginsToControllers()          continue;        int param = id & AC_PLUGIN_CTL_ID_MASK;        int idx = (id >> AC_PLUGIN_CTL_BASE_POW) - 1; -      PluginI* p = (*_efxPipe)[idx]; +      //PluginI* p = (*_efxPipe)[idx]; +       +      // p4.0.20 +      PluginIBase* p = 0; +      if(idx >= 0 && idx < PipelineDepth) +        p = (*_efxPipe)[idx]; +      // Support a special block for dssi synth ladspa controllers.  +      else if(idx == MAX_PLUGINS && type() == AUDIO_SOFTSYNTH)     +      { +        SynthI* synti = dynamic_cast < SynthI* > (this); +        if(synti) +        { +          SynthIF* sif = synti->sif(); +          if(sif) +          { +            DssiSynthIF* dsif = dynamic_cast < DssiSynthIF* > (sif); +            if(dsif) +              p = dsif; +          } +        } +      } +              // If there's no plugin at that rack position, or the param is out of range of        //  the number of controls in the plugin, then it's a stray controller. Delete it.        // Future: Leave room for possible bypass controller at AC_PLUGIN_CTL_ID_MASK -1. @@ -1159,7 +1203,7 @@ void AudioTrack::mapRackPluginsToControllers()    while (loop); -    // Although this tested OK, and is the 'official' way to erase while iterating, +    // FIXME: Although this tested OK, and is the 'official' way to erase while iterating,      //  I don't trust it. I'm weary of this method. The technique didn't work       //  in Audio::msgRemoveTracks(), see comments there.      /* diff --git a/muse2/muse/confmport.cpp b/muse2/muse/confmport.cpp index d05e174d..8c27d9eb 100644 --- a/muse2/muse/confmport.cpp +++ b/muse2/muse/confmport.cpp @@ -380,10 +380,16 @@ void MPConfig::rbClicked(QTableWidgetItem* item)              case DEVCOL_GUI:                    if (dev == 0)                          return; -                  if (port->hasGui()) +                  //if (port->hasGui()) +                  if (port->hasNativeGui())                    { -                        port->instrument()->showGui(!port->guiVisible()); -                        item->setIcon(port->guiVisible() ? QIcon(*dotIcon) : QIcon(*dothIcon)); +                        //bool v = port->nativeGuiVisible() +                        //port->instrument()->showGui(!port->guiVisible()); +                        port->instrument()->showNativeGui(!port->nativeGuiVisible()); +                        //port->instrument()->showNativeGui(!v); +                        //item->setIcon(port->guiVisible() ? QIcon(*dotIcon) : QIcon(*dothIcon)); +                        item->setIcon(port->nativeGuiVisible() ? QIcon(*dotIcon) : QIcon(*dothIcon)); +                        //item->setIcon(!v ? QIcon(*dotIcon) : QIcon(*dothIcon));                    }                    return; @@ -1226,8 +1232,10 @@ void MPConfig::songChanged(int flags)  		  itemrec->setIcon(QIcon(QPixmap()));  		  itemplay->setIcon(QIcon(QPixmap()));                    } -            if (port->hasGui()) { -                  itemgui->setIcon(port->guiVisible() ? QIcon(*dotIcon) : QIcon(*dothIcon)); +            //if (port->hasGui()) { +            if (port->hasNativeGui()) { +                  //itemgui->setIcon(port->guiVisible() ? QIcon(*dotIcon) : QIcon(*dothIcon)); +                  itemgui->setIcon(port->nativeGuiVisible() ? QIcon(*dotIcon) : QIcon(*dothIcon));                    }              else {  	      itemgui->setIcon(QIcon(QPixmap())); diff --git a/muse2/muse/driver/dummyaudio.cpp b/muse2/muse/driver/dummyaudio.cpp index dfa7a86b..597ecf2b 100644 --- a/muse2/muse/driver/dummyaudio.cpp +++ b/muse2/muse/driver/dummyaudio.cpp @@ -57,6 +57,7 @@ class DummyAudioDevice : public AudioDevice {        int _framePos;        int playPos;        bool realtimeFlag; +      bool seekflag;        DummyAudioDevice();        virtual ~DummyAudioDevice() @@ -117,8 +118,7 @@ class DummyAudioDevice : public AudioDevice {        virtual int getState() {   //            if(DEBUG_DUMMY)  //                printf("DummyAudioDevice::getState %d\n", state); -       -      return state; } +            return state; }        virtual unsigned getCurFrame() {               if(DEBUG_DUMMY)                  printf("DummyAudioDevice::getCurFrame %d\n", _framePos); @@ -133,10 +133,14 @@ class DummyAudioDevice : public AudioDevice {        virtual void startTransport() {              if(DEBUG_DUMMY)                  printf("DummyAudioDevice::startTransport playPos=%d\n", playPos); +#if 0                          Msg trcmd;              trcmd.cmd = trStart;              trcmd.arg = playPos;              cmdQueue.push_front(trcmd); +#else +            state = Audio::PLAY; +#endif              /*            state = Audio::START_PLAY;              audio->sync(state, playPos);                          state = Audio::PLAY;*/ @@ -152,20 +156,33 @@ class DummyAudioDevice : public AudioDevice {        {              if(DEBUG_DUMMY)                  printf("DummyAudioDevice::seekTransport frame=%d topos=%d\n",playPos, p.frame()); +#if 0                          Msg trcmd;              trcmd.cmd = trSeek;              trcmd.arg = p.frame();              cmdQueue.push_front(trcmd);              playPos = p.frame(); +#else +            seekflag = true; +            //pos = n; +            playPos = p.frame(); +#endif             +                    }        virtual void seekTransport(unsigned pos) {              if(DEBUG_DUMMY)                  printf("DummyAudioDevice::seekTransport frame=%d topos=%d\n",playPos,pos); +#if 0                          Msg trcmd;              trcmd.cmd = trSeek;              trcmd.arg = pos;              cmdQueue.push_front(trcmd);              playPos = pos; +#else +            seekflag = true; +            //pos = n; +            playPos = pos; +#endif              /*              Audio::State tempState = state;              state = Audio::START_PLAY; @@ -187,7 +204,9 @@ DummyAudioDevice::DummyAudioDevice()        dummyThread = 0;        realtimeFlag = false; +      seekflag = false;        state = Audio::STOP; +      //startTime = curTime();        _framePos = 0;        playPos = 0;        cmdQueue.clear(); @@ -259,6 +278,7 @@ static void* dummyLoop(void* ptr)        sampleRate = config.dummyAudioSampleRate;        //segmentSize = dummyFrames;        segmentSize = config.dummyAudioBufSize; +#if 0              //unsigned int tickRate = sampleRate / dummyFrames;        unsigned int tickRate = sampleRate / segmentSize; @@ -289,13 +309,15 @@ static void* dummyLoop(void* ptr)        sampleRate = tickRate * segmentSize;        timer.startTimer(); +#endif                DummyAudioDevice *drvPtr = (DummyAudioDevice *)ptr; -      pollfd myPollFd; +      ///pollfd myPollFd; + +      ///myPollFd.fd = fd; +      ///myPollFd.events = POLLIN; -      myPollFd.fd = fd; -      myPollFd.events = POLLIN;        /*        doSetuid(); @@ -360,6 +382,7 @@ static void* dummyLoop(void* ptr)        undoSetuid();  #endif +#if 0              /* unsigned long tick = 0;*/    // prevent compiler warning: unused variable        for (;;) {              int _pollWait = 10;   // ms @@ -408,7 +431,38 @@ static void* dummyLoop(void* ptr)                    drvPtr->playPos+=increment;                    }              } -      timer.stopTimer(); +#else +      // Adapted from muse_qt4_evolution. p4.0.20        +      for(;;)  +      { +            //if(audioState == AUDIO_RUNNING) +            if(audio->isRunning()) +              //audio->process(segmentSize, drvPtr->state); +              audio->process(segmentSize); +            //else if (audioState == AUDIO_START1) +            //  audioState = AUDIO_START2; +            //usleep(dummyFrames*1000000/AL::sampleRate); +            usleep(segmentSize*1000000/sampleRate); +            //if(dummyAudio->seekflag)  +            if(drvPtr->seekflag)  +            { +              //audio->sync(Audio::STOP, dummyAudio->pos); +              //audio->sync(drvPtr->state, drvPtr->playPos); +              audio->sync(Audio::STOP, drvPtr->playPos); +               +              //dummyAudio->seekflag = false; +              drvPtr->seekflag = false; +            } +             +            //if(dummyAudio->state == Audio::PLAY)  +            //  dummyAudio->pos += dummyFrames; +            drvPtr->_framePos += segmentSize; +            if(drvPtr->state == Audio::PLAY)  +              drvPtr->playPos += segmentSize; +      } +#endif +             +      ///timer.stopTimer();        pthread_exit(0);        } diff --git a/muse2/muse/dssihost.cpp b/muse2/muse/dssihost.cpp index ca867bd4..aa18025d 100644 --- a/muse2/muse/dssihost.cpp +++ b/muse2/muse/dssihost.cpp @@ -615,8 +615,9 @@ SynthIF* DssiSynth::createSIF(SynthI* synti)            _controlInPorts = 0;            _controlOutPorts = 0; -          pIdx.clear();  -          opIdx.clear(); +          ///pIdx.clear();  +          ///opIdx.clear(); +                      iIdx.clear();             oIdx.clear();             rpIdx.clear(); @@ -662,7 +663,7 @@ SynthIF* DssiSynth::createSIF(SynthI* synti)                {                  rpIdx.push_back(_controlInPorts);                  ++_controlInPorts; -                pIdx.push_back(k); +                ///pIdx.push_back(k);                  // Set to false at first.                  //synti->_guiUpdateControls.push_back(false);                } @@ -670,7 +671,7 @@ SynthIF* DssiSynth::createSIF(SynthI* synti)                {                  rpIdx.push_back((unsigned long)-1);                  ++_controlOutPorts; -                opIdx.push_back(k); +                ///opIdx.push_back(k);                }              }            } @@ -718,7 +719,8 @@ SynthIF* DssiSynth::createSIF(SynthI* synti)  //   guiVisible  //--------------------------------------------------------- -bool DssiSynthIF::guiVisible() const +//bool DssiSynthIF::guiVisible() const +bool DssiSynthIF::nativeGuiVisible() const        {        //return _guiVisible;        #ifdef OSC_SUPPORT @@ -727,11 +729,19 @@ bool DssiSynthIF::guiVisible() const        return false;        } +bool DssiSynthIF::guiVisible() const +      { +      //return _guiVisible; +      //return false; +      return _gui && _gui->isVisible(); +      } +  //---------------------------------------------------------  //   showGui  //--------------------------------------------------------- -void DssiSynthIF::showGui(bool v) +//void DssiSynthIF::showGui(bool v)     +void DssiSynthIF::showNativeGui(bool v)        {        #ifdef OSC_SUPPORT @@ -786,6 +796,26 @@ void DssiSynthIF::showGui(bool v)        }  //--------------------------------------------------------- +//   showGui +//--------------------------------------------------------- + +void DssiSynthIF::showGui(bool v) +{ +  //if (_plugin)  +  { +        if (v) { +                if (_gui == 0) +                    makeGui(); +                _gui->show(); +                } +        else { +                if (_gui) +                    _gui->hide(); +                } +  } +} + +//---------------------------------------------------------  //   receiveEvent  //--------------------------------------------------------- @@ -866,8 +896,10 @@ bool DssiSynthIF::init(DssiSynth* s)        synti->_guiUpdateControls.clear();        synti->_guiUpdateProgram = false; +/*              for (int k = 0; k < controlPorts; ++k) {                  int i = synth->pIdx[k]; +                controls[k].idx = i;    // p4.0.20                  //controls[k].val = ladspaDefaultValue(ld, i);                  ladspaDefaultValue(ld, i, &controls[k].val); @@ -937,85 +969,188 @@ bool DssiSynthIF::init(DssiSynth* s)        for (int k = 0; k < controlOutPorts; ++k) {                  int i = synth->opIdx[k]; +                controlsOut[k].idx = i;    // p4.0.20                  #ifdef DSSI_DEBUG                   printf("DssiSynthIF::init control output port:%d port idx:%d name:%s\n", k, i, ld->PortNames[i]);                  #endif -                 -                // p3.3.39 Removed. -                /* -                 -                //controls[k].val = ladspaDefaultValue(ld, i); -                ladspaDefaultValue(ld, i, &controlsOut[k].val); -                 -                // This code is duplicated in ::getControllerInfo() -                // -                 -                int ctlnum = DSSI_NONE; -                if(dssi->get_midi_controller_for_port) -                  ctlnum = dssi->get_midi_controller_for_port(handle, i); -                 -                // No controller number? Try to give it a unique one... -                if(ctlnum == DSSI_NONE) -                { -                  // FIXME: Be more careful. Must make sure to pick numbers not already chosen or which WILL BE chosen. -                  // Simple but flawed solution: Start them at 0x60000 + 0x3000 = 0x63000. Max NRPN number is 0x3fff. -                  // TODO: CC etc. etc. -                  ctlnum = CTRL_NRPN14_OFFSET + 0x3000 + k;  -                } -                else -                { -                  int c = ctlnum; -                  // Can be both CC and NRPN! Prefer CC over NRPN. -                  if(DSSI_IS_CC(ctlnum)) -                  { -                    #ifdef DSSI_DEBUG  -                    printf("DssiSynthIF::init is CC control\n"); -                    #endif -                    ctlnum = DSSI_CC_NUMBER(c); -                     -                    #ifdef DSSI_DEBUG  -                    if(DSSI_IS_NRPN(ctlnum)) -                      printf("DssiSynthIF::init is also NRPN control. Using CC.\n"); -                    #endif   -                  } -                  else -                  if(DSSI_IS_NRPN(ctlnum)) -                  { -                    #ifdef DSSI_DEBUG  -                    printf("DssiSynthIF::init  is NRPN control\n"); -                    #endif -                     -                    ctlnum = DSSI_NRPN_NUMBER(c) + CTRL_NRPN14_OFFSET; -                  }   -                     -                } +                //  - Control outs are not handled but still must be connected to something. +                ld->connect_port(handle, i, &controlsOut[k].val); +            } +*/ +      // p4.0.20 +      int cip = 0; +      int cop = 0; +      for (unsigned long k = 0; k < synth->_portCount; ++k)  +      { +        LADSPA_PortDescriptor pd = ld->PortDescriptors[k]; +         +        #ifdef DSSI_DEBUG  +        printf("DssiSynth::init ladspa plugin Port:%ld Name:%s descriptor:%x\n", k, ld->PortNames[k], pd); +        #endif +         +        if (LADSPA_IS_PORT_CONTROL(pd))  +        { +          if (LADSPA_IS_PORT_INPUT(pd))  +          { +            controls[cip].idx = k;     +            float val; +            ladspaDefaultValue(ld, k, &val); +            controls[cip].val    = val; +            controls[cip].tmpVal = val; +            controls[cip].enCtrl  = true; +            controls[cip].en2Ctrl = true; +             +            // Set to false at first. +            synti->_guiUpdateControls.push_back(false); +           +            #ifdef DSSI_DEBUG  +            printf("DssiSynthIF::init control port:%d port idx:%d name:%s\n", cip, k, ld->PortNames[k]); +            #endif +             +            // This code is duplicated in ::getControllerInfo() +            // +             +            int ctlnum = DSSI_NONE; +            if(dssi->get_midi_controller_for_port) +              ctlnum = dssi->get_midi_controller_for_port(handle, k); +             +            // No controller number? Try to give it a unique one... +            if(ctlnum == DSSI_NONE) +            { +              // FIXME: Be more careful. Must make sure to pick numbers not already chosen or which WILL BE chosen. +              // Simple but flawed solution: Start them at 0x60000 + 0x2000 = 0x62000. Max NRPN number is 0x3fff. +              // TODO: Update: Actually we want to try to use CC Controller7 controllers if possible (or a choice) because what if +              //  the user's controller hardware doesn't support RPN? +              // If CC Controller7 is chosen we must make sure to use only non-common numbers. An already limited range +              //  of 127 now becomes narrower. See the cool document midi-controllers.txt in the DSSI source for a  +              //  nice roundup of numbers and how to choose them and how they relate to synths and DSSI synths etc. ! +              ctlnum = CTRL_NRPN14_OFFSET + 0x2000 + cip;  +            } +            else +            { +              int c = ctlnum; +              // Can be both CC and NRPN! Prefer CC over NRPN. +              if(DSSI_IS_CC(ctlnum)) +              { +                #ifdef DSSI_DEBUG  +                printf("DssiSynthIF::init is CC control\n"); +                #endif +                ctlnum = DSSI_CC_NUMBER(c);                  #ifdef DSSI_DEBUG  -                printf("DssiSynthIF::init inserting to midiCtl2PortMap: ctlnum:%d k:%d\n", ctlnum, k); +                if(DSSI_IS_NRPN(ctlnum)) +                  printf("DssiSynthIF::init is also NRPN control. Using CC.\n"); +                #endif   +              } +              else +              if(DSSI_IS_NRPN(ctlnum)) +              { +                #ifdef DSSI_DEBUG  +                printf("DssiSynthIF::init  is NRPN control\n");                  #endif -                // We have a controller number! Insert it and the DSSI port number into the map. -                // p3.3.39 Removed. Doesn't say whether it's in or out! Don't need this for now.  -                //synth->midiCtl2PortMap.insert(std::pair<int, int>(ctlnum, k)); -                     -                */     -                     -                //  - Control outs are not handled but still must be connected to something. -                ld->connect_port(handle, i, &controlsOut[k].val); +                ctlnum = DSSI_NRPN_NUMBER(c) + CTRL_NRPN14_OFFSET; +              }   +                              } +             +            #ifdef DSSI_DEBUG  +            printf("DssiSynthIF::init inserting to midiCtl2PortMap: ctlnum:%d k:%d\n", ctlnum, cip); +            #endif +             +            // We have a controller number! Insert it and the DSSI port number into both maps. +            synth->midiCtl2PortMap.insert(std::pair<int, int>(ctlnum, cip)); +            synth->port2MidiCtlMap.insert(std::pair<int, int>(cip, ctlnum)); +             +            // Support a special block for dssi synth ladspa controllers. p4.0.20 +            // Put the ID at a special block after plugins (far after). +            int id = genACnum(MAX_PLUGINS, cip); +            const char* name = ld->PortNames[k]; +            float min, max; +            ladspaControlRange(ld, k, &min, &max); +            CtrlList* cl; +            CtrlListList* cll = ((AudioTrack*)synti)->controller(); +            iCtrlList icl = cll->find(id); +            if (icl == cll->end()) +            { +              cl = new CtrlList(id); +              cll->add(cl); +              cl->setCurVal(controls[cip].val); +            } +            else  +            { +              cl = icl->second; +              controls[cip].val = cl->curVal(); +            } +            cl->setRange(min, max); +            cl->setName(QString(name)); +            LADSPA_PortRangeHint range = ld->PortRangeHints[k]; +            if(LADSPA_IS_HINT_TOGGLED(range.HintDescriptor)) +            {     +              cl->setMode(CtrlList::DISCRETE); +              cl->setValueType(VAL_BOOL); +            }   +            else   +            { +              cl->setMode(CtrlList::INTERPOLATE); +              cl->setValueType(VAL_LINEAR); +            }   +             +            ld->connect_port(handle, k, &controls[cip].val); +             +            ++cip; +          } +          else if (LADSPA_IS_PORT_OUTPUT(pd)) +          { +            controlsOut[cop].idx = k;     +            controls[cop].val    = 0.0; +            controls[cop].tmpVal = 0.0; +            controls[cop].enCtrl  = false; +            controls[cop].en2Ctrl = false; -      // Set the latency to zero. -      //controls[controlPorts].val = 0.0; -      // Insert a controller for latency and the DSSI port number into the map. -      //synth->midiCtl2PortMap.insert(std::pair<int, int>(CTRL_NRPN14_OFFSET + 0x2000, controlPorts)); -      // Connect the port. -      //ld->connect_port(handle, controlPorts, &controls[controlPorts].val); -       -      // Just a test. It works! We can instantiate a ladspa plugin for the synth. But it needs more work... -      //plugins.add(&synth->info, LADSPA_Descriptor_Function(NULL), ld, false); +            #ifdef DSSI_DEBUG  +            printf("DssiSynthIF::init control output port:%d port idx:%d name:%s\n", cop, k, ld->PortNames[k]); +            #endif +             +            //  Control outs are not handled but still must be connected to something. +            ld->connect_port(handle, k, &controlsOut[cop].val); +            ++cop; +          } +        } +      } +           +       +      /* +      // Add the LADSPA controllers to the audio track controller list. p4.0.20 +      //int controller = plugin->parameters(); +      int controller = controlPorts; +      for (int i = 0; i < controller; ++i)  +      { +        //int id = genACnum(idx, i); +        // Put the ID at a special block after plugins (far after). +        int id = genACnum(MAX_PLUGINS, i); +        const char* name = plugin->paramName(i); +        synth->dssi->LADSPA_Plugin->PortNames[controls[i].idx] +        float min, max; +        plugin->range(i, &min, &max); +        CtrlValueType t = plugin->valueType(); +        CtrlList* cl = new CtrlList(id); +        cl->setRange(min, max); +        cl->setName(QString(name)); +        cl->setValueType(t); +        LADSPA_PortRangeHint range = plugin->range(i); +        if(LADSPA_IS_HINT_TOGGLED(range.HintDescriptor)) +          cl->setMode(CtrlList::DISCRETE); +        else   +          cl->setMode(CtrlList::INTERPOLATE); +        cl->setCurVal(plugin->param(i)); +        addController(cl); +      } +      */ +              if (ld->activate)              ld->activate(handle); @@ -1654,7 +1789,8 @@ bool DssiSynthIF::processEvent(const MidiPlayEvent& e, snd_seq_event_t* event)        //int num = ip->first;        unsigned long k = ip->second; -      unsigned long i = synth->pIdx[k]; +      ///unsigned long i = synth->pIdx[k]; +      unsigned long i = controls[k].idx;        int ctlnum = DSSI_NONE;        if(dssi->get_midi_controller_for_port) @@ -2145,8 +2281,8 @@ void DssiSynth::incInstances(int val)              handle = 0;              dssi = NULL;              df   = NULL; -            pIdx.clear();  -            opIdx.clear(); +            ///pIdx.clear();  +            ///opIdx.clear();              iIdx.clear();               oIdx.clear();               rpIdx.clear(); @@ -2334,8 +2470,9 @@ void DssiSynthIF::guiHeartBeat()    {      if(synti->_guiUpdateControls[i])      { -      unsigned long k = synth->pIdx[i]; -      _oscif.oscSendControl(k, controls[i].val); +      ///unsigned long k = synth->pIdx[i]; +      ///_oscif.oscSendControl(k, controls[i].val); +      _oscif.oscSendControl(controls[i].idx, controls[i].val);        // Reset.        synti->_guiUpdateControls[i] = false; @@ -2376,8 +2513,10 @@ int DssiSynthIF::oscUpdate()        unsigned long ports = synth->_controlInPorts;        for(unsigned long i = 0; i < ports; ++i)         { -        unsigned long k = synth->pIdx[i]; -        _oscif.oscSendControl(k, controls[i].val); +        ///unsigned long k = synth->pIdx[i]; +        ///_oscif.oscSendControl(k, controls[i].val); +        _oscif.oscSendControl(controls[i].idx, controls[i].val); +                  // Avoid overloading the GUI if there are lots and lots of ports.           if((i+1) % 50 == 0)            usleep(300000); @@ -2835,8 +2974,9 @@ int DssiSynthIF::getControllerInfo(int id, const char** name, int* ctrl, int* mi    //int ctlnum = ip->first;    //int k = ip->second; -  int i = synth->pIdx[id]; +  ///int i = synth->pIdx[id];    //int i = synth->pIdx[k]; +  int i = controls[id].idx;    //ladspaDefaultValue(ld, i, &controls[id].val); @@ -2964,7 +3104,8 @@ int DssiSynthIF::totalInChannels() const  bool DssiSynthIF::on() const                                 { return true; }  // Synth is not part of a rack plugin chain. Always on.  void DssiSynthIF::setOn(bool /*val*/)                        { }     int DssiSynthIF::pluginID()                                  { return (synth && synth->dssi) ? synth->dssi->LADSPA_Plugin->UniqueID : 0; }  -int DssiSynthIF::id()                                        { return 0; } // Synth is not part of a rack plugin chain. Always 0. +//int DssiSynthIF::id()                                        { return 0; } // Synth is not part of a rack plugin chain. Always 0. +int DssiSynthIF::id()                                        { return MAX_PLUGINS; } // Set for special block reserved for dssi synth. p4.0.20  QString DssiSynthIF::pluginLabel() const                     { return (synth && synth->dssi) ? QString(synth->dssi->LADSPA_Plugin->Label) : QString(); }   QString DssiSynthIF::name() const                            { return synti->name(); }  QString DssiSynthIF::lib() const                             { return synth ? synth->completeBaseName() : QString(); } @@ -2980,9 +3121,9 @@ bool DssiSynthIF::readConfiguration(Xml& /*xml*/, bool /*readPreset*/) { return  int DssiSynthIF::parameters() const                          { return synth ? synth->_controlInPorts : 0; }  void DssiSynthIF::setParam(int i, double val)                { setParameter(i, val); }  double DssiSynthIF::param(int i) const                       { return getParameter(i); } -const char* DssiSynthIF::paramName(int i)                    { return (synth && synth->dssi) ? synth->dssi->LADSPA_Plugin->PortNames[i] : 0; } +const char* DssiSynthIF::paramName(int i)                    { return (synth && synth->dssi) ? synth->dssi->LADSPA_Plugin->PortNames[controls[i].idx] : 0; }  //LADSPA_PortRangeHint DssiSynthIF::range(int i)               { return (synth && synth->dssi) ? synth->dssi->LADSPA_Plugin->PortRangeHints[i] : 0; } -LADSPA_PortRangeHint DssiSynthIF::range(int i)               { return synth->dssi->LADSPA_Plugin->PortRangeHints[i]; } +LADSPA_PortRangeHint DssiSynthIF::range(int i)               { return synth->dssi->LADSPA_Plugin->PortRangeHints[controls[i].idx]; }  #else //DSSI_SUPPORT diff --git a/muse2/muse/dssihost.h b/muse2/muse/dssihost.h index a8607ce0..a98cfd87 100644 --- a/muse2/muse/dssihost.h +++ b/muse2/muse/dssihost.h @@ -64,8 +64,8 @@ class DssiSynth : public Synth {        const DSSI_Descriptor* dssi;        DSSI_Descriptor_Function df;        unsigned long _portCount, _inports, _outports, _controlInPorts, _controlOutPorts; -      std::vector<unsigned long> pIdx;  // Control input index to port number.  -      std::vector<unsigned long> opIdx; // Control output index to port number. This is sometimes a latency port and...? +      //std::vector<unsigned long> pIdx;  // Control input index to port number.  +      //std::vector<unsigned long> opIdx; // Control output index to port number. This is sometimes a latency port and...?        std::vector<unsigned long> iIdx;  // Audio input index to port number.        std::vector<unsigned long> oIdx;  // Audio output index to port number.        std::vector<bool> iUsedIdx;       // During process, tells whether an audio input port was used by any input routes. @@ -104,7 +104,7 @@ class DssiSynth : public Synth {        unsigned long inControls()  const { return _controlInPorts; }        unsigned long outControls() const { return _controlOutPorts; } -      unsigned long inControlPortIdx(unsigned long i) { return pIdx[i]; } +      //unsigned long inControlPortIdx(unsigned long i) { return pIdx[i]; }        };  //--------------------------------------------------------- @@ -160,10 +160,17 @@ class DssiSynthIF : public SynthIF, public PluginIBase        virtual bool initGui();        virtual void guiHeartBeat();        virtual bool guiVisible() const; -      virtual void showGui(bool v); -      virtual bool hasGui() const { return synth->_hasGui; } -      virtual void getGeometry(int*, int*, int*, int*) const {} +      virtual void showGui(bool); +      //virtual bool hasGui() const { return synth->_hasGui; } +      virtual bool hasGui() const { return true; } +      virtual bool nativeGuiVisible() const;                                        // p4.0.20 +      virtual void showNativeGui(bool);                                             //  +      //virtual bool hasNativeGui() const { /*return synth->_hasGui; */}            //  +      virtual bool hasNativeGui() const { return !dssi_ui_filename().isEmpty(); }   //  +      virtual void getGeometry(int*x, int*y, int*w, int*h) const { *x=0;*y=0;*w=0;*h=0; }        virtual void setGeometry(int, int, int, int) {} +      virtual void getNativeGeometry(int*x, int*y, int*w, int*h) const { *x=0;*y=0;*w=0;*h=0; } +      virtual void setNativeGeometry(int, int, int, int) {}        virtual void preProcessAlways(); diff --git a/muse2/muse/globaldefs.h b/muse2/muse/globaldefs.h index 74c18d7d..92ccf0e0 100644 --- a/muse2/muse/globaldefs.h +++ b/muse2/muse/globaldefs.h @@ -21,9 +21,13 @@ enum AutomationType {        };  const int MAX_CHANNELS = 2;   // max audio channels -const int MAX_PLUGINS  = 4;   // plugins in mixer rack +// Absolute max number of plugins in mixer rack (if we ever want to increase PipelineDepth). +// Used to determine the index where special blocks (dssi ladspa controls) appear in the list of controllers. +// The special block(s) must appear AFTER any rack plugins, so we need this variable to help us +//  leave some room in case we ever want to increase the number of rack plugins. +const int MAX_PLUGINS  = 8;    +const int PipelineDepth = 4;  // plugins in mixer rack, max up to MAX_PLUGINS -//const int MIDI_PORTS   = 32;  // max Number of Midi Ports  const int MIDI_PORTS   = 200;  // max Number of Midi Ports  #ifndef MIDI_CHANNELS diff --git a/muse2/muse/instruments/minstrument.h b/muse2/muse/instruments/minstrument.h index 0c37701f..a8fb1168 100644 --- a/muse2/muse/instruments/minstrument.h +++ b/muse2/muse/instruments/minstrument.h @@ -111,6 +111,9 @@ class MidiInstrument {        virtual bool guiVisible() const   { return false; }        virtual void showGui(bool)        {}        virtual bool hasGui() const       { return false; } +      virtual bool nativeGuiVisible() const   { return false; } +      virtual void showNativeGui(bool)        {} +      virtual bool hasNativeGui() const       { return false; }        virtual void writeToGui(const MidiPlayEvent&) {}        virtual void reset(int, MType); diff --git a/muse2/muse/midiedit/scoreedit.cpp b/muse2/muse/midiedit/scoreedit.cpp index a796d862..72b0c4de 100644 --- a/muse2/muse/midiedit/scoreedit.cpp +++ b/muse2/muse/midiedit/scoreedit.cpp @@ -90,8 +90,7 @@ ScoreEdit::ScoreEdit(PartList* pl, QWidget* parent, const char* name, unsigned i  connect(hscroll, SIGNAL(valueChanged(int)), test,   SLOT(scroll_event(int))); -connect(test, SIGNAL(xpos_changed(int)), hscroll,   SLOT(setValue(int))); -connect(song, SIGNAL(songChanged(int)), test, SLOT(song_changed(int))); +connect(test, SIGNAL(xpos_changed(int)), hscroll,   SLOT(setValue(int)));connect(song, SIGNAL(songChanged(int)), test, SLOT(song_changed(int)));  connect(test, SIGNAL(canvas_width_changed(int)), SLOT(canvas_width_changed(int)));  connect(test, SIGNAL(viewport_width_changed(int)), SLOT(viewport_width_changed(int)));  //	      mainGrid->setRowStretch(0, 100); @@ -140,6 +139,17 @@ void ScoreEdit::closeEvent(QCloseEvent* e) +//creation of the static variables +QPixmap *ScoreCanvas::pix_whole, *ScoreCanvas::pix_half, *ScoreCanvas::pix_quarter; +QPixmap *ScoreCanvas::pix_dot, *ScoreCanvas::pix_b, *ScoreCanvas::pix_sharp, *ScoreCanvas::pix_noacc; +QPixmap *ScoreCanvas::pix_r1, *ScoreCanvas::pix_r2, *ScoreCanvas::pix_r4, *ScoreCanvas::pix_r8, *ScoreCanvas::pix_r16; +QPixmap *ScoreCanvas::pix_flag_up, *ScoreCanvas::pix_flag_down; +QPixmap *ScoreCanvas::pix_num; +QPixmap *ScoreCanvas::pix_clef_violin, *ScoreCanvas::pix_clef_bass; +bool ScoreCanvas::pixmaps_loaded=false; + + +  ScoreCanvas::ScoreCanvas(MidiEditor* pr, QWidget* parent,     int sx, int sy) : View(parent, sx, sy)  { @@ -148,7 +158,6 @@ ScoreCanvas::ScoreCanvas(MidiEditor* pr, QWidget* parent,  	setBg(Qt::white);  	setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding); -//	setMinimumSize(400,600);  	load_pixmaps(); @@ -198,8 +207,6 @@ int ScoreCanvas::viewport_width()  	return (width() - x_left);  } -//flo code starting here -  string IntToStr(int i)  {  	ostringstream s; @@ -243,35 +250,67 @@ void load_colored_pixmaps(string file, QPixmap* array)  } +  void ScoreCanvas::load_pixmaps()  { -	load_colored_pixmaps(FONT_PATH "whole.png", pix_whole); -	load_colored_pixmaps(FONT_PATH "half.png", pix_half); -	load_colored_pixmaps(FONT_PATH "quarter.png", pix_quarter); -	load_colored_pixmaps(FONT_PATH "dot.png", pix_dot); -	load_colored_pixmaps(FONT_PATH "acc_none.png", pix_noacc); -	load_colored_pixmaps(FONT_PATH "acc_sharp.png", pix_sharp); -	load_colored_pixmaps(FONT_PATH "acc_b.png", pix_b); - -	pix_r1.load(FONT_PATH "rest1.png"); -	pix_r2.load(FONT_PATH "rest2.png"); -	pix_r4.load(FONT_PATH "rest4.png"); -	pix_r8.load(FONT_PATH "rest8.png"); -	pix_r16.load(FONT_PATH "rest16.png"); -	pix_flag_up[0].load(FONT_PATH "flags8u.png"); -	pix_flag_up[1].load(FONT_PATH "flags16u.png"); -	pix_flag_up[2].load(FONT_PATH "flags32u.png"); -	pix_flag_up[3].load(FONT_PATH "flags64u.png"); -	pix_flag_down[0].load(FONT_PATH "flags8d.png"); -	pix_flag_down[1].load(FONT_PATH "flags16d.png"); -	pix_flag_down[2].load(FONT_PATH "flags32d.png"); -	pix_flag_down[3].load(FONT_PATH "flags64d.png"); -	 -	pix_clef_violin.load(FONT_PATH "clef_violin_big.png"); -	pix_clef_bass.load(FONT_PATH "clef_bass_big.png"); -	 -	for (int i=0;i<10;i++) -		pix_num[i].load(QString((string(FONT_PATH "")+IntToStr(i)+string(".png")).c_str()));	 +	if (!pixmaps_loaded) +	{ +		cout << "loading pixmaps..." << endl; +		 +		pix_whole=new QPixmap[NUM_PARTCOLORS+2]; +		pix_half=new QPixmap[NUM_PARTCOLORS+2]; +		pix_quarter=new QPixmap[NUM_PARTCOLORS+2]; +		pix_dot=new QPixmap[NUM_PARTCOLORS+2]; +		pix_b=new QPixmap[NUM_PARTCOLORS+2]; +		pix_sharp=new QPixmap[NUM_PARTCOLORS+2]; +		pix_noacc=new QPixmap[NUM_PARTCOLORS+2]; +		pix_num=new QPixmap[10]; +		 +		pix_r1=new QPixmap; +		pix_r2=new QPixmap; +		pix_r4=new QPixmap; +		pix_r8=new QPixmap; +		pix_r16=new QPixmap; +		 +		pix_clef_violin=new QPixmap; +		pix_clef_bass=new QPixmap; +		 +		pix_flag_up=new QPixmap[4]; +		pix_flag_down=new QPixmap[4]; +		 +		 +		 +		 +		load_colored_pixmaps(FONT_PATH "whole.png", pix_whole); +		load_colored_pixmaps(FONT_PATH "half.png", pix_half); +		load_colored_pixmaps(FONT_PATH "quarter.png", pix_quarter); +		load_colored_pixmaps(FONT_PATH "dot.png", pix_dot); +		load_colored_pixmaps(FONT_PATH "acc_none.png", pix_noacc); +		load_colored_pixmaps(FONT_PATH "acc_sharp.png", pix_sharp); +		load_colored_pixmaps(FONT_PATH "acc_b.png", pix_b); + +		pix_r1->load(FONT_PATH "rest1.png"); +		pix_r2->load(FONT_PATH "rest2.png"); +		pix_r4->load(FONT_PATH "rest4.png"); +		pix_r8->load(FONT_PATH "rest8.png"); +		pix_r16->load(FONT_PATH "rest16.png"); +		pix_flag_up[0].load(FONT_PATH "flags8u.png"); +		pix_flag_up[1].load(FONT_PATH "flags16u.png"); +		pix_flag_up[2].load(FONT_PATH "flags32u.png"); +		pix_flag_up[3].load(FONT_PATH "flags64u.png"); +		pix_flag_down[0].load(FONT_PATH "flags8d.png"); +		pix_flag_down[1].load(FONT_PATH "flags16d.png"); +		pix_flag_down[2].load(FONT_PATH "flags32d.png"); +		pix_flag_down[3].load(FONT_PATH "flags64d.png"); +		 +		pix_clef_violin->load(FONT_PATH "clef_violin_big.png"); +		pix_clef_bass->load(FONT_PATH "clef_bass_big.png"); +		 +		for (int i=0;i<10;i++) +			pix_num[i].load(QString((string(FONT_PATH "")+IntToStr(i)+string(".png")).c_str()));	 +		 +		pixmaps_loaded=true; +	}  } @@ -1497,11 +1536,11 @@ void ScoreCanvas::calc_item_pos(ScoreItemList& itemlist)  			{  				switch (it->len)  				{ -					case 0: it->pix=&pix_r1; break; -					case 1: it->pix=&pix_r2; break; -					case 2: it->pix=&pix_r4; break; -					case 3: it->pix=&pix_r8; break; -					case 4: it->pix=&pix_r16; break; +					case 0: it->pix=pix_r1; break; +					case 1: it->pix=pix_r2; break; +					case 2: it->pix=pix_r4; break; +					case 3: it->pix=pix_r8; break; +					case 4: it->pix=pix_r16; break;  				}  				it->x+=NOTE_MOVE_X + (it->ausweich ? REST_AUSWEICH_X : 0); //AUSWEICH_X @@ -1885,7 +1924,7 @@ void ScoreCanvas::draw_preamble(QPainter& p)  	int tick=x_to_tick(x_pos);  	// draw clef -------------------------------------------------------- -	QPixmap* pix_clef= (USED_CLEF==BASS) ? &pix_clef_bass : &pix_clef_violin; +	QPixmap* pix_clef= (USED_CLEF==BASS) ? pix_clef_bass : pix_clef_violin;  	int y_coord=YDIST+4*YLEN  -  ( clef_height(USED_CLEF) -2)*YLEN/2; //Y_MARKER  	draw_pixmap(p,CLEF_LEFTMARGIN + pix_clef->width()/2,y_coord,*pix_clef); @@ -2545,7 +2584,6 @@ void ScoreCanvas::pos_changed(int index, unsigned tick, bool scroll)   *   o check if making the program clef-aware hasn't broken anything   *     e.g. accidentials, creating notes, rendering etc.   *   o check if the new function for drawing accidential works - *     the change was introduced after 873815e57a5d1edc147710b524936b6f6260f555   *   o refuse to resize so that width gets smaller or equal than x_left   *   o set distances properly [looks okay, doesn't it?]   *   o maybe eliminate all the compiler warnings diff --git a/muse2/muse/midiedit/scoreedit.h b/muse2/muse/midiedit/scoreedit.h index 2d301d92..53bcae66 100644 --- a/muse2/muse/midiedit/scoreedit.h +++ b/muse2/muse/midiedit/scoreedit.h @@ -419,36 +419,50 @@ class ScoreCanvas : public View  {  	Q_OBJECT  	private: -		void load_pixmaps(); -		ScoreEventList create_appropriate_eventlist(PartList* pl); -		note_pos_t note_pos_(int note, tonart_t key); -		note_pos_t note_pos (unsigned note, tonart_t key, clef_t clef); -		int calc_len(int l, int d); -		list<note_len_t> parse_note_len(int len_ticks, int begin_tick, vector<int>& foo, bool allow_dots=true, bool allow_normal=true); -		void draw_tie (QPainter& p, int x1, int x4, int yo, bool up=true, QColor color=Qt::black); -		ScoreItemList create_itemlist(ScoreEventList& eventlist); +		static void load_pixmaps(); +		static void draw_pixmap(QPainter& p, int x, int y, const QPixmap& pm); +		static void draw_tie (QPainter& p, int x1, int x4, int yo, bool up=true, QColor color=Qt::black); + +		static void draw_accidentials(QPainter& p, int x, const list<int>& acc_list, const QPixmap& pix); +		static list<int> calc_accidentials(tonart_t key, clef_t clef, tonart_t next_key=C); + +		static void draw_timesig(QPainter& p, int x, int num, int denom); +		static int calc_timesig_width(int num, int denom); + +		static void draw_number(QPainter& p, int x, int y, int n); +		static int calc_number_width(int n); + + + +		static ScoreEventList create_appropriate_eventlist(PartList* pl); +		static ScoreItemList create_itemlist(ScoreEventList& eventlist); + +		static note_pos_t note_pos_(int note, tonart_t key); +		static note_pos_t note_pos (unsigned note, tonart_t key, clef_t clef); + +		static int calc_len(int l, int d); +		static list<note_len_t> parse_note_len(int len_ticks, int begin_tick, vector<int>& foo, bool allow_dots=true, bool allow_normal=true); + +		static int clef_height(clef_t clef); + +		static int height_to_pitch(int h, clef_t clef, tonart_t key); +		static int height_to_pitch(int h, clef_t clef); +		static int y_to_height(int y); +		int y_to_pitch(int y, int t, clef_t clef); + + + +  		void process_itemlist(ScoreItemList& itemlist); -		void draw_pixmap(QPainter& p, int x, int y, const QPixmap& pm);  		void draw_note_lines(QPainter& p);  		void draw_preamble(QPainter& p);  		void draw_items(QPainter& p, ScoreItemList& itemlist, ScoreItemList::iterator from_it, ScoreItemList::iterator to_it);  		void draw_items(QPainter& p, ScoreItemList& itemlist, int x1, int x2);  		void draw_items(QPainter& p, ScoreItemList& itemlist);  		void calc_item_pos(ScoreItemList& itemlist); -		list<int> calc_accidentials(tonart_t key, clef_t clef, tonart_t next_key=C); -		void draw_accidentials(QPainter& p, int x, const list<int>& acc_list, const QPixmap& pix); -		void draw_timesig(QPainter& p, int x, int num, int denom); -		int calc_timesig_width(int num, int denom); -		void draw_number(QPainter& p, int x, int y, int n); -		int calc_number_width(int n); -		int clef_height(clef_t clef); -		int y_to_pitch(int y, int t, clef_t clef); -		int y_to_height(int y); -		int height_to_pitch(int h, clef_t clef, tonart_t key); -		int height_to_pitch(int h, clef_t clef);  		timesig_t timesig_at_tick(int t);  		tonart_t key_at_tick(int t); @@ -464,13 +478,17 @@ class ScoreCanvas : public View  		int canvas_width();  		int viewport_width(); -		 -		QPixmap pix_whole[NUM_PARTCOLORS+2], pix_half[NUM_PARTCOLORS+2], pix_quarter[NUM_PARTCOLORS+2]; -		QPixmap pix_r1, pix_r2, pix_r4, pix_r8, pix_r16; -		QPixmap pix_dot[NUM_PARTCOLORS+2], pix_flag_up[4], pix_flag_down[4]; -		QPixmap pix_b[NUM_PARTCOLORS+2], pix_sharp[NUM_PARTCOLORS+2], pix_noacc[NUM_PARTCOLORS+2]; -		QPixmap pix_num[10]; -		QPixmap pix_clef_violin, pix_clef_bass; + + +// member variables --------------------------------------------------- + +		static QPixmap *pix_whole, *pix_half, *pix_quarter; // arrays [NUM_PARTCOLORS+2] +		static QPixmap *pix_dot, *pix_b, *pix_sharp, *pix_noacc; // arrays [NUM_PARTCOLORS+2] +		static QPixmap *pix_r1, *pix_r2, *pix_r4, *pix_r8, *pix_r16; // pointers +		static QPixmap *pix_flag_up, *pix_flag_down; // arrays [4] +		static QPixmap *pix_num; // array [10] +		static QPixmap *pix_clef_violin, *pix_clef_bass; //pointers +		static bool pixmaps_loaded;  		std::map<int,int> pos_add_list;  		ScoreEventList eventlist; diff --git a/muse2/muse/midiport.cpp b/muse2/muse/midiport.cpp index 6d04cff2..7c4f73fb 100644 --- a/muse2/muse/midiport.cpp +++ b/muse2/muse/midiport.cpp @@ -101,6 +101,24 @@ bool MidiPort::hasGui() const        }  //--------------------------------------------------------- +//   nativeGuiVisible +//--------------------------------------------------------- + +bool MidiPort::nativeGuiVisible() const +      { +      return _instrument ? _instrument->nativeGuiVisible() : false; +      } + +//--------------------------------------------------------- +//   hasNativeGui +//--------------------------------------------------------- + +bool MidiPort::hasNativeGui() const +      { +      return _instrument ? _instrument->hasNativeGui() : false; +      } + +//---------------------------------------------------------  //   setDevice  //--------------------------------------------------------- diff --git a/muse2/muse/midiport.h b/muse2/muse/midiport.h index 46107a8d..916c7337 100644 --- a/muse2/muse/midiport.h +++ b/muse2/muse/midiport.h @@ -66,6 +66,8 @@ class MidiPort {        bool guiVisible() const;        bool hasGui() const; +      bool nativeGuiVisible() const; +      bool hasNativeGui() const;        int portno() const;        bool foundInSongFile() const              { return _foundInSongFile; } diff --git a/muse2/muse/mixer/astrip.cpp b/muse2/muse/mixer/astrip.cpp index b5ab3aee..2f1a2262 100644 --- a/muse2/muse/mixer/astrip.cpp +++ b/muse2/muse/mixer/astrip.cpp @@ -1262,16 +1262,18 @@ static int addMultiChannelPorts(AudioTrack* t, PopupMenu* pup, int id, RouteMenu        {          case Track::AUDIO_INPUT: -              id = addWavePorts(t, chpup, id, mm, ch, 1, isOutput); +              //id = addWavePorts(t, chpup, id, mm, ch, 1, isOutput);  // Rem p4.0.20          case Track::WAVE:          case Track::AUDIO_GROUP:          case Track::AUDIO_SOFTSYNTH: +        case Track::AUDIO_AUX:        // p4.0.20 +              id = addWavePorts(t, chpup, id, mm, ch, 1, isOutput);                id = addOutPorts(t, chpup, id, mm, ch, 1, isOutput);                id = addGroupPorts(t, chpup, id, mm, ch, 1, isOutput);                id = addSyntiPorts(t, chpup, id, mm, ch, 1, isOutput); -              break; -        case Track::AUDIO_AUX: -              id = addOutPorts(t, chpup, id, mm, ch, 1, isOutput); +              //break;                                                // Rem p4.0.20 +        //case Track::AUDIO_AUX:                                      // +              //id = addOutPorts(t, chpup, id, mm, ch, 1, isOutput);  //                break;          default:                break; @@ -1290,13 +1292,14 @@ static int addMultiChannelPorts(AudioTrack* t, PopupMenu* pup, int id, RouteMenu                id = addSyntiPorts(t, chpup, id, mm, ch, 1, isOutput);                break;          case Track::WAVE: -              id = addInPorts(t, chpup, id, mm, ch, 1, isOutput); -              break; +              //id = addInPorts(t, chpup, id, mm, ch, 1, isOutput);    // Rem p4.0.20 +              //break;          case Track::AUDIO_SOFTSYNTH:          case Track::AUDIO_GROUP:                id = addWavePorts(t, chpup, id, mm, ch, 1, isOutput);                id = addInPorts(t, chpup, id, mm, ch, 1, isOutput);                id = addGroupPorts(t, chpup, id, mm, ch, 1, isOutput); +              id = addAuxPorts(t, chpup, id, mm, ch, 1, isOutput);     // p4.0.20                id = addSyntiPorts(t, chpup, id, mm, ch, 1, isOutput);                break;          default: @@ -1344,17 +1347,19 @@ static int addMultiChannelPorts(AudioTrack* t, PopupMenu* pup, int id, RouteMenu          switch(t->type())           {            case Track::AUDIO_INPUT: -                id = addWavePorts(t, chpup, id, mm, ch, 2, isOutput); +                //id = addWavePorts(t, chpup, id, mm, ch, 2, isOutput);   // Rem p4.0.20            case Track::WAVE:            case Track::AUDIO_GROUP:            case Track::AUDIO_SOFTSYNTH: +          case Track::AUDIO_AUX:                                          // p4.0.20 +                id = addWavePorts(t, chpup, id, mm, ch, 2, isOutput);     // p4.0.20                  id = addOutPorts(t, chpup, id, mm, ch, 2, isOutput);                  id = addGroupPorts(t, chpup, id, mm, ch, 2, isOutput);                  id = addSyntiPorts(t, chpup, id, mm, ch, 2, isOutput);                  break; -          case Track::AUDIO_AUX: -                id = addOutPorts(t, chpup, id, mm, ch, 2, isOutput); -                break; +          //case Track::AUDIO_AUX:                                         // Rem p4.0.20 +          //      id = addOutPorts(t, chpup, id, mm, ch, 2, isOutput); +          //      break;            default:                  break;          } @@ -1371,13 +1376,14 @@ static int addMultiChannelPorts(AudioTrack* t, PopupMenu* pup, int id, RouteMenu                  id = addSyntiPorts(t, chpup, id, mm, ch, 2, isOutput);                  break;            case Track::WAVE: -                id = addInPorts(t, chpup, id, mm, ch, 2, isOutput); -                break; +                //id = addInPorts(t, chpup, id, mm, ch, 2, isOutput);   // Rem p4.0.20 +                //break;            case Track::AUDIO_SOFTSYNTH:            case Track::AUDIO_GROUP:                  id = addWavePorts(t, chpup, id, mm, ch, 2, isOutput);                  id = addInPorts(t, chpup, id, mm, ch, 2, isOutput);                  id = addGroupPorts(t, chpup, id, mm, ch, 2, isOutput); +                id = addAuxPorts(t, chpup, id, mm, ch, 2, isOutput);     // p4.0.20                  id = addSyntiPorts(t, chpup, id, mm, ch, 2, isOutput);                  break;            default: @@ -1838,12 +1844,17 @@ void AudioStrip::iRoutePressed()                gid = nonSyntiTrackAddSyntis(t, pup, gid, gRoutingMenuMap, false);                break;          case Track::WAVE: +              gid = addWavePorts( t, pup, gid, gRoutingMenuMap, -1, -1, false);  // p4.0.20                gid = addInPorts(   t, pup, gid, gRoutingMenuMap, -1, -1, false); +              gid = addGroupPorts(t, pup, gid, gRoutingMenuMap, -1, -1, false);  // +              gid = addAuxPorts(  t, pup, gid, gRoutingMenuMap, -1, -1, false);  // +              gid = nonSyntiTrackAddSyntis(t, pup, gid, gRoutingMenuMap, false); //                break;          case Track::AUDIO_GROUP:                gid = addWavePorts( t, pup, gid, gRoutingMenuMap, -1, -1, false);                gid = addInPorts(   t, pup, gid, gRoutingMenuMap, -1, -1, false);                gid = addGroupPorts(t, pup, gid, gRoutingMenuMap, -1, -1, false); +              gid = addAuxPorts(  t, pup, gid, gRoutingMenuMap, -1, -1, false);  // p4.0.20                gid = nonSyntiTrackAddSyntis(t, pup, gid, gRoutingMenuMap, false);                break; @@ -1975,11 +1986,12 @@ void AudioStrip::oRoutePressed()          break;          case Track::AUDIO_INPUT: -              gid = addWavePorts(        t, pup, gid, gRoutingMenuMap, -1, -1, true); +              //gid = addWavePorts(        t, pup, gid, gRoutingMenuMap, -1, -1, true);  // Rem p4.0.20          case Track::WAVE:          case Track::AUDIO_GROUP:          case Track::AUDIO_AUX:          //case Track::AUDIO_SOFTSYNTH: +              gid = addWavePorts(        t, pup, gid, gRoutingMenuMap, -1, -1, true);  // p4.0.20                gid = addOutPorts(         t, pup, gid, gRoutingMenuMap, -1, -1, true);                gid = addGroupPorts(       t, pup, gid, gRoutingMenuMap, -1, -1, true);                gid = nonSyntiTrackAddSyntis(t, pup, gid, gRoutingMenuMap, true); diff --git a/muse2/muse/mixer/rack.cpp b/muse2/muse/mixer/rack.cpp index daebaa30..afb8ae49 100644 --- a/muse2/muse/mixer/rack.cpp +++ b/muse2/muse/mixer/rack.cpp @@ -26,6 +26,7 @@  #include "audio.h"  #include "icons.h"  #include "gconfig.h" +#include "globaldefs.h"  #include "plugin.h"  #include "filedialog.h" diff --git a/muse2/muse/osc.cpp b/muse2/muse/osc.cpp index 8b125a6c..2b567856 100644 --- a/muse2/muse/osc.cpp +++ b/muse2/muse/osc.cpp @@ -105,9 +105,13 @@ static int oscDebugHandler(const char* path, const char* types, lo_arg** argv,  int oscMessageHandler(const char* path, const char* types, lo_arg** argv,     int argc, void* data, void* user_data) +   //int argc, lo_message data, void* user_data)  {    const char* p = path; +  // NOTE: Tried this, always returns 0 sec and 1 fractional. Shame, looks like timestamps are not used. +  //lo_timetag lo_tt = lo_message_get_timestamp(data); +      #ifdef OSC_DEBUG     if(argc)     { diff --git a/muse2/muse/plugin.cpp b/muse2/muse/plugin.cpp index 7866bd39..e1abbb5e 100644 --- a/muse2/muse/plugin.cpp +++ b/muse2/muse/plugin.cpp @@ -38,6 +38,7 @@  #include <QHeaderView>  #include "globals.h" +#include "globaldefs.h"  #include "gconfig.h"  #include "filedialog.h"  #include "slider.h" @@ -578,6 +579,39 @@ void ladspaControlRange(const LADSPA_Descriptor* plugin, int i, float* min, floa              *max = 1.0;        } +/* +//--------------------------------------------------------- +//   PluginBase +//--------------------------------------------------------- + +//--------------------------------------------------------- +//   range +//--------------------------------------------------------- + +void PluginBase::range(unsigned long i, float* min, float* max) const +      { +      LADSPA_PortRangeHint range = plugin->PortRangeHints[i]; +      LADSPA_PortRangeHintDescriptor desc = range.HintDescriptor; +      if (desc & LADSPA_HINT_TOGGLED) { +            *min = 0.0; +            *max = 1.0; +            return; +            } +      float m = 1.0; +      if (desc & LADSPA_HINT_SAMPLE_RATE) +            m = float(sampleRate); + +      if (desc & LADSPA_HINT_BOUNDED_BELOW) +            *min =  range.LowerBound * m; +      else +            *min = 0.0; +      if (desc & LADSPA_HINT_BOUNDED_ABOVE) +            *max =  range.UpperBound * m; +      else +            *max = 1.0; +      } +*/ +  //---------------------------------------------------------  //   Plugin  //--------------------------------------------------------- @@ -859,6 +893,7 @@ int Plugin::incReferences(int val)  void Plugin::range(unsigned long i, float* min, float* max) const        { +      /*        LADSPA_PortRangeHint range = plugin->PortRangeHints[i];        LADSPA_PortRangeHintDescriptor desc = range.HintDescriptor;        if (desc & LADSPA_HINT_TOGGLED) { @@ -878,6 +913,8 @@ void Plugin::range(unsigned long i, float* min, float* max) const              *max =  range.UpperBound * m;        else              *max = 1.0; +      */       +      ladspaControlRange(plugin, i, min, max);  // p4.0.20        }  //--------------------------------------------------------- @@ -1464,6 +1501,17 @@ void Pipeline::apply(int ports, unsigned long nframes, float** buffer1)  //   PluginIBase  //--------------------------------------------------------- +PluginIBase::PluginIBase() +{ +  _gui = 0; +} +  +PluginIBase::~PluginIBase() +{ +  if(_gui) +    delete _gui; +}  +   QString PluginIBase::dssi_ui_filename() const   {     QString libr(lib()); @@ -1548,7 +1596,7 @@ void PluginI::init()        controlsOut       = 0;        controlPorts      = 0;        controlOutPorts   = 0; -      _gui              = 0; +      //_gui              = 0;        _on               = true;        initControlValues = false;        _showNativeGuiPending = false; @@ -1572,8 +1620,8 @@ PluginI::~PluginI()              deactivate();              _plugin->incReferences(-1);              } -      if (_gui) -            delete _gui; +      //if (_gui) +      //      delete _gui;        if (controlsOut)              delete[] controlsOut;        if (controls) @@ -2234,7 +2282,8 @@ bool PluginI::nativeGuiVisible()  //   makeGui  //--------------------------------------------------------- -void PluginI::makeGui() +//void PluginI::makeGui() +void PluginIBase::makeGui()        {        _gui = new PluginGui(this);        } @@ -2242,7 +2291,8 @@ void PluginI::makeGui()  //---------------------------------------------------------  //   deleteGui  //--------------------------------------------------------- -void PluginI::deleteGui() +//void PluginI::deleteGui() +void PluginIBase::deleteGui()  {    if(_gui)    { diff --git a/muse2/muse/plugin.h b/muse2/muse/plugin.h index f138737c..41da1bfb 100644 --- a/muse2/muse/plugin.h +++ b/muse2/muse/plugin.h @@ -61,6 +61,18 @@ class PluginLoader : public QUiLoader        PluginLoader(QObject * parent = 0) : QUiLoader(parent) {}  }; +/* +//--------------------------------------------------------- +//   PluginBase +//--------------------------------------------------------- + +class PluginBase  +{ +   protected: +      void range(unsigned long i, float*, float*) const; +}; +*/    +     //---------------------------------------------------------  //   Plugin  //--------------------------------------------------------- @@ -243,6 +255,7 @@ struct GuiWidgets {        };  class PluginI; +class PluginGui;  /*  class PluginBase  @@ -282,7 +295,14 @@ class PluginBase  class PluginIBase   { +   protected: +      PluginGui* _gui; + +      void makeGui(); +     public: +      PluginIBase();  +      ~PluginIBase();         virtual bool on() const = 0;               virtual void setOn(bool /*val*/) = 0;           virtual int pluginID() = 0; @@ -309,6 +329,11 @@ class PluginIBase        virtual const char* paramName(int /*i*/) = 0;             virtual LADSPA_PortRangeHint range(int /*i*/) = 0;         QString dssi_ui_filename() const; +       +      //virtual void showGui(bool) = 0;         // p4.0.20 +      //virtual void showNativeGui(bool) = 0;   // +      PluginGui* gui() const { return _gui; } +      void deleteGui();  };  //--------------------------------------------------------- @@ -381,7 +406,7 @@ class PluginI : public PluginIBase {        int controlPorts;        int controlOutPorts; -      PluginGui* _gui; +      ///PluginGui* _gui;        bool _on;        bool initControlValues;        QString _name; @@ -397,7 +422,7 @@ class PluginI : public PluginIBase {        bool _showNativeGuiPending;        void init(); -      void makeGui(); +      ///void makeGui();     public:        PluginI(); @@ -406,8 +431,8 @@ class PluginI : public PluginIBase {        Plugin* plugin() const { return _plugin; }        bool on() const        { return _on; }        void setOn(bool val)   { _on = val; } -      PluginGui* gui() const { return _gui; } -      void deleteGui(); +      ///PluginGui* gui() const { return _gui; } +      ///void deleteGui();        void setTrack(AudioTrack* t)  { _track = t; }        AudioTrack* track()           { return _track; } @@ -471,19 +496,11 @@ class PluginI : public PluginIBase {        double defaultValue(unsigned int param) const;        const char* paramName(int i)     { return _plugin->portName(controls[i].idx); }        LADSPA_PortDescriptor portd(int i) const { return _plugin->portd(controls[i].idx); } -      void range(int i, float* min, float* max) const { -            _plugin->range(controls[i].idx, min, max); -            } -      bool isAudioIn(int k) { -            return (_plugin->portd(k) & AUDIO_IN) == AUDIO_IN; -            } -      bool isAudioOut(int k) { -            return (_plugin->portd(k) & AUDIO_OUT) == AUDIO_OUT; -            } +      void range(int i, float* min, float* max) const { _plugin->range(controls[i].idx, min, max); } +      bool isAudioIn(int k) { return (_plugin->portd(k) & AUDIO_IN) == AUDIO_IN; } +      bool isAudioOut(int k) { return (_plugin->portd(k) & AUDIO_OUT) == AUDIO_OUT; }        bool inPlaceCapable() const { return _plugin->inPlaceCapable(); } -      LADSPA_PortRangeHint range(int i) { -            return _plugin->range(controls[i].idx); -            } +      LADSPA_PortRangeHint range(int i) { return _plugin->range(controls[i].idx); }        };  //--------------------------------------------------------- @@ -491,7 +508,7 @@ class PluginI : public PluginIBase {  //    chain of connected efx inserts  //--------------------------------------------------------- -const int PipelineDepth = 4; +//const int PipelineDepth = 4;  // Moved to globaldefs.h  class Pipeline : public std::vector<PluginI*> {        float* buffer[MAX_CHANNELS]; diff --git a/muse2/muse/remote/pyapi.cpp b/muse2/muse/remote/pyapi.cpp index 84543b18..29ea34b3 100644 --- a/muse2/muse/remote/pyapi.cpp +++ b/muse2/muse/remote/pyapi.cpp @@ -12,6 +12,7 @@  #include <QApplication>  #include "pyapi.h" +#include "globaldefs.h"  #include "song.h"  #include "tempo.h"  #include "track.h" diff --git a/muse2/muse/seqmsg.cpp b/muse2/muse/seqmsg.cpp index d2225190..564cce42 100644 --- a/muse2/muse/seqmsg.cpp +++ b/muse2/muse/seqmsg.cpp @@ -726,6 +726,20 @@ void Audio::msgShowInstrumentGui(MidiInstrument* instr, bool val)        }  //--------------------------------------------------------- +//   msgShowInstrumentNativeGui +//--------------------------------------------------------- + +void Audio::msgShowInstrumentNativeGui(MidiInstrument* instr, bool val) +      { +      instr->showNativeGui(val); +      AudioMsg msg; +      msg.id = MIDI_SHOW_INSTR_NATIVE_GUI; +      msg.p1 = instr; +      msg.a  = val; +      sendMessage(&msg, false); +      } + +//---------------------------------------------------------  //   msgAddTrack  //--------------------------------------------------------- diff --git a/muse2/muse/song.cpp b/muse2/muse/song.cpp index cf972b8c..dbb193d9 100644 --- a/muse2/muse/song.cpp +++ b/muse2/muse/song.cpp @@ -3431,6 +3431,8 @@ void Song::removeTrack1(Track* track)                  SynthI* si = (SynthI*)track;                  if(si->hasGui())                    si->showGui(false); +                if(si->hasNativeGui())       // p4.0.20 +                  si->showNativeGui(false);                  }                break;            default: diff --git a/muse2/muse/synth.cpp b/muse2/muse/synth.cpp index 13e3baa3..6212340f 100644 --- a/muse2/muse/synth.cpp +++ b/muse2/muse/synth.cpp @@ -61,23 +61,23 @@ const char* MessSynth::version() const        }  */ -bool MessSynthIF::guiVisible() const +bool MessSynthIF::nativeGuiVisible() const        { -      return _mess ? _mess->guiVisible() : false; +      return _mess ? _mess->nativeGuiVisible() : false;        } -void MessSynthIF::showGui(bool v) +void MessSynthIF::showNativeGui(bool v)        { -      if (v == guiVisible()) +      if (v == nativeGuiVisible())              return;        if (_mess) -            _mess->showGui(v); +            _mess->showNativeGui(v);        } -bool MessSynthIF::hasGui() const +bool MessSynthIF::hasNativeGui() const        {        if (_mess) -            return _mess->hasGui(); +            return _mess->hasNativeGui();        return false;        } @@ -107,6 +107,18 @@ void MessSynthIF::setGeometry(int x, int y, int w, int h)              _mess->setGeometry(x, y, w, h);        } +void MessSynthIF::getNativeGeometry(int* x, int* y, int* w, int* h) const +      { +      if (_mess) +            _mess->getNativeGeometry(x, y, w, h); +      } + +void MessSynthIF::setNativeGeometry(int x, int y, int w, int h) +      { +      if (_mess) +            _mess->setNativeGeometry(x, y, w, h); +      } +  //---------------------------------------------------------  //   findSynth  //    search for synthesizer base class @@ -658,6 +670,17 @@ void SynthI::write(int level, Xml& xml) const              getGeometry(&x, &y, &w, &h);              if (h || w)                    xml.qrectTag(level, "geometry", QRect(x, y, w, h)); +            //xml.geometryTag(level, "geometry", _gui); +            } + +      if (hasNativeGui()) { +            xml.intTag(level, "nativeGuiVisible", nativeGuiVisible()); +            int x, y, w, h; +            w = 0; +            h = 0; +            getNativeGeometry(&x, &y, &w, &h); +            if (h || w) +                  xml.qrectTag(level, "nativeGeometry", QRect(x, y, w, h));              }        _stringParamMap.write(level, xml, "stringParam"); @@ -745,7 +768,8 @@ void SynthI::read(Xml& xml)        int port = -1;        bool startgui = false; -      QRect r; +      bool startngui = false; +      QRect r, nr;        for (;;) {              Xml::Token token = xml.parse(); @@ -763,6 +787,8 @@ void SynthI::read(Xml& xml)                                port  = xml.parseInt();                          else if (tag == "guiVisible")                                startgui = xml.parseInt(); +                        else if (tag == "nativeGuiVisible") +                              startngui = xml.parseInt();                          else if (tag == "midistate")                                readMidiState(xml);                          else if (tag == "param") { @@ -775,6 +801,8 @@ void SynthI::read(Xml& xml)                                readProgram(xml, tag);                          else if (tag == "geometry")                                r = readGeometry(xml, tag); +                        else if (tag == "nativeGeometry") +                              nr = readGeometry(xml, tag);                          else if (AudioTrack::readProperties(xml, tag))                                xml.unknown("softSynth");                          break; @@ -795,11 +823,14 @@ void SynthI::read(Xml& xml)                                // No, initializing OSC without actually showing the gui doesn't work, at least for                                 //  dssi-vst plugins - without showing the gui they exit after ten seconds.                                //initGui(); -                              showGui(startgui); -                              setGeometry(r.x(), r.y(), r.width(), r.height()); +                              showNativeGui(startngui); +                              setNativeGeometry(nr.x(), nr.y(), nr.width(), nr.height());                                mapRackPluginsToControllers(); +                              showGui(startgui); +                              setGeometry(r.x(), r.y(), r.width(), r.height()); +                                                              // Now that the track has been added to the lists in insertTrack2(), if it's a dssi synth                                 //  OSC can find the track and its plugins, and start their native guis if required...                                showPendingPluginNativeGuis(); diff --git a/muse2/muse/synth.h b/muse2/muse/synth.h index f7d5d193..100d7bd6 100644 --- a/muse2/muse/synth.h +++ b/muse2/muse/synth.h @@ -120,8 +120,19 @@ class SynthIF {        virtual bool guiVisible() const = 0;        virtual void showGui(bool v) = 0;        virtual bool hasGui() const = 0; +      //virtual bool guiVisible() const { return false; } +      //virtual void showGui(bool v)    { }; +      //virtual bool hasGui() const     { return false; } +      virtual bool nativeGuiVisible() const = 0; +      virtual void showNativeGui(bool v) = 0; +      virtual bool hasNativeGui() const = 0; +      //virtual bool nativeGuiVisible() const { return false; } +      //virtual void showNativeGui(bool v) { }; +      //virtual bool hasNativeGui() const { return false; }        virtual void getGeometry(int*, int*, int*, int*) const = 0;        virtual void setGeometry(int, int, int, int) = 0; +      virtual void getNativeGeometry(int*, int*, int*, int*) const = 0; +      virtual void setNativeGeometry(int, int, int, int) = 0;        virtual void preProcessAlways() = 0;        virtual iMPEvent getData(MidiPort*, MPEventList*, iMPEvent, unsigned pos, int ports, unsigned n, float** buffer) = 0;        virtual bool putEvent(const MidiPlayEvent& ev) = 0; @@ -233,12 +244,21 @@ class SynthI : public AudioTrack, public MidiDevice,        bool guiVisible() const { return _sif->guiVisible(); }        void showGui(bool v)    { _sif->showGui(v); }        bool hasGui() const     { return _sif->hasGui(); } +      bool nativeGuiVisible() const { return _sif->nativeGuiVisible(); } +      void showNativeGui(bool v)    { _sif->showNativeGui(v); } +      bool hasNativeGui() const     { return _sif->hasNativeGui(); }        void getGeometry(int* x, int* y, int* w, int* h) const {              _sif->getGeometry(x, y, w, h);              }        void setGeometry(int x, int y, int w, int h) {              _sif->setGeometry(x, y, w, h);              } +      void getNativeGeometry(int* x, int* y, int* w, int* h) const { +            _sif->getNativeGeometry(x, y, w, h); +            } +      void setNativeGeometry(int x, int y, int w, int h) { +            _sif->setNativeGeometry(x, y, w, h); +            }        bool putEvent(const MidiPlayEvent& ev); @@ -267,13 +287,18 @@ class MessSynthIF : public SynthIF {        MessSynthIF(SynthI* s) : SynthIF(s) { _mess = 0; }        virtual ~MessSynthIF() { } -      virtual bool initGui()      { return true; }; -      virtual void guiHeartBeat()  {  } -      virtual bool guiVisible() const; -      virtual void showGui(bool v); -      virtual bool hasGui() const; +      virtual bool initGui()          { return true; } +      virtual void guiHeartBeat()     { } +      virtual bool guiVisible() const { return false; } +      virtual void showGui(bool)    { }; +      virtual bool hasGui() const     { return false; } +      virtual bool nativeGuiVisible() const; +      virtual void showNativeGui(bool v); +      virtual bool hasNativeGui() const;        virtual void getGeometry(int*, int*, int*, int*) const;        virtual void setGeometry(int, int, int, int); +      virtual void getNativeGeometry(int*, int*, int*, int*) const; +      virtual void setNativeGeometry(int, int, int, int);        virtual void preProcessAlways();        virtual iMPEvent getData(MidiPort*, MPEventList*, iMPEvent, unsigned pos, int ports, unsigned n, float** buffer);        virtual bool putEvent(const MidiPlayEvent& ev); diff --git a/muse2/muse/ticksynth.cpp b/muse2/muse/ticksynth.cpp index 69f3bf2d..c5d3a1e7 100644 --- a/muse2/muse/ticksynth.cpp +++ b/muse2/muse/ticksynth.cpp @@ -68,8 +68,14 @@ class MetronomeSynthIF : public SynthIF        virtual bool guiVisible() const { return false; }        virtual void showGui(bool) {}        virtual bool hasGui() const { return false; } -      virtual void getGeometry(int*, int*, int*, int*) const {} +      virtual bool nativeGuiVisible() const { return false; } +      virtual void showNativeGui(bool) { }; +      virtual bool hasNativeGui() const { return false; } +       +      virtual void getGeometry(int*x, int*y, int*w, int*h) const { *x=0;*y=0;*w=0;*h=0; }        virtual void setGeometry(int, int, int, int) {} +      virtual void getNativeGeometry(int*x, int*y, int*w, int*h) const { *x=0;*y=0;*w=0;*h=0; } +      virtual void setNativeGeometry(int, int, int, int) {}        virtual void preProcessAlways() { };        virtual iMPEvent getData(MidiPort*, MPEventList*, iMPEvent, unsigned pos, int ports, unsigned n, float** buffer);        virtual bool putEvent(const MidiPlayEvent& ev); diff --git a/muse2/muse/vst.cpp b/muse2/muse/vst.cpp index b34b71ca..7bcae7f6 100644 --- a/muse2/muse/vst.cpp +++ b/muse2/muse/vst.cpp @@ -361,7 +361,7 @@ void initVST()  //   guiVisible  //--------------------------------------------------------- -bool VstSynthIF::guiVisible() const +bool VstSynthIF::nativeGuiVisible() const        {        return _guiVisible;        } @@ -371,9 +371,9 @@ bool VstSynthIF::guiVisible() const  //   showGui  //--------------------------------------------------------- -void VstSynthIF::showGui(bool v) +void VstSynthIF::showNativeGui(bool v)        { -      if (v == guiVisible()) +      if (v == nativeGuiVisible())              return;        if (v)              fst_run_editor(_fst); @@ -395,7 +395,7 @@ MidiPlayEvent VstSynthIF::receiveEvent()  //   hasGui  //--------------------------------------------------------- -bool VstSynthIF::hasGui() const +bool VstSynthIF::hasNativeGui() const        {        return _fst->plugin->flags & effFlagsHasEditor;        } diff --git a/muse2/muse/vst.h b/muse2/muse/vst.h index 93012093..d41502e5 100644 --- a/muse2/muse/vst.h +++ b/muse2/muse/vst.h @@ -54,11 +54,16 @@ class VstSynthIF : public SynthIF        virtual bool initGui()       { return true; };        virtual void guiHeartBeat()  {  } -      virtual bool guiVisible() const; -      virtual void showGui(bool v); -      virtual bool hasGui() const; -      virtual void getGeometry(int*, int*, int*, int*) const {} +      virtual bool guiVisible() const { return false; } +      virtual void showGui(bool) {  } +      virtual bool hasGui() const { return false; } +      virtual bool nativeGuiVisible() const; +      virtual void showNativeGui(bool v); +      virtual bool hasNativeGui() const; +      virtual void getGeometry(int*x, int*y, int*w, int*h) const { *x=0;*y=0;*w=0;*h=0; }        virtual void setGeometry(int, int, int, int) {} +      virtual void getNativeGeometry(int*x, int*y, int*w, int*h) const { *x=0;*y=0;*w=0;*h=0; } +      virtual void setNativeGeometry(int, int, int, int) {}        virtual void preProcessAlways() { };        virtual iMPEvent getData(MidiPort*, MPEventList*, iMPEvent, unsigned pos, int ports, unsigned n, float** buffer) ;        virtual bool putEvent(const MidiPlayEvent& ev); diff --git a/muse2/muse/widgets/canvas.cpp b/muse2/muse/widgets/canvas.cpp index ff9d0c3b..596e4067 100644 --- a/muse2/muse/widgets/canvas.cpp +++ b/muse2/muse/widgets/canvas.cpp @@ -586,21 +586,14 @@ void Canvas::viewMousePressEvent(QMouseEvent* event)                                // Changed by T356. Alt is default reserved for moving the whole window in KDE. Changed to Shift-Alt.                                // Hmm, nope, shift-alt is also reserved sometimes. Must find a way to bypass,                                 //  why make user turn off setting? Left alone for now... -                              if (shift) +                              if (shift && !ctrl)                                      drag = DRAG_COPY_START;                                else if (alt) {                                      drag = DRAG_CLONE_START;                                      } -                              // -                              //if (shift) -                              //{ -                              //  if (alt) -                              //    drag = DRAG_CLONE_START; -                              //  else -                              //    drag = DRAG_COPY_START; -                              //}                                       else if (ctrl) { //Select all on the same pitch (e.g. same y-value) -                                    deselectAll(); +                                    if (!shift) +                                      deselectAll();                                      //printf("Yes, ctrl and press\n");                                      for (iCItem i = items.begin(); i != items.end(); ++i) {                                            if (i->second->y() == curItem->y() ) diff --git a/muse2/muse/widgets/genset.cpp b/muse2/muse/widgets/genset.cpp index 68405f9b..4a0550bb 100644 --- a/muse2/muse/widgets/genset.cpp +++ b/muse2/muse/widgets/genset.cpp @@ -83,7 +83,15 @@ GlobalSettingsConfig::GlobalSettingsConfig(QWidget* parent)        //DummyAudioDevice* dad = dynamic_cast<DummyAudioDevice*>(audioDevice);        //dummyAudioRealRate->setText(dad ? QString().setNum(sampleRate) : "---"); -      dummyAudioRealRate->setText(QString().setNum(sampleRate)); +      //dummyAudioRealRate->setText(QString().setNum(sampleRate));  // Not used any more. p4.0.20  +      // Just a record of what the gensetbase.ui file contained for dummyAudioRate whats this: +      /*  <property name="whatsThis"> +             <string>Actual rate used depends on limitations of + timer used. If a high rate timer is available, + short periods can be used with high sample rates.  +Period affects midi playback resolution.  +Shorter periods are desirable.</string> +            </property>                       */        startSongEntry->setText(config.startSong);        startSongGroup->button(config.startMode)->setChecked(true); @@ -188,7 +196,7 @@ void GlobalSettingsConfig::updateSettings()        //DummyAudioDevice* dad = dynamic_cast<DummyAudioDevice*>(audioDevice);        //dummyAudioRealRate->setText(dad ? QString().setNum(sampleRate) : "---"); -      dummyAudioRealRate->setText(QString().setNum(sampleRate)); +      //dummyAudioRealRate->setText(QString().setNum(sampleRate));   // Not used any more. p4.0.20         startSongEntry->setText(config.startSong);        startSongGroup->button(config.startMode)->setChecked(true); diff --git a/muse2/muse/widgets/gensetbase.ui b/muse2/muse/widgets/gensetbase.ui index cdbaea2c..e452de8b 100644 --- a/muse2/muse/widgets/gensetbase.ui +++ b/muse2/muse/widgets/gensetbase.ui @@ -23,7 +23,7 @@        </sizepolicy>       </property>       <property name="currentIndex"> -      <number>2</number> +      <number>0</number>       </property>       <widget class="QWidget" name="TabPage">        <attribute name="title"> @@ -774,7 +774,7 @@            <item row="0" column="0">             <widget class="QLabel" name="dummyAudioRateLabel">              <property name="text"> -             <string>Preferred sample rate</string> +             <string>Sample rate</string>              </property>              <property name="wordWrap">               <bool>false</bool> @@ -783,13 +783,6 @@            </item>            <item row="0" column="1">             <widget class="QSpinBox" name="dummyAudioRate"> -            <property name="whatsThis"> -             <string>Actual rate used depends on limitations of - timer used. If a high rate timer is available, - short periods can be used with high sample rates.  -Period affects midi playback resolution.  -Shorter periods are desirable.</string> -            </property>              <property name="suffix">               <string>Hz</string>              </property> @@ -808,26 +801,6 @@ Shorter periods are desirable.</string>             </widget>            </item>            <item row="1" column="0"> -           <widget class="QLabel" name="dummyAudioRealRateLabel"> -            <property name="text"> -             <string>Actual rate used now (dummy or not):</string> -            </property> -            <property name="wordWrap"> -             <bool>false</bool> -            </property> -           </widget> -          </item> -          <item row="1" column="1"> -           <widget class="QLabel" name="dummyAudioRealRate"> -            <property name="text"> -             <string>---</string> -            </property> -            <property name="wordWrap"> -             <bool>false</bool> -            </property> -           </widget> -          </item> -          <item row="2" column="0">             <widget class="QLabel" name="dummyAudioSizeLabel">              <property name="text">               <string>Period size (Frames per period):</string> @@ -837,8 +810,11 @@ Shorter periods are desirable.</string>              </property>             </widget>            </item> -          <item row="2" column="1"> +          <item row="1" column="1">             <widget class="QComboBox" name="dummyAudioSize"> +             <property name="toolTip"> +               <string>Shorter periods give better midi playback resolution.</string> +             </property>              <item>               <property name="text">                <string>16</string> | 
