diff options
author | Robert Jonsson <spamatica@gmail.com> | 2013-03-28 14:54:33 +0000 |
---|---|---|
committer | Robert Jonsson <spamatica@gmail.com> | 2013-03-28 14:54:33 +0000 |
commit | 46118f3b3b8737c526639ed66a34d2e7e67a9137 (patch) | |
tree | 45e42b6dc75f38222d55f60d7110111c927f4262 /muse2/muse | |
parent | f1648fa3c8ff5399750222dd416b416ceeb0888a (diff) |
read old drummaps
Diffstat (limited to 'muse2/muse')
-rw-r--r-- | muse2/muse/arranger/tlist.cpp | 9 | ||||
-rw-r--r-- | muse2/muse/helper.cpp | 23 | ||||
-rw-r--r-- | muse2/muse/helper.h | 2 | ||||
-rw-r--r-- | muse2/muse/midiedit/drumedit.cpp | 3 | ||||
-rw-r--r-- | muse2/muse/track.cpp | 11 | ||||
-rw-r--r-- | muse2/muse/track.h | 2 |
6 files changed, 37 insertions, 13 deletions
diff --git a/muse2/muse/arranger/tlist.cpp b/muse2/muse/arranger/tlist.cpp index 526b36de..dbed464e 100644 --- a/muse2/muse/arranger/tlist.cpp +++ b/muse2/muse/arranger/tlist.cpp @@ -2232,10 +2232,15 @@ void TList::loadTrackDrummap(MusECore::MidiTrack* t, const char* fn_) if (mode == 0 && tag == "muse") mode = 1; else if (mode == 1 && tag == "our_drummap") { - t->readOurDrumMap(xml, true); + t->readOurDrumMap(xml, tag, true); mode = 0; } - else + else if (mode == 1 && tag == "drummap") { // compatibility mode, read old drummaps + QMessageBox::information(this, tr("Drummap"), tr("This drummap was created with a previous version of MusE,\nit is being read but the format has changed slightly so some\nadjustments may be necessary.")); + t->readOurDrumMap(xml, tag, true, true); + mode = 0; + } + else xml.unknown("TList::loadTrackDrummap"); break; case MusECore::Xml::Attribut: diff --git a/muse2/muse/helper.cpp b/muse2/muse/helper.cpp index c50fb66d..efb4ec68 100644 --- a/muse2/muse/helper.cpp +++ b/muse2/muse/helper.cpp @@ -255,7 +255,7 @@ void write_new_style_drummap(int level, Xml& xml, const char* tagname, } void read_new_style_drummap(Xml& xml, const char* tagname, - DrumMap* drummap, bool* drummap_hidden) + DrumMap* drummap, bool* drummap_hidden, bool compatibility) { for (;;) { @@ -268,7 +268,8 @@ void read_new_style_drummap(Xml& xml, const char* tagname, case Xml::TagStart: if (tag == "entry") // then read that entry with a nested loop { - DrumMap* dm=NULL; + DrumMap* dm=NULL; + DrumMap temporaryMap; bool* hidden=NULL; for (;;) // nested loop { @@ -295,9 +296,13 @@ void read_new_style_drummap(Xml& xml, const char* tagname, break; case Xml::TagStart: - if (dm==NULL) + if (dm==NULL && compatibility == false) printf("ERROR: THIS SHOULD NEVER HAPPEN: no valid 'pitch' attribute in <entry> tag, but sub-tags follow in read_new_style_drummap()!\n"); - else if (tag == "name") + else if (dm ==NULL && compatibility == true) + { + dm = &temporaryMap; + } + if (tag == "name") dm->name = xml.parse(QString("name")); else if (tag == "vol") dm->vol = (unsigned char)xml.parseInt(); @@ -313,8 +318,16 @@ void read_new_style_drummap(Xml& xml, const char* tagname, dm->lv3 = xml.parseInt(); else if (tag == "lv4") dm->lv4 = xml.parseInt(); - else if (tag == "enote") + else if (tag == "enote") { dm->enote = xml.parseInt(); + if (compatibility) { + int pitch = temporaryMap.enote; + drummap[pitch] = temporaryMap; + dm = &drummap[pitch]; + hidden = drummap_hidden ? &drummap_hidden[pitch] : NULL; + dm->anote = pitch; + } + } else if (tag == "mute") dm->mute = xml.parseInt(); else if (tag == "hide") diff --git a/muse2/muse/helper.h b/muse2/muse/helper.h index 56bd0bc8..33b2e9a0 100644 --- a/muse2/muse/helper.h +++ b/muse2/muse/helper.h @@ -51,7 +51,7 @@ bool drummaps_almost_equal(const DrumMap* one, const DrumMap* two, int drummap_s void write_new_style_drummap(int level, Xml& xml, const char* tagname, DrumMap* drummap, bool* drummap_hidden=NULL, bool full=false); void read_new_style_drummap(Xml& xml, const char* tagname, - DrumMap* drummap, bool* drummap_hidden=NULL); + DrumMap* drummap, bool* drummap_hidden=NULL, bool compatibility=false); QSet<Part*> parts_at_tick(unsigned tick); diff --git a/muse2/muse/midiedit/drumedit.cpp b/muse2/muse/midiedit/drumedit.cpp index aa55e7d8..3ddf6f7b 100644 --- a/muse2/muse/midiedit/drumedit.cpp +++ b/muse2/muse/midiedit/drumedit.cpp @@ -1519,6 +1519,8 @@ void DrumEdit::keyPressEvent(QKeyEvent* event) dlist->setCurDrumInstrument(dlist->getSelectedInstrument()-1); dlist->redraw(); ((DrumCanvas*)canvas)->selectCursorEvent(((DrumCanvas*)canvas)->getEventAtCursorPos()); + ((DrumCanvas*)canvas)->keyPressed(dlist->getSelectedInstrument(),100); + MusEGlobal::song->update(SC_DRUMMAP); return; } @@ -1526,6 +1528,7 @@ void DrumEdit::keyPressEvent(QKeyEvent* event) dlist->setCurDrumInstrument(dlist->getSelectedInstrument()+1); dlist->redraw(); ((DrumCanvas*)canvas)->selectCursorEvent(((DrumCanvas*)canvas)->getEventAtCursorPos()); + ((DrumCanvas*)canvas)->keyPressed(dlist->getSelectedInstrument(),100); MusEGlobal::song->update(SC_DRUMMAP); return; } diff --git a/muse2/muse/track.cpp b/muse2/muse/track.cpp index 25f93804..65580793 100644 --- a/muse2/muse/track.cpp +++ b/muse2/muse/track.cpp @@ -39,6 +39,7 @@ #include "limits.h" #include "dssihost.h" #include "gconfig.h" +#include <QMessageBox> namespace MusECore { @@ -1152,8 +1153,10 @@ void MidiTrack::readOurDrumSettings(Xml& xml) else if (tag == "ordering_tied") _drummap_ordering_tied_to_patch = xml.parseInt(); else if (tag == "our_drummap") - readOurDrumMap(xml); - else + readOurDrumMap(xml, tag); + else if (tag == "drummap") + readOurDrumMap(xml, tag, false); + else xml.unknown("MidiTrack::readOurDrumSettings"); break; @@ -1167,12 +1170,12 @@ void MidiTrack::readOurDrumSettings(Xml& xml) } } -void MidiTrack::readOurDrumMap(Xml& xml, bool dont_init) +void MidiTrack::readOurDrumMap(Xml& xml, QString tag, bool dont_init, bool compatibility) { if (!dont_init) init_drummap(false); _drummap_tied_to_patch=false; _drummap_ordering_tied_to_patch=false; - read_new_style_drummap(xml, "our_drummap", _drummap, _drummap_hidden); + read_new_style_drummap(xml, tag.toLatin1().data(), _drummap, _drummap_hidden, compatibility); update_drum_in_map(); } diff --git a/muse2/muse/track.h b/muse2/muse/track.h index 61326b4a..1c1b28f6 100644 --- a/muse2/muse/track.h +++ b/muse2/muse/track.h @@ -327,7 +327,7 @@ class MidiTrack : public Track { //void writeOurDrumSettings(int level, Xml& xml) const; // above in private: //void readOurDrumSettings(Xml& xml); // above in private: void writeOurDrumMap(int level, Xml& xml, bool full) const; - void readOurDrumMap(Xml& xml, bool dont_init=false); + void readOurDrumMap(Xml& xml, QString tag, bool dont_init=false, bool compatibility=false); }; //--------------------------------------------------------- |