summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--muse2/muse/midiedit/dcanvas.cpp101
-rw-r--r--muse2/muse/midiedit/dcanvas.h5
-rw-r--r--muse2/muse/midiedit/dlist.cpp18
-rw-r--r--muse2/muse/midiedit/drummap.cpp2
-rw-r--r--muse2/muse/midiedit/drummap.h4
-rw-r--r--muse2/muse/midiedit/scoreedit.cpp17
-rw-r--r--muse2/muse/track.cpp29
7 files changed, 139 insertions, 37 deletions
diff --git a/muse2/muse/midiedit/dcanvas.cpp b/muse2/muse/midiedit/dcanvas.cpp
index 26e7aed4..81f8da00 100644
--- a/muse2/muse/midiedit/dcanvas.cpp
+++ b/muse2/muse/midiedit/dcanvas.cpp
@@ -125,7 +125,6 @@ DrumCanvas::DrumCanvas(MidiEditor* pr, QWidget* parent, int sx,
for (int i=0;i<DRUM_MAPSIZE;i++)
{
temp.pitch=i;
- temp.track_dlist_index=i; // actually unneeded, but who knows...
instrument_map.append(temp);
}
}
@@ -154,32 +153,42 @@ DrumCanvas::DrumCanvas(MidiEditor* pr, QWidget* parent, int sx,
// from now, we assume that every track_group's entry only groups tracks with identical
// drum maps, but not necessarily identical hide-lists together.
-
- for (QList< QSet<Track*> >::iterator group=track_groups.begin(); group!=track_groups.end(); group++)
+ for (global_drum_ordering_t::iterator order_it=global_drum_ordering.begin(); order_it!=global_drum_ordering.end(); order_it++)
{
- for (int i=0;i<128;i++) // find out if instrument is hidden and make "mute"
- { // consistent across groups for non-hidden instruments
+ // look if we have order_it->first (the MidiTrack*) in any of our track groups
+ QList< QSet<Track*> >::iterator group;
+ for (group=track_groups.begin(); group!=track_groups.end(); group++)
+ if (group->contains(order_it->first))
+ break;
+
+ if (group!=track_groups.end()) // we have
+ {
+ int pitch=order_it->second;
+
bool mute=true;
bool hidden=true;
for (QSet<Track*>::iterator track=group->begin(); track!=group->end() && (mute || hidden); track++)
{
- if (dynamic_cast<MidiTrack*>(*track)->drummap()[i].mute == false)
+ if (dynamic_cast<MidiTrack*>(*track)->drummap()[pitch].mute == false)
mute=false;
- if (dynamic_cast<MidiTrack*>(*track)->drummap_hidden()[i] == false)
+ if (dynamic_cast<MidiTrack*>(*track)->drummap_hidden()[pitch] == false)
hidden=false;
}
if (!hidden)
{
for (QSet<Track*>::iterator track=group->begin(); track!=group->end(); track++)
- dynamic_cast<MidiTrack*>(*track)->drummap()[i].mute=mute;
+ dynamic_cast<MidiTrack*>(*track)->drummap()[pitch].mute=mute;
- instrument_map.append(instrument_number_mapping_t(*group, dynamic_cast<MidiTrack*>(*group->begin())->drummap()[i].anote, i));
+ if (dynamic_cast<MidiTrack*>(*group->begin())->drummap()[pitch].anote != pitch)
+ printf("THIS SHOULD NEVER HAPPEN: track's_drummap[pitch].anote (%i)!= pitch (%i) !!!\n",dynamic_cast<MidiTrack*>(*group->begin())->drummap()[pitch].anote,pitch);
+
+ instrument_map.append(instrument_number_mapping_t(*group, pitch));
}
}
+ // else ignore it
}
-
// populate ourDrumMap
@@ -189,8 +198,7 @@ DrumCanvas::DrumCanvas(MidiEditor* pr, QWidget* parent, int sx,
must_delete_our_drum_map=true;
for (int i=0;i<size;i++)
- ourDrumMap[i] = dynamic_cast<MidiTrack*>(*instrument_map[i].tracks.begin())->drummap()[instrument_map[i].track_dlist_index];
- //ourDrumMap[i] = idrumMap[instrument_map[i%128].pitch]; //FINDMICH dummy!
+ ourDrumMap[i] = dynamic_cast<MidiTrack*>(*instrument_map[i].tracks.begin())->drummap()[instrument_map[i].pitch];
}
@@ -890,6 +898,9 @@ void DrumCanvas::keyReleased(int index, bool) //FINDMICH later
void DrumCanvas::mapChanged(int spitch, int dpitch)
{
+ // spitch may be the same as dpitch! and something in here must be executed
+ // even if they're same (i assume it's song->update(SC_DRUMMAP)) (flo93)
+
if (old_style_drummap_mode)
{
Undo operations;
@@ -972,15 +983,64 @@ void DrumCanvas::mapChanged(int spitch, int dpitch)
}
else // if (!old_style_drummap_mode)
{
- DrumMap dm = ourDrumMap[spitch];
- ourDrumMap[spitch] = ourDrumMap[dpitch];
- ourDrumMap[dpitch] = dm;
+ if (dpitch!=spitch)
+ {
+ DrumMap dm_temp = ourDrumMap[spitch];
+ instrument_number_mapping_t im_temp = instrument_map[spitch];
+
+ global_drum_ordering_t order_temp;
+ for (global_drum_ordering_t::iterator it=global_drum_ordering.begin(); it!=global_drum_ordering.end();)
+ {
+ if (im_temp.pitch==it->second && im_temp.tracks.contains(it->first))
+ {
+ order_temp.push_back(*it);
+ it=global_drum_ordering.erase(it);
+ }
+ else
+ it++;
+ }
+
+ // the instrument represented by instrument_map[dpitch] is always the instrument
+ // which will be immediately AFTER our dragged instrument
+ for (global_drum_ordering_t::iterator it=global_drum_ordering.begin(); it!=global_drum_ordering.end(); it++)
+ if (instrument_map[dpitch].pitch==it->second && instrument_map[dpitch].tracks.contains(it->first))
+ {
+ while (!order_temp.empty())
+ it=global_drum_ordering.insert(it, order_temp.takeLast());
+
+ break;
+ }
- instrument_number_mapping_t im = instrument_map[spitch];
- instrument_map[spitch] = instrument_map[dpitch];
- instrument_map[dpitch] = im;
- song->update(SC_DRUMMAP); //FINDMICHJETZT handle that properly!
+
+
+
+ if (dpitch > spitch)
+ {
+ for (int i=spitch; i<dpitch-1; i++)
+ {
+ ourDrumMap[i]=ourDrumMap[i+1];
+ instrument_map[i]=instrument_map[i+1];
+ }
+
+ ourDrumMap[dpitch-1] = dm_temp;
+ instrument_map[dpitch-1] = im_temp;
+ }
+ else if (spitch > dpitch)
+ {
+ for (int i=spitch; i>dpitch; i--)
+ {
+ ourDrumMap[i]=ourDrumMap[i-1];
+ instrument_map[i]=instrument_map[i-1];
+ }
+
+ ourDrumMap[dpitch] = dm_temp;
+ instrument_map[dpitch] = im_temp;
+ }
+ }
+
+
+ song->update(SC_DRUMMAP); //FINDMICHJETZT handle that properly! if not done already (?) i think it is
}
}
@@ -1294,10 +1354,9 @@ int DrumCanvas::pitch_and_track_to_instrument(int pitch, Track* track)
}
void DrumCanvas::propagate_drummap_change(int instr)
-//FINDMICHJETZT does that work properly?
{
const QSet<Track*>& tracks=instrument_map[instr].tracks;
- int index=instrument_map[instr].track_dlist_index;
+ int index=instrument_map[instr].pitch;
for (QSet<Track*>::const_iterator it = tracks.begin(); it != tracks.end(); it++)
dynamic_cast<MidiTrack*>(*it)->drummap()[index] = ourDrumMap[instr];
diff --git a/muse2/muse/midiedit/dcanvas.h b/muse2/muse/midiedit/dcanvas.h
index 736b63b3..75bcccf6 100644
--- a/muse2/muse/midiedit/dcanvas.h
+++ b/muse2/muse/midiedit/dcanvas.h
@@ -60,20 +60,17 @@ struct instrument_number_mapping_t
{
QSet<Track*> tracks;
int pitch;
- int track_dlist_index;
instrument_number_mapping_t()
{
pitch=-1;
- track_dlist_index=-1;
tracks.clear();
}
- instrument_number_mapping_t(const QSet<Track*>& tr, int p, int i)
+ instrument_number_mapping_t(const QSet<Track*>& tr, int p)
{
tracks=tr;
pitch=p;
- track_dlist_index=i;
}
};
diff --git a/muse2/muse/midiedit/dlist.cpp b/muse2/muse/midiedit/dlist.cpp
index 9f1d9b28..be7255b9 100644
--- a/muse2/muse/midiedit/dlist.cpp
+++ b/muse2/muse/midiedit/dlist.cpp
@@ -854,11 +854,21 @@ void DList::viewMouseReleaseEvent(QMouseEvent* ev)
{
if (drag == DRAG) {
int y = ev->y();
- unsigned dInstrument = y / TH;
+ int dInstrument;
+ if (old_style_drummap_mode)
+ dInstrument = y / TH;
+ else
+ dInstrument = (y+TH/2) / TH;
+
+ if (dInstrument < 0) dInstrument=0;
+ if (dInstrument >= ourDrumMapSize) dInstrument=ourDrumMapSize-1;
+
+ int cur_sel = (!old_style_drummap_mode && dInstrument>sInstrument) ? dInstrument-1 : dInstrument;
+
setCursor(QCursor(Qt::ArrowCursor));
- currentlySelected = &ourDrumMap[int(dInstrument)];
- emit curDrumInstrumentChanged(dInstrument);
- emit mapChanged(sInstrument, dInstrument); //Track instrument change done in canvas
+ currentlySelected = &ourDrumMap[cur_sel];
+ emit curDrumInstrumentChanged((unsigned)cur_sel);
+ emit mapChanged(sInstrument, (unsigned)dInstrument); //Track instrument change done in canvas
}
drag = NORMAL;
//?? redraw(); //commented out NOT by flo93; was already commented out
diff --git a/muse2/muse/midiedit/drummap.cpp b/muse2/muse/midiedit/drummap.cpp
index 032c2bd6..8f49afc0 100644
--- a/muse2/muse/midiedit/drummap.cpp
+++ b/muse2/muse/midiedit/drummap.cpp
@@ -26,6 +26,8 @@
#include "xml.h"
#include "song.h"
+global_drum_ordering_t global_drum_ordering;
+
char drumOutmap[DRUM_MAPSIZE];
char drumInmap[128];
diff --git a/muse2/muse/midiedit/drummap.h b/muse2/muse/midiedit/drummap.h
index 7bf2b834..9fe14cc9 100644
--- a/muse2/muse/midiedit/drummap.h
+++ b/muse2/muse/midiedit/drummap.h
@@ -59,5 +59,9 @@ extern void writeDrumMap(int level, Xml& xml, bool external);
extern void readDrumMap(Xml& xml, bool external);
extern void resetGMDrumMap();
+class MidiTrack;
+typedef QList< std::pair<MidiTrack*,int> > global_drum_ordering_t;
+
+extern global_drum_ordering_t global_drum_ordering;
#endif
diff --git a/muse2/muse/midiedit/scoreedit.cpp b/muse2/muse/midiedit/scoreedit.cpp
index b3c87206..ad43527a 100644
--- a/muse2/muse/midiedit/scoreedit.cpp
+++ b/muse2/muse/midiedit/scoreedit.cpp
@@ -4590,19 +4590,23 @@ void ScoreCanvas::add_new_parts(const std::map< Part*, std::set<Part*> >& param)
* o fix valgrind problems
*
* > o drum editor: channel-stuff
- * o hide instruments: should work
- * o remember ordering of instruments: IMPLEMENT
- * o tracks have own drumlists: should work.
+ * o dialog for maintaining drum lists, hide etc
+ * o grouping
* o respect "_drummap_tied_to_patch": IMPLEMENT
+ * o save hide, ordering, track's drumlists
+ * x hide instruments
+ * x remember ordering of instruments
+ * x tracks have own drumlists
*
- * o each track has its own drumlist and a bool maintained_automatically
+ * x each track has its own drumlist and a bool maintained_automatically
* o whenever changing the patch and maintained_automatically==true,
* the drumlist is replaced by the according one (for example, "jazz" drum kit's list)
* o whenever changing the drumlist and maintained_automatically==true,
* ask the user if he wants to proceed, and then set maintained_automatically to false
* o offer some way to set maintained_automatically to true again
- * o each track has a bool hidden[128], which is used for hiding entries.
+ * x each track has a bool hidden[128], which is used for hiding entries.
* when mixing, the values of all tracks are ANDed
+ * o offer a way to hide/show instruments
*
* o drum editor can: "display each track separately", "mix all with same port, patch and drumlist"
* x a map maps all y-coord.s to { set<Track*>, pitch }
@@ -4616,9 +4620,10 @@ void ScoreCanvas::add_new_parts(const std::map< Part*, std::set<Part*> >& param)
* 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=
- * o BUG: drummap[i].pitch MUST BE i! or instr_map.pitch must be set accordingly!
*
* IMPORTANT TODO
+ * o support "new style" reordering with old style drum tracks as well
+ * (not swapping but inserting!)
* ! o fix sigedit boxes (see also "current todo")
* o add "dotted quarter" quantize option (for 6/8 beat)
* o ticks-to-quarter spinboxes
diff --git a/muse2/muse/track.cpp b/muse2/muse/track.cpp
index 29917dc1..64ad928c 100644
--- a/muse2/muse/track.cpp
+++ b/muse2/muse/track.cpp
@@ -394,9 +394,17 @@ MidiTrack::MidiTrack()
for (int i=0;i<128;i++)
{
- _drummap[i]=idrumMap[i];
- _drummap_hidden[i]=false;
+ int idx=idrumMap[i].anote;
+ if (idx < 0 || idx >= 128)
+ printf ("ERROR: THIS SHOULD NEVER HAPPEN: idrumMap[%i].anote is not within 0..127!\n", idx);
+ else
+ _drummap[idx]=idrumMap[i];
+
+ global_drum_ordering.push_back(std::pair<MidiTrack*,int>(this,idx));
}
+ for (int i=0;i<128;i++)
+ _drummap_hidden[i]=false;
+
}
//MidiTrack::MidiTrack(const MidiTrack& mt)
@@ -422,6 +430,14 @@ MidiTrack::MidiTrack(const MidiTrack& mt, bool cloneParts)
_drummap_hidden=new bool[128];
memcpy(_drummap, mt._drummap, 128*sizeof(*_drummap));
memcpy(_drummap_hidden, mt._drummap_hidden, 128*sizeof(*_drummap_hidden));
+
+ for (global_drum_ordering_t::iterator it=global_drum_ordering.begin(); it!=global_drum_ordering.end(); it++)
+ if (it->first == &mt)
+ {
+ it=global_drum_ordering.insert(it, *it); // duplicates the entry at it, set it to the first entry of both
+ it++; // make it point to the second entry
+ it->first=this;
+ }
}
MidiTrack::~MidiTrack()
@@ -430,6 +446,15 @@ MidiTrack::~MidiTrack()
delete _mpevents;
delete [] _drummap;
delete [] _drummap_hidden;
+
+ // remove ourselves from the global_drum_ordering list
+ // this is not really necessary, but cleaner
+ for (global_drum_ordering_t::iterator it=global_drum_ordering.begin(); it!=global_drum_ordering.end();)
+ if (it->first == this)
+ it=global_drum_ordering.erase(it);
+ else
+ it++;
+
}
//---------------------------------------------------------