diff options
author | Florian Jung <flo@windfisch.org> | 2012-03-15 18:21:23 +0000 |
---|---|---|
committer | Florian Jung <flo@windfisch.org> | 2012-03-15 18:21:23 +0000 |
commit | 27b7bf6815cda7abb67026c37b3e44daee1803cb (patch) | |
tree | 0b9d1c0bc84ac7ff8032e707f2b5fb4e0aaabb5c /muse2/muse/synth.cpp | |
parent | 2d6f113a10eb485694e20a78500f650776d701e3 (diff) |
merged with trunk
Diffstat (limited to 'muse2/muse/synth.cpp')
-rw-r--r-- | muse2/muse/synth.cpp | 137 |
1 files changed, 31 insertions, 106 deletions
diff --git a/muse2/muse/synth.cpp b/muse2/muse/synth.cpp index 7ab18bda..cf065bbb 100644 --- a/muse2/muse/synth.cpp +++ b/muse2/muse/synth.cpp @@ -33,7 +33,6 @@ #include <QDir> #include <QString> -//#include <QMenu> #include "app.h" #include "arranger.h" @@ -50,7 +49,6 @@ #include "audio.h" #include "midiseq.h" #include "midictrl.h" -//#include "stringparam.h" #include "popupmenu.h" #include "globaldefs.h" @@ -76,26 +74,6 @@ Synth::Type string2SynthType(const QString& type) return Synth::SYNTH_TYPE_END; } -/* -//--------------------------------------------------------- -// description -//--------------------------------------------------------- - -const char* MessSynth::description() const - { - return _descr ? _descr->description : ""; - } - -//--------------------------------------------------------- -// version -//--------------------------------------------------------- - -const char* MessSynth::version() const - { - return _descr ? _descr->version : ""; - } -*/ - bool MessSynthIF::nativeGuiVisible() const { return _mess ? _mess->nativeGuiVisible() : false; @@ -186,7 +164,6 @@ static SynthI* createSynthInstance(const QString& sclass, const QString& label, si = new SynthI(); QString n; n.setNum(s->instances()); - //QString instance_name = s->baseName() + "-" + n; QString instance_name = s->name() + "-" + n; if (si->initInstance(s, instance_name)) { @@ -203,10 +180,6 @@ static SynthI* createSynthInstance(const QString& sclass, const QString& label, // Synth //--------------------------------------------------------- -//Synth::Synth(const QFileInfo& fi) -// : info(fi) -//Synth::Synth(const QFileInfo& fi, QString label) -// : info(fi), _name(label) Synth::Synth(const QFileInfo& fi, QString label, QString descr, QString maker, QString ver) : info(fi), _name(label), _description(descr), _maker(maker), _version(ver) { @@ -217,15 +190,10 @@ Synth::Synth(const QFileInfo& fi, QString label, QString descr, QString maker, Q // instantiate //--------------------------------------------------------- -//void* MessSynth::instantiate() void* MessSynth::instantiate(const QString& instanceName) { ++_instances; - //QString n; - //n.setNum(_instances); - //QString instanceName = baseName() + "-" + n; - MusEGlobal::doSetuid(); QByteArray ba = info.filePath().toLatin1(); const char* path = ba.constData(); @@ -326,13 +294,17 @@ void SynthI::close() //--------------------------------------------------------- bool SynthI::putEvent(const MidiPlayEvent& ev) -//bool SynthI::putMidiEvent(const MidiPlayEvent& ev) { if(_writeEnable) + { + if (MusEGlobal::midiOutputTrace) + { + printf("MidiOut: Synth: <%s>: ", name().toLatin1().constData()); + ev.dump(); + } return _sif->putEvent(ev); - - // Hmm, act as if the event went through? - //return true; + } + return false; } @@ -373,10 +345,8 @@ void SynthI::currentProg(unsigned long *prog, unsigned long *bankL, unsigned lon // init //--------------------------------------------------------- -//bool MessSynthIF::init(Synth* s) bool MessSynthIF::init(Synth* s, SynthI* si) { - //_mess = (Mess*)s->instantiate(); _mess = (Mess*)((MessSynth*)s)->instantiate(si->name()); return (_mess == 0); @@ -397,11 +367,8 @@ int MessSynthIF::totalInChannels() const return 0; } -//SynthIF* MessSynth::createSIF() const SynthIF* MessSynth::createSIF(SynthI* si) { - //return new MessSynthIF(si); - MessSynthIF* sif = new MessSynthIF(si); sif->init(this, si); return sif; @@ -415,17 +382,11 @@ SynthIF* MessSynth::createSIF(SynthI* si) bool SynthI::initInstance(Synth* s, const QString& instanceName) { synthesizer = s; - //sif = s->createSIF(); - //_sif = s->createSIF(this); - - //sif->init(s); setName(instanceName); // set midi device name setIName(instanceName); // set instrument name _sif = s->createSIF(this); - // p3.3.38 - //AudioTrack::setChannels(_sif->channels()); AudioTrack::setTotalOutChannels(_sif->totalOutChannels()); AudioTrack::setTotalInChannels(_sif->totalInChannels()); @@ -442,10 +403,8 @@ bool SynthI::initInstance(Synth* s, const QString& instanceName) int max; int initval = CTRL_VAL_UNKNOWN; id = _sif->getControllerInfo(id, &name, &ctrl, &min, &max, &initval); -// printf("looking for params\n"); if (id == 0) break; -// printf("got parameter:: %s\n", name); // Added by T356. Override existing program controller. @@ -543,8 +502,8 @@ void SynthI::deactivate2() void SynthI::deactivate3() { _sif->deactivate3(); - // Moved below by Tim. p3.3.14 - //synthesizer->incInstances(-1); + + //synthesizer->incInstances(-1); // Moved below by Tim. p3.3.14 if(MusEGlobal::debugMsg) printf("SynthI::deactivate3 deleting _sif...\n"); @@ -596,17 +555,13 @@ void initMidiSynth() while(it!=list.end()) { fi = &*it; - //MusEGlobal::doSetuid(); QByteArray ba = fi->filePath().toLatin1(); const char* path = ba.constData(); // load Synti dll - //printf("initMidiSynth: dlopen file:%s name:%s desc:%s\n", fi->filePath().toLatin1().constData(), QString(descr->name), QString(descr->description), QString(""), QString(descr->version))); void* handle = dlopen(path, RTLD_NOW); if (handle == 0) { fprintf(stderr, "initMidiSynth: MESS dlopen(%s) failed: %s\n", path, dlerror()); - //MusEGlobal::undoSetuid(); - //return 0; ++it; continue; } @@ -622,8 +577,6 @@ void initMidiSynth() "library file \"%s\": %s.\n" "Are you sure this is a MESS plugin file?\n", path, txt); - //MusEGlobal::undoSetuid(); - //return 0; } #endif dlclose(handle); @@ -633,19 +586,11 @@ void initMidiSynth() const MESS* descr = msynth(); if (descr == 0) { fprintf(stderr, "initMidiSynth: no MESS descr found in %s\n", path); - //MusEGlobal::undoSetuid(); - //return 0; dlclose(handle); ++it; continue; } - //Mess* mess = descr->instantiate(MusEGlobal::sampleRate, muse, &museProject, instanceName.toLatin1().constData()); - //MusEGlobal::undoSetuid(); - - - - //MusEGlobal::synthis.push_back(new MessSynth(*fi)); MusEGlobal::synthis.push_back(new MessSynth(*fi, QString(descr->name), QString(descr->description), QString(""), QString(descr->version))); dlclose(handle); @@ -665,38 +610,29 @@ void initMidiSynth() SynthI* Song::createSynthI(const QString& sclass, const QString& label, Synth::Type type, Track* insertAt) { - //printf("Song::createSynthI calling ::createSynthI class:%s\n", sclass.toLatin1().constData()); - SynthI* si = createSynthInstance(sclass, label, type); if(!si) return 0; - //printf("Song::createSynthI created SynthI. Before insertTrack1...\n"); int idx = insertAt ? _tracks.index(insertAt) : -1; insertTrack1(si, idx); - //printf("Song::createSynthI after insertTrack1. Before msgInsertTrack...\n"); msgInsertTrack(si, idx, true); // add to instance list - //printf("Song::createSynthI after msgInsertTrack. Before insertTrack3...\n"); insertTrack3(si, idx); - //printf("Song::createSynthI after insertTrack3. Adding default routes...\n"); - OutputList* ol = MusEGlobal::song->outputs(); // add default route to master (first audio output) if (!ol->empty()) { AudioOutput* ao = ol->front(); - // p3.3.38 - //MusEGlobal::audio->msgAddRoute(Route(si, -1), Route(ao, -1)); - //MusEGlobal::audio->msgAddRoute(Route((AudioTrack*)si, -1), Route(ao, -1)); // Make sure the route channel and channels are valid. MusEGlobal::audio->msgAddRoute(Route((AudioTrack*)si, 0, ((AudioTrack*)si)->channels()), Route(ao, 0, ((AudioTrack*)si)->channels())); MusEGlobal::audio->msgUpdateSoloStates(); } + // DELETETHIS 5 // Now that the track has been added to the lists in insertTrack2(), // if it's a dssi synth, OSC can find the synth, and initialize (and show) its native gui. // No, initializing OSC without actually showing the gui doesn't work, at least for @@ -714,7 +650,6 @@ void SynthI::write(int level, Xml& xml) const { xml.tag(level++, "SynthI"); AudioTrack::writeProperties(level, xml); - //xml.intTag(level, "synthType", synth()->synthType()); xml.strTag(level, "synthType", synthType2String(synth()->synthType())); xml.strTag(level, "class", synth()->baseName()); @@ -739,7 +674,6 @@ 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()) { @@ -851,7 +785,6 @@ void SynthI::read(Xml& xml) return; case Xml::TagStart: if (tag == "synthType") - //type = xml.parseInt(); type = string2SynthType(xml.parse1()); else if (tag == "class") sclass = xml.parse1(); @@ -900,6 +833,7 @@ void SynthI::read(Xml& xml) if (port != -1 && port < MIDI_PORTS) MusEGlobal::midiPorts[port].setMidiDevice(this); + // DELETETHIS 5 // Now that the track has been added to the lists in insertTrack2(), // if it's a dssi synth, OSC can find the synth, and initialize (and show) its native gui. // No, initializing OSC without actually showing the gui doesn't work, at least for @@ -934,7 +868,6 @@ const char* MessSynthIF::getPatchName(int channel, int prog, MType type, bool dr { if (_mess) { - //return _mess->getPatchName(channel, prog, type, drum); const char* s = _mess->getPatchName(channel, prog, type, drum); if(s) return s; @@ -953,7 +886,7 @@ void MessSynthIF::populatePatchPopup(MusEGui::PopupMenu* menu, int ch, MType, bo while (mp) { int id = ((mp->hbank & 0xff) << 16) + ((mp->lbank & 0xff) << 8) + mp->prog; - /* + /* DELETETHIS 9 int pgid = ((mp->hbank & 0xff) << 8) | (mp->lbank & 0xff) | 0x40000000; int itemnum = menu->indexOf(pgid); if(itemnum == -1) @@ -997,10 +930,10 @@ void SynthI::preProcessAlways() if(off()) { // Clear any accumulated play events. - //playEvents()->clear(); + //playEvents()->clear(); DELETETHIS _playEvents.clear(); // Eat up any fifo events. - //while(!eventFifo.isEmpty()) + //while(!eventFifo.isEmpty()) DELETETHIS // eventFifo.get(); eventFifo.clear(); // Clear is the same but faster AND safer, right? } @@ -1023,26 +956,18 @@ bool SynthI::getData(unsigned pos, int ports, unsigned n, float** buffer) int p = midiPort(); MidiPort* mp = (p != -1) ? &MusEGlobal::midiPorts[p] : 0; - //MPEventList* el = playEvents(); - ///iMPEvent ie = nextPlayEvent(); - //iMPEvent ie = el->begin(); // p4.0.15 Tim. iMPEvent ie = _playEvents.begin(); - - //ie = _sif->getData(mp, el, ie, pos, ports, n, buffer); ie = _sif->getData(mp, &_playEvents, ie, pos, ports, n, buffer); - ///setNextPlayEvent(ie); // p4.0.15 We are done with these events. Let us erase them here instead of Audio::processMidi. // That way we can simply set the next play event to the beginning. // This also allows other events to be inserted without the problems caused by the next play event // being at the 'end' iterator and not being *easily* set to some new place beginning of the newer insertions. // The way that MPEventList sorts made it difficult to predict where the iterator of the first newly inserted items was. // The erasure in Audio::processMidi was missing some events because of that. - //el->erase(el->begin(), ie); _playEvents.erase(_playEvents.begin(), ie); - // setNextPlayEvent(el->begin()); // Removed p4.0.15 return true; } @@ -1057,22 +982,17 @@ iMPEvent MessSynthIF::getData(MidiPort* mp, MPEventList* el, iMPEvent i, unsigne for (; i != el->end(); ++i) { int evTime = i->time(); - if (evTime == 0) { - // printf("MessSynthIF::getData - time is 0!\n"); - // continue; + if (evTime == 0) evTime=abs(frameOffset); // will cause frame to be zero, problem? - } + int frame = evTime - abs(frameOffset); - if (frame >= endPos) { - printf("frame > endPos!! frame = %d >= endPos %d, i->time() %d, frameOffset %d curPos=%d\n", frame, endPos, i->time(), frameOffset,curPos); - continue; - } + if (frame >= endPos) { + printf("frame > endPos!! frame = %d >= endPos %d, i->time() %d, frameOffset %d curPos=%d\n", frame, endPos, i->time(), frameOffset,curPos); + continue; + } if (frame > curPos) { - //willyfoobar-2011-02-13 - //!!! comparison of signed with unsigened - //old code//if (frame < pos) if (frame < (int) pos) printf("should not happen: missed event %d\n", pos -frame); else @@ -1085,14 +1005,16 @@ iMPEvent MessSynthIF::getData(MidiPort* mp, MPEventList* el, iMPEvent i, unsigne } } curPos = frame; - } + } + if (mp) mp->sendEvent(*i); else { if (putEvent(*i)) break; - } } + } + if (endPos - curPos) { if (!_mess) @@ -1112,14 +1034,17 @@ iMPEvent MessSynthIF::getData(MidiPort* mp, MPEventList* el, iMPEvent i, unsigne bool MessSynthIF::putEvent(const MidiPlayEvent& ev) { - if (MusEGlobal::midiOutputTrace) - ev.dump(); + //if (MusEGlobal::midiOutputTrace) DELETETHIS or re-enable? + //{ + // printf("MidiOut: MESS: <%s>: ", synti->name().toLatin1().constData()); + // ev.dump(); + //} if (_mess) return _mess->processEvent(ev); return true; } -//unsigned long MessSynthIF::uniqueID() const +//unsigned long MessSynthIF::uniqueID() const DELETETHIS //{ // return _mess ? _mess->uniqueID() : 0; //} |