void AbstractMidiEditor::readStatus(Xml& xml)/*{{{*/ { if (_pl == 0) _pl = new PartList; for (;;) { Xml::Token token = xml.parse(); QString tag = xml.s1(); switch (token) { case Xml::Error: case Xml::End: return; case Xml::TagStart: if (tag == "quant") _quant = xml.parseInt(); else if (tag == "raster") _raster = xml.parseInt(); else if (tag == "topwin") TopWin::readStatus(xml); else xml.unknown("AbstractMidiEditor"); break; case Xml::TagEnd: if (tag == "midieditor") return; default: break; } } }/*}}}*/
void WaveTrack::read(Xml& xml) { for (;;) { Xml::Token token = xml.parse(); const QString& tag = xml.s1(); switch (token) { case Xml::Error: case Xml::End: goto out_of_WaveTrackRead_forloop; case Xml::TagStart: if (tag == "part") { Part* p = 0; p = Part::readFromXml(xml, this); if(p) parts()->add(p); } else if (AudioTrack::readProperties(xml, tag)) xml.unknown("WaveTrack"); break; case Xml::Attribut: break; case Xml::TagEnd: if (tag == "wavetrack") { mapRackPluginsToControllers(); goto out_of_WaveTrackRead_forloop; } default: break; } } out_of_WaveTrackRead_forloop: chainTrackParts(this); }
void readGlobalInputList(Xml& xml)/*{{{*/ { gInputList.clear(); for (;;) { Xml::Token token = xml.parse(); const QString& tag = xml.s1(); switch (token) { case Xml::Error: case Xml::End: return; case Xml::TagStart: if(tag == "globalInput") { readGlobalInput(xml); } break; case Xml::Attribut: break; case Xml::TagEnd: if(tag == "globalInputList") {//Just return return; } default: break; } } }/*}}}*/
QColor readColor(Xml& xml) { int val, r = 0, g = 0, b = 0; for (;;) { Xml::Token token = xml.parse(); if (token != Xml::Attribut) break; QString tag = xml.s1(); switch (token) { case Xml::Attribut: val = xml.s2().toInt(); if (tag == "r") r = val; else if (tag == "g") g = val; else if (tag == "b") b = val; break; default: break; } } return QColor(r, g, b); }
int TEvent::read(Xml& xml) { int at = 0; for (;;) { Xml::Token token = xml.parse(); const QString& tag = xml.s1(); switch (token) { case Xml::Error: case Xml::End: return 0; case Xml::TagStart: if (tag == "tick") tick = xml.parseInt(); else if (tag == "val") tempo = xml.parseInt(); else xml.unknown("TEvent"); break; case Xml::Attribut: if (tag == "at") at = xml.s2().toInt(); break; case Xml::TagEnd: if (tag == "tempo") { return at; } default: break; } } return 0; }
int SigEvent::read(Xml& xml) { int at = 0; for (;;) { Xml::Token token = xml.parse(); const QString& tag = xml.s1(); switch (token) { case Xml::Error: case Xml::End: return 0; case Xml::TagStart: if (tag == "tick") tick = xml.parseInt(); else if (tag == "nom") z = xml.parseInt(); else if (tag == "denom") n = xml.parseInt(); else xml.unknown("SigEvent"); break; case Xml::Attribut: if (tag == "at") at = xml.s2().toInt(); break; case Xml::TagEnd: if (tag == "sig") return at; default: break; } } return 0; }
void readShortCuts(Xml& xml) { for (;;) { Xml::Token token = xml.parse(); if (token == Xml::Error || token == Xml::End) break; const QString& tag = xml.s1(); switch (token) { case Xml::TagStart: { if (tag.length()) { int index = getShrtByTag(tag.toUtf8().constData()); if (index != -1) { //printf("Index: %d\n",index); shortcuts[index].key = xml.parseInt(); //printf("shortcuts[%d].key = %d, %s\n",index, shortcuts[index].key, shortcuts[index].descr); } else xml.skip(tag); } } case Xml::TagEnd: if (tag == "shortcuts") return; default: break; } } }
void MasterEdit::readConfiguration(Xml& xml) { for (;;) { Xml::Token token = xml.parse(); const QString& tag = xml.s1(); switch (token) { case Xml::Error: case Xml::End: return; case Xml::TagStart: if (tag == "raster") _rasterInit = xml.parseInt(); else xml.unknown("MasterEdit"); break; case Xml::TagEnd: if (tag == "masteredit") return; default: break; } } }
void readShortCuts(Xml& xml) { for (;;) { Xml::Token token = xml.parse(); if (token == Xml::Error || token == Xml::End) break; const QString& tag = xml.s1(); switch (token) { case Xml::TagStart: { if (tag.length()) { int index = getShrtByTag(tag.toAscii().constData()); if (index == -1) //No such tag found printf("Config file might be corrupted. Unknown shortcut: %s\n", tag.toLatin1().constData()); else { //printf("Index: %d\n",index); shortcuts[index].key = xml.parseInt(); //printf("shortcuts[%d].key = %d, %s\n",index, shortcuts[index].key, shortcuts[index].descr); } } } case Xml::TagEnd: if (tag == "shortcuts") return; default: break; } } }
void EventList::read(Xml& xml, const char* name, bool midi) { for (;;) { Xml::Token token = xml.parse(); const QString& tag = xml.s1(); switch (token) { case Xml::Error: case Xml::End: return; case Xml::TagStart: if (tag == "event") { Event e(midi ? Note : Wave); e.read(xml); add(e); } else xml.unknown("readEventList"); break; case Xml::TagEnd: if (tag == name) return; default: break; } } }
static void readEventList(Xml& xml, EventList* el, const char* name) { for (;;) { Xml::Token token = xml.parse(); const QString& tag = xml.s1(); switch (token) { case Xml::Error: case Xml::End: return; case Xml::TagStart: if (tag == "event") { Event e(Note); e.read(xml); el->add(e); } else xml.unknown("readEventList"); break; case Xml::TagEnd: if (tag == name) return; default: break; } } }
void PatchGroup::read(Xml& xml) { for (;;) { Xml::Token token = xml.parse(); const QString& tag = xml.s1(); switch (token) { case Xml::Error: case Xml::End: return; case Xml::TagStart: if (tag == "Patch") { Patch* patch = new Patch; patch->read(xml); patches.push_back(patch); } else xml.unknown("PatchGroup"); break; case Xml::Attribut: if (tag == "name") name = xml.s2(); break; case Xml::TagEnd: if (tag == "PatchGroup") return; default: break; } } }
void MidiInstrument::readDrummaps(Xml& xml) { patch_drummap_mapping.clear(); for (;;) { Xml::Token token = xml.parse(); const QString& tag = xml.s1(); switch (token) { case Xml::Error: case Xml::End: return; case Xml::TagStart: if (tag == "entry") patch_drummap_mapping.push_back(readDrummapsEntry(xml)); else xml.unknown("MidiInstrument::readDrummaps"); break; case Xml::TagEnd: if (tag == "Drummaps") return; default: break; } } printf("ERROR: THIS CANNOT HAPPEN: exited infinite loop in MidiInstrument::readDrummaps()!\n" " not returning anything. expect undefined behaviour or even crashes.\n"); }
static void readPortChannel(Xml& xml, int midiPort) { int idx = 0; //torbenh for (;;) { Xml::Token token = xml.parse(); if (token == Xml::Error || token == Xml::End) break; QString tag = xml.s1(); switch (token) { case Xml::TagStart: if (tag == "controller") { readController(xml, midiPort, idx); } else xml.skip(tag); break; case Xml::Attribut: if (tag == "idx") idx = xml.s2().toInt(); break; case Xml::TagEnd: if (tag == "channel") return; default: break; } } }
static QPair<int, QString> readMidiPortPreset(Xml& xml)/*{{{*/ { int id = 0; QString sysex; for (;;) { Xml::Token token = xml.parse(); QString tag = xml.s1(); switch (token) { case Xml::TagStart: xml.unknown("midiPreset"); break; case Xml::Attribut: if (tag == "id") id = xml.s2().toInt(); else if (tag == "sysex") { sysex = xml.s2(); } break; case Xml::TagEnd: return qMakePair(id, sysex); default: break; } } }/*}}}*/
void MidiEventBase::read(Xml& xml) { setType(Note); a = 0; b = 0; c = 0; int dataLen = 0; for (;;) { Xml::Token token = xml.parse(); const QString& tag = xml.s1(); switch (token) { case Xml::Error: case Xml::End: return; case Xml::TagStart: xml.unknown("Event"); break; case Xml::Text: { QByteArray ba = tag.toLatin1(); const char*s = ba.constData(); edata.data = new unsigned char[dataLen]; edata.dataLen = dataLen; unsigned char* d = edata.data; for (int i = 0; i < dataLen; ++i) { char* endp; *d++ = strtol(s, &endp, 16); s = endp; } } break; case Xml::Attribut: if (tag == "tick") setTick(xml.s2().toInt()); else if (tag == "type") setType(EventType(xml.s2().toInt())); else if (tag == "len") setLenTick(xml.s2().toInt()); else if (tag == "a") a = xml.s2().toInt(); else if (tag == "b") b = xml.s2().toInt(); else if (tag == "c") c = xml.s2().toInt(); else if (tag == "datalen") dataLen = xml.s2().toInt(); break; case Xml::TagEnd: if (tag == "event") return; default: break; } } }
void AudioTrack::readAuxSend(Xml& xml) { qint64 idx; double val; bool pre = true; for (;;) { Xml::Token token = xml.parse(); const QString& tag = xml.s1(); switch (token) { case Xml::Error: case Xml::End: return; case Xml::Attribut: { if (tag == "idx") {//Backwards compatible idx = xml.s2().toLongLong(); gUpdateAuxes = true; } else if(tag == "trackId") {//New style trackId based idx = xml.s2().toLongLong(); } else if(tag == "pre") { pre = xml.s2().toInt(); } break; } case Xml::Text: val = tag.toDouble(); break; case Xml::TagEnd: if (xml.s1() == "auxSend") { AuxInfo info(pre, val); _auxSend[idx] = info; return; } default: break; } } }
void MasterEdit::readStatus(Xml& xml) { for (;;) { Xml::Token token = xml.parse(); const QString& tag = xml.s1(); switch (token) { case Xml::Error: case Xml::End: return; case Xml::TagStart: if (tag == "midieditor") AbstractMidiEditor::readStatus(xml); else if (tag == "ypos") vscroll->setPos(xml.parseInt()); else if (tag == "ymag") { // vscroll->setMag(xml.parseInt()); int mag = xml.parseInt(); vscroll->setMag(mag); } else xml.unknown("MasterEdit"); break; case Xml::TagEnd: if (tag == "master") { // raster setzen int item = 0; switch (_raster) { case 1: item = 0; break; case 0: item = 1; break; case 768: item = 2; break; case 384: item = 3; break; case 192: item = 4; break; case 96: item = 5; break; } _rasterInit = _raster; rasterLabel->setCurrentIndex(item); return; } default: break; } } }
void PosLen::read(Xml& xml, const char* name) { sn = -1; for (;;) { Xml::Token token = xml.parse(); const QString& tag = xml.s1(); switch (token) { case Xml::Error: case Xml::End: return; case Xml::TagStart: xml.unknown(name); break; case Xml::Attribut: if (tag == "tick") { setType(TICKS); setTick(xml.s2().toInt()); } else if (tag == "sample") { setType(FRAMES); setFrame(xml.s2().toInt()); } else if (tag == "len") { int n = xml.s2().toInt(); switch (type()) { case TICKS: setLenTick(n); break; case FRAMES: setLenFrame(n); break; } } else xml.unknown(name); break; case Xml::TagEnd: if (tag == name) return; default: break; } } }
static void readSeqConfiguration(Xml& xml) { //bool updatePorts = false; for (;;) { Xml::Token token = xml.parse(); if (token == Xml::Error || token == Xml::End) break; const QString& tag = xml.s1(); switch (token) { case Xml::TagStart: if (tag == "midiport") { //updatePorts = true; readConfigMidiPort(xml); } else if (tag == "rcStop") rcStopNote = xml.parseInt(); else if (tag == "rcEnable") rcEnable = xml.parseInt(); else if (tag == "rcRecord") rcRecordNote = xml.parseInt(); else if (tag == "rcGotoLeft") rcGotoLeftMarkNote = xml.parseInt(); else if (tag == "rcPlay") rcPlayNote = xml.parseInt(); else xml.skip(tag); break; case Xml::TagEnd: if (tag == "sequencer") { //All Midiports have been read so put all the unconfigured ports in the id list //if(updatePorts) //{ for(int i = 0; i < MIDI_PORTS; ++i) { MidiPort *mp = &midiPorts[i]; if(!losMidiPorts.contains(mp->id())) losMidiPorts.insert(mp->id(), mp); } //} return; } default: break; } } }
bool SysEx::read(Xml& xml) { for (;;) { Xml::Token token = xml.parse(); const QString& tag = xml.s1(); switch (token) { case Xml::Error: case Xml::End: return false; case Xml::TagStart: if (tag == "comment") comment = xml.parse1(); else if (tag == "data") { unsigned char*d; int len = string2sysex(xml.parse1(), &d); // Was the conversion succesful, even if empty? if(len != -1) { // Delete existing. if(dataLen != 0 && data) delete[] data; dataLen = len; data = d; } } else xml.unknown("SysEx"); break; case Xml::Attribut: if (tag == "name") name = xml.s2(); break; case Xml::TagEnd: if (tag == "SysEx") { return !name.isEmpty(); } default: break; } } return false; }
void Pos::read(Xml& xml, const char* name) { sn = -1; for (;;) { Xml::Token token = xml.parse(); const QString& tag = xml.s1(); switch (token) { case Xml::Error: case Xml::End: return; case Xml::TagStart: xml.unknown(name); break; case Xml::Attribut: if (tag == "tick") { _tick = xml.s2().toInt(); _type = TICKS; } else if (tag == "frame") { _frame = xml.s2().toInt(); _type = FRAMES; } else if (tag == "sample") { // obsolete _frame = xml.s2().toInt(); _type = FRAMES; } else xml.unknown(name); break; case Xml::TagEnd: if (tag == name) return; default: break; } } }
void TrackView::read(Xml& xml)/*{{{*/ { for (;;) { Xml::Token token = xml.parse(); const QString& tag = xml.s1(); switch (token) { case Xml::Error: case Xml::End: return; case Xml::TagStart: if(tag == "name") { _name = xml.parse1(); } else if(tag == "comment") { _comment = xml.parse1(); } else if(tag == "selected") { _selected = (bool)xml.parseInt(); } else if (tag == "vtrack") { Track* t = song->findTrack(xml.parse1()); if (t) { //printf("TrackView::read() Adding track\n"); addTrack(t); } } break; case Xml::Attribut: break; case Xml::TagEnd: if(tag == "trackview") return; default: break; } } }/*}}}*/
void WaveEventBase::read(Xml& xml) { for (;;) { Xml::Token token = xml.parse(); const QString& tag = xml.s1(); switch (token) { case Xml::Error: case Xml::End: case Xml::Attribut: return; case Xml::TagStart: if (tag == "poslen") PosLen::read(xml, "poslen"); else if (tag == "frame") _spos = xml.parseInt(); else if(tag == "leftclip") m_leftclip = xml.parseInt(); else if(tag == "rightclip") m_rightclip = xml.parseInt(); else if (tag == "file") { SndFile* wf = getWave(xml.parse1(), true); if (wf) { f = SndFileR(wf); } } else xml.unknown("Event"); break; case Xml::TagEnd: if (tag == "event") { Pos::setType(FRAMES); // DEBUG return; } default: break; } } }
void Patch::read(Xml& xml) { //typ = -1; hbank = -1; lbank = -1; prog = 0; drum = false; for (;;) { Xml::Token token = xml.parse(); const QString& tag = xml.s1(); switch (token) { case Xml::Error: case Xml::End: return; case Xml::TagStart: xml.unknown("Patch"); break; case Xml::Attribut: if (tag == "name") name = xml.s2(); else if (tag == "mode") // Obsolete { //typ = xml.s2().toInt(); xml.s2().toInt(); } else if (tag == "hbank") hbank = xml.s2().toInt(); else if (tag == "lbank") lbank = xml.s2().toInt(); else if (tag == "prog") prog = xml.s2().toInt(); else if (tag == "drum") drum = xml.s2().toInt(); break; case Xml::TagEnd: if (tag == "Patch") return; default: break; } } }
void TempoList::read(Xml& xml) { for (;;) { Xml::Token token = xml.parse(); const QString& tag = xml.s1(); switch (token) { case Xml::Error: case Xml::End: return; case Xml::TagStart: if (tag == "tempo") { TEvent* t = new TEvent(); unsigned tick = t->read(xml); iTEvent pos = find(tick); if (pos != end()) erase(pos); insert(std::pair<const int, TEvent*> (tick, t)); } else if (tag == "globalTempo") _globalTempo = xml.parseInt(); else xml.unknown("TempoList"); break; case Xml::Attribut: if (tag == "fix") _tempo = xml.s2().toInt(); break; case Xml::TagEnd: if (tag == "tempolist") { normalize(); ++_tempoSN; return; } default: break; } } }
patch_collection_t MidiInstrument::readDrummapsEntryPatchCollection(Xml& xml) { int first_prog=0, last_prog=256; // this means: int first_lbank=0, last_lbank=256; // "does not matter" int first_hbank=0, last_hbank=256; for (;;) { Xml::Token token = xml.parse(); const QString& tag = xml.s1(); switch (token) { case Xml::Error: case Xml::End: return patch_collection_t(-1,-1,-1,-1,-1,-1); // an invalid collection case Xml::TagStart: xml.unknown("MidiInstrument::readDrummapsEntryPatchCollection"); break; case Xml::Attribut: if (tag == "prog") parse_range(xml.s2(), &first_prog, &last_prog); else if (tag == "lbank") parse_range(xml.s2(), &first_lbank, &last_lbank); else if (tag == "hbank") parse_range(xml.s2(), &first_hbank, &last_hbank); break; case Xml::TagEnd: if (tag == "patch_collection") return patch_collection_t(first_prog, last_prog, first_lbank, last_lbank, first_hbank, last_hbank); default: break; } } printf("ERROR: THIS CANNOT HAPPEN: exited infinite loop in MidiInstrument::readDrummapsEntryPatchCollection()!\n" " not returning anything. expect undefined behaviour or even crashes.\n"); }
void MarkerView::readStatus(Xml& xml) { for (;;) { Xml::Token token = xml.parse(); const QString& tag = xml.s1(); if (token == Xml::Error || token == Xml::End) break; switch (token) { case Xml::TagStart: xml.unknown("Marker"); break; case Xml::TagEnd: if (tag == "marker") return; default: break; } } }
patch_drummap_mapping_t MidiInstrument::readDrummapsEntry(Xml& xml) { using std::list; patch_collection_t collection; DrumMap* drummap=new DrumMap[128]; for (int i=0;i<128;i++) drummap[i]=iNewDrumMap[i]; for (;;) { Xml::Token token = xml.parse(); const QString& tag = xml.s1(); switch (token) { case Xml::Error: case Xml::End: return patch_drummap_mapping_t(collection, drummap); case Xml::TagStart: if (tag == "patch_collection") collection=readDrummapsEntryPatchCollection(xml); else if (tag == "drummap") read_new_style_drummap(xml, "drummap", drummap); else xml.unknown("MidiInstrument::readDrummapsEntry"); break; case Xml::TagEnd: if (tag == "entry") return patch_drummap_mapping_t(collection, drummap); default: break; } } printf("ERROR: THIS CANNOT HAPPEN: exited infinite loop in MidiInstrument::readDrummapsEntry()!\n" " not returning anything. expect undefined behaviour or even crashes.\n"); return patch_drummap_mapping_t(); }
void KeyMap::read(Xml& xml)/*{{{*/ { program = -1; pname = ""; comment = ""; key = -1; hasProgram = false; for (;;) { Xml::Token token = xml.parse(); const QString& tag = xml.s1(); switch (token) { case Xml::Error: case Xml::End: return; case Xml::TagStart: xml.unknown("KeyMap"); break; case Xml::Attribut: if (tag == "comment") comment = xml.s2(); else if (tag == "program") program = xml.s2().toInt(); else if (tag == "key") key = xml.s2().toInt(); else if (tag == "pname") pname = xml.s2(); else if(tag == "hasProgram") hasProgram = (bool)xml.s2().toInt(); break; case Xml::TagEnd: if (tag == "KeyMap") return; default: break; } } }/*}}}*/