diff options
author | Florian Jung <flo@windfisch.org> | 2011-10-03 12:35:57 +0000 |
---|---|---|
committer | Florian Jung <flo@windfisch.org> | 2011-10-03 12:35:57 +0000 |
commit | b99988059eb65520df143380aa707c52256cf77c (patch) | |
tree | 1823821eb0bbe55cbfb02a550b4ca212c2280f0e | |
parent | fbb72c809a2e75e0d4b038056df80d60c09d62c5 (diff) |
added support for grouping tracks in drum editor
-rw-r--r-- | muse2/muse/helper.cpp | 12 | ||||
-rw-r--r-- | muse2/muse/helper.h | 4 | ||||
-rw-r--r-- | muse2/muse/midiedit/dcanvas.cpp | 64 | ||||
-rw-r--r-- | muse2/muse/midiedit/dcanvas.h | 7 | ||||
-rw-r--r-- | muse2/muse/midiedit/dlist.cpp | 15 | ||||
-rw-r--r-- | muse2/muse/midiedit/drumedit.cpp | 2 | ||||
-rw-r--r-- | muse2/muse/midiedit/drumedit.h | 9 | ||||
-rw-r--r-- | muse2/muse/midiedit/drummap.h | 3 | ||||
-rw-r--r-- | muse2/muse/midiedit/scoreedit.cpp | 3 | ||||
-rw-r--r-- | muse2/muse/track.h | 2 |
10 files changed, 92 insertions, 29 deletions
diff --git a/muse2/muse/helper.cpp b/muse2/muse/helper.cpp index 1a223bb3..255e8505 100644 --- a/muse2/muse/helper.cpp +++ b/muse2/muse/helper.cpp @@ -328,4 +328,16 @@ bool any_event_selected(const set<Part*>& parts, bool in_range) return !get_events(parts, in_range ? 3 : 1).empty(); } +bool drummaps_almost_equal(DrumMap* one, DrumMap* two, int len) +{ + for (int i=0; i<len; i++) + { + DrumMap tmp = one[i]; + tmp.mute=two[i].mute; + if (tmp!=two[i]) + return false; + } + return true; +} + } // namespace MusEUtil diff --git a/muse2/muse/helper.h b/muse2/muse/helper.h index e86a8949..b8ff391e 100644 --- a/muse2/muse/helper.h +++ b/muse2/muse/helper.h @@ -25,6 +25,8 @@ #include <set> +#include "drummap.h" + class QActionGroup; class QString; class QMenu; @@ -43,6 +45,8 @@ bool any_event_selected(const std::set<Part*>&, bool in_range=false); QMenu* populateAddSynth(QWidget* parent); QActionGroup* populateAddTrack(QMenu* addTrack); +bool drummaps_almost_equal(DrumMap* one, DrumMap* two, int drummap_size=128); + } #endif diff --git a/muse2/muse/midiedit/dcanvas.cpp b/muse2/muse/midiedit/dcanvas.cpp index 81f8da00..550de13b 100644 --- a/muse2/muse/midiedit/dcanvas.cpp +++ b/muse2/muse/midiedit/dcanvas.cpp @@ -50,6 +50,7 @@ #include "shortcuts.h" #include "icons.h" #include "functions.h" +#include "helper.h" #define CARET 10 #define CARET2 5 @@ -110,6 +111,8 @@ DrumCanvas::DrumCanvas(MidiEditor* pr, QWidget* parent, int sx, int sy, const char* name) : EventCanvas(pr, parent, sx, sy, name) { + using MusEUtil::drummaps_almost_equal; + old_style_drummap_mode = dynamic_cast<DrumEdit*>(pr)->old_style_drummap_mode(); if (old_style_drummap_mode) @@ -131,7 +134,6 @@ DrumCanvas::DrumCanvas(MidiEditor* pr, QWidget* parent, int sx, else { if (debugMsg) printf("DrumCanvas in new style drummap mode\n"); - // FINDMICHJETZT TrackList* tl=song->tracks(); QList< QSet<Track*> > track_groups; @@ -145,16 +147,61 @@ DrumCanvas::DrumCanvas(MidiEditor* pr, QWidget* parent, int sx, if (p_it!=pr->parts()->end()) // if *track is represented by some part in this editor { - QSet<Track*> temp; - temp.insert(*track); - track_groups.push_back(temp); + bool inserted=false; + + switch (dynamic_cast<DrumEdit*>(pr)->group_mode()) + { + case DrumEdit::GROUP_SAME_CHANNEL: + for (QList< QSet<Track*> >::iterator group=track_groups.begin(); group!=track_groups.end(); group++) + if ( ((MidiTrack*)*group->begin())->outChannel() == ((MidiTrack*)*track)->outChannel() && + ((MidiTrack*)*group->begin())->outPort() == ((MidiTrack*)*track)->outPort() && + (drummaps_almost_equal(((MidiTrack*)*group->begin())->drummap(), ((MidiTrack*)*track)->drummap())) ) + { + group->insert(*track); + inserted=true; + break; + } + break; + + case DrumEdit::GROUP_MAX: + for (QList< QSet<Track*> >::iterator group=track_groups.begin(); group!=track_groups.end(); group++) + if (drummaps_almost_equal(((MidiTrack*)*group->begin())->drummap(), ((MidiTrack*)*track)->drummap())) + { + group->insert(*track); + inserted=true; + break; + } + break; + + case DrumEdit::DONT_GROUP: + inserted=false; + break; + + default: + printf("THIS SHOULD NEVER HAPPEN: group_mode() is invalid!\n"); + inserted=false; + } + + if (!inserted) + { + QSet<Track*> temp; + temp.insert(*track); + track_groups.push_back(temp); + } } } + printf("FINDMICH DEBUG: we have %i groups\n",track_groups.size()); + // from now, we assume that every track_group's entry only groups tracks with identical // drum maps, but not necessarily identical hide-lists together. + QList< std::pair<MidiTrack*,int> > ignore_order_entries; for (global_drum_ordering_t::iterator order_it=global_drum_ordering.begin(); order_it!=global_drum_ordering.end(); order_it++) { + // if this entry should be ignored, ignore it. + if (ignore_order_entries.contains(*order_it)) + continue; + // 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++) @@ -186,6 +233,9 @@ DrumCanvas::DrumCanvas(MidiEditor* pr, QWidget* parent, int sx, instrument_map.append(instrument_number_mapping_t(*group, pitch)); } + + for (QSet<Track*>::iterator track=group->begin(); track!=group->end(); track++) + ignore_order_entries.append(std::pair<MidiTrack*,int>(dynamic_cast<MidiTrack*>(*track), pitch)); } // else ignore it } @@ -451,7 +501,7 @@ void DrumCanvas::newItem(MusEWidget::CItem* item, bool noSnap, bool replace) if (!noSnap) x = editor->rasterVal(x); event.setTick(x - nevent->part()->tick()); - int npitch = event.pitch(); //FINDMICH + int npitch = event.pitch(); //event.setPitch(npitch); // commented out by flo: has no effect // @@ -758,7 +808,7 @@ void DrumCanvas::cmd(int cmd) Event event = devent->event(); Event newEvent = event.clone(); // newEvent.setLenTick(drumMap[event.pitch()].len); - newEvent.setLenTick(ourDrumMap[y2pitch(devent->y())].len); //FINDMICH + newEvent.setLenTick(ourDrumMap[y2pitch(devent->y())].len); // Indicate no undo, and do not do port controller values and clone parts. audio->msgChangeEvent(event, newEvent, devent->part(), false, false, false); } @@ -1040,7 +1090,7 @@ void DrumCanvas::mapChanged(int spitch, int dpitch) } - song->update(SC_DRUMMAP); //FINDMICHJETZT handle that properly! if not done already (?) i think it is + song->update(SC_DRUMMAP); } } diff --git a/muse2/muse/midiedit/dcanvas.h b/muse2/muse/midiedit/dcanvas.h index 75bcccf6..f0c601f5 100644 --- a/muse2/muse/midiedit/dcanvas.h +++ b/muse2/muse/midiedit/dcanvas.h @@ -117,13 +117,6 @@ class DrumCanvas : public EventCanvas { virtual void curPartChanged(); int getNextStep(unsigned int pos, int basicStep, int stepSize=1); - /* FINDMICH OBSOLETE - int parts_first_instrument(Part* p); - int tracks_first_instrument(Track* t); - bool is_track_of_instrument(Track* t, int instr); - QSet<Track*> tracks_of_instrument(int instr); - */ - signals: void newWidth(int); diff --git a/muse2/muse/midiedit/dlist.cpp b/muse2/muse/midiedit/dlist.cpp index be7255b9..7de39b81 100644 --- a/muse2/muse/midiedit/dlist.cpp +++ b/muse2/muse/midiedit/dlist.cpp @@ -295,7 +295,7 @@ void DList::viewMousePressEvent(QMouseEvent* ev) else if (val > 127) val = 127; - if (old_style_drummap_mode) //FINDMICH auch beim doppelklick! + if (old_style_drummap_mode) { //Check if there is any other drumMap with the same inmap value (there should be one (and only one):-) //If so, switch the inmap between the instruments @@ -318,7 +318,7 @@ void DList::viewMousePressEvent(QMouseEvent* ev) dm->len = val; break; case COL_ANOTE: - if (old_style_drummap_mode) //only allow changing in old style mode FINDMICH auch beim doppelklick + if (old_style_drummap_mode) //only allow changing in old style mode { val = dm->anote + incVal; if (val < 0) @@ -412,10 +412,7 @@ void DList::viewMousePressEvent(QMouseEvent* ev) } if (!old_style_drummap_mode && dm_old != *dm) //something changed and we're in new style mode? - { - //FINDMICHJETZT propagate that! dcanvas->propagate_drummap_change(dm-ourDrumMap); - } redraw(); } @@ -579,7 +576,7 @@ void DList::setCurDrumInstrument(int instr) if (currentlySelected != dm) { currentlySelected = dm; emit curDrumInstrumentChanged(instr); - song->update(SC_DRUMMAP); //FINDMICH necessary?? + song->update(SC_DRUMMAP); } } @@ -678,10 +675,7 @@ void DList::returnPressed() } if (editEntryOld != *editEntry) - { - //FINDMICHJETZT propagate! dcanvas->propagate_drummap_change(editEntry-ourDrumMap); - } selectedColumn = -1; editor->hide(); @@ -740,10 +734,7 @@ void DList::pitchEdited() } if (editEntryOld != *editEntry) - { - //FINDMICHJETZT propagate dcanvas->propagate_drummap_change(editEntry-ourDrumMap); - } selectedColumn = -1; pitch_editor->hide(); diff --git a/muse2/muse/midiedit/drumedit.cpp b/muse2/muse/midiedit/drumedit.cpp index 9c433386..a74f3dd1 100644 --- a/muse2/muse/midiedit/drumedit.cpp +++ b/muse2/muse/midiedit/drumedit.cpp @@ -177,6 +177,8 @@ DrumEdit::DrumEdit(PartList* pl, QWidget* parent, const char* name, unsigned ini selPart = 0; QSignalMapper *signalMapper = new QSignalMapper(this); + _group_mode = GROUP_SAME_CHANNEL; + //---------Pulldown Menu---------------------------- menuFile = menuBar()->addMenu(tr("&File")); diff --git a/muse2/muse/midiedit/drumedit.h b/muse2/muse/midiedit/drumedit.h index 87226365..d854d054 100644 --- a/muse2/muse/midiedit/drumedit.h +++ b/muse2/muse/midiedit/drumedit.h @@ -67,7 +67,13 @@ class Toolbar1; class DrumEdit : public MidiEditor { Q_OBJECT - + + public: + enum group_mode_t { DONT_GROUP, GROUP_SAME_CHANNEL, GROUP_MAX }; + + private: + group_mode_t _group_mode; + Event selEvent; MidiPart* selPart; int selTick; @@ -144,6 +150,7 @@ class DrumEdit : public MidiEditor { static void writeConfiguration(int, Xml&); bool old_style_drummap_mode(); + group_mode_t group_mode() { return _group_mode; } }; #endif diff --git a/muse2/muse/midiedit/drummap.h b/muse2/muse/midiedit/drummap.h index 9fe14cc9..db512103 100644 --- a/muse2/muse/midiedit/drummap.h +++ b/muse2/muse/midiedit/drummap.h @@ -24,7 +24,8 @@ #ifndef __DRUMMAP_H__ #define __DRUMMAP_H__ -class QString; +#include <QString> +#include <QList> class Xml; diff --git a/muse2/muse/midiedit/scoreedit.cpp b/muse2/muse/midiedit/scoreedit.cpp index ad43527a..cf7d031f 100644 --- a/muse2/muse/midiedit/scoreedit.cpp +++ b/muse2/muse/midiedit/scoreedit.cpp @@ -4598,6 +4598,8 @@ void ScoreCanvas::add_new_parts(const std::map< Part*, std::set<Part*> >& param) * x remember ordering of instruments * x tracks have own drumlists * + * o "copy drumlist" from one track to another + * * 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) @@ -4622,6 +4624,7 @@ void ScoreCanvas::add_new_parts(const std::map< Part*, std::set<Part*> >& param) * o update [midi]track::read/write, readproperties, writeprop... (drumlist etc), operator= * * IMPORTANT TODO + * o all places where i added doubleclick-edits: only react on left-click double clicks! * o support "new style" reordering with old style drum tracks as well * (not swapping but inserting!) * ! o fix sigedit boxes (see also "current todo") diff --git a/muse2/muse/track.h b/muse2/muse/track.h index a2c6a190..1df73620 100644 --- a/muse2/muse/track.h +++ b/muse2/muse/track.h @@ -203,7 +203,7 @@ class Track { virtual bool canRecord() const { return false; } virtual AutomationType automationType() const = 0; virtual void setAutomationType(AutomationType t) = 0; - static void setVisible(bool ) { } + static void setVisible(bool) { } }; |