diff options
| -rw-r--r-- | muse/muse/audio.cpp | 10 | ||||
| -rw-r--r-- | muse/muse/dssihost.cpp | 9 | ||||
| -rw-r--r-- | muse/muse/dssihost.h | 2 | ||||
| -rw-r--r-- | muse/muse/midiout.cpp | 1 | ||||
| -rw-r--r-- | muse/muse/midioutport.cpp | 152 | ||||
| -rw-r--r-- | muse/muse/muse.cpp | 2 | ||||
| -rw-r--r-- | muse/muse/synth.cpp | 32 | ||||
| -rw-r--r-- | muse/muse/synth.h | 14 | ||||
| -rw-r--r-- | muse/muse/ticksynth.cpp | 7 | ||||
| -rw-r--r-- | muse/muse/vst.cpp | 12 | ||||
| -rw-r--r-- | muse/muse/vst.h | 2 | ||||
| -rw-r--r-- | muse/synti/zynaddsubfx/main.cpp | 6 | 
12 files changed, 61 insertions, 188 deletions
| diff --git a/muse/muse/audio.cpp b/muse/muse/audio.cpp index beab01b8..19eac9e9 100644 --- a/muse/muse/audio.cpp +++ b/muse/muse/audio.cpp @@ -650,6 +650,9 @@ void Audio::seek(const Pos& p)        MidiOutPortList* ol = song->midiOutPorts();        for (iMidiOutPort i = ol->begin(); i != ol->end(); ++i)              (*i)->seek(_curTickPos, _pos.frame()); +      SynthIList* sl      = song->syntis(); +      for (iSynthI i = sl->begin(); i != sl->end(); ++i) +            (*i)->seek(_curTickPos, _pos.frame());        sendMsgToGui(MSG_SEEK);        } @@ -678,6 +681,9 @@ void Audio::startRolling()        MidiOutPortList* ol = song->midiOutPorts();        for (iMidiOutPort i = ol->begin(); i != ol->end(); ++i)              (*i)->start(); +      SynthIList* sl      = song->syntis(); +      for (iSynthI i = sl->begin(); i != sl->end(); ++i) +            (*i)->start();        if (precountEnableFlag           && song->click() @@ -721,6 +727,10 @@ void Audio::stopRolling()        MidiOutPortList* ol = song->midiOutPorts();        for (iMidiOutPort i = ol->begin(); i != ol->end(); ++i)              (*i)->stop(); +      SynthIList* sl      = song->syntis(); +      for (iSynthI i = sl->begin(); i != sl->end(); ++i) +            (*i)->stop(); +  	recording    = false;        endRecordPos = _pos;        _bounce = 0; diff --git a/muse/muse/dssihost.cpp b/muse/muse/dssihost.cpp index 906aab99..1c379ccb 100644 --- a/muse/muse/dssihost.cpp +++ b/muse/muse/dssihost.cpp @@ -396,7 +396,7 @@ void DssiSynthIF::write(Xml&) const  //   getData  //--------------------------------------------------------- -iMPEvent DssiSynthIF::getData(MPEventList* el, iMPEvent i, unsigned, int ch, unsigned samples, float** data) +void DssiSynthIF::getData(MPEventList* el, unsigned pos, int ch, unsigned samples, float** data)        {        const DSSI_Descriptor* dssi = synth->dssi;        const LADSPA_Descriptor* descr = dssi->LADSPA_Plugin; @@ -408,8 +408,13 @@ iMPEvent DssiSynthIF::getData(MPEventList* el, iMPEvent i, unsigned, int ch, uns        memset(events, 0, sizeof(events));        nevents = 0; +      int endPos = pos + samples; +      iMPEvent i = el->begin();        for (; i != el->end(); ++i, ++nevents) { +            if (i->time() >= endPos) +                  break;              MidiEvent e = *i; +                          int chn = e.channel();              int a   = e.dataA();              int b   = e.dataB(); @@ -449,6 +454,7 @@ iMPEvent DssiSynthIF::getData(MPEventList* el, iMPEvent i, unsigned, int ch, uns                          break;                    }              } +      el->erase(el->begin(), i);        for (int k = 0; k < ch; ++k)              descr->connect_port(handle, synth->oIdx[k], data[k]); @@ -459,7 +465,6 @@ iMPEvent DssiSynthIF::getData(MPEventList* el, iMPEvent i, unsigned, int ch, uns              snd_seq_event_t* ev = events;              synth->dssi->run_multiple_synths(1, &handle, samples, &ev, &nevents);              } -      return i;        }  //--------------------------------------------------------- diff --git a/muse/muse/dssihost.h b/muse/muse/dssihost.h index fecc833a..736621c3 100644 --- a/muse/muse/dssihost.h +++ b/muse/muse/dssihost.h @@ -102,7 +102,7 @@ class DssiSynthIF : public SynthIF        virtual bool hasGui() const { return synth->_hasGui; }        virtual void getGeometry(int*, int*, int*, int*) const {}        virtual void setGeometry(int, int, int, int) {} -      virtual iMPEvent getData(MPEventList*, iMPEvent, unsigned pos, int ports, unsigned n, float** buffer) ; +      virtual void getData(MPEventList*, unsigned pos, int ports, unsigned n, float** buffer) ;        virtual bool putEvent(const MidiEvent& ev);        virtual MidiEvent receiveEvent();        virtual int eventsPending() const { return 0; } diff --git a/muse/muse/midiout.cpp b/muse/muse/midiout.cpp index c499ba6b..788d7ace 100644 --- a/muse/muse/midiout.cpp +++ b/muse/muse/midiout.cpp @@ -343,7 +343,6 @@ void MidiOut::processMidi(MPEventList& el, unsigned fromTick, unsigned toTick, u                          }                    }              } -        for (int ch = 0; ch < MIDI_CHANNELS; ++ch)  {              MidiChannel* mc = channel(ch); diff --git a/muse/muse/midioutport.cpp b/muse/muse/midioutport.cpp index 3b5a8ba1..b024a4ec 100644 --- a/muse/muse/midioutport.cpp +++ b/muse/muse/midioutport.cpp @@ -373,158 +373,6 @@ void MidiOutPort::setInstrument(MidiInstrument* i)        emit instrumentChanged();        } -#if 0 //TODO -//--------------------------------------------------------- -//    seek -//--------------------------------------------------------- - -void MidiOutPort::seek(unsigned tickPos, unsigned framePos) -      { -      if (genMCSync && sendSync()) { -            int beat = (tickPos * 4) / config.division; -            sendStop(); -            sendSongpos(beat); -            sendContinue(); -            } -      if (mute()) -            return; - -//    if (pos == 0 && !song->record()) -//          audio->initDevices(); - -      //--------------------------------------------------- -      //    stop all notes -      //--------------------------------------------------- - -      for (iMPEvent i = _schedEvents.begin(); i != _schedEvents.end(); ++i) { -            MidiEvent ev = *i; -            if (ev.isNoteOff()) { -                  ev.setTime(framePos); -                  routeEvent(ev); -                  } -            } -      _schedEvents.clear(); - -      //--------------------------------------------------- -      //    set all controller -      //--------------------------------------------------- - -      for (int ch = 0; ch < MIDI_CHANNELS; ++ch) { -            MidiChannel* mc = channel(ch); -            if (mc->mute() || mc->noInRoute() || !mc->autoRead()) -                  continue; -            CtrlList* cll = mc->controller(); -            for (iCtrl ivl = cll->begin(); ivl != cll->end(); ++ivl) { -                  Ctrl* c   = ivl->second; -                  int val = c->value(tickPos).i; -                  if (val != CTRL_VAL_UNKNOWN && val != c->curVal().i) { -                        routeEvent(MidiEvent(0, ch, ME_CONTROLLER, c->id(), val)); -                        } -                  } -            } -      } - -//--------------------------------------------------------- -//   stop -//--------------------------------------------------------- - -void MidiOutPort::stop() -      { -      int frame = AL::tempomap.tick2frame(audio->curTickPos()); - -      //--------------------------------------------------- -      //    stop all notes -      //--------------------------------------------------- - -      for (iMPEvent i = _schedEvents.begin(); i != _schedEvents.end(); ++i) { -            MidiEvent ev = *i; -            if (ev.isNoteOff()) { -                  ev.setTime(frame); -                  routeEvent(ev); -                  } -            } -      _schedEvents.clear(); - -      //--------------------------------------------------- -      //    reset sustain -      //--------------------------------------------------- - -      for (int ch = 0; ch < MIDI_CHANNELS; ++ch) { -            MidiChannel* mc = channel(ch); -            if (mc->noInRoute()) -                  continue; -            if (mc->hwCtrlState(CTRL_SUSTAIN) != CTRL_VAL_UNKNOWN) { -                  MidiEvent ev(0, 0, ME_CONTROLLER, CTRL_SUSTAIN, 0); -                  ev.setChannel(mc->channelNo()); -                  routeEvent(ev); -                  } -            } - -      if (sendSync()) { -            if (genMMC) { -                  unsigned char mmcPos[] = { -                        0x7f, 0x7f, 0x06, 0x44, 0x06, 0x01, -                        0, 0, 0, 0, 0 -                        }; -                  MTC mtc(double(frame) / double(AL::sampleRate)); -                  mmcPos[6] = mtc.h() | (AL::mtcType << 5); -                  mmcPos[7] = mtc.m(); -                  mmcPos[8] = mtc.s(); -                  mmcPos[9] = mtc.f(); -                  mmcPos[10] = mtc.sf(); -//TODO                  sendSysex(mmcStopMsg, sizeof(mmcStopMsg)); -//                  sendSysex(mmcPos, sizeof(mmcPos)); -                  } -            if (genMCSync) {         // Midi Clock -                  // send STOP and -                  // "set song position pointer" -//                  sendStop(); -//                  sendSongpos(audio->curTickPos() * 4 / config.division); -                  } -            } -      } - -//--------------------------------------------------------- -//   start -//--------------------------------------------------------- - -void MidiOutPort::start() -      { -      if (!(genMMC || genMCSync)) -            return; -      if (!sendSync()) -            return; -      if (genMMC) -            sendSysex(mmcDeferredPlayMsg, sizeof(mmcDeferredPlayMsg)); -      if (genMCSync) { -            if (audio->curTickPos()) -                  sendContinue(); -            else -                  sendStart(); -            } -      } - -//--------------------------------------------------------- -//   reset -//--------------------------------------------------------- - -void MidiOutPort::reset() -      { -/* TODO -      MidiEvent ev; -      ev.setType(0x90); -      for (int chan = 0; chan < MIDI_CHANNELS; ++chan) { -            ev.setChannel(chan); -            for (int pitch = 0; pitch < 128; ++pitch) { -                  ev.setA(pitch); -                  ev.setB(0); -                  mp->putEvent(ev); -                  } -            } -*/ -      } -#endif -  #if 0  //---------------------------------------------------------  //   processMidiClock diff --git a/muse/muse/muse.cpp b/muse/muse/muse.cpp index 36e25c06..35260aff 100644 --- a/muse/muse/muse.cpp +++ b/muse/muse/muse.cpp @@ -1263,6 +1263,8 @@ void MusE::loadProject1(const QString& path)                    if (ctrl->type() & Ctrl::INT) {                          CVal val;                          val = ctrl->curVal(); +                        if (track->isMidiTrack() && val.i == CTRL_VAL_UNKNOWN) +                              continue;                          ctrl->setCurVal(CTRL_VAL_UNKNOWN);                          song->setControllerVal(track, ctrl, val);                          } diff --git a/muse/muse/synth.cpp b/muse/muse/synth.cpp index 12c3ba21..732fdaf7 100644 --- a/muse/muse/synth.cpp +++ b/muse/muse/synth.cpp @@ -188,7 +188,7 @@ SynthI::SynthI()        _sif        = 0;        // setVolume(1.0);        // setPan(0.0); -      _instrument = genericMidiInstrument;      //TODO +      _instrument = this;        for (int ch = 0; ch < MIDI_CHANNELS; ++ch)              _channel[ch] = new MidiChannel(this, ch);        } @@ -256,7 +256,7 @@ bool SynthI::initInstance(Synth* s)        synthesizer = s;        _sif        = s->createSIF(this); -      _instrument->setIName(name());   // set instrument name +      setIName(name());   // set instrument name        AudioTrack::setChannels(_sif->channels());        //--------------------------------------------------- @@ -264,7 +264,7 @@ bool SynthI::initInstance(Synth* s)        //---------------------------------------------------        int id = 0; -      MidiControllerList* cl = _instrument->controller(); +      MidiControllerList* cl = MidiInstrument::controller();        for (;;) {              const char* name;              int ctrl; @@ -277,7 +277,7 @@ bool SynthI::initInstance(Synth* s)              cl->push_back(c);              } -      EventList* iel = _instrument->midiState(); +      EventList* iel = midiState();        if (!iel->empty()) {              for (iEvent i = iel->begin(); i != iel->end(); ++i) {                    Event ev = i->second; @@ -321,7 +321,7 @@ int MessSynthIF::getControllerInfo(int id, const char** name, int* ctrl, int* mi  void SynthI::deactivate2()        { -      removeMidiInstrument(_instrument); +      removeMidiInstrument(this);        }  //--------------------------------------------------------- @@ -453,7 +453,7 @@ void SynthI::read(QDomNode node)              else if (e.tagName() == "guiVisible")                    startGui = e.text().toInt();              else if (e.tagName() == "midistate") -                  _instrument->readMidiState(node.firstChild()); +                  readMidiState(node.firstChild());              else if (e.tagName() == "param") {                    float val = e.text().toFloat();                    initParams.push_back(val); @@ -532,7 +532,7 @@ void MessSynthIF::populatePatchPopup(QMenu* menu, int ch)  //   getData  //--------------------------------------------------------- -iMPEvent MessSynthIF::getData(MPEventList* el, iMPEvent i, unsigned pos, int ports, unsigned n, float** buffer) +void MessSynthIF::getData(MPEventList* el, unsigned pos, int ports, unsigned n, float** buffer)        {        // Reset buffers first        for (int port = 0; port < ports; ++port) @@ -545,6 +545,7 @@ iMPEvent MessSynthIF::getData(MPEventList* el, iMPEvent i, unsigned pos, int por        int endPos = pos + n;        if (ports >= channels()) { +            iMPEvent i = el->begin();              for (; i != el->end(); ++i) {                    int frame = i->time();                    if (frame >= endPos) @@ -559,6 +560,7 @@ iMPEvent MessSynthIF::getData(MPEventList* el, iMPEvent i, unsigned pos, int por              if (endPos - curPos > 0) {                    _mess->process(buffer, curPos-pos, endPos - curPos);                    } +            el->erase(el->begin(), i);              }        else {              // this happens if the synth has stereo and we switch the @@ -567,7 +569,6 @@ iMPEvent MessSynthIF::getData(MPEventList* el, iMPEvent i, unsigned pos, int por              printf("MessSynthIF::getData - ports %d < channels %d\n",                  ports, channels());              } -      return i;        }  //--------------------------------------------------------- @@ -577,9 +578,10 @@ iMPEvent MessSynthIF::getData(MPEventList* el, iMPEvent i, unsigned pos, int por  bool MessSynthIF::putEvent(const MidiEvent& ev)        { -// printf("put event %x %x %x\n", ev.type(), ev.dataA(), ev.dataB()); -      if (midiOutputTrace) +      if (midiOutputTrace) { +            printf("<%s>", synti->name().toLatin1().data());              ev.dump(); +            }        if (_mess)              return _mess->processEvent(ev);        return true; @@ -592,12 +594,8 @@ bool MessSynthIF::putEvent(const MidiEvent& ev)  void SynthI::collectInputData()        {        bufferEmpty = false; -      while (!eventFifo.isEmpty()) -            _schedEvents.add(eventFifo.get()); -      iMPEvent ie = _schedEvents.begin();        unsigned pos = audio->pos().frame(); -      _sif->getData(&_schedEvents, ie, pos, channels(), segmentSize, buffer); -      _schedEvents.clear(); +      _sif->getData(&_schedEvents, pos, channels(), segmentSize, buffer);        }  //------------------------------------------------------------------- @@ -606,9 +604,6 @@ void SynthI::collectInputData()  //    into _schedEvents queue. For note on events create the proper  //    note off events. The note off events maybe played after the  //    current process cycle. -//    From _schedEvents queue copy all events for the current cycle -//    to all output routes. Events routed to ALSA go into the  -//    _playEvents queue which is processed by the MidiSeq thread.  //-------------------------------------------------------------------  void SynthI::processMidi(unsigned fromTick, unsigned toTick, unsigned fromFrame, unsigned toFrame) @@ -617,3 +612,4 @@ void SynthI::processMidi(unsigned fromTick, unsigned toTick, unsigned fromFrame,              return;        MidiOut::processMidi(_schedEvents, fromTick, toTick, fromFrame, toFrame);        } + diff --git a/muse/muse/synth.h b/muse/muse/synth.h index 460cee2f..dfbbabc4 100644 --- a/muse/muse/synth.h +++ b/muse/muse/synth.h @@ -22,7 +22,7 @@  #define __SYNTH_H__  #include "globals.h" -// #include "instruments/minstrument.h" +#include "instruments/minstrument.h"  #include "audiotrack.h"  #include "midiout.h" @@ -94,7 +94,7 @@ class SynthIF {        virtual bool hasGui() const = 0;        virtual void getGeometry(int*, int*, int*, int*) const = 0;        virtual void setGeometry(int, int, int, int) = 0; -      virtual iMPEvent getData(MPEventList*, iMPEvent, unsigned pos, int ports, unsigned n, float** buffer) = 0; +      virtual void getData(MPEventList*, unsigned pos, int ports, unsigned n, float** buffer) = 0;        virtual bool putEvent(const MidiEvent& ev) = 0;        virtual MidiEvent receiveEvent() = 0;        virtual int eventsPending() const = 0; @@ -115,10 +115,10 @@ class SynthIF {  //    MidiInstrument  //--------------------------------------------------------- -class SynthI : public AudioTrack, public MidiOut +class SynthI : public AudioTrack, public MidiOut, public MidiInstrument        {        Q_OBJECT - +              SynthIF* _sif;     protected: @@ -167,8 +167,8 @@ class SynthI : public AudioTrack, public MidiOut        void setGeometry(int x, int y, int w, int h) {              _sif->setGeometry(x, y, w, h);              } -      MidiEvent receiveEvent() 	{ return _sif->receiveEvent(); } -      int eventsPending() const    	{ return _sif->eventsPending(); } +      MidiEvent receiveEvent() 	   { return _sif->receiveEvent(); } +      int eventsPending() const    	   { return _sif->eventsPending(); }        void deactivate2();        void deactivate3();        bool isActivated() const         { return synthesizer && _sif; } @@ -193,7 +193,7 @@ class MessSynthIF : public SynthIF {        virtual bool hasGui() const;        virtual void getGeometry(int*, int*, int*, int*) const;        virtual void setGeometry(int, int, int, int); -      virtual iMPEvent getData(MPEventList*, iMPEvent, unsigned pos, int ports, unsigned n, float** buffer); +      virtual void getData(MPEventList*, unsigned pos, int ports, unsigned n, float** buffer);        virtual bool putEvent(const MidiEvent& ev);        virtual MidiEvent receiveEvent();        virtual int eventsPending() const; diff --git a/muse/muse/ticksynth.cpp b/muse/muse/ticksynth.cpp index 472cadc4..fd3dbb16 100644 --- a/muse/muse/ticksynth.cpp +++ b/muse/muse/ticksynth.cpp @@ -69,7 +69,7 @@ class MetronomeSynthIF : public SynthIF        virtual bool hasGui() const { return false; }        virtual void getGeometry(int*, int*, int*, int*) const {}        virtual void setGeometry(int, int, int, int) {} -      virtual iMPEvent getData(MPEventList*, iMPEvent, unsigned pos, int ports, unsigned n, float** buffer); +      virtual void getData(MPEventList*, unsigned pos, int ports, unsigned n, float** buffer);        virtual bool putEvent(const MidiEvent& ev);        virtual MidiEvent receiveEvent() { return MidiEvent(); }        virtual int eventsPending() const { return 0; } @@ -89,12 +89,13 @@ class MetronomeSynthIF : public SynthIF  //   getData  //--------------------------------------------------------- -iMPEvent MetronomeSynthIF::getData(MPEventList* el, iMPEvent i, unsigned pos, int/*ports*/, unsigned n, float** buffer) +void MetronomeSynthIF::getData(MPEventList* el, unsigned pos, int/*ports*/, unsigned n, float** buffer)        {        unsigned curPos      = pos;        unsigned endPos      = pos + n;        unsigned off         = pos; +      iMPEvent i = el->begin();        for (; i != el->end(); ++i) {              unsigned frame = i->time();              if (frame >= endPos) @@ -110,7 +111,7 @@ iMPEvent MetronomeSynthIF::getData(MPEventList* el, iMPEvent i, unsigned pos, in              }        if (endPos - curPos)              process(buffer, curPos - off, endPos - curPos); -      return el->end(); +      el->erase(el->begin(), i);        }  //--------------------------------------------------------- diff --git a/muse/muse/vst.cpp b/muse/muse/vst.cpp index b38fa569..89a66a06 100644 --- a/muse/muse/vst.cpp +++ b/muse/muse/vst.cpp @@ -809,10 +809,17 @@ void VstSynthIF::write(Xml& xml) const  //   getData  //--------------------------------------------------------- -iMPEvent VstSynthIF::getData(MPEventList* el, iMPEvent i, unsigned /*pos*/, int ports, unsigned n, float** buffer) +void VstSynthIF::getData(MPEventList* el, unsigned pos, int ports, unsigned n, float** buffer)        { -      for (; i != el->end(); ++i) +      int endPos = pos + n; +      iMPEvent i = el->begin(); +      for (; i != el->end(); ++i) { +            if (i->time() >= endPos) +                  break;              putEvent(*i); +            } +      el->erase(el->begin(), i); +        int outputs = _fst->numOutputs();        if (ports < outputs) {              float* ob[outputs]; @@ -840,7 +847,6 @@ iMPEvent VstSynthIF::getData(MPEventList* el, iMPEvent i, unsigned /*pos*/, int                    _fst->process(0, buffer, n);                    }              } -      return el->end();        }  //--------------------------------------------------------- diff --git a/muse/muse/vst.h b/muse/muse/vst.h index 714dff15..6413d69f 100644 --- a/muse/muse/vst.h +++ b/muse/muse/vst.h @@ -101,7 +101,7 @@ class VstSynthIF : public SynthIF        virtual bool hasGui() const;        virtual void getGeometry(int*, int*, int*, int*) const {}        virtual void setGeometry(int, int, int, int) {} -      virtual iMPEvent getData(MPEventList*, iMPEvent, unsigned pos, int ports, unsigned n, float** buffer) ; +      virtual void getData(MPEventList*, unsigned pos, int ports, unsigned n, float** buffer) ;        virtual bool putEvent(const MidiEvent& ev);        virtual MidiEvent receiveEvent();        virtual int eventsPending() const { return 0; } diff --git a/muse/synti/zynaddsubfx/main.cpp b/muse/synti/zynaddsubfx/main.cpp index 2d53ca0d..4f7f8820 100644 --- a/muse/synti/zynaddsubfx/main.cpp +++ b/muse/synti/zynaddsubfx/main.cpp @@ -102,6 +102,8 @@ Zynadd::Zynadd() : Mess(2)        vmaster           = new Master();        vmaster->swaplr = swaplr; +      vmaster->bank.rescanforbanks(); +      vmaster->defaults();        pthread_create(&thr, NULL, guiThread, this);        } @@ -224,6 +226,10 @@ bool Zynadd::processEvent(const MidiEvent& e)                                {                                int bank = (e.dataB() >> 8) + 1;                                if (bank != currentBank) { +                                    if (vmaster->bank.banks[bank].dir == 0) { +                                          printf("Zynaddsubfx: empty bank %d\n", bank); +                                          return false; +                                          }                                      vmaster->bank.loadbank(vmaster->bank.banks[bank].dir);                                      currentBank = bank;                                      } | 
