summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--muse2/ChangeLog2
-rw-r--r--muse2/muse/arranger/tlist.cpp9
-rw-r--r--muse2/muse/helper.cpp23
-rw-r--r--muse2/muse/helper.h2
-rw-r--r--muse2/muse/midiedit/drumedit.cpp3
-rw-r--r--muse2/muse/track.cpp11
-rw-r--r--muse2/muse/track.h2
7 files changed, 39 insertions, 13 deletions
diff --git a/muse2/ChangeLog b/muse2/ChangeLog
index 4ede0d3b..96cf673d 100644
--- a/muse2/ChangeLog
+++ b/muse2/ChangeLog
@@ -1,3 +1,5 @@
+28.03.2013:
+ - Allow reading old drummaps for new style drumtracks (rj)
27.03.2013:
- Fixed moving events with keyboard in Drum editor (rj)
10.03.2013:
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);
};
//---------------------------------------------------------