diff options
-rw-r--r-- | muse2/muse/midiedit/dcanvas.cpp | 94 | ||||
-rw-r--r-- | muse2/muse/midiedit/dcanvas.h | 8 | ||||
-rw-r--r-- | muse2/muse/midiedit/dlist.cpp | 45 | ||||
-rw-r--r-- | muse2/muse/midiedit/dlist.h | 3 | ||||
-rw-r--r-- | muse2/muse/midiedit/drumedit.cpp | 2 | ||||
-rw-r--r-- | muse2/muse/midiedit/drummap.h | 2 | ||||
-rw-r--r-- | muse2/muse/midiedit/scoreedit.cpp | 12 | ||||
-rw-r--r-- | muse2/muse/track.cpp | 17 | ||||
-rw-r--r-- | muse2/muse/track.h | 11 |
9 files changed, 113 insertions, 81 deletions
diff --git a/muse2/muse/midiedit/dcanvas.cpp b/muse2/muse/midiedit/dcanvas.cpp index 0b39c409..26e7aed4 100644 --- a/muse2/muse/midiedit/dcanvas.cpp +++ b/muse2/muse/midiedit/dcanvas.cpp @@ -125,6 +125,7 @@ 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); } } @@ -156,29 +157,27 @@ DrumCanvas::DrumCanvas(MidiEditor* pr, QWidget* parent, int sx, for (QList< QSet<Track*> >::iterator group=track_groups.begin(); group!=track_groups.end(); group++) { - /* FINDMICH activate me when Track::drummap() works! - for (int i=0;i<128;i++) // make "mute" consistent across groups - { + for (int i=0;i<128;i++) // find out if instrument is hidden and make "mute" + { // consistent across groups for non-hidden instruments bool mute=true; - for (QSet<Track*>::iterator track=group->begin(); track!=group->end(); track++) + bool hidden=true; + for (QSet<Track*>::iterator track=group->begin(); track!=group->end() && (mute || hidden); track++) { - if (track->drummap()[i].mute == false) - { + if (dynamic_cast<MidiTrack*>(*track)->drummap()[i].mute == false) mute=false; - break; - } + + if (dynamic_cast<MidiTrack*>(*track)->drummap_hidden()[i] == false) + hidden=false; } - for (QSet<Track*>::iterator track=group->begin(); track!=group->end(); track++) - track->drummap()[i].mute=mute; - } */ - - bool hidden[128]; - for (int i=0;i<128;i++) hidden[i]=false; //FINDMICH later: respect the track's hidden-lists! - - for (int i=0;i<128;i++) - if (!hidden[i]) - instrument_map.append(instrument_number_mapping_t(*group, i)); + if (!hidden) + { + for (QSet<Track*>::iterator track=group->begin(); track!=group->end(); track++) + dynamic_cast<MidiTrack*>(*track)->drummap()[i].mute=mute; + + instrument_map.append(instrument_number_mapping_t(*group, dynamic_cast<MidiTrack*>(*group->begin())->drummap()[i].anote, i)); + } + } } @@ -190,8 +189,8 @@ DrumCanvas::DrumCanvas(MidiEditor* pr, QWidget* parent, int sx, must_delete_our_drum_map=true; for (int i=0;i<size;i++) - //ourDrumMap[i] = instrument_map[i].tracks.begin()->drummap()[instrument_map[i].pitch]; FINDMICH activate me when Track::drummap works - ourDrumMap[i] = idrumMap[instrument_map[i%128].pitch]; //FINDMICH dummy! + 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! } @@ -1284,52 +1283,6 @@ void DrumCanvas::midiNote(int pitch, int velo) //FINDMICH later. } -/* FINDMICH OBSOLETE -int DrumCanvas::tracks_first_instrument(Track* t) -{ - if (instrument_number_map.find(t) == instrument_number_map.end()) - { - printf("THIS SHOULD NEVER HAPPEN: DrumCanvas::tracks_first_instrument() called with unknown track!\n"); - return 0; - } - else - return instrument_number_map[t]; -} - -int DrumCanvas::parts_first_instrument(Part* p) -{ - return tracks_first_instrument(p->track()); -} - -QSet<Track*> DrumCanvas::tracks_of_instrument(int instr) -{ - QSet<Track*> result; - int first_instr = -1; - - for (std::map<Track*, int>::iterator it=instrument_number_map.begin(); it!=instrument_number_map.end(); it++) - { - if ((it->second <= instr) && (it->second > first_instr)) - { - first_instr = it->second; - result.clear(); - result.insert(it->first); - } - else if (it->second == first_instr) - { - result.insert(it->first); - } - } - - return result; -} - -bool DrumCanvas::is_track_of_instrument(Track* t, int instr) -{ - QSet<Track*> temp = tracks_of_instrument(instr); - return (temp.find(t) != temp.end()); -} -*/ - int DrumCanvas::pitch_and_track_to_instrument(int pitch, Track* track) { for (int i=0; i<instrument_map.size(); i++) @@ -1340,3 +1293,12 @@ int DrumCanvas::pitch_and_track_to_instrument(int pitch, Track* track) return -1; } +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; + + 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 c02c5442..736b63b3 100644 --- a/muse2/muse/midiedit/dcanvas.h +++ b/muse2/muse/midiedit/dcanvas.h @@ -60,17 +60,20 @@ 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) + instrument_number_mapping_t(const QSet<Track*>& tr, int p, int i) { tracks=tr; pitch=p; + track_dlist_index=i; } }; @@ -154,10 +157,11 @@ class DrumCanvas : public EventCanvas { virtual void keyPress(QKeyEvent* event); Event *getEventAtCursorPos(); void selectCursorEvent(Event *ev); - int drum_map_size() { return instrument_map.size(); } int pitch_and_track_to_instrument(int pitch, Track* track); DrumMap* getOurDrumMap() { return ourDrumMap; } //FINDMICH UGLY int getOurDrumMapSize() { return instrument_map.size(); } //FINDMICH UGLY + + void propagate_drummap_change(int instrument); //FINDMICH move to drumedit }; #endif diff --git a/muse2/muse/midiedit/dlist.cpp b/muse2/muse/midiedit/dlist.cpp index 6cd469ae..9f1d9b28 100644 --- a/muse2/muse/midiedit/dlist.cpp +++ b/muse2/muse/midiedit/dlist.cpp @@ -179,6 +179,12 @@ void DList::draw(QPainter& p, const QRect& rect) void DList::devicesPopupMenu(DrumMap* t, int x, int y, bool changeAll) { + if (!old_style_drummap_mode) + { + printf("THIS SHOULD NEVER HAPPEN: devicesPopupMenu() called in new style mode!\n"); + return; + } + QMenu* p = midiPortsPopup(); QAction* act = p->exec(mapToGlobal(QPoint(x, y)), 0); bool doemit = false; @@ -230,6 +236,7 @@ void DList::viewMousePressEvent(QMouseEvent* ev) int button = ev->button(); unsigned instrument = y / TH; DrumMap* dm = &ourDrumMap[instrument]; + DrumMap dm_old = *dm; setCurDrumInstrument(instrument); @@ -273,8 +280,8 @@ void DList::viewMousePressEvent(QMouseEvent* ev) val = dm->vol + incVal; if (val < 0) val = 0; - else if (val > 200) //FINDMICH: why 200? why not 999 or infinity? (flo93) - val = 200; + else if (val > 999) //changed from 200 to 999 by flo93 + val = 999; dm->vol = (unsigned char)val; break; case COL_QNT: @@ -403,6 +410,13 @@ void DList::viewMousePressEvent(QMouseEvent* ev) default: break; } + + 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(); } @@ -592,8 +606,8 @@ void DList::returnPressed() switch (selectedColumn) { case COL_VOL: - if (val > 200) //Check bounds for volume - val = 200; + if (val > 999) //changed from 200 to 999 by flo93 + val = 999; if (val < 0) val = 0; break; @@ -619,7 +633,8 @@ void DList::returnPressed() default: break; } } - + + DrumMap editEntryOld = *editEntry; switch(selectedColumn) { case COL_NAME: editEntry->name = editor->text(); @@ -661,6 +676,13 @@ void DList::returnPressed() printf("Return pressed in unknown column\n"); break; } + + if (editEntryOld != *editEntry) + { + //FINDMICHJETZT propagate! + dcanvas->propagate_drummap_change(editEntry-ourDrumMap); + } + selectedColumn = -1; editor->hide(); editEntry = 0; @@ -677,6 +699,7 @@ void DList::pitchEdited() int val=pitch_editor->value(); int instrument=(editEntry-ourDrumMap); + DrumMap editEntryOld=*editEntry; switch(selectedColumn) { case COL_ANOTE: if (old_style_drummap_mode) //should actually be always true, but to be sure... @@ -709,12 +732,19 @@ void DList::pitchEdited() //TODO: Set all the notes on the track with instrument=dm->enote to instrument=val drumInmap[val] = instrument; } - editEntry->enote = val; + editEntry->enote = val; break; default: printf("ERROR: THIS SHOULD NEVER HAPPEN: Value changed in unknown column\n"); break; } + + if (editEntryOld != *editEntry) + { + //FINDMICHJETZT propagate + dcanvas->propagate_drummap_change(editEntry-ourDrumMap); + } + selectedColumn = -1; pitch_editor->hide(); editEntry = 0; @@ -754,11 +784,12 @@ void DList::songChanged(int flags) // DList //--------------------------------------------------------- -DList::DList(QHeaderView* h, QWidget* parent, int ymag, DrumCanvas* dcanvas, bool oldstyle) +DList::DList(QHeaderView* h, QWidget* parent, int ymag, DrumCanvas* dcanvas_, bool oldstyle) : MusEWidget::View(parent, 1, ymag) { setBg(Qt::white); + dcanvas=dcanvas_; ourDrumMap=dcanvas->getOurDrumMap(); ourDrumMapSize=dcanvas->getOurDrumMapSize(); old_style_drummap_mode=oldstyle; diff --git a/muse2/muse/midiedit/dlist.h b/muse2/muse/midiedit/dlist.h index 8e141c3b..52bf8de4 100644 --- a/muse2/muse/midiedit/dlist.h +++ b/muse2/muse/midiedit/dlist.h @@ -87,7 +87,8 @@ class DPitchEdit: public Awl::PitchEdit class DList : public MusEWidget::View { Q_OBJECT - DrumMap* ourDrumMap; //FINDMICHJETZT init! + DrumCanvas* dcanvas; + DrumMap* ourDrumMap; int ourDrumMapSize; bool old_style_drummap_mode; diff --git a/muse2/muse/midiedit/drumedit.cpp b/muse2/muse/midiedit/drumedit.cpp index f21b0e8c..9c433386 100644 --- a/muse2/muse/midiedit/drumedit.cpp +++ b/muse2/muse/midiedit/drumedit.cpp @@ -410,7 +410,7 @@ DrumEdit::DrumEdit(PartList* pl, QWidget* parent, const char* name, unsigned ini gridS2->setSpacing(0); time = new MusEWidget::MTScale(&_raster, split1w2, xscale); canvas = new DrumCanvas(this, split1w2, xscale, yscale); - vscroll = new MusEWidget::ScrollScale(-4, 1, yscale, dynamic_cast<DrumCanvas*>(canvas)->drum_map_size()*TH, Qt::Vertical, split1w2); + vscroll = new MusEWidget::ScrollScale(-4, 1, yscale, dynamic_cast<DrumCanvas*>(canvas)->getOurDrumMapSize()*TH, Qt::Vertical, split1w2); int offset = -(MusEConfig::config.division/4); canvas->setOrigin(offset, 0); canvas->setCanvasTools(drumeditTools); diff --git a/muse2/muse/midiedit/drummap.h b/muse2/muse/midiedit/drummap.h index e4764b21..7bf2b834 100644 --- a/muse2/muse/midiedit/drummap.h +++ b/muse2/muse/midiedit/drummap.h @@ -44,8 +44,8 @@ struct DrumMap { bool mute; // bool selected; - //bool const operator==(const DrumMap& map) const; bool operator==(const DrumMap& map) const; + bool operator!=(const DrumMap& map) const { return !operator==(map); } }; #define DRUM_MAPSIZE 128 diff --git a/muse2/muse/midiedit/scoreedit.cpp b/muse2/muse/midiedit/scoreedit.cpp index 844c1311..b3c87206 100644 --- a/muse2/muse/midiedit/scoreedit.cpp +++ b/muse2/muse/midiedit/scoreedit.cpp @@ -4590,6 +4590,11 @@ 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 respect "_drummap_tied_to_patch": IMPLEMENT + * * o 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) @@ -4601,14 +4606,17 @@ void ScoreCanvas::add_new_parts(const std::map< Part*, std::set<Part*> >& param) * * 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 } - * o either open flo-tracks OR old-style-tracks - * o replace all DRUM_MAPSIZE by instrument_map.size() + * x either open flo-tracks OR old-style-tracks + * x replace all DRUM_MAPSIZE by instrument_map.size() * o signal for instrument_map.size or drum_map_size() changed! * o move generation and deletion of ourDrumMap from DCanvas to DrumEditor and remove ugly wrapper functions * o ... * * o 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= + * o BUG: drummap[i].pitch MUST BE i! or instr_map.pitch must be set accordingly! * * IMPORTANT TODO * ! o fix sigedit boxes (see also "current todo") diff --git a/muse2/muse/track.cpp b/muse2/muse/track.cpp index 57c4a658..29917dc1 100644 --- a/muse2/muse/track.cpp +++ b/muse2/muse/track.cpp @@ -32,6 +32,7 @@ #include "audio.h" #include "globaldefs.h" #include "route.h" +#include "drummap.h" bool MidiTrack::_isVisible=true; //bool Track::_isVisible=true; @@ -387,6 +388,15 @@ MidiTrack::MidiTrack() _events = new EventList; _mpevents = new MPEventList; clefType=trebleClef; + + _drummap=new DrumMap[128]; + _drummap_hidden=new bool[128]; + + for (int i=0;i<128;i++) + { + _drummap[i]=idrumMap[i]; + _drummap_hidden[i]=false; + } } //MidiTrack::MidiTrack(const MidiTrack& mt) @@ -407,12 +417,19 @@ MidiTrack::MidiTrack(const MidiTrack& mt, bool cloneParts) compression = mt.compression; _recEcho = mt.recEcho(); clefType=trebleClef; + + _drummap=new DrumMap[128]; + _drummap_hidden=new bool[128]; + memcpy(_drummap, mt._drummap, 128*sizeof(*_drummap)); + memcpy(_drummap_hidden, mt._drummap_hidden, 128*sizeof(*_drummap_hidden)); } MidiTrack::~MidiTrack() { delete _events; delete _mpevents; + delete [] _drummap; + delete [] _drummap_hidden; } //--------------------------------------------------------- diff --git a/muse2/muse/track.h b/muse2/muse/track.h index 9c6aea24..a2c6a190 100644 --- a/muse2/muse/track.h +++ b/muse2/muse/track.h @@ -43,6 +43,7 @@ class SndFile; class MPEventList; class SynthI; class PluginI; +class DrumMap; //--------------------------------------------------------- // Track @@ -225,6 +226,12 @@ class MidiTrack : public Track { MPEventList* _mpevents; // tmp Events druring recording static bool _isVisible; clefTypes clefType; + + DrumMap* _drummap; + bool _drummap_tied_to_patch; //if true, changing patch also changes drummap + bool* _drummap_hidden; + + void init(); public: MidiTrack(); @@ -232,7 +239,6 @@ class MidiTrack : public Track { MidiTrack(const MidiTrack&, bool cloneParts); virtual ~MidiTrack(); - void init(); virtual AutomationType automationType() const; virtual void setAutomationType(AutomationType); @@ -293,6 +299,9 @@ class MidiTrack : public Track { void setClef(clefTypes i) { clefType = i; } clefTypes getClef() { return clefType; } + + DrumMap* drummap() { return _drummap; } + bool* drummap_hidden() { return _drummap_hidden; } }; //--------------------------------------------------------- |