void CtrlListList::write(int level, Xml& xml) const { for (ciCtrlList icl = begin(); icl != end(); ++icl) { const CtrlList* cl = icl->second; QString s= QString("controller id=\"%1\" cur=\"%2\"").arg(cl->id()).arg(cl->curVal()).toAscii().constData(); s += QString(" color=\"%1\" visible=\"%2\"").arg(cl->color().name()).arg(cl->isVisible()); xml.tag(level++, s.toAscii().constData()); int i = 0; for (ciCtrl ic = cl->begin(); ic != cl->end(); ++ic) { QString s("%1 %2, "); xml.nput(level, s.arg(ic->second.frame).arg(ic->second.val).toAscii().constData()); ++i; if (i >= 4) { xml.put(level, ""); i = 0; } } if (i) xml.put(level, ""); xml.etag(level--, "controller"); } _midi_controls.write(level, xml); }
void AudioTrack::writeProperties(int level, Xml& xml) const { Track::writeProperties(level, xml); xml.intTag(level, "prefader", prefader()); xml.intTag(level, "sendMetronome", sendMetronome()); xml.intTag(level, "automation", int(automationType())); if (hasAuxSend()) { QHashIterator<qint64, AuxInfo> iter(_auxSend); while (iter.hasNext()) { iter.next(); Track* t = song->findTrackByIdAndType(iter.key(), Track::AUDIO_AUX); //Write it out only if the AUX track still exists if(t) { bool pre = iter.value().first; double val = iter.value().second; QString s("<auxSend trackId=\"%1\" pre=\"%2\">%3</auxSend>\n"); xml.nput(level, s.arg(iter.key()).arg(pre).arg(val).toAscii().constData()); } } } if (_wantsAutomation == false) { // _wantsAutomation is only set on fake midi automation tracks. on those, we don't need to save the plugins (synth) config for (ciPluginI ip = _efxPipe->begin(); ip != _efxPipe->end(); ++ip) { if (*ip) (*ip)->writeConfiguration(level, xml); } } for (ciCtrlList icl = _controller.begin(); icl != _controller.end(); ++icl) { const CtrlList* cl = icl->second; QString s= QString("controller id=\"%1\" cur=\"%2\"").arg(cl->id()).arg(cl->curVal()).toAscii().constData(); s += QString(" color=\"%1\" visible=\"%2\"").arg(cl->color().name()).arg(cl->isVisible()); xml.tag(level++, s.toAscii().constData()); int i = 0; for (ciCtrl ic = cl->begin(); ic != cl->end(); ++ic) { QString s("%1 %2, "); xml.nput(level, s.arg(ic->second.getFrame()).arg(ic->second.val).toAscii().constData()); ++i; if (i >= 4) { xml.put(level, ""); i = 0; } } if (i) xml.put(level, ""); xml.etag(--level, "controller"); } }
void TempoList::write(int level, Xml& xml) const { xml.put(level++, "<tempolist fix=\"%d\">", _tempo); if (_globalTempo != 100) xml.intTag(level, "globalTempo", _globalTempo); for (ciTEvent i = begin(); i != end(); ++i) i->second->write(level, xml, i->first); xml.tag(--level, "/tempolist"); }
void KeyMap::write(int level, Xml& xml)/*{{{*/ { xml.nput(level, "<KeyMap key=\"%d\"", key); xml.nput(" program=\"%d\"", program); xml.nput(" hasProgram=\"%d\"", hasProgram); xml.nput(" comment=\"%s\"", Xml::xmlString(comment).toLatin1().constData()); xml.nput(" pname=\"%s\"", Xml::xmlString(pname).toLatin1().constData()); xml.put(" />"); }/*}}}*/
void MidiInstrument::write(int level, Xml& xml) { xml.header(); xml.tag(level, "muse version=\"1.0\""); level++; xml.nput(level, "<MidiInstrument name=\"%s\"", Xml::xmlString(iname()).toLatin1().constData()); if(_nullvalue != -1) { QString nv; nv.setNum(_nullvalue); xml.nput(" nullparam=\"%s\"", nv.toLatin1().constData()); } xml.put(">"); level++; for (ciPatchGroup g = pg.begin(); g != pg.end(); ++g) { PatchGroup* pgp = *g; const PatchList& pl = pgp->patches; xml.tag(level, "PatchGroup name=\"%s\"", Xml::xmlString(pgp->name).toLatin1().constData()); level++; for (ciPatch p = pl.begin(); p != pl.end(); ++p) (*p)->write(level, xml); level--; xml.etag(level, "PatchGroup"); } for (iMidiController ic = _controller->begin(); ic != _controller->end(); ++ic) ic->second->write(level, xml); if(!_sysex.isEmpty()) { int j = _sysex.size(); for(int i = 0; i < j; ++i) _sysex.at(i)->write(level, xml); } xml.tag(level++, "Init"); for(ciEvent ev=_midiInit->begin(); ev != _midiInit->end(); ++ev) ev->second.write(level, xml, MusECore::Pos(0, true)); xml.etag(--level, "Init"); // ------------- // TODO: What about _midiReset, _midiState, and _initScript ? // ------------- writeDrummaps(level, xml); level--; xml.etag(level, "MidiInstrument"); level--; xml.etag(level, "muse"); }
void PosLen::write(int level, Xml& xml, const char* name) const { xml.nput(level++, "<%s ", name); switch(type()) { case TICKS: xml.nput("tick=\"%d\" len=\"%d\"", tick(), _lenTick); break; case FRAMES: xml.nput("sample=\"%d\" len=\"%d\"", frame(), _lenFrame); break; } xml.put(" />", name); }
void Pos::write(int level, Xml& xml, const char* name) const { xml.nput(level++, "<%s ", name); switch(_type) { case TICKS: xml.nput("tick=\"%d\"", _tick); break; case FRAMES: xml.nput("frame=\"%d\"", _frame); break; } xml.put(" />", name); }
void AbstractMidiEditor::writePartList(int level, Xml& xml) const/*{{{*/ { for (ciPart p = _pl->begin(); p != _pl->end(); ++p) { Part* part = p->second; MidiTrack* track = part->track(); int trkIdx = song->artracks()->index(track); int partIdx = track->parts()->index(part); if ((trkIdx == -1) || (partIdx == -1)) printf("AbstractMidiEditor::writePartList error: trkIdx:%d partIdx:%d\n", trkIdx, partIdx); xml.put(level, "<part>%d:%d</part>", trkIdx, partIdx); } }/*}}}*/
void Patch::write(int level, Xml& xml) { xml.nput(level, "<Patch name=\"%s\"", Xml::xmlString(name).toLatin1().constData()); //if(typ != -1) // xml.nput(" mode=\"%d\"", typ); // Obsolete if(hbank != -1) xml.nput(" hbank=\"%d\"", hbank); if(lbank != -1) xml.nput(" lbank=\"%d\"", lbank); xml.nput(" prog=\"%d\"", prog); if(drum) xml.nput(" drum=\"%d\"", int(drum)); xml.put(" />"); }
void MidiInstrument::write(int level, Xml& xml) { xml.header(); xml.tag(level, "los version=\"1.0\""); level++; xml.nput(level, "<MidiInstrument name=\"%s\" panValue=\"%f\"", Xml::xmlString(iname()).toLatin1().constData(), m_panValue); if (_nullvalue != -1) { QString nv; nv.setNum(_nullvalue); xml.nput(" nullparam=\"%s\"", nv.toLatin1().constData()); } xml.put(">"); // ------------- // What about Init, Reset, State, and InitScript ? // ------------- level++; for (ciPatchGroup g = pg.begin(); g != pg.end(); ++g) { PatchGroup* pgp = *g; const PatchList& pl = pgp->patches; xml.tag(level, "PatchGroup name=\"%s\"", Xml::xmlString(pgp->name).toLatin1().constData()); level++; for (ciPatch p = pl.begin(); p != pl.end(); ++p) (*p)->write(level, xml); level--; xml.etag(level, "PatchGroup"); } for (iMidiController ic = _controller->begin(); ic != _controller->end(); ++ic) ic->second->write(level, xml); for(QHash<int, KeyMap*>::const_iterator km = m_keymaps.begin(); km != m_keymaps.end(); ++km) { KeyMap *m = km.value(); m->write(level, xml); } level--; xml.etag(level, "MidiInstrument"); level--; xml.etag(level, "los"); }
void Patch::write(int level, Xml& xml) { xml.nput(level, "<Patch name=\"%s\"", Xml::xmlString(name).toLatin1().constData()); if (typ != -1) xml.nput(" mode=\"%d\"", typ); if (hbank != -1) xml.nput(" hbank=\"%d\"", hbank); if (lbank != -1) xml.nput(" lbank=\"%d\"", lbank); xml.nput(" prog=\"%d\"", prog); if (drum) xml.nput(" drum=\"%d\"", int(drum)); if(!keys.isEmpty()) { QString keyString; for(int i = 0; i < keys.size(); ++i) { keyString.append(QString::number(keys.at(i))); if(i < (keys.size() - 1)) keyString.append(" "); } xml.nput(" keys=\"%s\"", keyString.toUtf8().constData()); } if(!keyswitches.isEmpty()) { QString keyString; for(int i = 0; i < keyswitches.size(); ++i) { keyString.append(QString::number(keyswitches.at(i))); if(i < (keyswitches.size() - 1)) keyString.append(" "); } xml.nput(" keyswitches=\"%s\"", keyString.toUtf8().constData()); } xml.put(" />"); }
static void writeSeqConfiguration(int level, Xml& xml, bool writePortInfo)/*{{{*/ { xml.tag(level++, "sequencer"); if (writePortInfo) { // // write information about all midi ports, their assigned // instruments and all managed midi controllers // for (int i = 0; i < MIDI_PORTS; ++i) { bool used = false; MidiPort* mport = &midiPorts[i]; // Route check by Tim. Port can now be used for routing even if no device. // Also, check for other non-defaults and save port, to preserve settings even if no device. // Dont write the config for the global inputs list they will be auto created with each startup if (mport->defaultInChannels() || mport->defaultOutChannels() || (mport->instrument() && !mport->instrument()->iname().isEmpty() && mport->instrument()->iname() != "GM") /*|| !mport->syncInfo().isDefault()*/ ) { used = true; } else {//Put the ID of this track into a list MidiTrackList* tl = song->midis(); for (iMidiTrack it = tl->begin(); it != tl->end(); ++it) { MidiTrack* t = *it; if (t->outPort() == i) { used = true; break; } } } MidiDevice* dev = mport->device(); if (!used && !dev) continue; bool isGlobal = gInputListPorts.contains(mport->portno()); xml.tag(level++, "midiport portId=\"%lld\" isGlobalInput=\"%d\"", mport->id(), isGlobal); if (mport->defaultInChannels()) xml.intTag(level, "defaultInChans", mport->defaultInChannels()); if (mport->defaultOutChannels()) xml.intTag(level, "defaultOutChans", mport->defaultOutChannels()); if (mport->instrument() && !mport->instrument()->iname().isEmpty() && (mport->instrument()->iname() != "GM")) // FIXME: TODO: Make this user configurable. { xml.strTag(level, "instrument", mport->instrument()->iname()); } if (dev) { xml.strTag(level, "name", dev->name()); xml.intTag(level, "cacheNRPN", (int)dev->cacheNRPN()); if (dev->deviceType() != MidiDevice::ALSA_MIDI) xml.intTag(level, "type", dev->deviceType()); xml.intTag(level, "openFlags", dev->openFlags()); } // write out registered controller for all channels MidiCtrlValListList* vll = mport->controller(); for (int k = 0; k < MIDI_CHANNELS; ++k) { int min = k << 24; int max = min + 0x100000; xml.tag(level++, "channel idx=\"%d\"", k); iMidiCtrlValList s = vll->lower_bound(min); iMidiCtrlValList e = vll->lower_bound(max); if (s != e) { for (iMidiCtrlValList i = s; i != e; ++i) { if(i->second->num() != 262145) { xml.tag(level++, "controller id=\"%d\"", i->second->num()); if (i->second->hwVal() != CTRL_VAL_UNKNOWN) xml.intTag(level, "val", i->second->hwVal()); xml.etag(--level, "controller"); } } } xml.etag(--level, "channel"); } QList<PatchSequence*> *patchSequences = mport->patchSequences(); if (patchSequences && !patchSequences->isEmpty()) { for (int p = 0; p < patchSequences->size(); ++p) { PatchSequence* ps = patchSequences->at(p); QString pm = ps->name.replace('\n', " "); xml.put(level, "<patchSequence id=\"%d\" name=\"%s\" checked=\"%d\" />", ps->id, pm.toLatin1().constData(), ps->selected); } } if(!mport->presets()->isEmpty()) { QHashIterator<int, QString> iter(*mport->presets()); while(iter.hasNext()) { iter.next(); xml.put(level, "<midiPreset id=\"%d\" sysex=\"%s\"/>", iter.key(), iter.value().toLatin1().constData()); } } xml.etag(--level, "midiport"); } } xml.tag(--level, "/sequencer"); }/*}}}*/
void LOS::writeGlobalConfiguration(int level, Xml& xml) const { xml.tag(level++, "configuration"); xml.intTag(level, "division", config.division); xml.intTag(level, "rtcTicks", config.rtcTicks); xml.intTag(level, "minMeter", config.minMeter); xml.doubleTag(level, "minSlider", config.minSlider); xml.intTag(level, "freewheelMode", config.freewheelMode); xml.intTag(level, "denormalProtection", config.useDenormalBias); xml.intTag(level, "outputLimiter", config.useOutputLimiter); xml.intTag(level, "dummyAudioBufSize", config.dummyAudioBufSize); xml.intTag(level, "dummyAudioSampleRate", config.dummyAudioSampleRate); xml.intTag(level, "guiRefresh", config.guiRefresh); xml.strTag(level, "userInstrumentsDir", config.userInstrumentsDir); xml.intTag(level, "extendedMidi", config.extendedMidi); xml.intTag(level, "midiExportDivision", config.midiDivision); xml.intTag(level, "smfFormat", config.smfFormat); xml.intTag(level, "exp2ByteTimeSigs", config.exp2ByteTimeSigs); xml.intTag(level, "expOptimNoteOffs", config.expOptimNoteOffs); xml.intTag(level, "importMidiSplitParts", config.importMidiSplitParts); xml.intTag(level, "startMode", config.startMode); xml.strTag(level, "startSong", config.startSong); xml.strTag(level, "projectBaseFolder", config.projectBaseFolder); xml.intTag(level, "projectStoreInFolder", config.projectStoreInFolder); xml.intTag(level, "useProjectSaveDialog", config.useProjectSaveDialog); xml.intTag(level, "useAutoCrossFades", config.useAutoCrossFades); xml.intTag(level, "midiInputDevice", midiInputPorts); xml.intTag(level, "midiInputChannel", midiInputChannel); xml.intTag(level, "midiRecordType", midiRecordType); xml.intTag(level, "midiThruType", midiThruType); xml.intTag(level, "midiFilterCtrl1", midiFilterCtrl1); xml.intTag(level, "midiFilterCtrl2", midiFilterCtrl2); xml.intTag(level, "midiFilterCtrl3", midiFilterCtrl3); xml.intTag(level, "midiFilterCtrl4", midiFilterCtrl4); xml.strTag(level, "externalWavEditor", config.externalWavEditor); xml.intTag(level, "useOldStyleStopShortCut", config.useOldStyleStopShortCut); xml.intTag(level, "moveArmedCheckBox", config.moveArmedCheckBox); xml.intTag(level, "vuColorStrip", vuColorStrip); if(gInputList.size()) { const char* const tag = "globalInputList"; xml.put(level, "<%s count=\"%d\">", tag, gInputList.size()); level++; for(int i = 0; i < gInputList.size(); ++i) { QPair<int, QString> in = gInputList.at(i); xml.put(level, "<globalInput deviceType=\"%d\" deviceName=\"%s\" />", in.first, in.second.toUtf8().constData()); } level--; xml.put(level--, "</%s>", tag); level++; } writeSeqConfiguration(level, xml, false); writeShortCuts(level, xml); xml.etag(--level, "configuration"); writeInstrumentTemplates(level, xml); }
void Patch::write(int level, Xml& xml)/*{{{*/ { xml.nput(level, "<Patch name=\"%s\"", Xml::xmlString(name).toLatin1().constData()); if (typ != -1) xml.nput(" mode=\"%d\"", typ); if (hbank != -1) xml.nput(" hbank=\"%d\"", hbank); if (lbank != -1) xml.nput(" lbank=\"%d\"", lbank); xml.nput(" prog=\"%d\"", prog); if (drum) xml.nput(" drum=\"%d\"", int(drum)); if(!QString(filename).isEmpty()) xml.nput(" filename=\"%s\"", Xml::xmlString(filename).toLatin1().constData()); if(!QString(engine).isEmpty()) xml.nput(" engine=\"%s\"", Xml::xmlString(engine).toLatin1().constData()); if(loadmode != -1) xml.nput(" loadmode=\"%d\"", loadmode); if(index != -1) xml.nput(" index=\"%d\"", index); xml.nput(" volume=\"%f\"", volume); if(!keys.isEmpty()) { QString keyString; for(int i = 0; i < keys.size(); ++i) { keyString.append(QString::number(keys.at(i))); if(i < (keys.size() - 1)) keyString.append(" "); } xml.nput(" keys=\"%s\"", keyString.toUtf8().constData()); } if(!keyswitches.isEmpty()) { QString keyString; for(int i = 0; i < keyswitches.size(); ++i) { keyString.append(QString::number(keyswitches.at(i))); if(i < (keyswitches.size() - 1)) keyString.append(" "); } xml.nput(" keyswitches=\"%s\"", keyString.toUtf8().constData()); } if(!comments.empty()) { QString c; QHashIterator<int, QString> it(comments); while(it.hasNext()) { it.next(); QString val = QString::number(it.key()).append("@@:@@").append(it.value()); c.append(val).append(" "); } xml.nput(" comments=\"%s\"", c.toUtf8().constData()); } xml.put(" />"); }/*}}}*/
void MidiController::write(int level, Xml& xml) const { ControllerType t = midiControllerType(_num); if(t == Velo) return; QString type(int2ctrlType(t)); int h = (_num >> 8) & 0x7f; int l = _num & 0x7f; QString sl; if (isPerNoteController()) sl = "pitch"; else sl.setNum(l); xml.nput(level, "<Controller name=\"%s\"", Xml::xmlString(_name).toLatin1().constData()); if(t != Controller7) xml.nput(" type=\"%s\"", type.toLatin1().constData()); int mn = 0; int mx = 0; switch (t) { case RPN: case NRPN: xml.nput(" h=\"%d\"", h); xml.nput(" l=\"%s\"", sl.toLatin1().constData()); mx = 127; break; case Controller7: xml.nput(" l=\"%s\"", sl.toLatin1().constData()); mx = 127; break; case Controller14: case RPN14: case NRPN14: xml.nput(" h=\"%d\"", h); xml.nput(" l=\"%s\"", sl.toLatin1().constData()); mx = 16383; break; case Pitch: mn = -8192; mx = 8191; break; case PolyAftertouch: mn = 0; mx = 127; break; case Aftertouch: mn = 0; mx = 127; break; case Program: case Velo: // Cannot happen break; } if(t == Program) { if(_initVal != CTRL_VAL_UNKNOWN && _initVal != 0xffffff) xml.nput(" init=\"0x%x\"", _initVal); } else { if(_minVal != mn) xml.nput(" min=\"%d\"", _minVal); if(_maxVal != mx) xml.nput(" max=\"%d\"", _maxVal); if(_initVal != CTRL_VAL_UNKNOWN) xml.nput(" init=\"%d\"", _initVal); } if(_showInTracks != (ShowInDrum | ShowInMidi)) xml.nput(" showType=\"%d\"", _showInTracks); xml.put(" />"); }