summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian Jung <flo@windfisch.org>2011-10-08 15:51:58 +0000
committerFlorian Jung <flo@windfisch.org>2011-10-08 15:51:58 +0000
commit9cd7615aaa5bc2818ae5f9425173f08673bbc194 (patch)
treef3d9820a84fd43b4667c0222ee3ac0704c3e6eee
parent9e6dc222b92bbfba58756d3be47890dd885b8f71 (diff)
parent80d1f99cbad08ee6b0d7076f8df80ae71857c9f3 (diff)
merged with trunk again
drum ordering is now stored in the songfile track reading bugfix
-rw-r--r--muse2/muse/midiedit/dlist.cpp13
-rw-r--r--muse2/muse/midiedit/drummap.cpp135
-rw-r--r--muse2/muse/midiedit/drummap.h17
-rw-r--r--muse2/muse/midiedit/scoreedit.cpp2
-rw-r--r--muse2/muse/songfile.cpp3
-rw-r--r--muse2/muse/track.cpp2
6 files changed, 163 insertions, 9 deletions
diff --git a/muse2/muse/midiedit/dlist.cpp b/muse2/muse/midiedit/dlist.cpp
index 1ffae02e..4ad971e7 100644
--- a/muse2/muse/midiedit/dlist.cpp
+++ b/muse2/muse/midiedit/dlist.cpp
@@ -398,10 +398,7 @@ void DList::viewMousePressEvent(QMouseEvent* ev)
}
}
- {
- int velocity = 127 * float(ev->x()) / width();
- emit keyPressed(instrument, velocity);//(dm->anote, shift);
- }
+ emit keyPressed(instrument, 100);
break;
case COL_OUTCHANNEL: // this column isn't visible in new style drum mode
val = dm->channel + incVal;
@@ -468,7 +465,12 @@ void DList::viewMousePressEvent(QMouseEvent* ev)
break;
case COL_NAME:
if (button == Qt::LeftButton)
- emit keyPressed(instrument, 100); //Mapping done on other side, send index
+ {
+ int velo = 127 * (ev->x() - header->sectionPosition(COL_NAME)) / (header->sectionSize(COL_NAME) - 10);
+ if (velo < 0) velo = 0;
+ if (velo > 127 ) velo = 127;
+ emit keyPressed(instrument, velo); //Mapping done on other side, send index
+ }
else if (button == Qt::MidButton) // hide that instrument
{
QSet<MusECore::Track*>* group = &dcanvas->get_instrument_map()[instrument].tracks;
@@ -510,7 +512,6 @@ void DList::viewMousePressEvent(QMouseEvent* ev)
delete popup;
}
break;
-
default:
break;
}
diff --git a/muse2/muse/midiedit/drummap.cpp b/muse2/muse/midiedit/drummap.cpp
index 9d4b23c2..43e66345 100644
--- a/muse2/muse/midiedit/drummap.cpp
+++ b/muse2/muse/midiedit/drummap.cpp
@@ -26,6 +26,7 @@
#include "xml.h"
#include "song.h"
+#include <QSet>
namespace MusEGlobal {
char drumOutmap[DRUM_MAPSIZE];
@@ -522,3 +523,137 @@ void readDrumMap(Xml& xml, bool external)
}
} // namespace MusECore
+
+
+namespace MusEGlobal {
+
+void global_drum_ordering_t::cleanup()
+{
+ using MusEGlobal::song;
+ using MusECore::MidiTrack;
+ using MusECore::ciTrack;
+
+ QSet<MidiTrack*> tracks;
+ for (ciTrack it = song->tracks()->begin(); it != song->tracks()->end(); it++)
+ tracks.insert( dynamic_cast<MidiTrack*>(*it) );
+
+ for (iterator it = begin(); it != end();)
+ {
+ if (!tracks.contains(it->first))
+ it=erase(it);
+ else
+ it++;
+ }
+}
+
+void global_drum_ordering_t::write(int level, MusECore::Xml& xml)
+{
+ cleanup();
+
+ xml.tag(level++, "drum_ordering");
+
+ for (iterator it = begin(); it != end(); it++)
+ write_single(level, xml, *it);
+
+ xml.etag(level, "drum_ordering");
+}
+
+void global_drum_ordering_t::write_single(int level, MusECore::Xml& xml, const entry_t& entry)
+{
+ xml.tag(level++, "entry");
+ xml.strTag(level, "track", entry.first->name());
+ xml.intTag(level, "instrument", entry.second);
+ xml.etag(level, "entry");
+}
+
+void global_drum_ordering_t::read(MusECore::Xml& xml)
+{
+ using MusECore::Xml;
+
+ clear();
+
+ 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 == "entry")
+ append(read_single(xml));
+ else
+ xml.unknown("global_drum_ordering_t");
+ break;
+
+ case Xml::TagEnd:
+ if (tag == "drum_ordering")
+ return;
+
+ default:
+ break;
+ }
+ }
+}
+
+global_drum_ordering_t::entry_t global_drum_ordering_t::read_single(MusECore::Xml& xml)
+{
+ using MusECore::Xml;
+ using MusEGlobal::song;
+ using MusECore::ciTrack;
+
+ entry_t entry;
+ entry.first=NULL;
+ entry.second=-1;
+
+ 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 == "track")
+ {
+ QString track_name=xml.parse1();
+
+ ciTrack it;
+ for (it = song->tracks()->begin(); it != song->tracks()->end(); it++)
+ if (track_name == (*it)->name())
+ break;
+
+ if (it != song->tracks()->end())
+ entry.first=dynamic_cast<MusECore::MidiTrack*>(*it);
+ }
+ else if (tag == "instrument")
+ entry.second=xml.parseInt();
+ else
+ xml.unknown("global_drum_ordering_t (single entry)");
+ break;
+
+ case Xml::TagEnd:
+ if (tag == "entry")
+ goto end_of_read_single;
+
+ default:
+ break;
+ }
+ }
+
+ end_of_read_single:
+
+ if (entry.first == NULL)
+ printf("ERROR: global_drum_ordering_t::read_single() couldn't find the specified track!\n");
+
+ if (entry.second < 0 || entry.second > 127)
+ printf("ERROR: global_drum_ordering_t::read_single(): instrument number is out of bounds (%i)!\n", entry.second);
+
+ return entry;
+}
+
+} // namespace MusEGlobal
diff --git a/muse2/muse/midiedit/drummap.h b/muse2/muse/midiedit/drummap.h
index 2dbaae42..f3186afa 100644
--- a/muse2/muse/midiedit/drummap.h
+++ b/muse2/muse/midiedit/drummap.h
@@ -66,9 +66,24 @@ namespace MusEGlobal {
extern char drumOutmap[DRUM_MAPSIZE];
extern char drumInmap[DRUM_MAPSIZE];
extern MusECore::DrumMap drumMap[DRUM_MAPSIZE];
-typedef QList< std::pair<MusECore::MidiTrack*,int> > global_drum_ordering_t;
+
+
+class global_drum_ordering_t : public QList< std::pair<MusECore::MidiTrack*,int> >
+{
+ public:
+ void cleanup();
+ void write(int level, MusECore::Xml& xml);
+ void read(MusECore::Xml& xml);
+
+ private:
+ typedef std::pair<MusECore::MidiTrack*,int> entry_t;
+
+ void write_single(int level, MusECore::Xml& xml, const entry_t& entry);
+ entry_t read_single(MusECore::Xml& xml);
+};
extern global_drum_ordering_t global_drum_ordering;
+
}
#endif
diff --git a/muse2/muse/midiedit/scoreedit.cpp b/muse2/muse/midiedit/scoreedit.cpp
index d09ebc34..5770ee6c 100644
--- a/muse2/muse/midiedit/scoreedit.cpp
+++ b/muse2/muse/midiedit/scoreedit.cpp
@@ -4617,7 +4617,7 @@ void ScoreCanvas::add_new_parts(const std::map< MusECore::Part*, std::set<MusECo
* o offer some way to set maintained_automatically to true again
* o move generation and deletion of ourDrumMap from DCanvas to DrumEditor and remove ugly wrapper functions
*
- * o when playing back a flo-drum-track: treat as a MIDI track,
+ * x when playing back a flo-drum-track: treat as a MIDI track,
* EXCEPT that the drum list's mute entries are respected!
* o when recording or echoing a flo-drum-track: watch out for In-Notes!
* o update [midi]track::read/write, readproperties, writeprop... (drumlist etc), operator=
diff --git a/muse2/muse/songfile.cpp b/muse2/muse/songfile.cpp
index 9efc75bd..3096312e 100644
--- a/muse2/muse/songfile.cpp
+++ b/muse2/muse/songfile.cpp
@@ -1121,6 +1121,8 @@ void Song::read(Xml& xml, bool isTemplate)
}
else if (tag == "drummap")
readDrumMap(xml, false);
+ else if (tag == "drum_ordering")
+ MusEGlobal::global_drum_ordering.read(xml);
else
xml.unknown("Song");
break;
@@ -1213,6 +1215,7 @@ void Song::write(int level, Xml& xml) const
_markerList->write(level, xml);
writeDrumMap(level, xml, false);
+ MusEGlobal::global_drum_ordering.write(level, xml);
xml.tag(level, "/song");
// Restore backup of the clone list, to retain any 'copy' items,
diff --git a/muse2/muse/track.cpp b/muse2/muse/track.cpp
index e2149ddb..32344b6e 100644
--- a/muse2/muse/track.cpp
+++ b/muse2/muse/track.cpp
@@ -862,7 +862,7 @@ void MidiTrack::read(Xml& xml)
case Xml::Attribut:
break;
case Xml::TagEnd:
- if (tag == "miditrack" || tag == "drumtrack")
+ if (tag == "miditrack" || tag == "drumtrack" || tag == "newdrumtrack")
{
setInPortAndChannelMask(portmask, chanmask); // p3.3.48: Support old files.
return;