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/songfile.cpp | |
parent | 2d6f113a10eb485694e20a78500f650776d701e3 (diff) |
merged with trunk
Diffstat (limited to 'muse2/muse/songfile.cpp')
-rw-r--r-- | muse2/muse/songfile.cpp | 161 |
1 files changed, 43 insertions, 118 deletions
diff --git a/muse2/muse/songfile.cpp b/muse2/muse/songfile.cpp index f76c16f9..07430c26 100644 --- a/muse2/muse/songfile.cpp +++ b/muse2/muse/songfile.cpp @@ -29,23 +29,18 @@ #include "song.h" #include "arranger.h" #include "arrangerview.h" -//#include "arranger/arranger.h" // p4.0.2 #include "cobject.h" #include "drumedit.h" -//#include "midiedit/drumedit.h" // p4.0.2 #include "pianoroll.h" #include "scoreedit.h" -//#include "midiedit/pianoroll.h" // p4.0.2 #include "globals.h" #include "xml.h" #include "drummap.h" -//#include "midiedit/drummap.h" // p4.0.2 #include "event.h" #include "marker/marker.h" #include "midiport.h" #include "audio.h" #include "mitplugin.h" -//#include "mplugins/mitplugin.h" // p4.0.2 #include "wave.h" #include "midictrl.h" #include "amixer.h" @@ -55,38 +50,13 @@ #include "keyevent.h" namespace MusEGlobal { -//static CloneList cloneList; -//static CloneList copyCloneList; MusECore::CloneList cloneList; -//CloneList copyCloneList; } namespace MusECore { -//struct ClonePart { - //const EventList* el; -// const Part* cp; -// int id; - //ClonePart(const EventList* e, int i) : el(e), id(i) {} -// ClonePart(const Part* p, int i) : cp(p), id(i) {} -// }; -//typedef std::list<ClonePart> CloneList; -//typedef CloneList::iterator iClone; - -//--------------------------------------------------------- -// ClonePart -//--------------------------------------------------------- - -ClonePart::ClonePart(const Part* p, int i) -{ - cp = p; - id = i; - uuid_generate(uuid); -} - - -/* +/* DELETETHIS 42 //--------------------------------------------------------- // updateCloneList //--------------------------------------------------------- @@ -219,41 +189,28 @@ Part* readXmlPart(Xml& xml, Track* track, bool doClone, bool toTrack) case Xml::End: return npart; case Xml::TagStart: - // If the part has not been created yet... - if(!npart) + if(!npart) // If the part has not been created yet... { - // If an id was found... - if(id != -1) + if(id != -1) // If an id was found... { for(iClone i = MusEGlobal::cloneList.begin(); i != MusEGlobal::cloneList.end(); ++i) { - // Is a matching part found in the clone list? - if(i->id == id) + if(i->id == id) // Is a matching part found in the clone list? { - // If it's a regular paste (not paste clone), and the original part is - // not a clone, defer so that a new copy is created in TagStart above. - //if(!doClone && i->cp->cevents()->arefCount() <= 1) - //if(!doClone && !isclone) - // break; - // This makes a clone, chains the part, and increases ref counts. npart = track->newPart((Part*)i->cp, true); break; } } } - else - // If a uuid was found... - if(uuidvalid) + else if(uuidvalid) // If a uuid was found... { for(iClone i = MusEGlobal::cloneList.begin(); i != MusEGlobal::cloneList.end(); ++i) { - // Is a matching part found in the clone list? - if(uuid_compare(uuid, i->uuid) == 0) + if(uuid_compare(uuid, i->uuid) == 0) // Is a matching part found in the clone list? { Track* cpt = i->cp->track(); - // If we want to paste to the given track... - if(toTrack) + if(toTrack) // If we want to paste to the given track... { // If the given track type is not the same as the part's // original track type, we can't continue. Just return. @@ -263,15 +220,13 @@ Part* readXmlPart(Xml& xml, Track* track, bool doClone, bool toTrack) return 0; } } - else - // ...else we want to paste to the part's original track. + else // ...else we want to paste to the part's original track. { // Make sure the track exists (has not been deleted). if((cpt->isMidiTrack() && MusEGlobal::song->midis()->find(cpt) != MusEGlobal::song->midis()->end()) || (cpt->type() == Track::WAVE && MusEGlobal::song->waves()->find(cpt) != MusEGlobal::song->waves()->end())) track = cpt; - else - // Track was not found. Try pasting to the given track, as above... + else // Track was not found. Try pasting to the given track, as above... { if(!track || cpt->type() != track->type()) { @@ -284,7 +239,6 @@ Part* readXmlPart(Xml& xml, Track* track, bool doClone, bool toTrack) // If it's a regular paste (not paste clone), and the original part is // not a clone, defer so that a new copy is created in TagStart above. - //if(!doClone && i->cp->cevents()->arefCount() <= 1) if(!doClone && !isclone) break; @@ -295,12 +249,11 @@ Part* readXmlPart(Xml& xml, Track* track, bool doClone, bool toTrack) } } - // If the part still has not been created yet... - if(!npart) + if(!npart) // If the part still has not been created yet... { - // A clone was not created from any matching part. Create a non-clone part now. - if(!track) - { + + if(!track) // A clone was not created from any matching + { // part. Create a non-clone part now. xml.skip("part"); return 0; } @@ -387,6 +340,7 @@ Part* readXmlPart(Xml& xml, Track* track, bool doClone, bool toTrack) e.move( -npart->tick() ); int tick = e.tick(); + // DELETETHIS 7 // Do not discard events belonging to clone parts, // at least not yet. A later clone might have a longer, // fully accommodating part length! @@ -396,7 +350,6 @@ Part* readXmlPart(Xml& xml, Track* track, bool doClone, bool toTrack) // No choice but to accept all events past 0. if(tick < 0) { - //printf("readClone: warning: event not in part: %d - %d -%d, discarded\n", printf("readClone: warning: event at tick:%d not in part:%s, discarded\n", tick, npart->name().toLatin1().constData()); } @@ -405,8 +358,7 @@ Part* readXmlPart(Xml& xml, Track* track, bool doClone, bool toTrack) npart->events()->add(e); } } - else - // ...Otherwise a clone was created, so we don't need the events. + else // ...Otherwise a clone was created, so we don't need the events. xml.skip(tag); } else @@ -421,7 +373,7 @@ Part* readXmlPart(Xml& xml, Track* track, bool doClone, bool toTrack) else if (tag == "cloneId") { id = xml.s2().toInt(); - //if(id != -1) + //if(id != -1) DELETETHIS 19 //{ // for(iClone i = MusEGlobal::cloneList.begin(); i != MusEGlobal::cloneList.end(); ++i) // { @@ -447,7 +399,7 @@ Part* readXmlPart(Xml& xml, Track* track, bool doClone, bool toTrack) if(!uuid_is_null(uuid)) { uuidvalid = true; - /* + /* DELETETHIS 50 for(iClone i = MusEGlobal::cloneList.begin(); i != MusEGlobal::cloneList.end(); ++i) { // Is a matching part found in the clone list? @@ -517,7 +469,6 @@ Part* readXmlPart(Xml& xml, Track* track, bool doClone, bool toTrack) // we can have 'Paste Clone' feature. //--------------------------------------------------------- -//void Part::write(int level, Xml& xml) const void Part::write(int level, Xml& xml, bool isCopy, bool forceWavePaths) const { const EventList* el = cevents(); @@ -529,28 +480,19 @@ void Part::write(int level, Xml& xml, bool isCopy, bool forceWavePaths) const if(isCopy) { - //for(iClone i = copyCloneList.begin(); i != copyCloneList.end(); ++i) for(iClone i = MusEGlobal::cloneList.begin(); i != MusEGlobal::cloneList.end(); ++i) { - //if(i->el == el) { if(i->cp->cevents() == el) { - //id = i->id; uuid_copy(uuid, i->uuid); dumpEvents = false; break; } } - //if(id == -1) if(uuid_is_null(uuid)) { - //id = copyCloneList.size(); - //id = MusEGlobal::cloneList.size(); - //ClonePart cp(el, id); - //ClonePart cp(this, id); ClonePart cp(this); uuid_copy(uuid, cp.uuid); - //copyCloneList.push_back(cp); MusEGlobal::cloneList.push_back(cp); } } @@ -560,22 +502,17 @@ void Part::write(int level, Xml& xml, bool isCopy, bool forceWavePaths) const { for (iClone i = MusEGlobal::cloneList.begin(); i != MusEGlobal::cloneList.end(); ++i) { - //if (i->el == el) { if (i->cp->cevents() == el) { id = i->id; - //uuid_copy(id, i->uid); dumpEvents = false; break; } } if (id == -1) - //if(uuid_is_null(id)) { id = MusEGlobal::cloneList.size(); - //ClonePart cp(el, id); ClonePart cp(this, id); - //ClonePart cp(this); MusEGlobal::cloneList.push_back(cp); } } @@ -588,9 +525,7 @@ void Part::write(int level, Xml& xml, bool isCopy, bool forceWavePaths) const char sid[40]; // uuid string is 36 chars. Try 40 for good luck. sid[0] = 0; uuid_unparse_lower(uuid, sid); - //if(midi) - // xml.nput(level, "<midipart uuid=\"%s\"", sid); - //else + if(wave) xml.nput(level, "<part type=\"wave\" uuid=\"%s\"", sid); else @@ -603,22 +538,14 @@ void Part::write(int level, Xml& xml, bool isCopy, bool forceWavePaths) const } else if (id != -1) - //if(!uuid_is_null(id)) { xml.tag(level++, "part cloneId=\"%d\"", id); - //char sid[40]; // uuid string is 36 chars. Try 40 for good luck. - //sid[0] = 0; - //uuid_unparse_lower(id, sid); - //xml.tag(level++, "part cloneId=\"%s\"", sid); } else xml.tag(level++, "part"); xml.strTag(level, "name", _name); -// PosLen poslen(*this); -// int tickpos = tick(); -// poslen.setTick(tickpos); PosLen::write(level, xml, "poslen"); xml.intTag(level, "selected", _selected); xml.intTag(level, "color", _colorIndex); @@ -626,12 +553,12 @@ void Part::write(int level, Xml& xml, bool isCopy, bool forceWavePaths) const xml.intTag(level, "mute", _mute); if (dumpEvents) { for (ciEvent e = el->begin(); e != el->end(); ++e) - //e->second.write(level, xml, *this); e->second.write(level, xml, *this, forceWavePaths); } xml.etag(level, "part"); } +// DELETETHIS 280! whoa! /* //--------------------------------------------------------- // Part::read @@ -920,7 +847,6 @@ void Song::writeFont(int level, Xml& xml, const char* name, const QFont& font) const { xml.nput(level, "<%s family=\"%s\" size=\"%d\"", - //name, font.family().toLatin1().constData(), font.pointSize()); name, Xml::xmlString(font.family()).toLatin1().constData(), font.pointSize()); if (font.weight() != QFont::Normal) xml.nput(" weight=\"%d\"", font.weight()); @@ -1183,33 +1109,18 @@ void Song::write(int level, Xml& xml) const (*i)->write(level, xml); // write routing - for (ciTrack i = _tracks.begin(); i != _tracks.end(); ++i) { - - // p3.3.38 Changed - //if ((*i)->isMidiTrack()) - // continue; - //MusECore::WaveTrack* track = (MusECore::WaveTrack*)(*i); - //track->writeRouting(level, xml); - + for (ciTrack i = _tracks.begin(); i != _tracks.end(); ++i) (*i)->writeRouting(level, xml); - } // Write midi device routing. - for (iMidiDevice i = MusEGlobal::midiDevices.begin(); i != MusEGlobal::midiDevices.end(); ++i) { - //MidiJackDevice* mjd = dynamic_cast<MidiJackDevice*>(*i); - //if (!mjd) - // continue; - //mjd->writeRouting(level, xml); + for (iMidiDevice i = MusEGlobal::midiDevices.begin(); i != MusEGlobal::midiDevices.end(); ++i) (*i)->writeRouting(level, xml); - } - // p3.3.49 Write midi port routing. - for (int i = 0; i < MIDI_PORTS; ++i) { + // Write midi port routing. + for (int i = 0; i < MIDI_PORTS; ++i) MusEGlobal::midiPorts[i].writeRouting(level, xml); - } MusEGlobal::tempomap.write(level, xml); - ///sigmap.write(level, xml); AL::sigmap.write(level, xml); MusEGlobal::keymap.write(level, xml); _markerList->write(level, xml); @@ -1386,7 +1297,7 @@ void MusE::readToplevels(MusECore::Xml& xml) void MusE::readCtrl(MusECore::Xml&, int /*prt*/, int /*channel*/) { -#if 0 +#if 0 // DELETETHIS 30. delete the whole function? ChannelState* iState = MusEGlobal::midiPorts[prt].iState(channel); int idx = 0; @@ -1410,7 +1321,6 @@ void MusE::readCtrl(MusECore::Xml&, int /*prt*/, int /*channel*/) case MusECore::Xml::TagEnd: if (xml.s1() == "ctrl") { iState->controller[idx] = val; -// printf("%d %d ctrl %d val %d\n", prt, channel, idx, val); return; } default: @@ -1427,7 +1337,6 @@ void MusE::readCtrl(MusECore::Xml&, int /*prt*/, int /*channel*/) void MusE::readMidichannel(MusECore::Xml& xml, int prt) { int channel = 0; -// MidiPort* port = &MusEGlobal::midiPorts[prt]; for (;;) { MusECore::Xml::Token token = xml.parse(); @@ -1438,7 +1347,7 @@ void MusE::readMidichannel(MusECore::Xml& xml, int prt) return; case MusECore::Xml::TagStart: if (tag == "pitch") { -//TODO port->setCtrl(channel, 0, CTRL_PITCH, xml.parseInt()); +//TODO port->setCtrl(channel, 0, CTRL_PITCH, xml.parseInt()); DELETETHIS? and below } else if (tag == "program") { //TODO port->setCtrl(channel, 0, CTRL_PROGRAM, xml.parseInt()); @@ -1507,6 +1416,9 @@ void MusE::readMidiport(MusECore::Xml& xml) void MusE::read(MusECore::Xml& xml, bool doReadMidiPorts, bool isTemplate) { bool skipmode = true; + + writeTopwinState=true; + for (;;) { if (progress) progress->setValue(progress->value()+1); @@ -1563,6 +1475,14 @@ void MusE::read(MusECore::Xml& xml, bool doReadMidiPorts, bool isTemplate) readStatusMidiInputTransformPlugin(xml); else if (tag == "toplevels") readToplevels(xml); + else if (tag == "no_toplevels") + { + if (!isTemplate) + writeTopwinState=false; + + xml.skip("no_toplevels"); + } + else xml.unknown("muse"); break; @@ -1588,7 +1508,7 @@ void MusE::read(MusECore::Xml& xml, bool doReadMidiPorts, bool isTemplate) // write song //--------------------------------------------------------- -void MusE::write(MusECore::Xml& xml) const +void MusE::write(MusECore::Xml& xml, bool writeTopwins) const { xml.header(); @@ -1600,7 +1520,7 @@ void MusE::write(MusECore::Xml& xml) const MusEGlobal::song->write(level, xml); - if (!toplevels.empty()) { + if (writeTopwins && !toplevels.empty()) { xml.tag(level++, "toplevels"); for (MusEGui::ciToplevel i = toplevels.begin(); i != toplevels.end(); ++i) { if ((*i)->isVisible()) @@ -1608,6 +1528,11 @@ void MusE::write(MusECore::Xml& xml) const } xml.tag(level--, "/toplevels"); } + else if (!writeTopwins) + { + xml.tag(level, "no_toplevels"); + xml.etag(level, "no_toplevels"); + } xml.tag(level, "/muse"); } |