From 56417f8e86e19d459a86f31a41a494f4a9e813a1 Mon Sep 17 00:00:00 2001 From: Florian Jung Date: Wed, 28 Sep 2011 15:34:53 +0000 Subject: first changes for "new-style-drumtracks" almost certainly buggy, incomplete etc. --- muse2/muse/midiedit/dcanvas.cpp | 316 ++++++++++++++++++++++++++++++-------- muse2/muse/midiedit/dcanvas.h | 40 ++++- muse2/muse/midiedit/drumedit.cpp | 11 +- muse2/muse/midiedit/drumedit.h | 2 + muse2/muse/midiedit/drummap.h | 1 + muse2/muse/midiedit/scoreedit.cpp | 21 +++ 6 files changed, 324 insertions(+), 67 deletions(-) (limited to 'muse2') diff --git a/muse2/muse/midiedit/dcanvas.cpp b/muse2/muse/midiedit/dcanvas.cpp index 3f80133a..172dd069 100644 --- a/muse2/muse/midiedit/dcanvas.cpp +++ b/muse2/muse/midiedit/dcanvas.cpp @@ -34,12 +34,12 @@ #include #include #include -#include //#include //#include #include "dcanvas.h" #include "midieditor.h" +#include "drumedit.h" #include "drummap.h" #include "event.h" #include "mpevent.h" @@ -54,14 +54,15 @@ #define CARET 10 #define CARET2 5 +using MusEGlobal::debugMsg; + //--------------------------------------------------------- // DEvent //--------------------------------------------------------- -DEvent::DEvent(Event e, Part* p) +DEvent::DEvent(Event e, Part* p, int instr) : CItem(e, p) { - int instr = e.pitch(); int y = instr * TH + TH/2; int tick = e.tick() + p->tick(); setPos(QPoint(tick, y)); @@ -79,7 +80,14 @@ void DrumCanvas::addItem(Part* part, Event& event) return; } - DEvent* ev = new DEvent(event, part); + int instr=pitch_and_track_to_instrument(event.pitch(), part->track()); + if (instr<0) + { + if (debugMsg) printf("trying to add event which is hidden or not in any part known to me\n"); + return; + } + + DEvent* ev = new DEvent(event, part, instr); items.add(ev); int diff = event.endTick()-part->lenTick(); @@ -101,6 +109,92 @@ DrumCanvas::DrumCanvas(MidiEditor* pr, QWidget* parent, int sx, int sy, const char* name) : EventCanvas(pr, parent, sx, sy, name) { + old_style_drummap_mode = dynamic_cast(pr)->old_style_drummap_mode(); //FINDMICH TODO + + if (old_style_drummap_mode) + { + if (debugMsg) printf("DrumCanvas in old style drummap mode\n"); + ourDrumMap = drumMap; + must_delete_our_drum_map=false; + + instrument_number_mapping_t temp; + for (ciPart it=pr->parts()->begin(); it!=pr->parts()->end(); it++) + temp.tracks.insert(it->second->track()); + + for (int i=0;itracks(); + + QList< QSet > track_groups; + + for (ciTrack track = tl->begin(); track!=tl->end(); track++) + { + ciPart p_it; + for (p_it=pr->parts()->begin(); p_it!=pr->parts()->end(); p_it++) + if (p_it->second->track() == *track) + break; + + if (p_it!=pr->parts()->end()) // if *track is represented by some part in this editor + { + QSet temp; + temp.insert(*track); + track_groups.push_back(temp); + } + } + + // 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 >::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 + { + bool mute=true; + for (QSet::iterator track=group->begin(); track!=group->end(); track++) + { + if (track->drummap()[i].mute == false) + { + mute=false; + break; + } + } + + for (QSet::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)); + } + + + + // populate ourDrumMap + + int size = instrument_map.size(); + ourDrumMap=new DrumMap[size]; + must_delete_our_drum_map=true; + + for (int i=0;idrummap()[instrument_map[i].pitch]; FINDMICH activate me when Track::drummap works + ourDrumMap[i] = idrumMap[instrument_map[i].pitch]; //FINDMICH dummy! + } + + + setVirt(false); cursorPos= QPoint(0,0); _stepSize=1; @@ -188,7 +282,7 @@ Undo DrumCanvas::moveCanvasItems(MusEWidget::CItemList& items, int dp, int dx, D for(MusEWidget::iCItem ici = items.begin(); ici != items.end(); ++ici) { - MusEWidget::CItem* ci = ici->second; + MusEWidget::CItem* ci = ici->second; int x = ci->pos().x(); int y = ci->pos().y(); @@ -206,11 +300,11 @@ Undo DrumCanvas::moveCanvasItems(MusEWidget::CItemList& items, int dp, int dx, D // Do not process if the event has already been processed (meaning it's an event in a clone part)... if (idl == doneList.end()) { - operations.push_back(moveItem(ci, newpos, dtype)); + operations.push_back(moveItem(ci, newpos, dtype)); //FINDMICH update moveItem() doneList.push_back(ci); } ci->move(newpos); - + if(moving.size() == 1) itemReleased(curItem, newpos); @@ -238,7 +332,7 @@ Undo DrumCanvas::moveCanvasItems(MusEWidget::CItemList& items, int dp, int dx, D // moveItem //--------------------------------------------------------- -UndoOp DrumCanvas::moveItem(MusEWidget::CItem* item, const QPoint& pos, DragType dtype) +UndoOp DrumCanvas::moveItem(MusEWidget::CItem* item, const QPoint& pos, DragType dtype) //FINDMICHJETZT { DEvent* nevent = (DEvent*) item; @@ -251,10 +345,20 @@ UndoOp DrumCanvas::moveItem(MusEWidget::CItem* item, const QPoint& pos, DragType int ntick = editor->rasterVal(x) - part->tick(); if (ntick < 0) ntick = 0; - int npitch = y2pitch(pos.y()); + int nheight = y2pitch(pos.y()); Event newEvent = event.clone(); - - newEvent.setPitch(npitch); + + Track* dest_track = part->track(); + if (!instrument_map[nheight].tracks.contains(dest_track)) + { + printf ("TODO FIXME: tried to move an event into a different track. this is not supported yet, but will be soon. ignoring this one...\n"); + //FINDMICH + return UndoOp(); + } + + int ev_pitch = instrument_map[nheight].pitch; + + newEvent.setPitch(ev_pitch); newEvent.setTick(ntick); // Added by T356, removed by flo93: with operation groups, it happens that the @@ -275,13 +379,13 @@ UndoOp DrumCanvas::moveItem(MusEWidget::CItem* item, const QPoint& pos, DragType MusEWidget::CItem* DrumCanvas::newItem(const QPoint& p, int state) { int instr = y2pitch(p.y()); //drumInmap[y2pitch(p.y())]; - int velo = drumMap[instr].lv4; + int velo = ourDrumMap[instr].lv4; if (state == Qt::ShiftModifier) - velo = drumMap[instr].lv3; + velo = ourDrumMap[instr].lv3; else if (state == Qt::ControlModifier) - velo = drumMap[instr].lv2; + velo = ourDrumMap[instr].lv2; else if (state == (Qt::ControlModifier | Qt::ShiftModifier)) - velo = drumMap[instr].lv1; + velo = ourDrumMap[instr].lv1; int tick = editor->rasterVal(p.x()); return newItem(tick, instr, velo); } @@ -292,13 +396,22 @@ MusEWidget::CItem* DrumCanvas::newItem(const QPoint& p, int state) MusEWidget::CItem* DrumCanvas::newItem(int tick, int instrument, int velocity) { - tick -= curPart->tick(); - Event e(Note); - e.setTick(tick); - e.setPitch(instrument); - e.setVelo(velocity); - e.setLenTick(drumMap[instrument].len); - return new DEvent(e, curPart); + if (!old_style_drummap_mode && !instrument_map[instrument].tracks.contains(curPart->track())) + { + printf("FINDMICH: tried to create a new Item which cannot be inside the current track. returning NULL\n"); + return NULL; + } + else + { + tick -= curPart->tick(); + Event e(Note); + e.setTick(tick); + e.setPitch(instrument_map[instrument].pitch); + e.setVelo(velocity); + e.setLenTick(ourDrumMap[instrument].len); + + return new DEvent(e, curPart, instrument); + } } //--------------------------------------------------------- @@ -321,15 +434,17 @@ void DrumCanvas::newItem(MusEWidget::CItem* item, bool noSnap) { } void DrumCanvas::newItem(MusEWidget::CItem* item, bool noSnap, bool replace) - { +{ + if (item) + { DEvent* nevent = (DEvent*) item; Event event = nevent->event(); int x = item->x(); if (!noSnap) x = editor->rasterVal(x); event.setTick(x - nevent->part()->tick()); - int npitch = event.pitch(); - event.setPitch(npitch); + int npitch = event.pitch(); //FINDMICH + //event.setPitch(npitch); // commented out by flo: has no effect // // check for existing event @@ -365,7 +480,7 @@ void DrumCanvas::newItem(MusEWidget::CItem* item, bool noSnap, bool replace) { operations.push_back(UndoOp(UndoOp::AddEvent,event, part, false, false)); - if (diff > 0)// part must be extended? + if (diff > 0) // part must be extended? { schedule_resize_all_same_len_clone_parts(part, event.endTick(), operations); printf("newItem: extending\n"); @@ -375,7 +490,10 @@ void DrumCanvas::newItem(MusEWidget::CItem* item, bool noSnap, bool replace) song->applyOperationGroup(operations); songChanged(SC_EVENT_INSERTED); //this forces an update of the itemlist, which is neccessary //to remove "forbidden" events from the list again - } + } + else + printf("THIS SHOULD NEVER HAPPEN: DrumCanvas::newItem called with NULL item!\n"); +} //--------------------------------------------------------- // deleteItem @@ -430,7 +548,7 @@ void DrumCanvas::drawItem(QPainter&p, const MusEWidget::CItem*item, const QRect& else { int velo = e->event().velo(); - DrumMap* dm = &drumMap[y2pitch(y)]; //Get the drum item + DrumMap* dm = &ourDrumMap[y2pitch(y)]; //Get the drum item QColor color; if (velo < dm->lv1) color.setRgb(240, 240, 255); @@ -521,8 +639,8 @@ void DrumCanvas::drawTopItem(QPainter& p, const QRect&) int DrumCanvas::y2pitch(int y) const { int pitch = y/TH; - if (pitch >= DRUM_MAPSIZE) - pitch = DRUM_MAPSIZE-1; + if (pitch >= instrument_map.size()) + pitch = instrument_map.size()-1; return pitch; } @@ -631,7 +749,8 @@ void DrumCanvas::cmd(int cmd) DEvent* devent = (DEvent*)(k->second); Event event = devent->event(); Event newEvent = event.clone(); - newEvent.setLenTick(drumMap[event.pitch()].len); + // newEvent.setLenTick(ourDrumMap[event.pitch()].len); + newEvent.setLenTick(ourDrumMap[y2pitch(devent->y())].len); //FINDMICH // Indicate no undo, and do not do port controller values and clone parts. audio->msgChangeEvent(event, newEvent, devent->part(), false, false, false); } @@ -733,19 +852,19 @@ void DrumCanvas::dragLeaveEvent(QDragLeaveEvent*) // keyPressed - called from DList //--------------------------------------------------------- -void DrumCanvas::keyPressed(int index, int velocity) +void DrumCanvas::keyPressed(int index, int velocity) //FINDMICH later { // called from DList - play event - int port = drumMap[index].port; - int channel = drumMap[index].channel; - int pitch = drumMap[index].anote; + int port = ourDrumMap[index].port; + int channel = ourDrumMap[index].channel; + int pitch = ourDrumMap[index].anote; // play note: MidiPlayEvent e(0, port, channel, 0x90, pitch, velocity); audio->msgPlayMidiEvent(&e); if (_steprec && pos[0] >= start_tick /* && pos[0] < end_tick [removed by flo93: this is handled in steprec->record] */ && curPart) - steprec->record(curPart,index,drumMap[index].len,editor->raster(),velocity,MusEGlobal::globalKeyState&Qt::ControlModifier,MusEGlobal::globalKeyState&Qt::ShiftModifier); + steprec->record(curPart,index,ourDrumMap[index].len,editor->raster(),velocity,MusEGlobal::globalKeyState&Qt::ControlModifier,MusEGlobal::globalKeyState&Qt::ShiftModifier); } @@ -753,12 +872,12 @@ void DrumCanvas::keyPressed(int index, int velocity) // keyReleased //--------------------------------------------------------- -void DrumCanvas::keyReleased(int index, bool) +void DrumCanvas::keyReleased(int index, bool) //FINDMICH later { // called from DList - silence playing event - int port = drumMap[index].port; - int channel = drumMap[index].channel; - int pitch = drumMap[index].anote; + int port = ourDrumMap[index].port; + int channel = ourDrumMap[index].channel; + int pitch = ourDrumMap[index].anote; // release note: MidiPlayEvent e(0, port, channel, 0x90, pitch, 0); @@ -767,10 +886,13 @@ void DrumCanvas::keyReleased(int index, bool) //--------------------------------------------------------- // mapChanged +// this function is only for old-style-drummaps //--------------------------------------------------------- void DrumCanvas::mapChanged(int spitch, int dpitch) { + if (!old_style_drummap_mode) return; + Undo operations; std::vector< std::pair > delete_events; std::vector< std::pair > add_events; @@ -900,6 +1022,7 @@ void DrumCanvas::modifySelected(MusEWidget::NoteInfo::ValType type, int delta) printf("DrumCanvas::modifySelected - MusEWidget::NoteInfo::VAL_VELOFF not implemented\n"); break; case MusEWidget::NoteInfo::VAL_PITCH: + if (old_style_drummap_mode) { int pitch = event.pitch() - delta; // Reversing order since the drumlist is displayed in increasing order if (pitch > 127) @@ -908,6 +1031,8 @@ void DrumCanvas::modifySelected(MusEWidget::NoteInfo::ValType type, int delta) pitch = 0; newEvent.setPitch(pitch); } + else + printf("DrumCanvas::modifySelected - MusEWidget::NoteInfo::VAL_PITCH not implemented for new style drum editors\n"); break; } song->changeEvent(event, newEvent, part); @@ -985,8 +1110,8 @@ void DrumCanvas::keyPress(QKeyEvent* event) return; } else if (key == shortcuts[SHRT_ADDNOTE_1].key) { - newItem(newItem(cursorPos.x(), cursorPos.y(), drumMap[cursorPos.y()].lv1),false,true); - keyPressed(cursorPos.y(), drumMap[cursorPos.y()].lv1); + newItem(newItem(cursorPos.x(), cursorPos.y(), ourDrumMap[cursorPos.y()].lv1),false,true); + keyPressed(cursorPos.y(), ourDrumMap[cursorPos.y()].lv1); keyReleased(cursorPos.y(), false); cursorPos.setX(getNextStep(cursorPos.x(),1, _stepSize)); selectCursorEvent(getEventAtCursorPos()); @@ -995,8 +1120,8 @@ void DrumCanvas::keyPress(QKeyEvent* event) return; } else if (key == shortcuts[SHRT_ADDNOTE_2].key) { - newItem(newItem(cursorPos.x(), cursorPos.y(), drumMap[cursorPos.y()].lv2),false,true); - keyPressed(cursorPos.y(), drumMap[cursorPos.y()].lv2); + newItem(newItem(cursorPos.x(), cursorPos.y(), ourDrumMap[cursorPos.y()].lv2),false,true); + keyPressed(cursorPos.y(), ourDrumMap[cursorPos.y()].lv2); keyReleased(cursorPos.y(), false); cursorPos.setX(getNextStep(cursorPos.x(),1, _stepSize)); selectCursorEvent(getEventAtCursorPos()); @@ -1005,8 +1130,8 @@ void DrumCanvas::keyPress(QKeyEvent* event) return; } else if (key == shortcuts[SHRT_ADDNOTE_3].key) { - newItem(newItem(cursorPos.x(), cursorPos.y(), drumMap[cursorPos.y()].lv3),false,true); - keyPressed(cursorPos.y(), drumMap[cursorPos.y()].lv3); + newItem(newItem(cursorPos.x(), cursorPos.y(), ourDrumMap[cursorPos.y()].lv3),false,true); + keyPressed(cursorPos.y(), ourDrumMap[cursorPos.y()].lv3); keyReleased(cursorPos.y(), false); cursorPos.setX(getNextStep(cursorPos.x(),1, _stepSize)); selectCursorEvent(getEventAtCursorPos()); @@ -1015,8 +1140,8 @@ void DrumCanvas::keyPress(QKeyEvent* event) return; } else if (key == shortcuts[SHRT_ADDNOTE_4].key) { - newItem(newItem(cursorPos.x(), cursorPos.y(), drumMap[cursorPos.y()].lv4),false,true); - keyPressed(cursorPos.y(), drumMap[cursorPos.y()].lv4); + newItem(newItem(cursorPos.x(), cursorPos.y(), ourDrumMap[cursorPos.y()].lv4),false,true); + keyPressed(cursorPos.y(), ourDrumMap[cursorPos.y()].lv4); keyReleased(cursorPos.y(), false); cursorPos.setX(getNextStep(cursorPos.x(),1, _stepSize)); selectCursorEvent(getEventAtCursorPos()); @@ -1064,17 +1189,19 @@ Event *DrumCanvas::getEventAtCursorPos() { if (_tool != MusEWidget::CursorTool) return 0; - EventList* el = curPart->events(); - iEvent lower = el->lower_bound(cursorPos.x()-curPart->tick()); - iEvent upper = el->upper_bound(cursorPos.x()-curPart->tick()); - for (iEvent i = lower; i != upper; ++i) { - Event &ev = i->second; - if(!ev.isNote()) - continue; - if (ev.pitch() == cursorPos.y()) { - return &ev; + if (instrument_map[cursorPos.y()].tracks.contains(curPart->track())) + { + EventList* el = curPart->events(); + iEvent lower = el->lower_bound(cursorPos.x()-curPart->tick()); + iEvent upper = el->upper_bound(cursorPos.x()-curPart->tick()); + int curPitch = instrument_map[cursorPos.y()].pitch; + for (iEvent i = lower; i != upper; ++i) { + Event &ev = i->second; + if (ev.isNote() && ev.pitch() == curPitch) + return &ev; } } + // else or if the for loop didn't find anything return 0; } //--------------------------------------------------------- @@ -1098,9 +1225,13 @@ void DrumCanvas::selectCursorEvent(Event *ev) void DrumCanvas::moveAwayUnused() { - using std::set; + if (!old_style_drummap_mode) + { + printf("THIS SHOULD NEVER HAPPEN: DrumCanvas::moveAwayUnused() cannot be used in new style mode\n"); //FINDMICH really disable that + return; + } - set used; + QSet used; for (MusEWidget::iCItem it=items.begin(); it!=items.end(); it++) { const Event& ev=it->second->event(); @@ -1110,7 +1241,7 @@ void DrumCanvas::moveAwayUnused() } int count=0; - for (set::iterator it=used.begin(); it!=used.end();) + for (QSet::iterator it=used.begin(); it!=used.end();) { while ((*it != count) && (used.find(count)!=used.end())) count++; @@ -1127,14 +1258,71 @@ void DrumCanvas::moveAwayUnused() //--------------------------------------------------------- // midiNote //--------------------------------------------------------- -void DrumCanvas::midiNote(int pitch, int velo) +void DrumCanvas::midiNote(int pitch, int velo) //FINDMICH later. { - if (MusEGlobal::debugMsg) printf("DrumCanvas::midiNote: pitch=%i, velo=%i\n", pitch, velo); + if (debugMsg) printf("DrumCanvas::midiNote: pitch=%i, velo=%i\n", pitch, velo); if (_midiin && _steprec && curPart && !audio->isPlaying() && velo && pos[0] >= start_tick - /* && pos[0] < end_tick [removed by flo93: this is handled in steprec->record] */ + /* && pos[0] < end_tick [removed by flo93: this is handled in steprec->record()] */ && !(MusEGlobal::globalKeyState & Qt::AltModifier)) { - steprec->record(curPart,drumInmap[pitch],drumMap[(int)drumInmap[pitch]].len,editor->raster(),velo,MusEGlobal::globalKeyState&Qt::ControlModifier,MusEGlobal::globalKeyState&Qt::ShiftModifier); + steprec->record(curPart,drumInmap[pitch],ourDrumMap[(int)drumInmap[pitch]].len,editor->raster(),velo,MusEGlobal::globalKeyState&Qt::ControlModifier,MusEGlobal::globalKeyState&Qt::ShiftModifier); } } + + +/* 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 DrumCanvas::tracks_of_instrument(int instr) +{ + QSet result; + int first_instr = -1; + + for (std::map::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 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 +#include +#include #define TH 18 @@ -36,6 +39,7 @@ class QDropEvent; class QDragMoveEvent; class QDragLeaveEvent; +class DrumMap; class MidiEditor; //--------------------------------------------------------- @@ -45,12 +49,31 @@ class MidiEditor; class DEvent : public MusEWidget::CItem { public: - DEvent(Event e, Part* p); + DEvent(Event e, Part* p, int instr); }; class ScrollScale; class PianoRoll; + +struct instrument_number_mapping_t +{ + QSet tracks; + int pitch; + + instrument_number_mapping_t() + { + pitch=-1; + tracks.clear(); + } + + instrument_number_mapping_t(const QSet& tr, int p) + { + tracks=tr; + pitch=p; + } +}; + //--------------------------------------------------------- // DrumCanvas //--------------------------------------------------------- @@ -58,6 +81,11 @@ class PianoRoll; class DrumCanvas : public EventCanvas { Q_OBJECT + bool old_style_drummap_mode; + DrumMap* ourDrumMap; + bool must_delete_our_drum_map; //FINDMICH really delete it! + QVector instrument_map; + StepRec* steprec; // Cursor tool position @@ -88,6 +116,13 @@ class DrumCanvas : public EventCanvas { virtual void resizeEvent(QResizeEvent*); 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 tracks_of_instrument(int instr); + */ signals: void newWidth(int); @@ -119,7 +154,8 @@ 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); }; #endif diff --git a/muse2/muse/midiedit/drumedit.cpp b/muse2/muse/midiedit/drumedit.cpp index 8821d0d8..4e99c0c1 100644 --- a/muse2/muse/midiedit/drumedit.cpp +++ b/muse2/muse/midiedit/drumedit.cpp @@ -406,7 +406,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, DRUM_MAPSIZE*TH, Qt::Vertical, split1w2); + vscroll = new MusEWidget::ScrollScale(-4, 1, yscale, dynamic_cast(canvas)->drum_map_size()*TH, Qt::Vertical, split1w2); int offset = -(MusEConfig::config.division/4); canvas->setOrigin(offset, 0); canvas->setCanvasTools(drumeditTools); @@ -1322,3 +1322,12 @@ void DrumEdit::setStep(QString v) stepLenWidget->setFocusPolicy(Qt::NoFocus); canvas->setFocus(); } + +bool DrumEdit::old_style_drummap_mode() +{ + for (ciPart p = parts()->begin(); p != parts()->end(); ++p) + if (p->second->track()->type()==Track::DRUM) + return true; + + return false; +} diff --git a/muse2/muse/midiedit/drumedit.h b/muse2/muse/midiedit/drumedit.h index 06f7e131..87226365 100644 --- a/muse2/muse/midiedit/drumedit.h +++ b/muse2/muse/midiedit/drumedit.h @@ -142,6 +142,8 @@ class DrumEdit : public MidiEditor { virtual void writeStatus(int, Xml&) const; static void readConfiguration(Xml& xml); static void writeConfiguration(int, Xml&); + + bool old_style_drummap_mode(); }; #endif diff --git a/muse2/muse/midiedit/drummap.h b/muse2/muse/midiedit/drummap.h index 2c02ffcc..e4764b21 100644 --- a/muse2/muse/midiedit/drummap.h +++ b/muse2/muse/midiedit/drummap.h @@ -53,6 +53,7 @@ struct DrumMap { extern char drumOutmap[DRUM_MAPSIZE]; extern char drumInmap[DRUM_MAPSIZE]; extern DrumMap drumMap[DRUM_MAPSIZE]; +extern const DrumMap idrumMap[DRUM_MAPSIZE]; //FINDMICH dummy! extern void initDrumMap(); extern void writeDrumMap(int level, Xml& xml, bool external); extern void readDrumMap(Xml& xml, bool external); diff --git a/muse2/muse/midiedit/scoreedit.cpp b/muse2/muse/midiedit/scoreedit.cpp index b17f9b1d..fe3e5696 100644 --- a/muse2/muse/midiedit/scoreedit.cpp +++ b/muse2/muse/midiedit/scoreedit.cpp @@ -4587,7 +4587,28 @@ void ScoreCanvas::add_new_parts(const std::map< Part*, std::set >& param) * CURRENT TODO * ! o fix sigedit boxes (see also "important todo") * o fix valgrind problems + * * > o drum editor: channel-stuff + * o stuff is inserted into the right part, but displayed in the wrong part + * + * 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) + * 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. + * when mixing, the values of all tracks are ANDed + * + * 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, pitch } + * o either open flo-tracks OR old-style-tracks + * o replace all DRUM_MAPSIZE by instrument_map.size() + * o signal for instrument_map.size or drum_map_size() changed! + * o ... + * + * o when playing back a flo-drum-track: treat as a MIDI track, + * EXCEPT that the drum list's mute entries are respected! * * IMPORTANT TODO * ! o fix sigedit boxes (see also "current todo") -- cgit v1.2.3 From 53a46fee00aa9256144c8cb71bc8e71444f339a8 Mon Sep 17 00:00:00 2001 From: Florian Jung Date: Wed, 28 Sep 2011 15:56:24 +0000 Subject: Undo::empty() also returns empty if the list only contains DoNothings removed unused, unimplemented function --- muse2/muse/undo.cpp | 12 ++++++++++++ muse2/muse/undo.h | 3 ++- 2 files changed, 14 insertions(+), 1 deletion(-) (limited to 'muse2') diff --git a/muse2/muse/undo.cpp b/muse2/muse/undo.cpp index c0191362..63911fcf 100644 --- a/muse2/muse/undo.cpp +++ b/muse2/muse/undo.cpp @@ -775,6 +775,7 @@ void Song::doRedo2() UndoOp::UndoOp() { + type=UndoOp::DoNothing; } UndoOp::UndoOp(UndoType type_) @@ -1073,3 +1074,14 @@ void Song::doRedo3() dirty = true; } + +bool Undo::empty() const +{ + if (std::list::empty()) return true; + + for (const_iterator it=begin(); it!=end(); it++) + if (it->type!=UndoOp::DoNothing) + return false; + + return true; +} diff --git a/muse2/muse/undo.h b/muse2/muse/undo.h index 5dca82b6..f2a523cc 100644 --- a/muse2/muse/undo.h +++ b/muse2/muse/undo.h @@ -119,7 +119,8 @@ struct UndoOp { }; class Undo : public std::list { - void undoOp(UndoOp::UndoType, int data); + public: + bool empty() const; }; typedef Undo::iterator iUndoOp; -- cgit v1.2.3 From bd41d7c53d2b7590263a7d126b02736268932c8f Mon Sep 17 00:00:00 2001 From: Florian Jung Date: Thu, 29 Sep 2011 16:11:59 +0000 Subject: removed "reorder list" function when in new-style-mode really tiny cleanups --- muse2/muse/midiedit/dcanvas.cpp | 13 +++++++------ muse2/muse/midiedit/drumedit.cpp | 12 ++++++++---- muse2/muse/midiedit/scoreedit.cpp | 3 +-- 3 files changed, 16 insertions(+), 12 deletions(-) (limited to 'muse2') diff --git a/muse2/muse/midiedit/dcanvas.cpp b/muse2/muse/midiedit/dcanvas.cpp index 172dd069..8aecc525 100644 --- a/muse2/muse/midiedit/dcanvas.cpp +++ b/muse2/muse/midiedit/dcanvas.cpp @@ -55,6 +55,7 @@ #define CARET2 5 using MusEGlobal::debugMsg; +using MusEGlobal::heavyDebugMsg; //--------------------------------------------------------- // DEvent @@ -83,7 +84,7 @@ void DrumCanvas::addItem(Part* part, Event& event) int instr=pitch_and_track_to_instrument(event.pitch(), part->track()); if (instr<0) { - if (debugMsg) printf("trying to add event which is hidden or not in any part known to me\n"); + if (heavyDebugMsg) printf("trying to add event which is hidden or not in any part known to me\n"); return; } @@ -109,7 +110,7 @@ DrumCanvas::DrumCanvas(MidiEditor* pr, QWidget* parent, int sx, int sy, const char* name) : EventCanvas(pr, parent, sx, sy, name) { - old_style_drummap_mode = dynamic_cast(pr)->old_style_drummap_mode(); //FINDMICH TODO + old_style_drummap_mode = dynamic_cast(pr)->old_style_drummap_mode(); if (old_style_drummap_mode) { @@ -300,7 +301,7 @@ Undo DrumCanvas::moveCanvasItems(MusEWidget::CItemList& items, int dp, int dx, D // Do not process if the event has already been processed (meaning it's an event in a clone part)... if (idl == doneList.end()) { - operations.push_back(moveItem(ci, newpos, dtype)); //FINDMICH update moveItem() + operations.push_back(moveItem(ci, newpos, dtype)); doneList.push_back(ci); } ci->move(newpos); @@ -332,7 +333,7 @@ Undo DrumCanvas::moveCanvasItems(MusEWidget::CItemList& items, int dp, int dx, D // moveItem //--------------------------------------------------------- -UndoOp DrumCanvas::moveItem(MusEWidget::CItem* item, const QPoint& pos, DragType dtype) //FINDMICHJETZT +UndoOp DrumCanvas::moveItem(MusEWidget::CItem* item, const QPoint& pos, DragType dtype) { DEvent* nevent = (DEvent*) item; @@ -749,7 +750,7 @@ void DrumCanvas::cmd(int cmd) DEvent* devent = (DEvent*)(k->second); Event event = devent->event(); Event newEvent = event.clone(); - // newEvent.setLenTick(ourDrumMap[event.pitch()].len); + // newEvent.setLenTick(drumMap[event.pitch()].len); newEvent.setLenTick(ourDrumMap[y2pitch(devent->y())].len); //FINDMICH // Indicate no undo, and do not do port controller values and clone parts. audio->msgChangeEvent(event, newEvent, devent->part(), false, false, false); @@ -1227,7 +1228,7 @@ void DrumCanvas::moveAwayUnused() { if (!old_style_drummap_mode) { - printf("THIS SHOULD NEVER HAPPEN: DrumCanvas::moveAwayUnused() cannot be used in new style mode\n"); //FINDMICH really disable that + printf("THIS SHOULD NEVER HAPPEN: DrumCanvas::moveAwayUnused() cannot be used in new style mode\n"); return; } diff --git a/muse2/muse/midiedit/drumedit.cpp b/muse2/muse/midiedit/drumedit.cpp index 4e99c0c1..230eef04 100644 --- a/muse2/muse/midiedit/drumedit.cpp +++ b/muse2/muse/midiedit/drumedit.cpp @@ -253,8 +253,14 @@ DrumEdit::DrumEdit(PartList* pl, QWidget* parent, const char* name, unsigned ini menuFunctions->setTearOffEnabled(true); - QAction* reorderListAction = menuFunctions->addAction(tr("Re-order list")); - menuFunctions->addSeparator(); + if (old_style_drummap_mode()) + { + QAction* reorderListAction = menuFunctions->addAction(tr("Re-order list")); + connect(reorderListAction, SIGNAL(triggered()), signalMapper, SLOT(map())); + signalMapper->setMapping(reorderListAction, DrumCanvas::CMD_REORDER_LIST); + menuFunctions->addSeparator(); + } + fixedAction = menuFunctions->addAction(tr("Set Fixed Length")); veloAction = menuFunctions->addAction(tr("Modify Velocity")); crescAction = menuFunctions->addAction(tr("Crescendo/Decrescendo")); @@ -263,7 +269,6 @@ DrumEdit::DrumEdit(PartList* pl, QWidget* parent, const char* name, unsigned ini QAction* noteShiftAction = menuFunctions->addAction(tr("Move Notes")); QAction* delOverlapsAction = menuFunctions->addAction(tr("Delete Overlaps")); - connect(reorderListAction, SIGNAL(triggered()), signalMapper, SLOT(map())); connect(fixedAction, SIGNAL(triggered()), signalMapper, SLOT(map())); connect(veloAction, SIGNAL(triggered()), signalMapper, SLOT(map())); connect(crescAction, SIGNAL(triggered()), signalMapper, SLOT(map())); @@ -272,7 +277,6 @@ DrumEdit::DrumEdit(PartList* pl, QWidget* parent, const char* name, unsigned ini connect(noteShiftAction, SIGNAL(triggered()), signalMapper, SLOT(map())); connect(delOverlapsAction, SIGNAL(triggered()), signalMapper, SLOT(map())); - signalMapper->setMapping(reorderListAction, DrumCanvas::CMD_REORDER_LIST); signalMapper->setMapping(fixedAction, DrumCanvas::CMD_FIXED_LEN); signalMapper->setMapping(veloAction, DrumCanvas::CMD_MODIFY_VELOCITY); signalMapper->setMapping(crescAction, DrumCanvas::CMD_CRESCENDO); diff --git a/muse2/muse/midiedit/scoreedit.cpp b/muse2/muse/midiedit/scoreedit.cpp index fe3e5696..c9f5454d 100644 --- a/muse2/muse/midiedit/scoreedit.cpp +++ b/muse2/muse/midiedit/scoreedit.cpp @@ -4581,6 +4581,7 @@ void ScoreCanvas::add_new_parts(const std::map< Part*, std::set >& param) * because after A (and B) got resized, the B-resize is invalid! * o when changing toolbarstate when sharing and immediately after that * changing "share" status, the changed state isn't stored + * o arranger state and mixer state aren't stored (says tim) * ? pasting in editors sometimes fails oO? ( ERROR: reading eventlist * from clipboard failed. ignoring this one... ) [ not reproducible ] * @@ -4589,8 +4590,6 @@ void ScoreCanvas::add_new_parts(const std::map< Part*, std::set >& param) * o fix valgrind problems * * > o drum editor: channel-stuff - * o stuff is inserted into the right part, but displayed in the wrong part - * * 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) -- cgit v1.2.3 From 790900244f2eca7370ebdc7d40426ff5f7178416 Mon Sep 17 00:00:00 2001 From: Florian Jung Date: Thu, 29 Sep 2011 17:38:25 +0000 Subject: drum list supports new style mode added ability to reorder in new style mode (properly) still work-in-progress --- muse2/muse/midiedit/dcanvas.cpp | 25 +++++-- muse2/muse/midiedit/dcanvas.h | 2 + muse2/muse/midiedit/dlist.cpp | 150 +++++++++++++++++++++----------------- muse2/muse/midiedit/dlist.h | 12 ++- muse2/muse/midiedit/drumedit.cpp | 8 +- muse2/muse/midiedit/scoreedit.cpp | 1 + 6 files changed, 122 insertions(+), 76 deletions(-) (limited to 'muse2') diff --git a/muse2/muse/midiedit/dcanvas.cpp b/muse2/muse/midiedit/dcanvas.cpp index 8aecc525..0b39c409 100644 --- a/muse2/muse/midiedit/dcanvas.cpp +++ b/muse2/muse/midiedit/dcanvas.cpp @@ -191,7 +191,7 @@ DrumCanvas::DrumCanvas(MidiEditor* pr, QWidget* parent, int sx, for (int i=0;idrummap()[instrument_map[i].pitch]; FINDMICH activate me when Track::drummap works - ourDrumMap[i] = idrumMap[instrument_map[i].pitch]; //FINDMICH dummy! + ourDrumMap[i] = idrumMap[instrument_map[i%128].pitch]; //FINDMICH dummy! } @@ -887,13 +887,12 @@ void DrumCanvas::keyReleased(int index, bool) //FINDMICH later //--------------------------------------------------------- // mapChanged -// this function is only for old-style-drummaps //--------------------------------------------------------- void DrumCanvas::mapChanged(int spitch, int dpitch) - { - if (!old_style_drummap_mode) return; - +{ + if (old_style_drummap_mode) + { Undo operations; std::vector< std::pair > delete_events; std::vector< std::pair > add_events; @@ -971,7 +970,20 @@ void DrumCanvas::mapChanged(int spitch, int dpitch) song->applyOperationGroup(operations, false); // do not indicate undo song->update(SC_DRUMMAP); //this update is neccessary, as it's not handled by applyOperationGroup() - } + } + else // if (!old_style_drummap_mode) + { + DrumMap dm = ourDrumMap[spitch]; + ourDrumMap[spitch] = ourDrumMap[dpitch]; + ourDrumMap[dpitch] = dm; + + 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! + } +} //--------------------------------------------------------- // resizeEvent @@ -1327,3 +1339,4 @@ int DrumCanvas::pitch_and_track_to_instrument(int pitch, Track* track) printf("ERROR: DrumCanvas::pitch_and_track_to_instrument() called with invalid arguments!\n"); return -1; } + diff --git a/muse2/muse/midiedit/dcanvas.h b/muse2/muse/midiedit/dcanvas.h index 7c574821..c02c5442 100644 --- a/muse2/muse/midiedit/dcanvas.h +++ b/muse2/muse/midiedit/dcanvas.h @@ -156,6 +156,8 @@ class DrumCanvas : public EventCanvas { 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 }; #endif diff --git a/muse2/muse/midiedit/dlist.cpp b/muse2/muse/midiedit/dlist.cpp index 8e9633c0..6cd469ae 100644 --- a/muse2/muse/midiedit/dlist.cpp +++ b/muse2/muse/midiedit/dlist.cpp @@ -38,6 +38,7 @@ #include "dlist.h" #include "song.h" #include "scrollscale.h" +#include "dcanvas.h" //--------------------------------------------------------- // draw @@ -56,13 +57,13 @@ void DList::draw(QPainter& p, const QRect& rect) p.setPen(Qt::black); - for (int i = 0; i < DRUM_MAPSIZE; ++i) { + for (int i = 0; i < ourDrumMapSize; ++i) { int yy = i * TH; if (yy+TH < y) continue; if (yy > y + h) break; - DrumMap* dm = &drumMap[i]; + DrumMap* dm = &ourDrumMap[i]; if (dm == currentlySelected) p.fillRect(x, yy, w, TH, Qt::yellow); // else @@ -199,8 +200,8 @@ void DList::devicesPopupMenu(DrumMap* t, int x, int y, bool changeAll) // Delete all port controller events. song->changeAllPortDrumCtrlEvents(false); - for (int i = 0; i < DRUM_MAPSIZE; i++) - drumMap[i].port = n; + for (int i = 0; i < ourDrumMapSize; i++) + ourDrumMap[i].port = n; // Add all port controller events. song->changeAllPortDrumCtrlEvents(true); @@ -227,16 +228,16 @@ void DList::viewMousePressEvent(QMouseEvent* ev) int x = ev->x(); int y = ev->y(); int button = ev->button(); - unsigned pitch = y / TH; - DrumMap* dm = &drumMap[pitch]; + unsigned instrument = y / TH; + DrumMap* dm = &ourDrumMap[instrument]; - setCurDrumInstrument(pitch); + setCurDrumInstrument(instrument); startY = y; - sPitch = pitch; + sInstrument = instrument; drag = START_DRAG; - DCols col = DCols(x2col(x)); + DCols col = DCols(x2col(x)); //FINDMICH update int val; int incVal = 0; @@ -262,17 +263,17 @@ void DList::viewMousePressEvent(QMouseEvent* ev) if (button == Qt::LeftButton) dm->mute = !dm->mute; break; - case COL_PORT: + case COL_PORT: // this column isn't visible in new style drum mode if ((button == Qt::RightButton) || (button == Qt::LeftButton)) { bool changeAll = ev->modifiers() & Qt::ControlModifier; - devicesPopupMenu(dm, mapx(x), mapy(pitch * TH), changeAll); + devicesPopupMenu(dm, mapx(x), mapy(instrument * TH), changeAll); } break; case COL_VOL: val = dm->vol + incVal; if (val < 0) val = 0; - else if (val > 200) + else if (val > 200) //FINDMICH: why 200? why not 999 or infinity? (flo93) val = 200; dm->vol = (unsigned char)val; break; @@ -286,18 +287,22 @@ void DList::viewMousePressEvent(QMouseEvent* ev) val = 0; else if (val > 127) val = 127; - //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 - for (int i=0; ienote)] = i; - drumMap[i].enote = dm->enote; - break; - } - } - //TODO: Set all the notes on the track with pitch=dm->enote to pitch=val + + if (old_style_drummap_mode) //FINDMICH auch beim doppelklick! + { + //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 + for (int i=0; ienote)] = i; + ourDrumMap[i].enote = dm->enote; + break; + } + } + //TODO: Set all the notes on the track with instrument=dm->enote to instrument=val + drumInmap[val] = instrument; + } dm->enote = val; - drumInmap[val] = pitch; break; case COL_LEN: val = dm->len + incVal; @@ -306,6 +311,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 { val = dm->anote + incVal; if (val < 0) @@ -315,16 +321,19 @@ void DList::viewMousePressEvent(QMouseEvent* ev) if(val != dm->anote) { audio->msgIdle(true); - song->remapPortDrumCtrlEvents(pitch, val, -1, -1); + song->remapPortDrumCtrlEvents(instrument, val, -1, -1); audio->msgIdle(false); dm->anote = val; song->update(SC_DRUMMAP); } - int velocity = 127 * float(ev->x()) / width(); - emit keyPressed(pitch, velocity);//(dm->anote, shift); + } + + { + int velocity = 127 * float(ev->x()) / width(); + emit keyPressed(instrument, velocity);//(dm->anote, shift); } break; - case COL_CHANNEL: + case COL_CHANNEL: // this column isn't visible in new style drum mode val = dm->channel + incVal; if (val < 0) val = 0; @@ -336,8 +345,8 @@ void DList::viewMousePressEvent(QMouseEvent* ev) // Delete all port controller events. song->changeAllPortDrumCtrlEvents(false, true); - for (int i = 0; i < DRUM_MAPSIZE; i++) - drumMap[i].channel = val; + for (int i = 0; i < ourDrumMapSize; i++) + ourDrumMap[i].channel = val; // Add all port controller events. song->changeAllPortDrumCtrlEvents(true, true); audio->msgIdle(false); @@ -348,7 +357,7 @@ void DList::viewMousePressEvent(QMouseEvent* ev) if(val != dm->channel) { audio->msgIdle(true); - song->remapPortDrumCtrlEvents(pitch, -1, val, -1); + song->remapPortDrumCtrlEvents(instrument, -1, val, -1); audio->msgIdle(false); dm->channel = val; song->update(SC_DRUMMAP); @@ -388,7 +397,7 @@ void DList::viewMousePressEvent(QMouseEvent* ev) dm->lv4 = val; break; case COL_NAME: - emit keyPressed(pitch, 100); //Mapping done on other side, send index + emit keyPressed(instrument, 100); //Mapping done on other side, send index break; default: @@ -405,18 +414,18 @@ void DList::viewMouseDoubleClickEvent(QMouseEvent* ev) { int x = ev->x(); int y = ev->y(); - unsigned pitch = y / TH; + unsigned instrument = y / TH; int section = header->logicalIndexAt(x); if ((section == COL_NAME || section == COL_VOL || section == COL_LEN || section == COL_LV1 || - section == COL_LV2 || section == COL_LV3 || section == COL_LV4 || section == COL_CHANNEL || - section == COL_QNT) && (ev->button() == Qt::LeftButton)) + section == COL_LV2 || section == COL_LV3 || section == COL_LV4 || section == COL_QNT || + (section == COL_CHANNEL && old_style_drummap_mode) ) && (ev->button() == Qt::LeftButton)) { - lineEdit(pitch, section); + lineEdit(instrument, section); } - else if ((section == COL_ANOTE || section == COL_ENOTE) && (ev->button() == Qt::LeftButton)) - pitchEdit(pitch, section); + else if (((section == COL_ANOTE && old_style_drummap_mode) || section == COL_ENOTE) && (ev->button() == Qt::LeftButton)) + pitchEdit(instrument, section); else viewMousePressEvent(ev); } @@ -428,7 +437,7 @@ void DList::viewMouseDoubleClickEvent(QMouseEvent* ev) //--------------------------------------------------------- void DList::lineEdit(int line, int section) { - DrumMap* dm = &drumMap[line]; + DrumMap* dm = &ourDrumMap[line]; editEntry = dm; if (editor == 0) { editor = new DLineEdit(this); @@ -496,7 +505,7 @@ void DList::lineEdit(int line, int section) //--------------------------------------------------------- void DList::pitchEdit(int line, int section) { - DrumMap* dm = &drumMap[line]; + DrumMap* dm = &ourDrumMap[line]; editEntry = dm; if (pitch_editor == 0) { pitch_editor = new DPitchEdit(this); @@ -550,13 +559,13 @@ int DList::x2col(int x) const void DList::setCurDrumInstrument(int instr) { - if (instr < 0 || instr >= DRUM_MAPSIZE -1) + if (instr < 0 || instr >= ourDrumMapSize -1) return; // illegal instrument - DrumMap* dm = &drumMap[instr]; + DrumMap* dm = &ourDrumMap[instr]; if (currentlySelected != dm) { - currentlySelected = &drumMap[instr]; + currentlySelected = dm; emit curDrumInstrumentChanged(instr); - song->update(SC_DRUMMAP); + song->update(SC_DRUMMAP); //FINDMICH necessary?? } } @@ -578,7 +587,6 @@ void DList::returnPressed() int val = -1; if (selectedColumn != COL_NAME) { - ///val = atoi(editor->text().ascii()); val = atoi(editor->text().toAscii().constData()); switch (selectedColumn) @@ -618,7 +626,6 @@ void DList::returnPressed() break; case COL_LEN: - ///editEntry->len = atoi(editor->text().ascii()); editEntry->len = atoi(editor->text().toAscii().constData()); break; @@ -668,36 +675,44 @@ void DList::returnPressed() void DList::pitchEdited() { int val=pitch_editor->value(); - int pitch=(editEntry-drumMap); + int instrument=(editEntry-ourDrumMap); switch(selectedColumn) { case COL_ANOTE: + if (old_style_drummap_mode) //should actually be always true, but to be sure... + { if(val != editEntry->anote) { audio->msgIdle(true); - song->remapPortDrumCtrlEvents(pitch, val, -1, -1); + song->remapPortDrumCtrlEvents(instrument, val, -1, -1); audio->msgIdle(false); editEntry->anote = val; song->update(SC_DRUMMAP); } - break; + } + else + printf("ERROR: THIS SHOULD NEVER HAPPEN: pitch edited of anote in new style mode!\n"); + break; case COL_ENOTE: + 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 - for (int i=0; ienote)] = i; - drumMap[i].enote = editEntry->enote; + ourDrumMap[i].enote = editEntry->enote; break; } } - //TODO: Set all the notes on the track with pitch=dm->enote to pitch=val - editEntry->enote = val; - drumInmap[val] = pitch; - break; + //TODO: Set all the notes on the track with instrument=dm->enote to instrument=val + drumInmap[val] = instrument; + } + editEntry->enote = val; + break; default: - printf("Value changed in unknown column\n"); + printf("ERROR: THIS SHOULD NEVER HAPPEN: Value changed in unknown column\n"); break; } selectedColumn = -1; @@ -739,10 +754,15 @@ void DList::songChanged(int flags) // DList //--------------------------------------------------------- -DList::DList(QHeaderView* h, QWidget* parent, int ymag) +DList::DList(QHeaderView* h, QWidget* parent, int ymag, DrumCanvas* dcanvas, bool oldstyle) : MusEWidget::View(parent, 1, ymag) { setBg(Qt::white); + + ourDrumMap=dcanvas->getOurDrumMap(); + ourDrumMapSize=dcanvas->getOurDrumMapSize(); + old_style_drummap_mode=oldstyle; + if (!h){ h = new QHeaderView(Qt::Horizontal, parent);} header = h; @@ -757,7 +777,7 @@ DList::DList(QHeaderView* h, QWidget* parent, int ymag) pitch_editor = 0; editEntry = 0; // always select a drum instrument - currentlySelected = &drumMap[0]; + currentlySelected = &ourDrumMap[0]; selectedColumn = -1; } @@ -803,11 +823,11 @@ void DList::viewMouseReleaseEvent(QMouseEvent* ev) { if (drag == DRAG) { int y = ev->y(); - unsigned dPitch = y / TH; + unsigned dInstrument = y / TH; setCursor(QCursor(Qt::ArrowCursor)); - currentlySelected = &drumMap[int(dPitch)]; - emit curDrumInstrumentChanged(dPitch); - emit mapChanged(sPitch, dPitch); //Track pitch change done in canvas + currentlySelected = &ourDrumMap[int(dInstrument)]; + emit curDrumInstrumentChanged(dInstrument); + emit mapChanged(sInstrument, dInstrument); //Track instrument change done in canvas } drag = NORMAL; //?? redraw(); //commented out NOT by flo93; was already commented out @@ -816,16 +836,16 @@ void DList::viewMouseReleaseEvent(QMouseEvent* ev) int x = ev->x(); int y = ev->y(); bool shift = ev->modifiers() & Qt::ShiftModifier; - unsigned pitch = y / TH; + unsigned instrument = y / TH; DCols col = DCols(x2col(x)); switch (col) { case COL_NAME: - emit keyReleased(pitch, shift); + emit keyReleased(instrument, shift); break; case COL_ANOTE: - emit keyReleased(pitch, shift); + emit keyReleased(instrument, shift); break; default: break; diff --git a/muse2/muse/midiedit/dlist.h b/muse2/muse/midiedit/dlist.h index 0fb1fd0b..8e141c3b 100644 --- a/muse2/muse/midiedit/dlist.h +++ b/muse2/muse/midiedit/dlist.h @@ -39,7 +39,7 @@ class ScrollScale; class Device; class QLineEdit; class DrumMap; - +class DrumCanvas; //--------------------------------------------------------- // DLineEdit @@ -86,7 +86,11 @@ class DPitchEdit: public Awl::PitchEdit class DList : public MusEWidget::View { Q_OBJECT - + + DrumMap* ourDrumMap; //FINDMICHJETZT init! + int ourDrumMapSize; + bool old_style_drummap_mode; + QHeaderView* header; ScrollScale* scroll; QLineEdit* editor; @@ -98,7 +102,7 @@ class DList : public MusEWidget::View { int startY; int curY; - int sPitch; + int sInstrument; enum { NORMAL, START_DRAG, DRAG } drag; virtual void draw(QPainter& p, const QRect&); @@ -132,7 +136,7 @@ class DList : public MusEWidget::View { void lineEdit(int line, int section); void pitchEdit(int line, int section); void setCurDrumInstrument(int n); - DList(QHeaderView*, QWidget* parent, int ymag); + DList(QHeaderView*, QWidget* parent, int ymag, DrumCanvas* dcanvas, bool oldstyle); ~DList(); void setScroll(ScrollScale* s) { scroll = s; } int getSelectedInstrument(); diff --git a/muse2/muse/midiedit/drumedit.cpp b/muse2/muse/midiedit/drumedit.cpp index 230eef04..f21b0e8c 100644 --- a/muse2/muse/midiedit/drumedit.cpp +++ b/muse2/muse/midiedit/drumedit.cpp @@ -458,7 +458,13 @@ DrumEdit::DrumEdit(PartList* pl, QWidget* parent, const char* name, unsigned ini setHeaderToolTips(); setHeaderWhatsThis(); - dlist = new DList(header, split1w1, yscale); + if (!old_style_drummap_mode()) + { + header->hideSection(COL_OUTPORT); + header->hideSection(COL_OUTCHANNEL); + } + + dlist = new DList(header, split1w1, yscale, (DrumCanvas*)canvas, old_style_drummap_mode()); // p3.3.44 setCurDrumInstrument(dlist->getSelectedInstrument()); diff --git a/muse2/muse/midiedit/scoreedit.cpp b/muse2/muse/midiedit/scoreedit.cpp index c9f5454d..844c1311 100644 --- a/muse2/muse/midiedit/scoreedit.cpp +++ b/muse2/muse/midiedit/scoreedit.cpp @@ -4604,6 +4604,7 @@ void ScoreCanvas::add_new_parts(const std::map< Part*, std::set >& param) * o either open flo-tracks OR old-style-tracks * o 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, -- cgit v1.2.3 From 0d93b9b7a99847b19b7f0863a694e5441727419e Mon Sep 17 00:00:00 2001 From: Florian Jung Date: Fri, 30 Sep 2011 16:34:40 +0000 Subject: added dedicated drummap to tracks (only relevant for new-style-drumtracks) propagating ourDrumMap changes to track's drummaps changed volume percent limit from 200 to 999 cleaned up a bit --- muse2/muse/midiedit/dcanvas.cpp | 94 ++++++++++++--------------------------- muse2/muse/midiedit/dcanvas.h | 8 +++- muse2/muse/midiedit/dlist.cpp | 45 ++++++++++++++++--- muse2/muse/midiedit/dlist.h | 3 +- muse2/muse/midiedit/drumedit.cpp | 2 +- muse2/muse/midiedit/drummap.h | 2 +- muse2/muse/midiedit/scoreedit.cpp | 12 ++++- muse2/muse/track.cpp | 17 +++++++ muse2/muse/track.h | 11 ++++- 9 files changed, 113 insertions(+), 81 deletions(-) (limited to 'muse2') 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 >::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::iterator track=group->begin(); track!=group->end(); track++) + bool hidden=true; + for (QSet::iterator track=group->begin(); track!=group->end() && (mute || hidden); track++) { - if (track->drummap()[i].mute == false) - { + if (dynamic_cast(*track)->drummap()[i].mute == false) mute=false; - break; - } + + if (dynamic_cast(*track)->drummap_hidden()[i] == false) + hidden=false; } - for (QSet::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::iterator track=group->begin(); track!=group->end(); track++) + dynamic_cast(*track)->drummap()[i].mute=mute; + + instrument_map.append(instrument_number_mapping_t(*group, dynamic_cast(*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;idrummap()[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(*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 DrumCanvas::tracks_of_instrument(int instr) -{ - QSet result; - int first_instr = -1; - - for (std::map::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 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& tracks=instrument_map[instr].tracks; + int index=instrument_map[instr].track_dlist_index; + + for (QSet::const_iterator it = tracks.begin(); it != tracks.end(); it++) + dynamic_cast(*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 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& tr, int p) + instrument_number_mapping_t(const QSet& 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(canvas)->drum_map_size()*TH, Qt::Vertical, split1w2); + vscroll = new MusEWidget::ScrollScale(-4, 1, yscale, dynamic_cast(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 >& 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 >& 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, 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; } }; //--------------------------------------------------------- -- cgit v1.2.3 From fbb72c809a2e75e0d4b038056df80d60c09d62c5 Mon Sep 17 00:00:00 2001 From: Florian Jung Date: Sun, 2 Oct 2011 14:53:39 +0000 Subject: drum list entry ordering is now remembered bugfix in reordering drummap --- muse2/muse/midiedit/dcanvas.cpp | 101 ++++++++++++++++++++++++++++++-------- muse2/muse/midiedit/dcanvas.h | 5 +- muse2/muse/midiedit/dlist.cpp | 18 +++++-- muse2/muse/midiedit/drummap.cpp | 2 + muse2/muse/midiedit/drummap.h | 4 ++ muse2/muse/midiedit/scoreedit.cpp | 17 ++++--- muse2/muse/track.cpp | 29 ++++++++++- 7 files changed, 139 insertions(+), 37 deletions(-) (limited to 'muse2') 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 >::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 >::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::iterator track=group->begin(); track!=group->end() && (mute || hidden); track++) { - if (dynamic_cast(*track)->drummap()[i].mute == false) + if (dynamic_cast(*track)->drummap()[pitch].mute == false) mute=false; - if (dynamic_cast(*track)->drummap_hidden()[i] == false) + if (dynamic_cast(*track)->drummap_hidden()[pitch] == false) hidden=false; } if (!hidden) { for (QSet::iterator track=group->begin(); track!=group->end(); track++) - dynamic_cast(*track)->drummap()[i].mute=mute; + dynamic_cast(*track)->drummap()[pitch].mute=mute; - instrument_map.append(instrument_number_mapping_t(*group, dynamic_cast(*group->begin())->drummap()[i].anote, i)); + if (dynamic_cast(*group->begin())->drummap()[pitch].anote != pitch) + printf("THIS SHOULD NEVER HAPPEN: track's_drummap[pitch].anote (%i)!= pitch (%i) !!!\n",dynamic_cast(*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(*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(*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) + { + 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& tracks=instrument_map[instr].tracks; - int index=instrument_map[instr].track_dlist_index; + int index=instrument_map[instr].pitch; for (QSet::const_iterator it = tracks.begin(); it != tracks.end(); it++) dynamic_cast(*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 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& tr, int p, int i) + instrument_number_mapping_t(const QSet& 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 > 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 >& 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, pitch } @@ -4616,9 +4620,10 @@ void ScoreCanvas::add_new_parts(const std::map< Part*, std::set >& 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(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++; + } //--------------------------------------------------------- -- cgit v1.2.3 From b99988059eb65520df143380aa707c52256cf77c Mon Sep 17 00:00:00 2001 From: Florian Jung Date: Mon, 3 Oct 2011 12:35:57 +0000 Subject: added support for grouping tracks in drum editor --- muse2/muse/helper.cpp | 12 ++++++++ muse2/muse/helper.h | 4 +++ muse2/muse/midiedit/dcanvas.cpp | 64 ++++++++++++++++++++++++++++++++++----- muse2/muse/midiedit/dcanvas.h | 7 ----- muse2/muse/midiedit/dlist.cpp | 15 ++------- muse2/muse/midiedit/drumedit.cpp | 2 ++ muse2/muse/midiedit/drumedit.h | 9 +++++- muse2/muse/midiedit/drummap.h | 3 +- muse2/muse/midiedit/scoreedit.cpp | 3 ++ muse2/muse/track.h | 2 +- 10 files changed, 92 insertions(+), 29 deletions(-) (limited to 'muse2') 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& 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 +#include "drummap.h" + class QActionGroup; class QString; class QMenu; @@ -43,6 +45,8 @@ bool any_event_selected(const std::set&, 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(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_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 temp; - temp.insert(*track); - track_groups.push_back(temp); + bool inserted=false; + + switch (dynamic_cast(pr)->group_mode()) + { + case DrumEdit::GROUP_SAME_CHANNEL: + for (QList< QSet >::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 >::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 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 > 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 >::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::iterator track=group->begin(); track!=group->end(); track++) + ignore_order_entries.append(std::pair(dynamic_cast(*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 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 +#include 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 >& 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 >& 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) { } }; -- cgit v1.2.3 From 09e02c07130a56a992e919cf19d32f50d067d149 Mon Sep 17 00:00:00 2001 From: Florian Jung Date: Mon, 3 Oct 2011 13:15:24 +0000 Subject: added infrastructure for being able to handle major drummap changes should have changed nothing in functionality --- muse2/muse/midiedit/dcanvas.cpp | 252 +++++++++++++++++++++------------------ muse2/muse/midiedit/dcanvas.h | 5 + muse2/muse/midiedit/dlist.cpp | 28 ++++- muse2/muse/midiedit/dlist.h | 5 +- muse2/muse/midiedit/drumedit.cpp | 8 ++ muse2/muse/midiedit/drumedit.h | 3 +- 6 files changed, 177 insertions(+), 124 deletions(-) (limited to 'muse2') diff --git a/muse2/muse/midiedit/dcanvas.cpp b/muse2/muse/midiedit/dcanvas.cpp index 550de13b..07e5a430 100644 --- a/muse2/muse/midiedit/dcanvas.cpp +++ b/muse2/muse/midiedit/dcanvas.cpp @@ -111,9 +111,9 @@ DrumCanvas::DrumCanvas(MidiEditor* pr, QWidget* parent, int sx, int sy, const char* name) : EventCanvas(pr, parent, sx, sy, name) { - using MusEUtil::drummaps_almost_equal; + drumEditor=dynamic_cast(pr); - old_style_drummap_mode = dynamic_cast(pr)->old_style_drummap_mode(); + old_style_drummap_mode = drumEditor->old_style_drummap_mode(); if (old_style_drummap_mode) { @@ -122,7 +122,7 @@ DrumCanvas::DrumCanvas(MidiEditor* pr, QWidget* parent, int sx, must_delete_our_drum_map=false; instrument_number_mapping_t temp; - for (ciPart it=pr->parts()->begin(); it!=pr->parts()->end(); it++) + for (ciPart it=drumEditor->parts()->begin(); it!=drumEditor->parts()->end(); it++) temp.tracks.insert(it->second->track()); for (int i=0;itracks(); - - QList< QSet > track_groups; - - for (ciTrack track = tl->begin(); track!=tl->end(); track++) - { - ciPart p_it; - for (p_it=pr->parts()->begin(); p_it!=pr->parts()->end(); p_it++) - if (p_it->second->track() == *track) - break; - - if (p_it!=pr->parts()->end()) // if *track is represented by some part in this editor - { - bool inserted=false; - - switch (dynamic_cast(pr)->group_mode()) - { - case DrumEdit::GROUP_SAME_CHANNEL: - for (QList< QSet >::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 >::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 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 > 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 >::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::iterator track=group->begin(); track!=group->end() && (mute || hidden); track++) - { - if (dynamic_cast(*track)->drummap()[pitch].mute == false) - mute=false; - - if (dynamic_cast(*track)->drummap_hidden()[pitch] == false) - hidden=false; - } - - if (!hidden) - { - for (QSet::iterator track=group->begin(); track!=group->end(); track++) - dynamic_cast(*track)->drummap()[pitch].mute=mute; - - if (dynamic_cast(*group->begin())->drummap()[pitch].anote != pitch) - printf("THIS SHOULD NEVER HAPPEN: track's_drummap[pitch].anote (%i)!= pitch (%i) !!!\n",dynamic_cast(*group->begin())->drummap()[pitch].anote,pitch); - - instrument_map.append(instrument_number_mapping_t(*group, pitch)); - } - - for (QSet::iterator track=group->begin(); track!=group->end(); track++) - ignore_order_entries.append(std::pair(dynamic_cast(*track), pitch)); - } - // else ignore it - } - - - // populate ourDrumMap - - int size = instrument_map.size(); - ourDrumMap=new DrumMap[size]; - must_delete_our_drum_map=true; - - for (int i=0;i(*instrument_map[i].tracks.begin())->drummap()[instrument_map[i].pitch]; + ourDrumMap=NULL; + rebuildOurDrumMap(); } @@ -1411,3 +1298,132 @@ void DrumCanvas::propagate_drummap_change(int instr) for (QSet::const_iterator it = tracks.begin(); it != tracks.end(); it++) dynamic_cast(*it)->drummap()[index] = ourDrumMap[instr]; } + + +void DrumCanvas::rebuildOurDrumMap() +{ + using MusEUtil::drummaps_almost_equal; + + if (!old_style_drummap_mode) + { + TrackList* tl=song->tracks(); + QList< QSet > track_groups; + + instrument_map.clear(); + + for (ciTrack track = tl->begin(); track!=tl->end(); track++) + { + ciPart p_it; + for (p_it=drumEditor->parts()->begin(); p_it!=drumEditor->parts()->end(); p_it++) + if (p_it->second->track() == *track) + break; + + if (p_it!=drumEditor->parts()->end()) // if *track is represented by some part in this editor + { + bool inserted=false; + + switch (drumEditor->group_mode()) + { + case DrumEdit::GROUP_SAME_CHANNEL: + for (QList< QSet >::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 >::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 temp; + temp.insert(*track); + track_groups.push_back(temp); + } + } + } + + // 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 > 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 >::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::iterator track=group->begin(); track!=group->end() && (mute || hidden); track++) + { + if (dynamic_cast(*track)->drummap()[pitch].mute == false) + mute=false; + + if (dynamic_cast(*track)->drummap_hidden()[pitch] == false) + hidden=false; + } + + if (!hidden) + { + for (QSet::iterator track=group->begin(); track!=group->end(); track++) + dynamic_cast(*track)->drummap()[pitch].mute=mute; + + if (dynamic_cast(*group->begin())->drummap()[pitch].anote != pitch) + printf("THIS SHOULD NEVER HAPPEN: track's_drummap[pitch].anote (%i)!= pitch (%i) !!!\n",dynamic_cast(*group->begin())->drummap()[pitch].anote,pitch); + + instrument_map.append(instrument_number_mapping_t(*group, pitch)); + } + + for (QSet::iterator track=group->begin(); track!=group->end(); track++) + ignore_order_entries.append(std::pair(dynamic_cast(*track), pitch)); + } + // else ignore it + } + + + // maybe delete and then populate ourDrumMap + + if (must_delete_our_drum_map && ourDrumMap!=NULL) + delete [] ourDrumMap; + + int size = instrument_map.size(); + ourDrumMap=new DrumMap[size]; + must_delete_our_drum_map=true; + + for (int i=0;i(*instrument_map[i].tracks.begin())->drummap()[instrument_map[i].pitch]; + + emit ourDrumMapChanged(); + } +} diff --git a/muse2/muse/midiedit/dcanvas.h b/muse2/muse/midiedit/dcanvas.h index f0c601f5..0f519b70 100644 --- a/muse2/muse/midiedit/dcanvas.h +++ b/muse2/muse/midiedit/dcanvas.h @@ -41,6 +41,7 @@ class QDragLeaveEvent; class DrumMap; class MidiEditor; +class DrumEdit; //--------------------------------------------------------- // DEvent @@ -86,6 +87,8 @@ class DrumCanvas : public EventCanvas { bool must_delete_our_drum_map; //FINDMICH really delete it! QVector instrument_map; + DrumEdit* drumEditor; + StepRec* steprec; // Cursor tool position @@ -119,6 +122,7 @@ class DrumCanvas : public EventCanvas { signals: void newWidth(int); + void ourDrumMapChanged(); private slots: void midiNote(int pitch, int velo); @@ -152,6 +156,7 @@ class DrumCanvas : public EventCanvas { int getOurDrumMapSize() { return instrument_map.size(); } //FINDMICH UGLY void propagate_drummap_change(int instrument); //FINDMICH move to drumedit + void rebuildOurDrumMap(); }; #endif diff --git a/muse2/muse/midiedit/dlist.cpp b/muse2/muse/midiedit/dlist.cpp index 7de39b81..c35f2a21 100644 --- a/muse2/muse/midiedit/dlist.cpp +++ b/muse2/muse/midiedit/dlist.cpp @@ -37,7 +37,6 @@ #include "icons.h" #include "dlist.h" #include "song.h" -#include "scrollscale.h" #include "dcanvas.h" //--------------------------------------------------------- @@ -595,6 +594,12 @@ void DList::sizeChange(int, int, int) void DList::returnPressed() { + if (editEntry==NULL) + { + printf("THIS SHOULD NEVER HAPPEN: editEntry is NULL in DList::returnPressed()!\n"); + return; + } + int val = -1; if (selectedColumn != COL_NAME) { @@ -690,6 +695,12 @@ void DList::returnPressed() void DList::pitchEdited() { + if (editEntry==NULL) + { + printf("THIS SHOULD NEVER HAPPEN: editEntry is NULL in DList::pitchEdited()!\n"); + return; + } + int val=pitch_editor->value(); int instrument=(editEntry-ourDrumMap); @@ -784,11 +795,11 @@ DList::DList(QHeaderView* h, QWidget* parent, int ymag, DrumCanvas* dcanvas_, bo ourDrumMap=dcanvas->getOurDrumMap(); ourDrumMapSize=dcanvas->getOurDrumMapSize(); old_style_drummap_mode=oldstyle; + connect(dcanvas, SIGNAL(ourDrumMapChanged()), SLOT(ourDrumMapChanged())); if (!h){ h = new QHeaderView(Qt::Horizontal, parent);} header = h; - scroll = 0; //ORCAN- CHECK if really needed: header->setTracking(true); connect(header, SIGNAL(sectionResized(int,int,int)), SLOT(sizeChange(int,int,int))); @@ -896,3 +907,16 @@ int DList::getSelectedInstrument() } +void DList::ourDrumMapChanged() +{ + int selIdx = currentlySelected - ourDrumMap; + + ourDrumMap=dcanvas->getOurDrumMap(); + ourDrumMapSize=dcanvas->getOurDrumMapSize(); + + editEntry=NULL; + if (selIdx >= ourDrumMapSize) selIdx=ourDrumMapSize-1; + currentlySelected = &ourDrumMap[selIdx]; + + redraw(); +} diff --git a/muse2/muse/midiedit/dlist.h b/muse2/muse/midiedit/dlist.h index 52bf8de4..1d87f3dc 100644 --- a/muse2/muse/midiedit/dlist.h +++ b/muse2/muse/midiedit/dlist.h @@ -35,7 +35,6 @@ class QHeaderView; class QMouseEvent; class QPainter; -class ScrollScale; class Device; class QLineEdit; class DrumMap; @@ -93,7 +92,6 @@ class DList : public MusEWidget::View { bool old_style_drummap_mode; QHeaderView* header; - ScrollScale* scroll; QLineEdit* editor; DPitchEdit* pitch_editor; DrumMap* editEntry; @@ -133,13 +131,14 @@ class DList : public MusEWidget::View { public slots: void tracklistChanged(); void songChanged(int); + void ourDrumMapChanged(); + public: void lineEdit(int line, int section); void pitchEdit(int line, int section); void setCurDrumInstrument(int n); DList(QHeaderView*, QWidget* parent, int ymag, DrumCanvas* dcanvas, bool oldstyle); ~DList(); - void setScroll(ScrollScale* s) { scroll = s; } int getSelectedInstrument(); enum DCols { COL_MUTE=0, COL_NAME, COL_VOL, COL_QNT, COL_ENOTE, COL_LEN, diff --git a/muse2/muse/midiedit/drumedit.cpp b/muse2/muse/midiedit/drumedit.cpp index a74f3dd1..4cb6a7b1 100644 --- a/muse2/muse/midiedit/drumedit.cpp +++ b/muse2/muse/midiedit/drumedit.cpp @@ -420,6 +420,7 @@ DrumEdit::DrumEdit(PartList* pl, QWidget* parent, const char* name, unsigned ini connect(canvas, SIGNAL(toolChanged(int)), tools2, SLOT(set(int))); connect(canvas, SIGNAL(horizontalZoomIn()), SLOT(horizontalZoomIn())); connect(canvas, SIGNAL(horizontalZoomOut()), SLOT(horizontalZoomOut())); + connect(canvas, SIGNAL(ourDrumMapChanged()), SLOT(ourDrumMapChanged())); time->setOrigin(offset, 0); QList mops; @@ -1343,3 +1344,10 @@ bool DrumEdit::old_style_drummap_mode() return false; } + +void DrumEdit::ourDrumMapChanged() +{ + int vmin,vmax; + vscroll->range(&vmin, &vmax); + vscroll->setRange(vmin, dynamic_cast(canvas)->getOurDrumMapSize()*TH); +} diff --git a/muse2/muse/midiedit/drumedit.h b/muse2/muse/midiedit/drumedit.h index d854d054..7d85cb2f 100644 --- a/muse2/muse/midiedit/drumedit.h +++ b/muse2/muse/midiedit/drumedit.h @@ -136,8 +136,9 @@ class DrumEdit : public MidiEditor { void execDeliveredScript(int); void execUserScript(int); CtrlEdit* addCtrl(); - + void ourDrumMapChanged(); virtual void updateHScrollRange(); + signals: void deleted(TopWin*); -- cgit v1.2.3 From d2427fa3b72eeb897ab214b38572009e6e4f4987 Mon Sep 17 00:00:00 2001 From: Florian Jung Date: Mon, 3 Oct 2011 13:40:36 +0000 Subject: added support for changing grouping mode --- muse2/muse/midiedit/dcanvas.cpp | 4 ++++ muse2/muse/midiedit/dcanvas.h | 3 ++- muse2/muse/midiedit/drumedit.cpp | 49 +++++++++++++++++++++++++++++++++++++++- muse2/muse/midiedit/drumedit.h | 3 ++- 4 files changed, 56 insertions(+), 3 deletions(-) (limited to 'muse2') diff --git a/muse2/muse/midiedit/dcanvas.cpp b/muse2/muse/midiedit/dcanvas.cpp index 07e5a430..8e2f284d 100644 --- a/muse2/muse/midiedit/dcanvas.cpp +++ b/muse2/muse/midiedit/dcanvas.cpp @@ -1424,6 +1424,10 @@ void DrumCanvas::rebuildOurDrumMap() for (int i=0;i(*instrument_map[i].tracks.begin())->drummap()[instrument_map[i].pitch]; + if (debugMsg) printf("rebuilt drummap, size is now %i\n",size); + + songChanged(SC_EVENT_INSERTED); // force an update of the itemlist + emit ourDrumMapChanged(); } } diff --git a/muse2/muse/midiedit/dcanvas.h b/muse2/muse/midiedit/dcanvas.h index 0f519b70..e06857a9 100644 --- a/muse2/muse/midiedit/dcanvas.h +++ b/muse2/muse/midiedit/dcanvas.h @@ -142,7 +142,8 @@ class DrumCanvas : public EventCanvas { CMD_SELECT_ALL, CMD_SELECT_NONE, CMD_SELECT_INVERT, CMD_SELECT_ILOOP, CMD_SELECT_OLOOP, CMD_SELECT_PREV_PART, CMD_SELECT_NEXT_PART, CMD_DEL, CMD_FIXED_LEN, CMD_RIGHT, CMD_LEFT, CMD_RIGHT_NOSNAP, CMD_LEFT_NOSNAP, CMD_MODIFY_VELOCITY, CMD_CRESCENDO, - CMD_QUANTIZE, CMD_ERASE_EVENT, CMD_NOTE_SHIFT, CMD_DELETE_OVERLAPS, CMD_REORDER_LIST + CMD_QUANTIZE, CMD_ERASE_EVENT, CMD_NOTE_SHIFT, CMD_DELETE_OVERLAPS, CMD_REORDER_LIST, + CMD_GROUP_NONE, CMD_GROUP_CHAN, CMD_GROUP_MAX }; DrumCanvas(MidiEditor*, QWidget*, int, int, const char* name = 0); diff --git a/muse2/muse/midiedit/drumedit.cpp b/muse2/muse/midiedit/drumedit.cpp index 4cb6a7b1..ce261425 100644 --- a/muse2/muse/midiedit/drumedit.cpp +++ b/muse2/muse/midiedit/drumedit.cpp @@ -287,10 +287,40 @@ DrumEdit::DrumEdit(PartList* pl, QWidget* parent, const char* name, unsigned ini signalMapper->setMapping(noteShiftAction, DrumCanvas::CMD_NOTE_SHIFT); signalMapper->setMapping(delOverlapsAction, DrumCanvas::CMD_DELETE_OVERLAPS); + + QMenu* menuScriptPlugins = menuBar()->addMenu(tr("&Plugins")); song->populateScriptMenu(menuScriptPlugins, this); QMenu* settingsMenu = menuBar()->addMenu(tr("Window &Config")); + if (!old_style_drummap_mode()) + { + QMenu* menuGrouping=settingsMenu->addMenu(tr("Group")); + groupNoneAction = menuGrouping->addAction(tr("Don't group")); + groupChanAction = menuGrouping->addAction(tr("Group by channel")); + groupMaxAction = menuGrouping->addAction(tr("Group maximally")); + settingsMenu->addSeparator(); + + groupNoneAction->setCheckable(true); + groupChanAction->setCheckable(true); + groupMaxAction ->setCheckable(true); + + connect(groupNoneAction, SIGNAL(triggered()), signalMapper, SLOT(map())); + connect(groupChanAction, SIGNAL(triggered()), signalMapper, SLOT(map())); + connect(groupMaxAction, SIGNAL(triggered()), signalMapper, SLOT(map())); + + signalMapper->setMapping(groupNoneAction, DrumCanvas::CMD_GROUP_NONE); + signalMapper->setMapping(groupChanAction, DrumCanvas::CMD_GROUP_CHAN); + signalMapper->setMapping(groupMaxAction, DrumCanvas::CMD_GROUP_MAX); + + updateGroupingActions(); + } + else + { + groupNoneAction=NULL; + groupChanAction=NULL; + groupMaxAction =NULL; + } settingsMenu->addAction(subwinAction); settingsMenu->addAction(shareAction); settingsMenu->addAction(fullscreenAction); @@ -964,7 +994,11 @@ void DrumEdit::cmd(int cmd) case DrumCanvas::CMD_REORDER_LIST: ((DrumCanvas*)(canvas))->moveAwayUnused(); break; //case DrumCanvas::CMD_FIXED_LEN: // this must be handled by the drum canvas, due to its // special nature (each drum has its own length) - + + case DrumCanvas::CMD_GROUP_NONE: _group_mode=DONT_GROUP; updateGroupingActions(); ((DrumCanvas*)(canvas))->rebuildOurDrumMap(); break; + case DrumCanvas::CMD_GROUP_CHAN: _group_mode=GROUP_SAME_CHANNEL; updateGroupingActions(); ((DrumCanvas*)(canvas))->rebuildOurDrumMap(); break; + case DrumCanvas::CMD_GROUP_MAX: _group_mode=GROUP_MAX; updateGroupingActions(); ((DrumCanvas*)(canvas))->rebuildOurDrumMap(); break; + default: ((DrumCanvas*)(canvas))->cmd(cmd); } } @@ -1351,3 +1385,16 @@ void DrumEdit::ourDrumMapChanged() vscroll->range(&vmin, &vmax); vscroll->setRange(vmin, dynamic_cast(canvas)->getOurDrumMapSize()*TH); } + +void DrumEdit::updateGroupingActions() +{ + if (groupNoneAction==NULL || groupChanAction==NULL || groupMaxAction==NULL) + { + printf("THIS SHOULD NEVER HAPPEN: DrumEdit::updateGroupingActions() called, but one of the actions is NULL!\n"); + return; + } + + groupNoneAction->setChecked(_group_mode==DONT_GROUP); + groupChanAction->setChecked(_group_mode==GROUP_SAME_CHANNEL); + groupMaxAction ->setChecked(_group_mode==GROUP_MAX); +} diff --git a/muse2/muse/midiedit/drumedit.h b/muse2/muse/midiedit/drumedit.h index 7d85cb2f..743d6151 100644 --- a/muse2/muse/midiedit/drumedit.h +++ b/muse2/muse/midiedit/drumedit.h @@ -101,7 +101,7 @@ class DrumEdit : public MidiEditor { QAction *fixedAction, *veloAction, *crescAction, *quantizeAction; QAction *sallAction, *snoneAction, *invAction, *inAction , *outAction; QAction *prevAction, *nextAction; - + QAction *groupNoneAction, *groupChanAction, *groupMaxAction; void initShortcuts(); @@ -129,6 +129,7 @@ class DrumEdit : public MidiEditor { void configChanged(); void songChanged1(int); void setStep(QString); + void updateGroupingActions(); public slots: void setSelection(int, Event&, Part*); -- cgit v1.2.3 From 890ee8999eaca679fa1874adf3f572f365138e29 Mon Sep 17 00:00:00 2001 From: Florian Jung Date: Mon, 3 Oct 2011 14:02:55 +0000 Subject: drum map changes are now handled properly --- muse2/muse/midiedit/dcanvas.cpp | 4 +++- muse2/muse/midiedit/dlist.cpp | 9 ++++++--- muse2/muse/midiedit/drumedit.cpp | 6 +++++- 3 files changed, 14 insertions(+), 5 deletions(-) (limited to 'muse2') diff --git a/muse2/muse/midiedit/dcanvas.cpp b/muse2/muse/midiedit/dcanvas.cpp index 8e2f284d..35236e87 100644 --- a/muse2/muse/midiedit/dcanvas.cpp +++ b/muse2/muse/midiedit/dcanvas.cpp @@ -977,7 +977,9 @@ void DrumCanvas::mapChanged(int spitch, int dpitch) } - song->update(SC_DRUMMAP); + song->update(SC_DRUMMAP); // this causes a complete rebuild of ourDrumMap + // which also handles the changed order in all + // other drum editors } } diff --git a/muse2/muse/midiedit/dlist.cpp b/muse2/muse/midiedit/dlist.cpp index c35f2a21..85382c4a 100644 --- a/muse2/muse/midiedit/dlist.cpp +++ b/muse2/muse/midiedit/dlist.cpp @@ -413,7 +413,8 @@ void DList::viewMousePressEvent(QMouseEvent* ev) if (!old_style_drummap_mode && dm_old != *dm) //something changed and we're in new style mode? dcanvas->propagate_drummap_change(dm-ourDrumMap); - redraw(); + song->update(SC_DRUMMAP); + //redraw(); //this is done by the songChanged slot } //--------------------------------------------------------- @@ -686,7 +687,8 @@ void DList::returnPressed() editor->hide(); editEntry = 0; setFocus(); - redraw(); + song->update(SC_DRUMMAP); + //redraw(); //this is done by the songChanged slot } //--------------------------------------------------------- @@ -751,7 +753,8 @@ void DList::pitchEdited() pitch_editor->hide(); editEntry = 0; setFocus(); - redraw(); + song->update(SC_DRUMMAP); + //redraw(); //this is done by the songChanged slot } //--------------------------------------------------------- diff --git a/muse2/muse/midiedit/drumedit.cpp b/muse2/muse/midiedit/drumedit.cpp index ce261425..92cc765a 100644 --- a/muse2/muse/midiedit/drumedit.cpp +++ b/muse2/muse/midiedit/drumedit.cpp @@ -587,8 +587,12 @@ void DrumEdit::songChanged1(int bits) toolbar->setSolo(canvas->track()->solo()); return; } + if ( !old_style_drummap_mode() && + ( bits & (SC_DRUMMAP | SC_TRACK_INSERTED | SC_TRACK_REMOVED | SC_TRACK_MODIFIED | + SC_PART_INSERTED | SC_PART_REMOVED | SC_PART_MODIFIED) ) ) + ((DrumCanvas*)(canvas))->rebuildOurDrumMap(); + songChanged(bits); - } //--------------------------------------------------------- -- cgit v1.2.3 From f60ddccd6d328a5cebc4d524246e33b399a8dfdd Mon Sep 17 00:00:00 2001 From: Florian Jung Date: Thu, 6 Oct 2011 11:37:57 +0000 Subject: you can now hide and show drumlist instruments squashed some minor bugs --- muse2/muse/icons.cpp | 11 ++ muse2/muse/icons.h | 3 + muse2/muse/midiedit/dcanvas.cpp | 32 +++++- muse2/muse/midiedit/dcanvas.h | 15 ++- muse2/muse/midiedit/dlist.cpp | 231 +++++++++++++++++++++++++++----------- muse2/muse/midiedit/dlist.h | 5 +- muse2/muse/midiedit/drumedit.cpp | 66 +++++++---- muse2/muse/midiedit/drumedit.h | 24 +++- muse2/muse/midiedit/scoreedit.cpp | 7 +- muse2/muse/song.cpp | 8 +- muse2/muse/song.h | 4 +- muse2/xpm/eye.xpm | 22 ++++ muse2/xpm/eye_crossed.xpm | 23 ++++ muse2/xpm/eye_gray.xpm | 22 ++++ 14 files changed, 368 insertions(+), 105 deletions(-) create mode 100644 muse2/xpm/eye.xpm create mode 100644 muse2/xpm/eye_crossed.xpm create mode 100644 muse2/xpm/eye_gray.xpm (limited to 'muse2') diff --git a/muse2/muse/icons.cpp b/muse2/muse/icons.cpp index 89a3a48e..34493d13 100644 --- a/muse2/muse/icons.cpp +++ b/muse2/muse/icons.cpp @@ -1,4 +1,5 @@ //========================================================= +//========================================================= // MusE // Linux Music Editor // $Id: icons.cpp,v 1.13.2.8 2009/11/14 03:37:48 terminator356 Exp $ @@ -120,6 +121,10 @@ #include "xpm/rec_echo_on.xpm" #include "xpm/rec_echo_off.xpm" +#include "xpm/eye.xpm" +#include "xpm/eye_gray.xpm" +#include "xpm/eye_crossed.xpm" + #include "xpm/up.xpm" #include "xpm/down.xpm" #include "xpm/bold.xpm" @@ -331,6 +336,9 @@ QPixmap* homeIcon; QPixmap* backIcon; QPixmap* forwardIcon; QPixmap* muteIcon; +QPixmap* eyeIcon; +QPixmap* eyeCrossedIcon; +QPixmap* eyeGrayIcon; QPixmap* upIcon; QPixmap* downIcon; QPixmap* boldIcon; @@ -534,6 +542,9 @@ void initIcons() backIcon = new MPIXMAP(back_xpm, "go-previous"); forwardIcon = new MPIXMAP(forward_xpm, "go-next"); muteIcon = new MPIXMAP(editmuteS_xpm, "audio-volume-muted"); + eyeIcon = new MPIXMAP(eye_xpm, NULL); + eyeCrossedIcon = new MPIXMAP(eye_crossed_xpm, NULL); + eyeGrayIcon = new MPIXMAP(eye_gray_xpm, NULL); upIcon = new MPIXMAP(up_xpm, "go-up"); downIcon = new MPIXMAP(down_xpm, "go-down"); boldIcon = new MPIXMAP(bold_xpm, "format-text-bold"); diff --git a/muse2/muse/icons.h b/muse2/muse/icons.h index 957f4a74..30852f81 100644 --- a/muse2/muse/icons.h +++ b/muse2/muse/icons.h @@ -85,6 +85,9 @@ extern QPixmap* homeIcon; extern QPixmap* backIcon; extern QPixmap* forwardIcon; extern QPixmap* muteIcon; +extern QPixmap* eyeIcon; +extern QPixmap* eyeCrossedIcon; +extern QPixmap* eyeGrayIcon; extern QPixmap* upIcon; extern QPixmap* downIcon; extern QPixmap* boldIcon; diff --git a/muse2/muse/midiedit/dcanvas.cpp b/muse2/muse/midiedit/dcanvas.cpp index 34173780..c6b39e76 100644 --- a/muse2/muse/midiedit/dcanvas.cpp +++ b/muse2/muse/midiedit/dcanvas.cpp @@ -1317,8 +1317,11 @@ void DrumCanvas::rebuildOurDrumMap() if (!old_style_drummap_mode) { + bool need_update = false; + TrackList* tl=song->tracks(); QList< QSet > track_groups; + QVector old_instrument_map = instrument_map; instrument_map.clear(); @@ -1396,6 +1399,9 @@ void DrumCanvas::rebuildOurDrumMap() bool mute=true; bool hidden=true; + + if (drumEditor->ignore_hide()) hidden=false; + for (QSet::iterator track=group->begin(); track!=group->end() && (mute || hidden); track++) { if (dynamic_cast(*track)->drummap()[pitch].mute == false) @@ -1408,7 +1414,14 @@ void DrumCanvas::rebuildOurDrumMap() if (!hidden) { for (QSet::iterator track=group->begin(); track!=group->end(); track++) - dynamic_cast(*track)->drummap()[pitch].mute=mute; + { + DrumMap* dm = &dynamic_cast(*track)->drummap()[pitch]; + if (dm->mute != mute) + { + dm->mute=mute; + need_update = true; + } + } if (dynamic_cast(*group->begin())->drummap()[pitch].anote != pitch) printf("THIS SHOULD NEVER HAPPEN: track's_drummap[pitch].anote (%i)!= pitch (%i) !!!\n",dynamic_cast(*group->begin())->drummap()[pitch].anote,pitch); @@ -1435,10 +1448,19 @@ void DrumCanvas::rebuildOurDrumMap() for (int i=0;i(*instrument_map[i].tracks.begin())->drummap()[instrument_map[i].pitch]; - if (debugMsg) printf("rebuilt drummap, size is now %i\n",size); + if (instrument_map!=old_instrument_map) + { + if (debugMsg) printf("rebuilt drummap and instrument map, size is now %i\n",size); - songChanged(SC_EVENT_INSERTED); // force an update of the itemlist - - emit ourDrumMapChanged(); + songChanged(SC_EVENT_INSERTED); // force an update of the itemlist + emit ourDrumMapChanged(true); + } + else + emit ourDrumMapChanged(false); + + if (need_update) + song->update(SC_DRUMMAP, true); // i know, this causes a recursion, which possibly + // isn't the most elegant solution here. but it will + // never be an infinite recursion } } diff --git a/muse2/muse/midiedit/dcanvas.h b/muse2/muse/midiedit/dcanvas.h index 9a45f6ac..8ecbdac9 100644 --- a/muse2/muse/midiedit/dcanvas.h +++ b/muse2/muse/midiedit/dcanvas.h @@ -73,6 +73,17 @@ struct instrument_number_mapping_t tracks=tr; pitch=p; } + + bool operator==(const instrument_number_mapping_t& that) //TODO maybe compare the Track* serial numbers, not the pointers themselves? + { + return (this->tracks == that.tracks && this->pitch==that.pitch); + } + + bool operator!=(const instrument_number_mapping_t& that) + { + return !operator==(that); + } + }; //--------------------------------------------------------- @@ -122,7 +133,7 @@ class DrumCanvas : public EventCanvas { signals: void newWidth(int); - void ourDrumMapChanged(); + void ourDrumMapChanged(bool /*instrumentMap changed as well?*/); private slots: void midiNote(int pitch, int velo); @@ -156,7 +167,7 @@ class DrumCanvas : public EventCanvas { int pitch_and_track_to_instrument(int pitch, Track* track); DrumMap* getOurDrumMap() { return ourDrumMap; } //FINDMICH UGLY int getOurDrumMapSize() { return instrument_map.size(); } //FINDMICH UGLY - + QVector& get_instrument_map() { return instrument_map; } //FINDMICH UGLY void propagate_drummap_change(int instrument); //FINDMICH move to drumedit void rebuildOurDrumMap(); }; diff --git a/muse2/muse/midiedit/dlist.cpp b/muse2/muse/midiedit/dlist.cpp index 350f5e5e..c5379a15 100644 --- a/muse2/muse/midiedit/dlist.cpp +++ b/muse2/muse/midiedit/dlist.cpp @@ -33,6 +33,7 @@ #include "pitchedit.h" #include "midiport.h" #include "drummap.h" +#include "drumedit.h" #include "helper.h" #include "icons.h" #include "dlist.h" @@ -56,13 +57,13 @@ void DList::draw(QPainter& p, const QRect& rect) p.setPen(Qt::black); - for (int i = 0; i < ourDrumMapSize; ++i) { - int yy = i * TH; + for (int instrument = 0; instrument < ourDrumMapSize; ++instrument) { + int yy = instrument * TH; if (yy+TH < y) continue; if (yy > y + h) break; - DrumMap* dm = &ourDrumMap[i]; + DrumMap* dm = &ourDrumMap[instrument]; if (dm == currentlySelected) p.fillRect(x, yy, w, TH, Qt::yellow); // else @@ -71,6 +72,10 @@ void DList::draw(QPainter& p, const QRect& rect) p.save(); p.setWorldMatrixEnabled(false); for (int k = 0; k < h->count(); ++k) { + if (h->isSectionHidden(k)) + continue; + + int x = h->sectionPosition(k); int w = h->sectionSize(k); //QRect r = p.combinedTransform().mapRect(QRect(x+2, yy, w-4, TH)); // Gives inconsistent positions. Source shows wrong operation for our needs. @@ -81,33 +86,72 @@ void DList::draw(QPainter& p, const QRect& rect) //p.save(); //p.setWorldMatrixEnabled(false); switch (k) { - case COL_VOL: + case COL_VOLUME: s.setNum(dm->vol); break; - case COL_QNT: + case COL_QUANT: s.setNum(dm->quant); break; - case COL_LEN: + case COL_NOTELENGTH: s.setNum(dm->len); break; - case COL_ANOTE: + case COL_NOTE: s = MusEUtil::pitch2string(dm->anote); break; - case COL_ENOTE: + case COL_INPUTTRIGGER: s = MusEUtil::pitch2string(dm->enote); break; - case COL_LV1: + case COL_LEVEL1: s.setNum(dm->lv1); break; - case COL_LV2: + case COL_LEVEL2: s.setNum(dm->lv2); break; - case COL_LV3: + case COL_LEVEL3: s.setNum(dm->lv3); break; - case COL_LV4: + case COL_LEVEL4: s.setNum(dm->lv4); break; + case COL_HIDE: + { + bool hidden=false; + bool shown=false; + QSet* group = &dcanvas->get_instrument_map()[instrument].tracks; + int pitch = dcanvas->get_instrument_map()[instrument].pitch; + + for (QSet::iterator track=group->begin(); track!=group->end() && !(hidden&&shown); track++) + if (dynamic_cast(*track)->drummap_hidden()[pitch]) + hidden=true; + else + shown=true; + + if (!hidden && !shown) + printf("THIS SHOULD NEVER HAPPEN: in DList::draw(): instrument %i's track group is empty. strange...\n", instrument); + + const QPixmap* pm = NULL; + + if (shown && !hidden) + pm = eyeIcon; + else if (!shown && hidden) + pm = eyeCrossedIcon; + else if (shown && hidden) + pm = eyeGrayIcon; + else //if (!shown && !hidden) + pm = NULL; + + if (pm) + { + // p.setPen(Qt::red); + p.drawPixmap( + r.x() + r.width()/2 - pm->width()/2, + r.y() + r.height()/2 - pm->height()/2, + *pm); + // p.setPen(Qt::black); + } + + break; + } case COL_MUTE: if (dm->mute) { p.setPen(Qt::red); @@ -123,10 +167,10 @@ void DList::draw(QPainter& p, const QRect& rect) s = dm->name; align = Qt::AlignVCenter | Qt::AlignLeft; break; - case COL_CHANNEL: + case COL_OUTCHANNEL: s.setNum(dm->channel+1); break; - case COL_PORT: + case COL_OUTPORT: s.sprintf("%d:%s", dm->port+1, midiPorts[dm->port].portname().toLatin1().constData()); align = Qt::AlignVCenter | Qt::AlignLeft; break; @@ -243,7 +287,7 @@ void DList::viewMousePressEvent(QMouseEvent* ev) sInstrument = instrument; drag = START_DRAG; - DCols col = DCols(x2col(x)); + DrumColumn col = DrumColumn(x2col(x)); int val; int incVal = 0; @@ -257,7 +301,7 @@ void DList::viewMousePressEvent(QMouseEvent* ev) // In that case, treat it as if a return was pressed if (button == Qt::LeftButton) { - if (((editEntry && editEntry != dm) || col != selectedColumn) && editEntry != 0) { + if (editEntry && (editEntry != dm || col != selectedColumn)) { returnPressed(); } } @@ -265,17 +309,35 @@ void DList::viewMousePressEvent(QMouseEvent* ev) switch (col) { case COL_NONE: break; + case COL_HIDE: + if (button == Qt::LeftButton) + { + bool hidden=true; + QSet* group = &dcanvas->get_instrument_map()[instrument].tracks; + int pitch = dcanvas->get_instrument_map()[instrument].pitch; + + for (QSet::iterator track=group->begin(); track!=group->end(); track++) + if (dynamic_cast(*track)->drummap_hidden()[pitch] == false) + { + hidden=false; + break; + } + + for (QSet::iterator track=group->begin(); track!=group->end(); track++) + dynamic_cast(*track)->drummap_hidden()[pitch] = !hidden; + } + break; case COL_MUTE: if (button == Qt::LeftButton) dm->mute = !dm->mute; break; - case COL_PORT: // this column isn't visible in new style drum mode + case COL_OUTPORT: // this column isn't visible in new style drum mode if ((button == Qt::RightButton) || (button == Qt::LeftButton)) { bool changeAll = ev->modifiers() & Qt::ControlModifier; devicesPopupMenu(dm, mapx(x), mapy(instrument * TH), changeAll); } break; - case COL_VOL: + case COL_VOLUME: val = dm->vol + incVal; if (val < 0) val = 0; @@ -283,11 +345,11 @@ void DList::viewMousePressEvent(QMouseEvent* ev) val = 999; dm->vol = (unsigned char)val; break; - case COL_QNT: + case COL_QUANT: dm->quant += incVal; // ?? range break; - case COL_ENOTE: + case COL_INPUTTRIGGER: val = dm->enote + incVal; if (val < 0) val = 0; @@ -310,13 +372,13 @@ void DList::viewMousePressEvent(QMouseEvent* ev) } dm->enote = val; break; - case COL_LEN: + case COL_NOTELENGTH: val = dm->len + incVal; if (val < 0) val = 0; dm->len = val; break; - case COL_ANOTE: + case COL_NOTE: if (old_style_drummap_mode) //only allow changing in old style mode { val = dm->anote + incVal; @@ -339,7 +401,7 @@ void DList::viewMousePressEvent(QMouseEvent* ev) emit keyPressed(instrument, velocity);//(dm->anote, shift); } break; - case COL_CHANNEL: // this column isn't visible in new style drum mode + case COL_OUTCHANNEL: // this column isn't visible in new style drum mode val = dm->channel + incVal; if (val < 0) val = 0; @@ -370,7 +432,7 @@ void DList::viewMousePressEvent(QMouseEvent* ev) } } break; - case COL_LV1: + case COL_LEVEL1: val = dm->lv1 + incVal; if (val < 0) val = 0; @@ -378,7 +440,7 @@ void DList::viewMousePressEvent(QMouseEvent* ev) val = 127; dm->lv1 = val; break; - case COL_LV2: + case COL_LEVEL2: val = dm->lv2 + incVal; if (val < 0) val = 0; @@ -386,7 +448,7 @@ void DList::viewMousePressEvent(QMouseEvent* ev) val = 127; dm->lv2 = val; break; - case COL_LV3: + case COL_LEVEL3: val = dm->lv3 + incVal; if (val < 0) val = 0; @@ -394,7 +456,7 @@ void DList::viewMousePressEvent(QMouseEvent* ev) val = 127; dm->lv3 = val; break; - case COL_LV4: + case COL_LEVEL4: val = dm->lv4 + incVal; if (val < 0) val = 0; @@ -403,7 +465,48 @@ void DList::viewMousePressEvent(QMouseEvent* ev) dm->lv4 = val; break; case COL_NAME: - emit keyPressed(instrument, 100); //Mapping done on other side, send index + if (button == Qt::LeftButton) + emit keyPressed(instrument, 100); //Mapping done on other side, send index + else if (button == Qt::MidButton) // hide that instrument + { + QSet* group = &dcanvas->get_instrument_map()[instrument].tracks; + int pitch = dcanvas->get_instrument_map()[instrument].pitch; + for (QSet::iterator track=group->begin(); track!=group->end(); track++) + dynamic_cast(*track)->drummap_hidden()[pitch] = true; + } + else if (button == Qt::RightButton) + { + bool hidden=false; + bool shown=false; + QSet* group = &dcanvas->get_instrument_map()[instrument].tracks; + int pitch = dcanvas->get_instrument_map()[instrument].pitch; + + for (QSet::iterator track=group->begin(); track!=group->end() && !(hidden&&shown); track++) + if (dynamic_cast(*track)->drummap_hidden()[pitch]) + hidden=true; + else + shown=true; + + QMenu* popup = new QMenu(NULL /* intendedly not "this" */); + QAction* hideAction = popup->addAction(tr("hide this instrument")); + QAction* showAction = popup->addAction(tr("show this instrument")); + showAction->setToolTip(tr("this turns a grayed out eye into a blue eye")); + + if (!hidden) + showAction->setEnabled(false); + if (!shown) + hideAction->setEnabled(false); + + QAction* result = popup->exec(ev->globalPos()); + if (result==hideAction) + for (QSet::iterator track=group->begin(); track!=group->end(); track++) + dynamic_cast(*track)->drummap_hidden()[pitch] = true; + else if (result==showAction) + for (QSet::iterator track=group->begin(); track!=group->end(); track++) + dynamic_cast(*track)->drummap_hidden()[pitch] = false; + + delete popup; + } break; default: @@ -429,13 +532,13 @@ void DList::viewMouseDoubleClickEvent(QMouseEvent* ev) int section = header->logicalIndexAt(x); - if ((section == COL_NAME || section == COL_VOL || section == COL_LEN || section == COL_LV1 || - section == COL_LV2 || section == COL_LV3 || section == COL_LV4 || section == COL_QNT || - (section == COL_CHANNEL && old_style_drummap_mode) ) && (ev->button() == Qt::LeftButton)) + if ((section == COL_NAME || section == COL_VOLUME || section == COL_NOTELENGTH || section == COL_LEVEL1 || + section == COL_LEVEL2 || section == COL_LEVEL3 || section == COL_LEVEL4 || section == COL_QUANT || + (section == COL_OUTCHANNEL && old_style_drummap_mode) ) && (ev->button() == Qt::LeftButton)) { lineEdit(instrument, section); } - else if (((section == COL_ANOTE && old_style_drummap_mode) || section == COL_ENOTE) && (ev->button() == Qt::LeftButton)) + else if (((section == COL_NOTE && old_style_drummap_mode) || section == COL_INPUTTRIGGER) && (ev->button() == Qt::LeftButton)) pitchEdit(instrument, section); else viewMousePressEvent(ev); @@ -466,37 +569,37 @@ void DList::lineEdit(int line, int section) editor->setText(dm->name); break; - case COL_VOL: { + case COL_VOLUME: { editor->setText(QString::number(dm->vol)); break; } - case COL_LEN: { + case COL_NOTELENGTH: { editor->setText(QString::number(dm->len)); break; } - case COL_LV1: + case COL_LEVEL1: editor->setText(QString::number(dm->lv1)); break; - case COL_LV2: + case COL_LEVEL2: editor->setText(QString::number(dm->lv2)); break; - case COL_LV3: + case COL_LEVEL3: editor->setText(QString::number(dm->lv3)); break; - case COL_LV4: + case COL_LEVEL4: editor->setText(QString::number(dm->lv4)); break; - case COL_QNT: + case COL_QUANT: editor->setText(QString::number(dm->quant)); break; - case COL_CHANNEL: + case COL_OUTCHANNEL: editor->setText(QString::number(dm->channel+1)); break; } @@ -530,11 +633,11 @@ void DList::pitchEdit(int line, int section) int colh = rmapy(TH); selectedColumn = section; //Store selected column to have an idea of which one was selected when return is pressed switch (section) { - case COL_ENOTE: + case COL_INPUTTRIGGER: pitch_editor->setValue(dm->enote); break; - case COL_ANOTE: + case COL_NOTE: pitch_editor->setValue(dm->anote); break; } @@ -608,24 +711,24 @@ void DList::returnPressed() switch (selectedColumn) { - case COL_VOL: + case COL_VOLUME: if (val > 999) //changed from 200 to 999 by flo93 val = 999; if (val < 0) val = 0; break; - case COL_LV1: - case COL_LV2: - case COL_LV3: - case COL_LV4: + case COL_LEVEL1: + case COL_LEVEL2: + case COL_LEVEL3: + case COL_LEVEL4: if (val > 127) //Check bounds for lv1-lv4 values val = 127; if (val < 0) val = 0; break; - case COL_CHANNEL: + case COL_OUTCHANNEL: val--; if (val >= 16) val = 15; @@ -643,35 +746,35 @@ void DList::returnPressed() editEntry->name = editor->text(); break; - case COL_LEN: + case COL_NOTELENGTH: editEntry->len = atoi(editor->text().toAscii().constData()); break; - case COL_VOL: + case COL_VOLUME: editEntry->vol = val; break; - case COL_LV1: + case COL_LEVEL1: editEntry->lv1 = val; break; - case COL_LV2: + case COL_LEVEL2: editEntry->lv2 = val; break; - case COL_LV3: + case COL_LEVEL3: editEntry->lv3 = val; break; - case COL_LV4: + case COL_LEVEL4: editEntry->lv4 = val; break; - case COL_QNT: + case COL_QUANT: editEntry->quant = val; break; - case COL_CHANNEL: + case COL_OUTCHANNEL: editEntry->channel = val; break; @@ -708,7 +811,7 @@ void DList::pitchEdited() DrumMap editEntryOld=*editEntry; switch(selectedColumn) { - case COL_ANOTE: + case COL_NOTE: if (old_style_drummap_mode) //should actually be always true, but to be sure... { if(val != editEntry->anote) @@ -724,7 +827,7 @@ void DList::pitchEdited() printf("ERROR: THIS SHOULD NEVER HAPPEN: pitch edited of anote in new style mode!\n"); break; - case COL_ENOTE: + case COL_INPUTTRIGGER: if (old_style_drummap_mode) { //Check if there is any other drumMap with the same inmap value (there should be one (and only one):-) @@ -798,7 +901,7 @@ DList::DList(QHeaderView* h, QWidget* parent, int ymag, DrumCanvas* dcanvas_, bo ourDrumMap=dcanvas->getOurDrumMap(); ourDrumMapSize=dcanvas->getOurDrumMapSize(); old_style_drummap_mode=oldstyle; - connect(dcanvas, SIGNAL(ourDrumMapChanged()), SLOT(ourDrumMapChanged())); + connect(dcanvas, SIGNAL(ourDrumMapChanged(bool)), SLOT(ourDrumMapChanged(bool))); if (!h){ h = new QHeaderView(Qt::Horizontal, parent);} @@ -884,13 +987,13 @@ void DList::viewMouseReleaseEvent(QMouseEvent* ev) bool shift = ev->modifiers() & Qt::ShiftModifier; unsigned instrument = y / TH; - DCols col = DCols(x2col(x)); + DrumColumn col = DrumColumn(x2col(x)); switch (col) { case COL_NAME: emit keyReleased(instrument, shift); break; - case COL_ANOTE: + case COL_NOTE: emit keyReleased(instrument, shift); break; default: @@ -910,14 +1013,16 @@ int DList::getSelectedInstrument() } -void DList::ourDrumMapChanged() +void DList::ourDrumMapChanged(bool instrMapChanged) { int selIdx = currentlySelected - ourDrumMap; ourDrumMap=dcanvas->getOurDrumMap(); ourDrumMapSize=dcanvas->getOurDrumMapSize(); - editEntry=NULL; + if (instrMapChanged) + editEntry=NULL; + if (selIdx >= ourDrumMapSize) selIdx=ourDrumMapSize-1; currentlySelected = &ourDrumMap[selIdx]; diff --git a/muse2/muse/midiedit/dlist.h b/muse2/muse/midiedit/dlist.h index 1d87f3dc..cc3f3edc 100644 --- a/muse2/muse/midiedit/dlist.h +++ b/muse2/muse/midiedit/dlist.h @@ -131,7 +131,7 @@ class DList : public MusEWidget::View { public slots: void tracklistChanged(); void songChanged(int); - void ourDrumMapChanged(); + void ourDrumMapChanged(bool); public: void lineEdit(int line, int section); @@ -141,9 +141,6 @@ class DList : public MusEWidget::View { ~DList(); int getSelectedInstrument(); -enum DCols { COL_MUTE=0, COL_NAME, COL_VOL, COL_QNT, COL_ENOTE, COL_LEN, - COL_ANOTE, COL_CHANNEL, COL_PORT, - COL_LV1, COL_LV2, COL_LV3, COL_LV4, COL_NONE=-1}; }; #endif // __DLIST_H_ diff --git a/muse2/muse/midiedit/drumedit.cpp b/muse2/muse/midiedit/drumedit.cpp index 92cc765a..c98d0632 100644 --- a/muse2/muse/midiedit/drumedit.cpp +++ b/muse2/muse/midiedit/drumedit.cpp @@ -80,27 +80,12 @@ static const char* map_file_save_pattern[] = { int DrumEdit::_rasterInit = 96; int DrumEdit::_dlistWidthInit = 50; int DrumEdit::_dcanvasWidthInit = 300; +bool DrumEdit::_ignore_hide_init = false; static const int xscale = -10; static const int yscale = 1; static const int drumeditTools = MusEWidget::PointerTool | MusEWidget::PencilTool | MusEWidget::RubberTool | MusEWidget::CursorTool | MusEWidget::DrawTool; -enum DrumColumn { - COL_MUTE = 0, - COL_NAME, - COL_VOLUME, - COL_QUANT, - COL_INPUTTRIGGER, - COL_NOTELENGTH, - COL_NOTE, - COL_OUTCHANNEL, - COL_OUTPORT, - COL_LEVEL1, - COL_LEVEL2, - COL_LEVEL3, - COL_LEVEL4, - COL_NONE = -1 -}; //--------------------------------------------------------- // setHeaderWhatsThis @@ -108,6 +93,7 @@ enum DrumColumn { void DrumEdit::setHeaderWhatsThis() { + header->setWhatsThis(COL_HIDE, tr("hide instrument")); header->setWhatsThis(COL_MUTE, tr("mute instrument")); header->setWhatsThis(COL_NAME, tr("sound name")); header->setWhatsThis(COL_VOLUME, tr("volume percent")); @@ -129,6 +115,7 @@ void DrumEdit::setHeaderWhatsThis() void DrumEdit::setHeaderToolTips() { + header->setToolTip(COL_HIDE, tr("hide instrument")); header->setToolTip(COL_MUTE, tr("mute instrument")); header->setToolTip(COL_NAME, tr("sound name")); header->setToolTip(COL_VOLUME, tr("volume percent")); @@ -178,6 +165,7 @@ DrumEdit::DrumEdit(PartList* pl, QWidget* parent, const char* name, unsigned ini QSignalMapper *signalMapper = new QSignalMapper(this); _group_mode = GROUP_SAME_CHANNEL; + _ignore_hide = _ignore_hide_init; //---------Pulldown Menu---------------------------- menuFile = menuBar()->addMenu(tr("&File")); @@ -299,15 +287,19 @@ DrumEdit::DrumEdit(PartList* pl, QWidget* parent, const char* name, unsigned ini groupNoneAction = menuGrouping->addAction(tr("Don't group")); groupChanAction = menuGrouping->addAction(tr("Group by channel")); groupMaxAction = menuGrouping->addAction(tr("Group maximally")); + QAction* ignoreHideAction = settingsMenu->addAction(tr("Also show hidden events")); settingsMenu->addSeparator(); groupNoneAction->setCheckable(true); groupChanAction->setCheckable(true); groupMaxAction ->setCheckable(true); + ignoreHideAction->setCheckable(true); + ignoreHideAction->setChecked(_ignore_hide); connect(groupNoneAction, SIGNAL(triggered()), signalMapper, SLOT(map())); connect(groupChanAction, SIGNAL(triggered()), signalMapper, SLOT(map())); connect(groupMaxAction, SIGNAL(triggered()), signalMapper, SLOT(map())); + connect(ignoreHideAction, SIGNAL(toggled(bool)), SLOT(set_ignore_hide(bool))); signalMapper->setMapping(groupNoneAction, DrumCanvas::CMD_GROUP_NONE); signalMapper->setMapping(groupChanAction, DrumCanvas::CMD_GROUP_CHAN); @@ -450,7 +442,7 @@ DrumEdit::DrumEdit(PartList* pl, QWidget* parent, const char* name, unsigned ini connect(canvas, SIGNAL(toolChanged(int)), tools2, SLOT(set(int))); connect(canvas, SIGNAL(horizontalZoomIn()), SLOT(horizontalZoomIn())); connect(canvas, SIGNAL(horizontalZoomOut()), SLOT(horizontalZoomOut())); - connect(canvas, SIGNAL(ourDrumMapChanged()), SLOT(ourDrumMapChanged())); + connect(canvas, SIGNAL(ourDrumMapChanged(bool)), SLOT(ourDrumMapChanged(bool))); time->setOrigin(offset, 0); QList mops; @@ -474,6 +466,7 @@ DrumEdit::DrumEdit(PartList* pl, QWidget* parent, const char* name, unsigned ini // header = new MusEWidget::Header(split1w1, "header"); header->setFixedHeight(31); + header->setColumnLabel(tr("H"), COL_HIDE, 20); header->setColumnLabel(tr("M"), COL_MUTE, 20); header->setColumnLabel(tr("Sound"), COL_NAME, 120); header->setColumnLabel(tr("Vol"), COL_VOLUME); @@ -496,6 +489,11 @@ DrumEdit::DrumEdit(PartList* pl, QWidget* parent, const char* name, unsigned ini header->hideSection(COL_OUTPORT); header->hideSection(COL_OUTCHANNEL); } + + if (!old_style_drummap_mode() && _ignore_hide) + header->showSection(COL_HIDE); + else + header->hideSection(COL_HIDE); dlist = new DList(header, split1w1, yscale, (DrumCanvas*)canvas, old_style_drummap_mode()); // p3.3.44 @@ -749,6 +747,7 @@ void DrumEdit::writeStatus(int level, Xml& xml) const xml.intTag(level, "xmag", hscroll->mag()); xml.intTag(level, "ypos", vscroll->pos()); xml.intTag(level, "ymag", vscroll->mag()); + xml.intTag(level, "ignore_hide", _ignore_hide); xml.tag(level, "/drumedit"); } @@ -796,6 +795,8 @@ void DrumEdit::readStatus(Xml& xml) vscroll->setMag(xml.parseInt()); else if (tag == "ypos") vscroll->setPos(xml.parseInt()); + else if (tag == "ignore_hide") + _ignore_hide=xml.parseInt(); else xml.unknown("DrumEdit"); break; @@ -832,6 +833,8 @@ void DrumEdit::readConfiguration(Xml& xml) _dcanvasWidthInit = xml.parseInt(); else if (tag == "dlistwidth") _dlistWidthInit = xml.parseInt(); + else if (tag == "ignore_hide_init") + _ignore_hide_init = xml.parseInt(); else if (tag == "topwin") TopWin::readConfiguration(DRUM, xml); else @@ -857,6 +860,7 @@ void DrumEdit::writeConfiguration(int level, Xml& xml) xml.intTag(level, "raster", _rasterInit); xml.intTag(level, "dlistwidth", _dlistWidthInit); xml.intTag(level, "dcanvaswidth", _dcanvasWidthInit); + xml.intTag(level, "ignore_hide_init", _ignore_hide_init); TopWin::writeConfiguration(DRUM, level,xml); xml.tag(level, "/drumedit"); } @@ -1177,7 +1181,7 @@ void DrumEdit::keyPressEvent(QKeyEvent* event) return; } else if (key == Qt::Key_F2) { - dlist->lineEdit(dlist->getSelectedInstrument(),(int)DList::COL_NAME); + dlist->lineEdit(dlist->getSelectedInstrument(),(int)COL_NAME); return; } else if (key == shortcuts[SHRT_INSTRUMENT_STEP_UP].key) { @@ -1383,11 +1387,14 @@ bool DrumEdit::old_style_drummap_mode() return false; } -void DrumEdit::ourDrumMapChanged() +void DrumEdit::ourDrumMapChanged(bool instrMapChanged) { - int vmin,vmax; - vscroll->range(&vmin, &vmax); - vscroll->setRange(vmin, dynamic_cast(canvas)->getOurDrumMapSize()*TH); + if (instrMapChanged) + { + int vmin,vmax; + vscroll->range(&vmin, &vmax); + vscroll->setRange(vmin, dynamic_cast(canvas)->getOurDrumMapSize()*TH); + } } void DrumEdit::updateGroupingActions() @@ -1402,3 +1409,18 @@ void DrumEdit::updateGroupingActions() groupChanAction->setChecked(_group_mode==GROUP_SAME_CHANNEL); groupMaxAction ->setChecked(_group_mode==GROUP_MAX); } + +void DrumEdit::set_ignore_hide(bool val) +{ + _ignore_hide=val; + _ignore_hide_init=val; + // this may only called be from the action's toggled signal. + // if called otherwise, the action's checked state isn't updated! + + if (!old_style_drummap_mode() && _ignore_hide) + header->showSection(COL_HIDE); + else + header->hideSection(COL_HIDE); + + ((DrumCanvas*)(canvas))->rebuildOurDrumMap(); +} diff --git a/muse2/muse/midiedit/drumedit.h b/muse2/muse/midiedit/drumedit.h index 743d6151..4b0a39b8 100644 --- a/muse2/muse/midiedit/drumedit.h +++ b/muse2/muse/midiedit/drumedit.h @@ -61,6 +61,24 @@ class Splitter; class Toolbar1; } +enum DrumColumn { + COL_HIDE = 0, + COL_MUTE, + COL_NAME, + COL_VOLUME, + COL_QUANT, + COL_INPUTTRIGGER, + COL_NOTELENGTH, + COL_NOTE, + COL_OUTCHANNEL, + COL_OUTPORT, + COL_LEVEL1, + COL_LEVEL2, + COL_LEVEL3, + COL_LEVEL4, + COL_NONE = -1 +}; + //--------------------------------------------------------- // DrumEdit //--------------------------------------------------------- @@ -73,6 +91,7 @@ class DrumEdit : public MidiEditor { private: group_mode_t _group_mode; + bool _ignore_hide; Event selEvent; MidiPart* selPart; @@ -95,6 +114,7 @@ class DrumEdit : public MidiEditor { static int _rasterInit; static int _dlistWidthInit, _dcanvasWidthInit; + static bool _ignore_hide_init; QAction *loadAction, *saveAction, *resetAction; QAction *cutAction, *copyAction, *copyRangeAction, *pasteAction, *pasteDialogAction, *deleteAction; @@ -130,6 +150,7 @@ class DrumEdit : public MidiEditor { void songChanged1(int); void setStep(QString); void updateGroupingActions(); + void set_ignore_hide(bool); public slots: void setSelection(int, Event&, Part*); @@ -137,7 +158,7 @@ class DrumEdit : public MidiEditor { void execDeliveredScript(int); void execUserScript(int); CtrlEdit* addCtrl(); - void ourDrumMapChanged(); + void ourDrumMapChanged(bool); virtual void updateHScrollRange(); signals: @@ -153,6 +174,7 @@ class DrumEdit : public MidiEditor { bool old_style_drummap_mode(); group_mode_t group_mode() { return _group_mode; } + bool ignore_hide() { return _ignore_hide; } }; #endif diff --git a/muse2/muse/midiedit/scoreedit.cpp b/muse2/muse/midiedit/scoreedit.cpp index 64258f60..e82ab7ad 100644 --- a/muse2/muse/midiedit/scoreedit.cpp +++ b/muse2/muse/midiedit/scoreedit.cpp @@ -4591,11 +4591,11 @@ void ScoreCanvas::add_new_parts(const std::map< Part*, std::set >& param) * from clipboard failed. ignoring this one... ) [ not reproducible ] * * CURRENT TODO - * ! o fix sigedit boxes (see also "important todo") * o fix valgrind problems - * + * * > o drum editor: channel-stuff - * o dialog for maintaining drum lists, hide etc + * o clearly state in the changelog: when having multiple drumeditors open, + * the mute-column may not work, because another editor is overriding this. * o respect "_drummap_tied_to_patch": IMPLEMENT * o save hide, ordering, track's drumlists * o "copy drumlist" from one track to another @@ -4615,7 +4615,6 @@ void ScoreCanvas::add_new_parts(const std::map< Part*, std::set >& param) * 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") * o add "dotted quarter" quantize option (for 6/8 beat) * o ticks-to-quarter spinboxes * o newly created windows have to be focussed! diff --git a/muse2/muse/song.cpp b/muse2/muse/song.cpp index a994b0e6..db2bcad5 100644 --- a/muse2/muse/song.cpp +++ b/muse2/muse/song.cpp @@ -1468,11 +1468,13 @@ void Song::rewindStart() // update //--------------------------------------------------------- -void Song::update(int flags) +void Song::update(int flags, bool allowRecursion) { static int level = 0; // DEBUG - if (level) { - printf("Song::update %08x, level %d\n", flags, level); + if (level && !allowRecursion) { + printf("THIS SHOULD NEVER HAPPEN: unallowed recursion in Song::update(%08x), level %d!\n" + " the songChanged() signal is NOT emitted. this will\n" + " probably cause windows being not up-to-date.\n", flags, level); return; } ++level; diff --git a/muse2/muse/song.h b/muse2/muse/song.h index 79e5521f..ad77d723 100644 --- a/muse2/muse/song.h +++ b/muse2/muse/song.h @@ -379,7 +379,9 @@ class Song : public QObject { public slots: void seekTo(int tick); - void update(int flags = -1); + void update(int flags = -1, bool allowRecursion=false); // use allowRecursion with care! this + // could lock up muse if you aren't sure + // that your recursion will be finite! void beat(); void undo(); diff --git a/muse2/xpm/eye.xpm b/muse2/xpm/eye.xpm new file mode 100644 index 00000000..74e5bcc1 --- /dev/null +++ b/muse2/xpm/eye.xpm @@ -0,0 +1,22 @@ +/* XPM */ +static const char * eye_xpm[] = { +"16 16 3 1", +" c None", +". c #000000", +"+ c #0000FD", +" ", +" ", +" ", +" .... ", +" ........ ", +" ... ... ", +" ... ++++ ... ", +"... ++++++ ...", +".. ++++++ ..", +"... ++++++ ...", +" ... ++++ ... ", +" ... ... ", +" ........ ", +" .... ", +" ", +" "}; diff --git a/muse2/xpm/eye_crossed.xpm b/muse2/xpm/eye_crossed.xpm new file mode 100644 index 00000000..65dca19c --- /dev/null +++ b/muse2/xpm/eye_crossed.xpm @@ -0,0 +1,23 @@ +/* XPM */ +static const char * eye_crossed_xpm[] = { +"16 16 4 1", +" c None", +". c #E10E08", +"+ c #000000", +"@ c #0000FD", +" ", +" .. ", +" ....", +" ++++ .... ", +" ++++++.... ", +" +++ ....+ ", +" +++ @@....+++ ", +"+++ @@.... +++", +"++ @....@ ++", +"+++ ....@@ +++", +" +++....@@ +++ ", +" +.... +++ ", +" ....++++++ ", +" .... ++++ ", +" .. ", +" "}; diff --git a/muse2/xpm/eye_gray.xpm b/muse2/xpm/eye_gray.xpm new file mode 100644 index 00000000..8d5a7d9d --- /dev/null +++ b/muse2/xpm/eye_gray.xpm @@ -0,0 +1,22 @@ +/* XPM */ +static const char * eye_gray_xpm[] = { +"16 16 3 1", +" c None", +". c #292929", +"+ c #535353", +" ", +" ", +" ", +" .... ", +" ........ ", +" ... ... ", +" ... ++++ ... ", +"... ++++++ ...", +".. ++++++ ..", +"... ++++++ ...", +" ... ++++ ... ", +" ... ... ", +" ........ ", +" .... ", +" ", +" "}; -- cgit v1.2.3 From 3e6f82d7b9b29e8df7d63658540b762203b820f6 Mon Sep 17 00:00:00 2001 From: Florian Jung Date: Fri, 7 Oct 2011 14:53:22 +0000 Subject: added new style drum tracks atm, they aren't different from midi tracks except that they launch a drum editor by default added markers to help me finding the places to change TODO: instrument muting, in-note-mapping etc... --- muse2/muse/app.cpp | 1 + muse2/muse/appearance.cpp | 5 ++--- muse2/muse/arranger/arrangerview.cpp | 12 +++++++----- muse2/muse/arranger/arrangerview.h | 2 +- muse2/muse/arranger/pcanvas.cpp | 6 +++++- muse2/muse/arranger/tlist.cpp | 25 +++++++++++++++++++------ muse2/muse/conf.cpp | 10 +++++++++- muse2/muse/ctrl/ctrlcanvas.cpp | 6 +++--- muse2/muse/ctrl/ctrlpanel.cpp | 6 +++--- muse2/muse/gconfig.cpp | 6 ++++-- muse2/muse/gconfig.h | 3 +++ muse2/muse/helper.cpp | 18 ++++++++++++++++++ muse2/muse/importmidi.cpp | 4 ++-- muse2/muse/liste/editevent.cpp | 6 +++--- muse2/muse/midi.cpp | 18 +++++++++--------- muse2/muse/midiedit/scoreedit.cpp | 8 ++++++++ muse2/muse/mixer/amixer.cpp | 17 +++++++++++++++-- muse2/muse/mixer/amixer.h | 2 ++ muse2/muse/mixer/strip.cpp | 4 ++++ muse2/muse/part.cpp | 11 +++++++---- muse2/muse/remote/pyapi.cpp | 6 ++++-- muse2/muse/shortcuts.cpp | 1 + muse2/muse/shortcuts.h | 1 + muse2/muse/song.cpp | 23 ++++++++++++++++------- muse2/muse/songfile.cpp | 8 +++++++- muse2/muse/track.cpp | 25 ++++++++++++++++--------- muse2/muse/track.h | 4 ++-- muse2/muse/widgets/mtrackinfo.cpp | 23 ++++++++++++++--------- muse2/muse/widgets/musewidgetsplug.cpp | 6 ++++-- 29 files changed, 190 insertions(+), 77 deletions(-) (limited to 'muse2') diff --git a/muse2/muse/app.cpp b/muse2/muse/app.cpp index fd024d57..c56376fe 100644 --- a/muse2/muse/app.cpp +++ b/muse2/muse/app.cpp @@ -1792,6 +1792,7 @@ void MusE::startEditor(Track* t) switch (t->type()) { case Track::MIDI: startPianoroll(); break; case Track::DRUM: startDrumEditor(); break; + case Track::NEW_DRUM: startDrumEditor(); break; case Track::WAVE: startWaveEditor(); break; default: break; diff --git a/muse2/muse/appearance.cpp b/muse2/muse/appearance.cpp index b3e89aa1..a702965c 100644 --- a/muse2/muse/appearance.cpp +++ b/muse2/muse/appearance.cpp @@ -1,5 +1,4 @@ //========================================================= -//========================================================= // MusE // Linux Music Editor // $Id: appearance.cpp,v 1.11.2.5 2009/11/14 03:37:48 terminator356 Exp $ @@ -841,7 +840,7 @@ void Appearance::colorItemSelectionChanged() case 0x300: color = &config->waveEditBackgroundColor; break; case 0x411: color = &config->trackBg; break; case 0x412: color = &config->midiTrackBg; break; - case 0x413: color = &config->drumTrackBg; break; + case 0x413: color = &config->drumTrackBg; break; //FINDMICHJETZT add newDrum... case 0x414: color = &config->waveTrackBg; break; case 0x415: color = &config->outputTrackBg; break; case 0x416: color = &config->inputTrackBg; break; @@ -855,7 +854,7 @@ void Appearance::colorItemSelectionChanged() case 0x500: color = &config->mixerBg; break; case 0x501: color = &config->midiTrackLabelBg; break; - case 0x502: color = &config->drumTrackLabelBg; break; + case 0x502: color = &config->drumTrackLabelBg; break; //FINDMICHJETZT add newDrum... case 0x503: color = &config->waveTrackLabelBg; break; case 0x504: color = &config->outputTrackLabelBg; break; case 0x505: color = &config->inputTrackLabelBg; break; diff --git a/muse2/muse/arranger/arrangerview.cpp b/muse2/muse/arranger/arrangerview.cpp index 96ce4c09..d828feeb 100644 --- a/muse2/muse/arranger/arrangerview.cpp +++ b/muse2/muse/arranger/arrangerview.cpp @@ -634,11 +634,12 @@ void ArrangerView::populateAddTrack() trackMidiAction = grp->actions()[0]; trackDrumAction = grp->actions()[1]; - trackWaveAction = grp->actions()[2]; - trackAOutputAction = grp->actions()[3]; - trackAGroupAction = grp->actions()[4]; - trackAInputAction = grp->actions()[5]; - trackAAuxAction = grp->actions()[6]; + trackNewStyleDrumAction = grp->actions()[2]; + trackWaveAction = grp->actions()[3]; + trackAOutputAction = grp->actions()[4]; + trackAGroupAction = grp->actions()[5]; + trackAInputAction = grp->actions()[6]; + trackAAuxAction = grp->actions()[7]; } void ArrangerView::addNewTrack(QAction* action) @@ -662,6 +663,7 @@ void ArrangerView::updateShortcuts() trackMidiAction->setShortcut(shortcuts[SHRT_ADD_MIDI_TRACK].key); trackDrumAction->setShortcut(shortcuts[SHRT_ADD_DRUM_TRACK].key); + trackNewStyleDrumAction->setShortcut(shortcuts[SHRT_ADD_NEW_STYLE_DRUM_TRACK].key); trackWaveAction->setShortcut(shortcuts[SHRT_ADD_WAVE_TRACK].key); trackAOutputAction->setShortcut(shortcuts[SHRT_ADD_AUDIO_OUTPUT].key); trackAGroupAction->setShortcut(shortcuts[SHRT_ADD_AUDIO_GROUP].key); diff --git a/muse2/muse/arranger/arrangerview.h b/muse2/muse/arranger/arrangerview.h index 20655840..7c273ad8 100644 --- a/muse2/muse/arranger/arrangerview.h +++ b/muse2/muse/arranger/arrangerview.h @@ -88,7 +88,7 @@ class ArrangerView : public TopWin QMenu* master; QAction *strGlobalCutAction, *strGlobalInsertAction, *strGlobalSplitAction; - QAction *trackMidiAction, *trackDrumAction, *trackWaveAction, *trackAOutputAction, *trackAGroupAction; + QAction *trackMidiAction, *trackDrumAction, *trackNewStyleDrumAction, *trackWaveAction, *trackAOutputAction, *trackAGroupAction; QAction *trackAInputAction, *trackAAuxAction; QAction *editCutAction, *editCopyAction, *editCopyRangeAction; QAction *editPasteAction, *editPasteCloneAction, *editPasteDialogAction, *editPasteCloneDialogAction; diff --git a/muse2/muse/arranger/pcanvas.cpp b/muse2/muse/arranger/pcanvas.cpp index 5b5f3a6f..eaeec291 100644 --- a/muse2/muse/arranger/pcanvas.cpp +++ b/muse2/muse/arranger/pcanvas.cpp @@ -238,6 +238,7 @@ void PartCanvas::viewMouseDoubleClickEvent(QMouseEvent* event) switch(track->type()) { case Track::MIDI: case Track::DRUM: + case Track::NEW_DRUM: { MidiPart* part = new MidiPart((MidiTrack*)track); part->setTick(pos[1]); @@ -521,6 +522,7 @@ MusEWidget::CItem* PartCanvas::newItem(const QPoint& pos, int) switch(track->type()) { case Track::MIDI: case Track::DRUM: + case Track::NEW_DRUM: pa = new MidiPart((MidiTrack*)track); pa->setTick(x); pa->setLenTick(0); @@ -659,6 +661,7 @@ QMenu* PartCanvas::genItemPopup(MusEWidget::CItem* item) act_mexport->setData(16); } break; + case Track::NEW_DRUM: case Track::DRUM: { partPopup->addAction(MusEGlobal::muse->arranger()->parentWin->startDrumEditAction); partPopup->addAction(MusEGlobal::muse->arranger()->parentWin->startListEditAction); @@ -1259,6 +1262,7 @@ void PartCanvas::keyPress(QKeyEvent* event) // else track is midi switch (track->type()) { + case Track::NEW_DRUM: case Track::DRUM: type = 3; break; @@ -2302,7 +2306,7 @@ void PartCanvas::drawMidiPart(QPainter& p, const QRect&, EventList* events, Midi using std::pair; iEvent ito(events->lower_bound(to)); - bool isdrum = (mt->type() == Track::DRUM); + bool isdrum = (mt->type() == Track::DRUM || mt->type() == Track::NEW_DRUM); // draw controllers ------------------------------------------ p.setPen(QColor(192,192,color_brightness/2)); diff --git a/muse2/muse/arranger/tlist.cpp b/muse2/muse/arranger/tlist.cpp index 68f6dceb..c4a2094a 100644 --- a/muse2/muse/arranger/tlist.cpp +++ b/muse2/muse/arranger/tlist.cpp @@ -226,6 +226,9 @@ void TList::paint(const QRect& r) case Track::DRUM: bg = MusEConfig::config.drumTrackBg; break; + case Track::NEW_DRUM: + bg = MusEConfig::config.newDrumTrackBg; + break; case Track::WAVE: bg = MusEConfig::config.waveTrackBg; break; @@ -281,6 +284,7 @@ void TList::paint(const QRect& r) case Track::MIDI: pm = addtrack_addmiditrackIcon; break; + case Track::NEW_DRUM: case Track::DRUM: pm = addtrack_drumtrackIcon; break; @@ -585,6 +589,7 @@ void TList::portsPopupMenu(Track* t, int x, int y) switch(t->type()) { case Track::MIDI: case Track::DRUM: + case Track::NEW_DRUM: case Track::AUDIO_SOFTSYNTH: { MidiTrack* track = (MidiTrack*)t; @@ -739,7 +744,7 @@ void TList::oportPropertyPopupMenu(Track* t, int x, int y) } - if (t->type() != Track::MIDI && t->type() != Track::DRUM) + if (t->type() != Track::MIDI && t->type() != Track::DRUM && t->type() != Track::NEW_DRUM) return; int oPort = ((MidiTrack*)t)->outPort(); MidiPort* port = &midiPorts[oPort]; @@ -923,7 +928,8 @@ TrackList TList::getRecEnabledTracks() void TList::changeAutomation(QAction* act) { //printf("changeAutomation %d\n", act->data().toInt()); - if (editAutomation->type() == Track::MIDI) { + if (editAutomation->type() == Track::MIDI) { //FINDMICHJETZT is this correct? or should we also + //consider DRUM and NEW_DRUM? svn blame could help printf("this is wrong, we can't edit automation for midi tracks from arranger yet!\n"); return; } @@ -949,7 +955,7 @@ void TList::changeAutomation(QAction* act) //--------------------------------------------------------- void TList::changeAutomationColor(QAction* act) { - if (editAutomation->type() == Track::MIDI) { + if (editAutomation->type() == Track::MIDI) { //FINDMICHJETZT is this correct? see above printf("this is wrong, we can't edit automation for midi tracks from arranger yet!\n"); return; } @@ -1707,13 +1713,14 @@ void TList::classesPopupMenu(Track* t, int x, int y) p.clear(); p.addAction(QIcon(*addtrack_addmiditrackIcon), tr("Midi"))->setData(Track::MIDI); p.addAction(QIcon(*addtrack_drumtrackIcon), tr("Drum"))->setData(Track::DRUM); + p.addAction(QIcon(*addtrack_drumtrackIcon), tr("New style drum"))->setData(Track::NEW_DRUM); QAction* act = p.exec(mapToGlobal(QPoint(x, y)), 0); if (!act) return; int n = act->data().toInt(); - if (Track::TrackType(n) == Track::MIDI && t->type() == Track::DRUM) { + if ((Track::TrackType(n) == Track::MIDI || Track::TrackType(n) == Track::NEW_DRUM) && t->type() == Track::DRUM) { //FINDMICHJETZT passt das? // // Drum -> Midi // @@ -1747,11 +1754,11 @@ void TList::classesPopupMenu(Track* t, int x, int y) } } - t->setType(Track::MIDI); + t->setType(Track::TrackType(n)); audio->msgIdle(false); song->update(SC_EVENT_MODIFIED); } - else if (Track::TrackType(n) == Track::DRUM && t->type() == Track::MIDI) { + else if (Track::TrackType(n) == Track::DRUM && (t->type() == Track::MIDI || t->type() == Track::NEW_DRUM)) { //FINDMICHJETZT passt das? // // Midi -> Drum // @@ -1809,6 +1816,12 @@ void TList::classesPopupMenu(Track* t, int x, int y) audio->msgIdle(false); song->update(SC_EVENT_MODIFIED); } + else // MIDI -> NEW_DRUM or vice versa. added by flo. FINDMICHJETZT does this work properly? + { + Track* t2 = t->clone(false); + t->setType(Track::TrackType(n)); + audio->msgChangeTrack(t2, t, true); + } } } // namespace MusEArranger diff --git a/muse2/muse/conf.cpp b/muse2/muse/conf.cpp index 35b96591..e1d141e7 100644 --- a/muse2/muse/conf.cpp +++ b/muse2/muse/conf.cpp @@ -786,6 +786,8 @@ void readConfiguration(Xml& xml, bool readOnlySequencer, bool doReadGlobalConfig MusEConfig::config.midiTrackLabelBg = readColor(xml); else if (tag == "drumTrackLabelBg") MusEConfig::config.drumTrackLabelBg = readColor(xml); + else if (tag == "newDrumTrackLabelBg") + MusEConfig::config.newDrumTrackLabelBg = readColor(xml); else if (tag == "waveTrackLabelBg") MusEConfig::config.waveTrackLabelBg = readColor(xml); else if (tag == "outputTrackLabelBg") @@ -805,6 +807,8 @@ void readConfiguration(Xml& xml, bool readOnlySequencer, bool doReadGlobalConfig MusEConfig::config.ctrlGraphFg = readColor(xml); else if (tag == "drumTrackBg") MusEConfig::config.drumTrackBg = readColor(xml); + else if (tag == "newDrumTrackBg") + MusEConfig::config.newDrumTrackBg = readColor(xml); else if (tag == "waveTrackBg") MusEConfig::config.waveTrackBg = readColor(xml); else if (tag == "outputTrackBg") @@ -1317,6 +1321,7 @@ void MusE::writeGlobalConfiguration(int level, Xml& xml) const xml.colorTag(level, "mixerBg", MusEConfig::config.mixerBg); xml.colorTag(level, "midiTrackLabelBg", MusEConfig::config.midiTrackLabelBg); xml.colorTag(level, "drumTrackLabelBg", MusEConfig::config.drumTrackLabelBg); + xml.colorTag(level, "newDrumTrackLabelBg", MusEConfig::config.newDrumTrackLabelBg); xml.colorTag(level, "waveTrackLabelBg", MusEConfig::config.waveTrackLabelBg); xml.colorTag(level, "outputTrackLabelBg", MusEConfig::config.outputTrackLabelBg); xml.colorTag(level, "inputTrackLabelBg", MusEConfig::config.inputTrackLabelBg); @@ -1326,7 +1331,7 @@ void MusE::writeGlobalConfiguration(int level, Xml& xml) const xml.colorTag(level, "midiTrackBg", MusEConfig::config.midiTrackBg); xml.colorTag(level, "ctrlGraphFg", MusEConfig::config.ctrlGraphFg); - xml.colorTag(level, "drumTrackBg", MusEConfig::config.drumTrackBg); + xml.colorTag(level, "newDrumTrackBg", MusEConfig::config.newDrumTrackBg); xml.colorTag(level, "waveTrackBg", MusEConfig::config.waveTrackBg); xml.colorTag(level, "outputTrackBg", MusEConfig::config.outputTrackBg); xml.colorTag(level, "inputTrackBg", MusEConfig::config.inputTrackBg); @@ -1655,6 +1660,7 @@ void MixerConfig::write(int level, Xml& xml) xml.intTag(level, "showMidiTracks", showMidiTracks); xml.intTag(level, "showDrumTracks", showDrumTracks); + xml.intTag(level, "showNewDrumTracks", showNewDrumTracks); xml.intTag(level, "showInputTracks", showInputTracks); xml.intTag(level, "showOutputTracks", showOutputTracks); xml.intTag(level, "showWaveTracks", showWaveTracks); @@ -1692,6 +1698,8 @@ void MixerConfig::read(Xml& xml) showMidiTracks = xml.parseInt(); else if (tag == "showDrumTracks") showDrumTracks = xml.parseInt(); + else if (tag == "showNewDrumTracks") + showNewDrumTracks = xml.parseInt(); else if (tag == "showInputTracks") showInputTracks = xml.parseInt(); else if (tag == "showOutputTracks") diff --git a/muse2/muse/ctrl/ctrlcanvas.cpp b/muse2/muse/ctrl/ctrlcanvas.cpp index 7c77a836..fb4816f9 100644 --- a/muse2/muse/ctrl/ctrlcanvas.cpp +++ b/muse2/muse/ctrl/ctrlcanvas.cpp @@ -535,10 +535,10 @@ void CtrlCanvas::partControllers(const MidiPart* part, int num, int* dnum, int* int di; int n; - if((mt->type() != Track::DRUM) && curDrumInstrument != -1) + if((mt->type() != Track::DRUM) && curDrumInstrument != -1) //FINDMICHJETZT was ist das? printf("keyfilter != -1 in non drum track?\n"); - if((mt->type() == Track::DRUM) && (curDrumInstrument != -1) && ((num & 0xff) == 0xff)) + if((mt->type() == Track::DRUM) && (curDrumInstrument != -1) && ((num & 0xff) == 0xff)) //FINDMICHJETZT was ist das? { di = (num & ~0xff) | curDrumInstrument; n = (num & ~0xff) | drumMap[curDrumInstrument].anote; // construct real controller number @@ -1688,7 +1688,7 @@ void CtrlCanvas::pdrawItems(QPainter& p, const QRect& rect, const MidiPart* part MidiTrack* mt = part->track(); MidiPort* mp; - if((mt->type() == Track::DRUM) && (curDrumInstrument != -1) && ((_cnum & 0xff) == 0xff)) + if((mt->type() == Track::DRUM) && (curDrumInstrument != -1) && ((_cnum & 0xff) == 0xff)) //FINDMICHJETZT was ist das? mp = &midiPorts[drumMap[curDrumInstrument].port]; else mp = &midiPorts[mt->outPort()]; diff --git a/muse2/muse/ctrl/ctrlpanel.cpp b/muse2/muse/ctrl/ctrlpanel.cpp index cb18afad..ef2196fa 100644 --- a/muse2/muse/ctrl/ctrlpanel.cpp +++ b/muse2/muse/ctrl/ctrlpanel.cpp @@ -169,7 +169,7 @@ void CtrlPanel::heartBeat() int outport; int chan; int cdi = editor->curDrumInstrument(); - if(_track->type() == Track::DRUM && ((_ctrl->num() & 0xff) == 0xff) && cdi != -1) + if(_track->type() == Track::DRUM && ((_ctrl->num() & 0xff) == 0xff) && cdi != -1) //FINDMICHJETZT was ist das? und ähnliche dinger { outport = drumMap[cdi].port; chan = drumMap[cdi].channel; @@ -560,7 +560,7 @@ void CtrlPanel::ctrlPopup() int channel = track->outChannel(); MidiPort* port = &midiPorts[track->outPort()]; int curDrumInstrument = editor->curDrumInstrument(); - bool isDrum = track->type() == Track::DRUM; + bool isDrum = track->type() == Track::DRUM; //FINDMICHJETZT ist das wichtig? QMenu* pop = new QMenu; //pop->clear(); @@ -718,7 +718,7 @@ void CtrlPanel::ctrlPopup() int channel = track->outChannel(); MidiPort* port = &midiPorts[track->outPort()]; int curDrumInstrument = editor->curDrumInstrument(); - bool isDrum = track->type() == Track::DRUM; + bool isDrum = track->type() == Track::DRUM; //FINDMICHJETZT ist das wichtig? MidiInstrument* instr = port->instrument(); MidiControllerList* mcl = instr->controller(); diff --git a/muse2/muse/gconfig.cpp b/muse2/muse/gconfig.cpp index 0a521c3a..f8334b1e 100644 --- a/muse2/muse/gconfig.cpp +++ b/muse2/muse/gconfig.cpp @@ -103,6 +103,7 @@ GlobalConfigValues config = { QColor(74, 150, 194), // midiTrackLabelBg; // Med blue QColor(74, 150, 194), // drumTrackLabelBg; // Med blue + QColor(74, 150, 194), // newDrumTrackLabelBg; // Med blue QColor(213, 128, 202), // waveTrackLabelBg; // magenta QColor(84, 185, 58), // outputTrackLabelBg; // green QColor(199, 75, 64), // inputTrackLabelBg; // red @@ -112,6 +113,7 @@ GlobalConfigValues config = { QColor(215, 220, 230), // midiTrackBg; QColor(215, 220, 230), // drumTrackBg; + QColor(215, 220, 230), // newDrumTrackBg; QColor(220, 209, 217), // waveTrackBg; QColor(197, 220, 206), // outputTrackBg; QColor(220, 214, 206), // inputTrackBg; @@ -149,13 +151,13 @@ GlobalConfigValues config = { QString("Mixer A"), QRect(0, 0, 300, 500), // Mixer1 true, true, true, true, - true, true, true, true + true, true, true, true, true }, { QString("Mixer B"), QRect(200, 200, 300, 500), // Mixer2 true, true, true, true, - true, true, true, true + true, true, true, true, true }, true, // TransportVisible; false, // BigTimeVisible; diff --git a/muse2/muse/gconfig.h b/muse2/muse/gconfig.h index dd5f10fd..0d173b26 100644 --- a/muse2/muse/gconfig.h +++ b/muse2/muse/gconfig.h @@ -45,6 +45,7 @@ struct MixerConfig { QRect geometry; bool showMidiTracks; bool showDrumTracks; + bool showNewDrumTracks; bool showInputTracks; bool showOutputTracks; bool showWaveTracks; @@ -81,6 +82,7 @@ struct GlobalConfigValues { QColor midiTrackLabelBg; QColor drumTrackLabelBg; + QColor newDrumTrackLabelBg; QColor waveTrackLabelBg; QColor outputTrackLabelBg; QColor inputTrackLabelBg; @@ -90,6 +92,7 @@ struct GlobalConfigValues { QColor midiTrackBg; QColor drumTrackBg; + QColor newDrumTrackBg; QColor waveTrackBg; QColor outputTrackBg; QColor inputTrackBg; diff --git a/muse2/muse/helper.cpp b/muse2/muse/helper.cpp index 255e8505..2c128ef3 100644 --- a/muse2/muse/helper.cpp +++ b/muse2/muse/helper.cpp @@ -285,26 +285,44 @@ QActionGroup* populateAddTrack(QMenu* addTrack) QT_TRANSLATE_NOOP("@default", "Add Midi Track")); midi->setData(Track::MIDI); grp->addAction(midi); + + QAction* drum = addTrack->addAction(QIcon(*addtrack_drumtrackIcon), QT_TRANSLATE_NOOP("@default", "Add Drum Track")); drum->setData(Track::DRUM); grp->addAction(drum); + + + QAction* newdrum = addTrack->addAction(QIcon(*addtrack_drumtrackIcon), + QT_TRANSLATE_NOOP("@default", "Add New Style Drum Track")); + newdrum->setData(Track::NEW_DRUM); + grp->addAction(newdrum); + + QAction* wave = addTrack->addAction(QIcon(*addtrack_wavetrackIcon), QT_TRANSLATE_NOOP("@default", "Add Wave Track")); wave->setData(Track::WAVE); grp->addAction(wave); + + QAction* aoutput = addTrack->addAction(QIcon(*addtrack_audiooutputIcon), QT_TRANSLATE_NOOP("@default", "Add Audio Output")); aoutput->setData(Track::AUDIO_OUTPUT); grp->addAction(aoutput); + + QAction* agroup = addTrack->addAction(QIcon(*addtrack_audiogroupIcon), QT_TRANSLATE_NOOP("@default", "Add Audio Group")); agroup->setData(Track::AUDIO_GROUP); grp->addAction(agroup); + + QAction* ainput = addTrack->addAction(QIcon(*addtrack_audioinputIcon), QT_TRANSLATE_NOOP("@default", "Add Audio Input")); ainput->setData(Track::AUDIO_INPUT); grp->addAction(ainput); + + QAction* aaux = addTrack->addAction(QIcon(*addtrack_auxsendIcon), QT_TRANSLATE_NOOP("@default", "Add Aux Send")); aaux->setData(Track::AUDIO_AUX); diff --git a/muse2/muse/importmidi.cpp b/muse2/muse/importmidi.cpp index 558ffb69..0e09ecfa 100644 --- a/muse2/muse/importmidi.cpp +++ b/muse2/muse/importmidi.cpp @@ -181,7 +181,7 @@ bool MusE::importMidi(const QString name, bool merge) MidiTrack* track = new MidiTrack(); if ((*t)->isDrumTrack) - track->setType(Track::DRUM); + track->setType(Track::DRUM); //FINDMICHJETZT track->setOutChannel(channel); track->setOutPort(port); @@ -200,7 +200,7 @@ bool MusE::importMidi(const QString name, bool merge) // Hmm. buildMidiEventList already takes care of this. // But it seems to work. How? Must test. if (channel == 9 && song->mtype() != MT_UNKNOWN) { - track->setType(Track::DRUM); + track->setType(Track::DRUM); //FINDMICHJETZT // // remap drum pitch with drumInmap // diff --git a/muse2/muse/liste/editevent.cpp b/muse2/muse/liste/editevent.cpp index e211e7f7..702e61e5 100644 --- a/muse2/muse/liste/editevent.cpp +++ b/muse2/muse/liste/editevent.cpp @@ -617,7 +617,7 @@ EditCtrlDialog::EditCtrlDialog(int tick, const Event& event, MidiTrack* track = part->track(); int portn = track->outPort(); MidiPort* port = &midiPorts[portn]; - bool isDrum = track->type() == Track::DRUM; + bool isDrum = track->type() == Track::DRUM; //FINDMICHJETZT was soll das? MidiCtrlValListList* cll = port->controller(); ctrlList->clear(); @@ -833,7 +833,7 @@ void EditCtrlDialog::updatePatch() int port = track->outPort(); int channel = track->outChannel(); MidiInstrument* instr = midiPorts[port].instrument(); - patchName->setText(instr->getPatchName(channel, val, song->mtype(), track->type() == Track::DRUM)); + patchName->setText(instr->getPatchName(channel, val, song->mtype(), track->type() == Track::DRUM)); //FINDMICHJETZT was soll das? int hb = ((val >> 16) & 0xff) + 1; if (hb == 0x100) @@ -872,7 +872,7 @@ void EditCtrlDialog::instrPopup() ///instr->populatePatchPopup(pop, channel, song->mtype(), track->type() == Track::DRUM); //QMenu* pup = new QMenu(this); MusEWidget::PopupMenu* pup = new MusEWidget::PopupMenu(this); - instr->populatePatchPopup(pup, channel, song->mtype(), track->type() == Track::DRUM); + instr->populatePatchPopup(pup, channel, song->mtype(), track->type() == Track::DRUM); //FINDMICHJETZT was soll das? ///if(pop->actions().count() == 0) /// return; diff --git a/muse2/muse/midi.cpp b/muse2/muse/midi.cpp index 39642348..5d7fe560 100644 --- a/muse2/muse/midi.cpp +++ b/muse2/muse/midi.cpp @@ -254,7 +254,7 @@ void buildMidiEventList(EventList* del, const MPEventList* el, MidiTrack* track, case ME_NOTEON: e.setType(Note); - if (track->type() == Track::DRUM) { + if (track->type() == Track::DRUM) { //FINDMICHJETZT int instr = drumInmap[ev.dataA()]; e.setPitch(instr); } @@ -268,7 +268,7 @@ void buildMidiEventList(EventList* del, const MPEventList* el, MidiTrack* track, break; case ME_NOTEOFF: e.setType(Note); - if (track->type() == Track::DRUM) { + if (track->type() == Track::DRUM) { //FINDMICHJETZT int instr = drumInmap[ev.dataA()]; e.setPitch(instr); } @@ -370,7 +370,7 @@ void buildMidiEventList(EventList* del, const MPEventList* el, MidiTrack* track, int ctl = ev.dataA(); e.setA(ctl); - if(track->type() == Track::DRUM) + if(track->type() == Track::DRUM) //FINDMICHJETZT drum controller? { // Is it a drum controller event, according to the track port's instrument? MidiController *mc = midiPorts[track->outPort()].drumController(ctl); @@ -723,7 +723,7 @@ void Audio::collectEvents(MidiTrack* track, unsigned int cts, unsigned int nts) // if (ev.type() == Meta) continue; - if (track->type() == Track::DRUM) { + if (track->type() == Track::DRUM) { //FINDMICHJETZT ignore muted int instr = ev.pitch(); // ignore muted drums if (ev.isNote() && drumMap[instr].mute) @@ -747,7 +747,7 @@ void Audio::collectEvents(MidiTrack* track, unsigned int cts, unsigned int nts) channel = drumMap[instr].channel; velo = int(double(velo) * (double(drumMap[instr].vol) / 100.0)) ; } - else { + else { //FINDMICHJETZT don't transpose for new style drum tracks // // transpose non drum notes // @@ -800,7 +800,7 @@ void Audio::collectEvents(MidiTrack* track, unsigned int cts, unsigned int nts) case Controller: { - if (track->type() == Track::DRUM) + if (track->type() == Track::DRUM) //FINDMICHJETZT was ist das? drumcontroller -_- { int ctl = ev.dataA(); // Is it a drum controller event, according to the track port's instrument? @@ -972,7 +972,7 @@ void Audio::processMidi() // //Apply drum inkey: - if (track->type() == Track::DRUM) + if (track->type() == Track::DRUM) //FINDMICHJETZT schwierig... { int pitch = event.dataA(); //Map note that is played according to drumInmap @@ -1009,7 +1009,7 @@ void Audio::processMidi() else if(event.type() == ME_CONTROLLER) { - if(track->type() == Track::DRUM) + if(track->type() == Track::DRUM) //FINDMICHJETZT was ist das? { ctl = event.dataA(); // Regardless of what port the event came from, is it a drum controller event @@ -1072,7 +1072,7 @@ void Audio::processMidi() // to the track port so buildMidiEventList will accept it. Even though // the port may have no device "". // - if (track->type() == Track::DRUM) + if (track->type() == Track::DRUM) //FINDMICHJETZT was ist das? { // Is it a drum controller event? if(mc) diff --git a/muse2/muse/midiedit/scoreedit.cpp b/muse2/muse/midiedit/scoreedit.cpp index e82ab7ad..a06d2a8c 100644 --- a/muse2/muse/midiedit/scoreedit.cpp +++ b/muse2/muse/midiedit/scoreedit.cpp @@ -4591,6 +4591,14 @@ void ScoreCanvas::add_new_parts(const std::map< Part*, std::set >& param) * from clipboard failed. ignoring this one... ) [ not reproducible ] * * CURRENT TODO + * o in appearance.cpp: add the new stuff for drumTrackLabelBg and drumTrackBg + * o find and fix FINDMICHJETZT + * o fix all segfaults and non-working stuff! + * - creating, changing types to and from, erasing NEW_DRUM tracks + * - move parts around + * - playing them. mute? + * - recording/echoing/steprec them + * - load, save them * o fix valgrind problems * * > o drum editor: channel-stuff diff --git a/muse2/muse/mixer/amixer.cpp b/muse2/muse/mixer/amixer.cpp index 18fe926f..082b9461 100644 --- a/muse2/muse/mixer/amixer.cpp +++ b/muse2/muse/mixer/amixer.cpp @@ -183,6 +183,7 @@ AudioMixerApp::AudioMixerApp(QWidget* parent, MusEConfig::MixerConfig* c) showMidiTracksId = new QAction(tr("Show Midi Tracks"), actionItems); showDrumTracksId = new QAction(tr("Show Drum Tracks"), actionItems); + showNewDrumTracksId = new QAction(tr("Show New Style Drum Tracks"), actionItems); showWaveTracksId = new QAction(tr("Show Wave Tracks"), actionItems); QAction *separator = new QAction(this); @@ -197,6 +198,7 @@ AudioMixerApp::AudioMixerApp(QWidget* parent, MusEConfig::MixerConfig* c) showMidiTracksId->setCheckable(true); showDrumTracksId->setCheckable(true); + showNewDrumTracksId->setCheckable(true); showWaveTracksId->setCheckable(true); showInputTracksId->setCheckable(true); showOutputTracksId->setCheckable(true); @@ -208,6 +210,7 @@ AudioMixerApp::AudioMixerApp(QWidget* parent, MusEConfig::MixerConfig* c) //connect(actionItems, SIGNAL(selected(QAction*)), this, SLOT(showTracksChanged(QAction*))); connect(showMidiTracksId, SIGNAL(triggered(bool)), SLOT(showMidiTracksChanged(bool))); connect(showDrumTracksId, SIGNAL(triggered(bool)), SLOT(showDrumTracksChanged(bool))); + connect(showNewDrumTracksId, SIGNAL(triggered(bool)), SLOT(showNewDrumTracksChanged(bool))); connect(showWaveTracksId, SIGNAL(triggered(bool)), SLOT(showWaveTracksChanged(bool))); connect(showInputTracksId, SIGNAL(triggered(bool)), SLOT(showInputTracksChanged(bool))); connect(showOutputTracksId, SIGNAL(triggered(bool)), SLOT(showOutputTracksChanged(bool))); @@ -349,6 +352,7 @@ void AudioMixerApp::updateMixer(UpdateAction action) showMidiTracksId->setChecked(cfg->showMidiTracks); showDrumTracksId->setChecked(cfg->showDrumTracks); + showNewDrumTracksId->setChecked(cfg->showNewDrumTracks); showInputTracksId->setChecked(cfg->showInputTracks); showOutputTracksId->setChecked(cfg->showOutputTracks); showWaveTracksId->setChecked(cfg->showWaveTracks); @@ -428,7 +432,7 @@ void AudioMixerApp::updateMixer(UpdateAction action) for (iMidiTrack i = mtl->begin(); i != mtl->end(); ++i) { MidiTrack* mt = *i; - if((mt->type() == Track::MIDI && cfg->showMidiTracks) || (mt->type() == Track::DRUM && cfg->showDrumTracks)) + if((mt->type() == Track::MIDI && cfg->showMidiTracks) || (mt->type() == Track::DRUM && cfg->showDrumTracks) || (mt->type() == Track::NEW_DRUM && cfg->showNewDrumTracks)) addStrip(*i, idx++); } @@ -485,7 +489,7 @@ void AudioMixerApp::updateMixer(UpdateAction action) for (iMidiTrack i = mtl->begin(); i != mtl->end(); ++i) { MidiTrack* mt = *i; - if((mt->type() == Track::MIDI && cfg->showMidiTracks) || (mt->type() == Track::DRUM && cfg->showDrumTracks)) + if((mt->type() == Track::MIDI && cfg->showMidiTracks) || (mt->type() == Track::DRUM && cfg->showDrumTracks) || (mt->type() == Track::NEW_DRUM && cfg->showNewDrumTracks)) addStrip(*i, idx++); } @@ -627,6 +631,8 @@ void AudioMixerApp::showTracksChanged(QAction* id) cfg->showMidiTracks = val; else if (id == showDrumTracksId) cfg->showDrumTracks = val; + else if (id == showNewDrumTracksId) + cfg->showNewDrumTracks = val; else if (id == showInputTracksId) cfg->showInputTracks = val; else if (id == showOutputTracksId) @@ -655,6 +661,12 @@ void AudioMixerApp::showDrumTracksChanged(bool v) updateMixer(UPDATE_ALL); } +void AudioMixerApp::showNewDrumTracksChanged(bool v) +{ + cfg->showNewDrumTracks = v; + updateMixer(UPDATE_ALL); +} + void AudioMixerApp::showWaveTracksChanged(bool v) { cfg->showWaveTracks = v; @@ -710,6 +722,7 @@ void AudioMixerApp::write(int level, Xml& xml) xml.intTag(level, "showMidiTracks", cfg->showMidiTracks); xml.intTag(level, "showDrumTracks", cfg->showDrumTracks); + xml.intTag(level, "showNewDrumTracks", cfg->showNewDrumTracks); xml.intTag(level, "showInputTracks", cfg->showInputTracks); xml.intTag(level, "showOutputTracks", cfg->showOutputTracks); xml.intTag(level, "showWaveTracks", cfg->showWaveTracks); diff --git a/muse2/muse/mixer/amixer.h b/muse2/muse/mixer/amixer.h index 5be12659..60a77f12 100644 --- a/muse2/muse/mixer/amixer.h +++ b/muse2/muse/mixer/amixer.h @@ -101,6 +101,7 @@ class AudioMixerApp : public QMainWindow { QAction* showMidiTracksId; QAction* showDrumTracksId; + QAction* showNewDrumTracksId; QAction* showInputTracksId; QAction* showOutputTracksId; QAction* showWaveTracksId; @@ -134,6 +135,7 @@ class AudioMixerApp : public QMainWindow { //void showTracksChanged(QAction*); void showMidiTracksChanged(bool); void showDrumTracksChanged(bool); + void showNewDrumTracksChanged(bool); void showWaveTracksChanged(bool); void showInputTracksChanged(bool); void showOutputTracksChanged(bool); diff --git a/muse2/muse/mixer/strip.cpp b/muse2/muse/mixer/strip.cpp index 59149222..67594e3a 100644 --- a/muse2/muse/mixer/strip.cpp +++ b/muse2/muse/mixer/strip.cpp @@ -150,6 +150,10 @@ void Strip::setLabelText() //c = QColor(0, 160, 255); // Med blue c = MusEConfig::config.drumTrackLabelBg; break; + case Track::NEW_DRUM: + //c = QColor(0, 160, 255); // Med blue + c = MusEConfig::config.newDrumTrackLabelBg; + break; default: return; } diff --git a/muse2/muse/part.cpp b/muse2/muse/part.cpp index 6d273c82..2d9111f7 100644 --- a/muse2/muse/part.cpp +++ b/muse2/muse/part.cpp @@ -401,7 +401,7 @@ void addPortCtrlEvents(Event& event, Part* part, bool doClones) MidiPort* mp = &midiPorts[port]; // Is it a drum controller event, according to the track port's instrument? - if(mt->type() == Track::DRUM) + if(mt->type() == Track::DRUM) //FINDMICHJETZT was ist das? { MidiController* mc = mp->drumController(cntrl); if(mc) @@ -469,7 +469,7 @@ void addPortCtrlEvents(Part* part, bool doClones) MidiPort* mp = &midiPorts[port]; // Is it a drum controller event, according to the track port's instrument? - if(mt->type() == Track::DRUM) + if(mt->type() == Track::DRUM) //FINDMICHJETZT was ist das? { MidiController* mc = mp->drumController(cntrl); if(mc) @@ -528,7 +528,7 @@ void removePortCtrlEvents(Event& event, Part* part, bool doClones) MidiPort* mp = &midiPorts[port]; // Is it a drum controller event, according to the track port's instrument? - if(mt->type() == Track::DRUM) + if(mt->type() == Track::DRUM) //FINDMICHJETZT was ist das? { MidiController* mc = mp->drumController(cntrl); if(mc) @@ -597,7 +597,7 @@ void removePortCtrlEvents(Part* part, bool doClones) MidiPort* mp = &midiPorts[port]; // Is it a drum controller event, according to the track port's instrument? - if(mt->type() == Track::DRUM) + if(mt->type() == Track::DRUM) //FINDMICHJETZT was ist das? { MidiController* mc = mp->drumController(cntrl); if(mc) @@ -913,6 +913,7 @@ void Song::cmdResizePart(Track* track, Part* oPart, unsigned int len, bool doClo break; case Track::MIDI: case Track::DRUM: + case Track::NEW_DRUM: { Undo operations; @@ -959,6 +960,7 @@ void Track::splitPart(Part* part, int tickpos, Part*& p1, Part*& p2) break; case MIDI: case DRUM: + case NEW_DRUM: l1 = tickpos - part->tick(); l2 = part->lenTick() - l1; break; @@ -982,6 +984,7 @@ void Track::splitPart(Part* part, int tickpos, Part*& p1, Part*& p2) break; case MIDI: case DRUM: + case NEW_DRUM: p1->setLenTick(l1); p2->setTick(tickpos); p2->setLenTick(l2); diff --git a/muse2/muse/remote/pyapi.cpp b/muse2/muse/remote/pyapi.cpp index 27a44e49..ff88ca23 100644 --- a/muse2/muse/remote/pyapi.cpp +++ b/muse2/muse/remote/pyapi.cpp @@ -695,7 +695,8 @@ PyObject* getAudioTrackVolume(PyObject*, PyObject* args) if (t == NULL) return NULL; - if (t->type() == Track::DRUM || t->type() == Track::MIDI) + //if (t->type() == Track::DRUM || t->type() == Track::MIDI || t->type() == Track::NEW_DRUM) + if (t->isMidiTrack()) // changed by flo. should do the same thing and is better maintainable return NULL; AudioTrack* track = (AudioTrack*) t; @@ -1089,7 +1090,8 @@ bool Song::event(QEvent* _e) if (t == NULL) return false; - if (t->type() == Track::DRUM || t->type() == Track::MIDI) + if (t->isMidiTrack()) // changed by flo. is better maintainable + //if (t->type() == Track::DRUM || t->type() == Track::NEW_DRUM || t->type() == Track::MIDI) return false; AudioTrack* track = (AudioTrack*) t; diff --git a/muse2/muse/shortcuts.cpp b/muse2/muse/shortcuts.cpp index 2270befa..a8cd8062 100644 --- a/muse2/muse/shortcuts.cpp +++ b/muse2/muse/shortcuts.cpp @@ -98,6 +98,7 @@ void initShortCuts() defShrt(SHRT_OPEN_MIDI_TRANSFORM, Qt::CTRL + Qt::Key_T, "Open midi transformer", ARRANG_SHRT, "open_midi_transform"); defShrt(SHRT_ADD_MIDI_TRACK, Qt::CTRL + Qt::Key_J, "Add midi track", ARRANG_SHRT, "add_midi_track"); defShrt(SHRT_ADD_DRUM_TRACK, 0, "Add drum track", ARRANG_SHRT, "add_drum_track"); + defShrt(SHRT_ADD_NEW_STYLE_DRUM_TRACK, 0, "Add new style drum track", ARRANG_SHRT, "add_new_style_drum_track"); defShrt(SHRT_ADD_WAVE_TRACK, 0, "Add wave track", ARRANG_SHRT, "add_wave_track"); defShrt(SHRT_ADD_AUDIO_OUTPUT, 0, "Add audio output", ARRANG_SHRT, "add_audio_output"); defShrt(SHRT_ADD_AUDIO_GROUP, 0, "Add audio group", ARRANG_SHRT, "add_audio_group"); diff --git a/muse2/muse/shortcuts.h b/muse2/muse/shortcuts.h index 451c4ec3..37e8b507 100644 --- a/muse2/muse/shortcuts.h +++ b/muse2/muse/shortcuts.h @@ -172,6 +172,7 @@ enum { SHRT_ADD_MIDI_TRACK, //Default: Ctrl+J SHRT_ADD_DRUM_TRACK, //Default: undefined + SHRT_ADD_NEW_STYLE_DRUM_TRACK, //Default: undefined SHRT_ADD_WAVE_TRACK, //Default: undefined SHRT_ADD_AUDIO_OUTPUT, //Default: undefined SHRT_ADD_AUDIO_GROUP, //Default: undefined diff --git a/muse2/muse/song.cpp b/muse2/muse/song.cpp index db2bcad5..dca43681 100644 --- a/muse2/muse/song.cpp +++ b/muse2/muse/song.cpp @@ -238,6 +238,11 @@ Track* Song::addTrack(Track::TrackType type, Track* insertAt) track = new MidiTrack(); track->setType(Track::MIDI); break; + case Track::NEW_DRUM: + track = new MidiTrack(); + track->setType(Track::NEW_DRUM); + ((MidiTrack*)track)->setOutChannel(9); + break; case Track::DRUM: track = new MidiTrack(); track->setType(Track::DRUM); @@ -315,7 +320,7 @@ Track* Song::addTrack(Track::TrackType type, Track* insertAt) { defOutFound = true; mt->setOutPort(i); - if(type != Track::DRUM) // p4.0.17 Leave drum tracks at channel 10. + if(type != Track::DRUM && type != Track::NEW_DRUM) // p4.0.17 Leave drum tracks at channel 10. mt->setOutChannel(ch); updateFlags |= SC_ROUTE; break; @@ -336,6 +341,7 @@ Track* Song::addTrack(Track::TrackType type, Track* insertAt) switch(type) { //case Track::MIDI: //case Track::DRUM: + //case Track::NEW_DRUM: //case Track::AUDIO_OUTPUT: // break; @@ -435,7 +441,7 @@ bool Song::addEvent(Event& event, Part* part) MidiPort* mp = &midiPorts[track->outPort()]; // Is it a drum controller event, according to the track port's instrument? - if(track->type() == Track::DRUM) + if(track->type() == Track::DRUM) //FINDMICHJETZT was ist das? { MidiController* mc = mp->drumController(cntrl); if(mc) @@ -508,7 +514,7 @@ void Song::changeEvent(Event& oldEvent, Event& newEvent, Part* part) int cntrl = oldEvent.dataA(); MidiPort* mp = &midiPorts[track->outPort()]; // Is it a drum controller event, according to the track port's instrument? - if(track->type() == Track::DRUM) + if(track->type() == Track::DRUM) //FINDMICHJETZT was ist das? { MidiController* mc = mp->drumController(cntrl); if(mc) @@ -535,7 +541,7 @@ void Song::changeEvent(Event& oldEvent, Event& newEvent, Part* part) int val = newEvent.dataB(); MidiPort* mp = &midiPorts[track->outPort()]; // Is it a drum controller event, according to the track port's instrument? - if(track->type() == Track::DRUM) + if(track->type() == Track::DRUM) //FINDMICHJETZT was ist das? { MidiController* mc = mp->drumController(cntrl); if(mc) @@ -569,7 +575,7 @@ void Song::deleteEvent(Event& event, Part* part) MidiPort* mp = &midiPorts[track->outPort()]; // Is it a drum controller event, according to the track port's instrument? - if(track->type() == Track::DRUM) + if(track->type() == Track::DRUM) //FINDMICHJETZT was ist das? { MidiController* mc = mp->drumController(cntrl); if(mc) @@ -610,7 +616,7 @@ void Song::remapPortDrumCtrlEvents(int mapidx, int newnote, int newchan, int new for(ciMidiTrack it = _midis.begin(); it != _midis.end(); ++it) { MidiTrack* mt = *it; - if(mt->type() != Track::DRUM) + if(mt->type() != Track::DRUM) //FINDMICHJETZT was ist das? drumcontroller? continue; MidiPort* trackmp = &midiPorts[mt->outPort()]; @@ -624,6 +630,7 @@ void Song::remapPortDrumCtrlEvents(int mapidx, int newnote, int newchan, int new { const Event& ev = ie->second; // Added by T356. Do not handle events which are past the end of the part. + //FINDMICHJETZT why not? if(ev.tick() >= len) break; @@ -680,7 +687,7 @@ void Song::changeAllPortDrumCtrlEvents(bool add, bool drumonly) for(ciMidiTrack it = _midis.begin(); it != _midis.end(); ++it) { MidiTrack* mt = *it; - if(mt->type() != Track::DRUM) + if(mt->type() != Track::DRUM) //FINDMICHJETZT was ist das? drumcontroller continue; trackmp = &midiPorts[mt->outPort()]; @@ -3351,6 +3358,7 @@ void Song::insertTrack2(Track* track, int idx) switch(track->type()) { case Track::MIDI: case Track::DRUM: + case Track::NEW_DRUM: _midis.push_back((MidiTrack*)track); // Added by T356. //((MidiTrack*)track)->addPortCtrlEvents(); @@ -3601,6 +3609,7 @@ void Song::removeTrack2(Track* track) switch(track->type()) { case Track::MIDI: case Track::DRUM: + case Track::NEW_DRUM: // Added by T356. //((MidiTrack*)track)->removePortCtrlEvents(); removePortCtrlEvents(((MidiTrack*)track)); diff --git a/muse2/muse/songfile.cpp b/muse2/muse/songfile.cpp index 344ecc89..c430ed1e 100644 --- a/muse2/muse/songfile.cpp +++ b/muse2/muse/songfile.cpp @@ -719,7 +719,7 @@ void Part::read(Xml& xml, int, bool toTrack) // int newPartOffset newPartOffset=this->tick(); int ctl = e.dataA(); - if(mt->type() == Track::DRUM) + if(mt->type() == Track::DRUM) //FINDMICHJETZT commented out: was ist das? { // Is it a drum controller event, according to the track port's instrument? MidiController* mc = mp->drumController(ctl); @@ -1403,6 +1403,12 @@ void Song::read(Xml& xml, bool isTemplate) track->read(xml); insertTrack0(track, -1); } + else if (tag == "newdrumtrack") { + MidiTrack* track = new MidiTrack(); + track->setType(Track::NEW_DRUM); + track->read(xml); + insertTrack0(track, -1); + } else if (tag == "wavetrack") { WaveTrack* track = new WaveTrack(); track->read(xml); diff --git a/muse2/muse/track.cpp b/muse2/muse/track.cpp index 90e9beec..58c53f63 100644 --- a/muse2/muse/track.cpp +++ b/muse2/muse/track.cpp @@ -43,8 +43,8 @@ bool Track::_tmpSoloChainDoIns = false; bool Track::_tmpSoloChainNoDec = false; const char* Track::_cname[] = { - "Midi", "Drum", "Wave", "AudioOut", "AudioIn", "AudioGroup", - "AudioAux", "AudioSynth" + "Midi", "Drum", "NewStyleDrum", "Wave", + "AudioOut", "AudioIn", "AudioGroup", "AudioAux", "AudioSynth" }; //--------------------------------------------------------- @@ -75,7 +75,7 @@ void addPortCtrlEvents(MidiTrack* t) MidiPort* mp = &midiPorts[t->outPort()]; // Is it a drum controller event, according to the track port's instrument? - if(t->type() == Track::DRUM) + if(t->type() == Track::DRUM) //FINDMICHJETZT was soll das? drumcontroller -_- { MidiController* mc = mp->drumController(cntrl); if(mc) @@ -123,7 +123,7 @@ void removePortCtrlEvents(MidiTrack* t) MidiPort* mp = &midiPorts[t->outPort()]; // Is it a drum controller event, according to the track port's instrument? - if(t->type() == Track::DRUM) + if(t->type() == Track::DRUM) //FINDMICHJETZT was soll das? drumcontroller... { MidiController* mc = mp->drumController(cntrl); if(mc) @@ -239,7 +239,8 @@ Track::Track(const Track& t, bool cloneParts) // A couple of schemes were conceived to deal with cloneList being invalid, but the best way is // to not alter the part list here. It's a big headache because: Either the parts in the cloneList // need to be reliably looked up replaced with the new ones, or the clipboard and cloneList must be cleared. - // Fortunately the ONLY part of muse using this function is track rename (in TrackList and TrackInfo). + // Fortunately the ONLY parts of muse using this function are track rename (in TrackList and TrackInfo) and + // changing track type from MIDI to NEW_DRUM or vice versa (NOT something -> DRUM or vice versa). // So we can get away with leaving this out: //for (iPart ip = _parts.begin(); ip != _parts.end(); ++ip) // ip->second->setTrack(this); @@ -311,6 +312,7 @@ void Track::setDefaultName() switch(_type) { case MIDI: case DRUM: + case NEW_DRUM: case WAVE: base = QString("Track"); break; @@ -469,7 +471,7 @@ MidiTrack::~MidiTrack() void MidiTrack::init() { _outPort = 0; - _outChannel = 0; + _outChannel = (type()==NEW_DRUM) ? 9 : 0; // Changed by Tim. p3.3.8 //_inPortMask = 0xffff; ///_inPortMask = 0xffffffff; @@ -643,7 +645,7 @@ void MidiTrack::addPortCtrlEvents() MidiPort* mp = &midiPorts[_outPort]; // Is it a drum controller event, according to the track port's instrument? - if(type() == DRUM) + if(type() == DRUM) //FINDMICHJETZT commented out. was soll das? { MidiController* mc = mp->drumController(cntrl); if(mc) @@ -684,7 +686,7 @@ void MidiTrack::removePortCtrlEvents() MidiPort* mp = &midiPorts[_outPort]; // Is it a drum controller event, according to the track port's instrument? - if(type() == DRUM) + if(type() == DRUM) //FINDMICHJETZT commented out: was soll das? { MidiController* mc = mp->drumController(cntrl); if(mc) @@ -941,8 +943,13 @@ void MidiTrack::write(int level, Xml& xml) const if (type() == DRUM) tag = "drumtrack"; - else + else if (type() == MIDI) tag = "miditrack"; + else if (type() == NEW_DRUM) + tag = "newdrumtrack"; + else + printf("THIS SHOULD NEVER HAPPEN: non-midi-type in MidiTrack::write()\n"); + xml.tag(level++, tag); Track::writeProperties(level, xml); diff --git a/muse2/muse/track.h b/muse2/muse/track.h index 752a79be..7ed30914 100644 --- a/muse2/muse/track.h +++ b/muse2/muse/track.h @@ -52,7 +52,7 @@ class DrumMap; class Track { public: enum TrackType { - MIDI=0, DRUM, WAVE, AUDIO_OUTPUT, AUDIO_INPUT, AUDIO_GROUP, + MIDI=0, DRUM, NEW_DRUM, WAVE, AUDIO_OUTPUT, AUDIO_INPUT, AUDIO_GROUP, AUDIO_AUX, AUDIO_SOFTSYNTH }; private: @@ -199,7 +199,7 @@ class Track { void setDefaultName(); int channels() const { return _channels; } virtual void setChannels(int n); - bool isMidiTrack() const { return type() == MIDI || type() == DRUM; } + bool isMidiTrack() const { return type() == MIDI || type() == DRUM || type() == NEW_DRUM; } virtual bool canRecord() const { return false; } virtual AutomationType automationType() const = 0; virtual void setAutomationType(AutomationType t) = 0; diff --git a/muse2/muse/widgets/mtrackinfo.cpp b/muse2/muse/widgets/mtrackinfo.cpp index 56429879..57674395 100644 --- a/muse2/muse/widgets/mtrackinfo.cpp +++ b/muse2/muse/widgets/mtrackinfo.cpp @@ -216,6 +216,7 @@ void MidiTrackInfo::heartBeat() { case Track::MIDI: case Track::DRUM: + case Track::NEW_DRUM: { MidiTrack* track = (MidiTrack*)selected; @@ -344,7 +345,7 @@ void MidiTrackInfo::heartBeat() else { MidiInstrument* instr = mp->instrument(); - QString name = instr->getPatchName(outChannel, nprogram, song->mtype(), track->type() == Track::DRUM); + QString name = instr->getPatchName(outChannel, nprogram, song->mtype(), track->type() == Track::DRUM); //FINDMICHJETZT was soll das? if(name.isEmpty()) { const QString n("???"); @@ -390,7 +391,7 @@ void MidiTrackInfo::heartBeat() //else //{ MidiInstrument* instr = mp->instrument(); - QString name = instr->getPatchName(outChannel, program, song->mtype(), track->type() == Track::DRUM); + QString name = instr->getPatchName(outChannel, program, song->mtype(), track->type() == Track::DRUM); //FINDMICHJETZT was soll das? if(iPatch->text() != name) iPatch->setText(name); @@ -567,8 +568,12 @@ void MidiTrackInfo::setLabelText() //pal.setColor(trackNameLabel->backgroundRole(), QColor(0, 160, 255)); // Med blue if(track->type() == Track::DRUM) c = MusEConfig::config.drumTrackLabelBg; - else + else if (track->type() == Track::MIDI) c = MusEConfig::config.midiTrackLabelBg; + else if (track->type() == Track::NEW_DRUM) + c = MusEConfig::config.newDrumTrackLabelBg; + else + printf("THIS SHOULD NEVER HAPPEN: track is not a MIDI track in MidiTrackInfo::setLabelText()!\n"); QLinearGradient gradient(trackNameLabel->geometry().topLeft(), trackNameLabel->geometry().bottomLeft()); //gradient.setColorAt(0, c.darker()); @@ -757,7 +762,7 @@ void MidiTrackInfo::iProgHBankChanged() audio->msgPlayMidiEvent(&ev); MidiInstrument* instr = mp->instrument(); - iPatch->setText(instr->getPatchName(channel, program, song->mtype(), track->type() == Track::DRUM)); + iPatch->setText(instr->getPatchName(channel, program, song->mtype(), track->type() == Track::DRUM)); //FINDMICHJETZT was soll das? // updateTrackInfo(); } @@ -835,7 +840,7 @@ void MidiTrackInfo::iProgLBankChanged() audio->msgPlayMidiEvent(&ev); MidiInstrument* instr = mp->instrument(); - iPatch->setText(instr->getPatchName(channel, program, song->mtype(), track->type() == Track::DRUM)); + iPatch->setText(instr->getPatchName(channel, program, song->mtype(), track->type() == Track::DRUM)); //FINDMICHJETZT was soll das? // updateTrackInfo(); } @@ -913,7 +918,7 @@ void MidiTrackInfo::iProgramChanged() audio->msgPlayMidiEvent(&ev); MidiInstrument* instr = mp->instrument(); - iPatch->setText(instr->getPatchName(channel, program, song->mtype(), track->type() == Track::DRUM)); + iPatch->setText(instr->getPatchName(channel, program, song->mtype(), track->type() == Track::DRUM)); //FINDMICHJETZT was soll das? } // updateTrackInfo(); @@ -1082,7 +1087,7 @@ void MidiTrackInfo::instrPopup() PopupMenu* pup = new PopupMenu(true); //instr->populatePatchPopup(pop, channel, song->mtype(), track->type() == Track::DRUM); - instr->populatePatchPopup(pup, channel, song->mtype(), track->type() == Track::DRUM); + instr->populatePatchPopup(pup, channel, song->mtype(), track->type() == Track::DRUM); //FINDMICHJETZT was soll das? //if(pop->actions().count() == 0) // return; @@ -1406,7 +1411,7 @@ void MidiTrackInfo::updateTrackInfo(int flags) else { MidiInstrument* instr = mp->instrument(); - iPatch->setText(instr->getPatchName(outChannel, nprogram, song->mtype(), track->type() == Track::DRUM)); + iPatch->setText(instr->getPatchName(outChannel, nprogram, song->mtype(), track->type() == Track::DRUM)); //FINDMICHJETZT was soll das? } } else @@ -1422,7 +1427,7 @@ void MidiTrackInfo::updateTrackInfo(int flags) //else //{ MidiInstrument* instr = mp->instrument(); - iPatch->setText(instr->getPatchName(outChannel, program, song->mtype(), track->type() == Track::DRUM)); + iPatch->setText(instr->getPatchName(outChannel, program, song->mtype(), track->type() == Track::DRUM)); //FINDMICHJETZT was soll das? int hb = ((program >> 16) & 0xff) + 1; if (hb == 0x100) diff --git a/muse2/muse/widgets/musewidgetsplug.cpp b/muse2/muse/widgets/musewidgetsplug.cpp index 3ebd1aa5..01cc68b3 100644 --- a/muse2/muse/widgets/musewidgetsplug.cpp +++ b/muse2/muse/widgets/musewidgetsplug.cpp @@ -131,6 +131,7 @@ GlobalConfigValues config = { QColor(0, 160, 255), // midiTrackLabelBg; // Med blue QColor(0, 160, 255), // drumTrackLabelBg; // Med blue + QColor(0, 160, 255), // newDrumTrackLabelBg; // Med blue Qt::magenta, // waveTrackLabelBg; Qt::green, // outputTrackLabelBg; Qt::red, // inputTrackLabelBg; @@ -140,6 +141,7 @@ GlobalConfigValues config = { QColor(220, 220, 220), // midiTrackBg; QColor(220, 220, 220), // drumTrackBg; + QColor(220, 220, 220), // newDrumTrackBg; QColor(220, 220, 220), // waveTrackBg; QColor(189, 220, 193), // outputTrackBg; QColor(189, 220, 193), // inputTrackBg; @@ -178,13 +180,13 @@ GlobalConfigValues config = { QString("Mixer A"), QRect(0, 0, 300, 500), // Mixer1 true, true, true, true, - true, true, true, true + true, true, true, true, true }, { QString("Mixer B"), QRect(200, 200, 300, 500), // Mixer2 true, true, true, true, - true, true, true, true + true, true, true, true, true }, true, // TransportVisible; false, // BigTimeVisible; -- cgit v1.2.3 From 375d6a53630f364c6560eb40255a8cc4c0496b8c Mon Sep 17 00:00:00 2001 From: Florian Jung Date: Fri, 7 Oct 2011 14:55:42 +0000 Subject: fixed small bug in tlist.cpp --- muse2/muse/arranger/tlist.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'muse2') diff --git a/muse2/muse/arranger/tlist.cpp b/muse2/muse/arranger/tlist.cpp index c4a2094a..73c8eec7 100644 --- a/muse2/muse/arranger/tlist.cpp +++ b/muse2/muse/arranger/tlist.cpp @@ -928,8 +928,7 @@ TrackList TList::getRecEnabledTracks() void TList::changeAutomation(QAction* act) { //printf("changeAutomation %d\n", act->data().toInt()); - if (editAutomation->type() == Track::MIDI) { //FINDMICHJETZT is this correct? or should we also - //consider DRUM and NEW_DRUM? svn blame could help + if ( (editAutomation->type() == Track::MIDI) || (editAutomation->type() == Track::DRUM) || (editAutomation->type() == Track::NEW_DRUM) ) { printf("this is wrong, we can't edit automation for midi tracks from arranger yet!\n"); return; } -- cgit v1.2.3 From 9e6dc222b92bbfba58756d3be47890dd885b8f71 Mon Sep 17 00:00:00 2001 From: Florian Jung Date: Sat, 8 Oct 2011 14:10:24 +0000 Subject: muted instruments in new style drum tracks are now respected --- muse2/muse/midi.cpp | 8 +++++++- muse2/muse/track.h | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) (limited to 'muse2') diff --git a/muse2/muse/midi.cpp b/muse2/muse/midi.cpp index e927674f..65bccc70 100644 --- a/muse2/muse/midi.cpp +++ b/muse2/muse/midi.cpp @@ -730,12 +730,18 @@ void Audio::collectEvents(MusECore::MidiTrack* track, unsigned int cts, unsigned // if (ev.type() == Meta) continue; - if (track->type() == Track::DRUM) { //FINDMICHJETZT ignore muted + if (track->type() == Track::DRUM) { int instr = ev.pitch(); // ignore muted drums if (ev.isNote() && MusEGlobal::drumMap[instr].mute) continue; } + else if (track->type() == Track::NEW_DRUM) { + int instr = ev.pitch(); + // ignore muted drums + if (ev.isNote() && track->drummap()[instr].mute) + continue; + } unsigned tick = ev.tick() + offset; unsigned frame = MusEGlobal::tempomap.tick2frame(tick) + frameOffset; switch (ev.type()) { diff --git a/muse2/muse/track.h b/muse2/muse/track.h index 9d3db8af..0911b4f1 100644 --- a/muse2/muse/track.h +++ b/muse2/muse/track.h @@ -229,7 +229,7 @@ class MidiTrack : public Track { static bool _isVisible; clefTypes clefType; - DrumMap* _drummap; + DrumMap* _drummap; // _drummap[foo].anote is always equal to foo bool _drummap_tied_to_patch; //if true, changing patch also changes drummap bool* _drummap_hidden; -- cgit v1.2.3 From 159a2b58fd28c7a00b9b723dcea77e6c2ec2e874 Mon Sep 17 00:00:00 2001 From: Florian Jung Date: Sun, 9 Oct 2011 13:20:51 +0000 Subject: updated MidiTrack::read and ::write --- muse2/muse/midiedit/drummap.cpp | 9 ++ muse2/muse/midiedit/drummap.h | 1 + muse2/muse/midiedit/scoreedit.cpp | 6 +- muse2/muse/track.cpp | 245 ++++++++++++++++++++++++++++++++++---- muse2/muse/track.h | 9 +- 5 files changed, 246 insertions(+), 24 deletions(-) (limited to 'muse2') diff --git a/muse2/muse/midiedit/drummap.cpp b/muse2/muse/midiedit/drummap.cpp index 43e66345..47232011 100644 --- a/muse2/muse/midiedit/drummap.cpp +++ b/muse2/muse/midiedit/drummap.cpp @@ -43,6 +43,15 @@ namespace MusECore { const DrumMap blankdm = { QString(""), 100, 16, 32, 9, 0, 70, 90, 127, 110, 127, 127, false }; +// this map must have 128 entries, as it's used for initalising new-style-drummaps as well. +// new-style-drummaps only have 128 entries. also, the every "out-note" ("anote") must be +// represented exactly once in that map, and there may be no duplicate or unused "out-notes". +// reason: the track's drummap are inited as follows: iterate through the full idrumMap[], +// tracks_drummap[ idrumMap[i].anote ] = idrumMap[i] +// if you ever want to change this, you will need to go through track.cpp/.h and +// {dlist,dcanvas,drumedit,drummap}{.cpp,.h} (and possibly some more) and find every usage +// of idrumMap by new style drummaps, and fix the problem. a possible fix would be duplicating +// idrumMap, change idrumMap, and use the duplicate for the new style stuff instead. const DrumMap idrumMap[DRUM_MAPSIZE] = { { QString("Acoustic Bass Drum"), 100, 16, 32, 9, 0, 70, 90, 127, 110, 35, 35, false }, { QString("Bass Drum 1"), 100, 16, 32, 9, 0, 70, 90, 127, 110, 36, 36, false }, diff --git a/muse2/muse/midiedit/drummap.h b/muse2/muse/midiedit/drummap.h index f3186afa..3b6ffaf3 100644 --- a/muse2/muse/midiedit/drummap.h +++ b/muse2/muse/midiedit/drummap.h @@ -51,6 +51,7 @@ struct DrumMap { bool operator!=(const DrumMap& map) const { return !operator==(map); } }; +// please let this at "128". idrumMap must have length 128 (see drummap.cpp for details) #define DRUM_MAPSIZE 128 extern const DrumMap idrumMap[DRUM_MAPSIZE]; //FINDMICH dummy! diff --git a/muse2/muse/midiedit/scoreedit.cpp b/muse2/muse/midiedit/scoreedit.cpp index 5770ee6c..8f647966 100644 --- a/muse2/muse/midiedit/scoreedit.cpp +++ b/muse2/muse/midiedit/scoreedit.cpp @@ -4608,7 +4608,7 @@ void ScoreCanvas::add_new_parts(const std::map< MusECore::Part*, std::set= 128) - printf ("ERROR: THIS SHOULD NEVER HAPPEN: idrumMap[%i].anote is not within 0..127!\n", idx); - else - _drummap[idx]=idrumMap[i]; - - MusEGlobal::global_drum_ordering.push_back(std::pair(this,idx)); - } - for (int i=0;i<128;i++) - _drummap_hidden[i]=false; - + init_drummap(true /* write drummap ordering information as well */); } //MidiTrack::MidiTrack(const MidiTrack& mt) @@ -460,16 +448,18 @@ MidiTrack::~MidiTrack() delete [] _drummap; delete [] _drummap_hidden; - // remove ourselves from the global_drum_ordering list - // this is not really necessary, but cleaner - for (MusEGlobal::global_drum_ordering_t::iterator it=MusEGlobal::global_drum_ordering.begin(); it!=MusEGlobal::global_drum_ordering.end();) - if (it->first == this) - it=MusEGlobal::global_drum_ordering.erase(it); - else - it++; - + remove_ourselves_from_drum_ordering(); } +void MidiTrack::remove_ourselves_from_drum_ordering() +{ + for (MusEGlobal::global_drum_ordering_t::iterator it=MusEGlobal::global_drum_ordering.begin(); it!=MusEGlobal::global_drum_ordering.end();) + if (it->first == this) + it=MusEGlobal::global_drum_ordering.erase(it); + else + it++; +} + //--------------------------------------------------------- // init //--------------------------------------------------------- @@ -491,6 +481,26 @@ void MidiTrack::init() _recEcho = true; } +void MidiTrack::init_drummap(bool write_ordering) +{ + for (int i=0;i<128;i++) + { + 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]; + + if (write_ordering) + MusEGlobal::global_drum_ordering.push_back(std::pair(this,idx)); + } + + for (int i=0;i<128;i++) + _drummap_hidden[i]=false; +} + + + //--------------------------------------------------------- // height //--------------------------------------------------------- @@ -793,9 +803,77 @@ void MidiTrack::write(int level, Xml& xml) const const PartList* pl = cparts(); for (ciPart p = pl->begin(); p != pl->end(); ++p) p->second->write(level, xml); + + writeOurDrumSettings(level, xml); + xml.etag(level, tag); } +void MidiTrack::writeOurDrumSettings(int level, Xml& xml) const +{ + xml.tag(level++, "our_drum_settings"); + + xml.intTag(level, "tied", _drummap_tied_to_patch); + + writeOurDrumMap(level, xml); + + xml.etag(level, "our_drum_settings"); +} + +void MidiTrack::writeOurDrumMap(int level, Xml& xml) const +{ + xml.tag(level++, "our_drummap"); + + for (int i=0;i<128;i++) + { + int j; + for (j=0;j<128;j++) + if (idrumMap[j].anote == i) break; + + if (j==128) + printf("THIS SHOULD NEVER HAPPEN: couldn't find initial drum map entry in MidiTrack::writeOurDrumMap()\n"); + else + { + DrumMap* dm = &_drummap[i]; + const DrumMap* idm = &idrumMap[j]; + + if ( (dm->name != idm->name) || (dm->vol != idm->vol) || + (dm->quant != idm->quant) || (dm->len != idm->len) || + (dm->lv1 != idm->lv1) || (dm->lv2 != idm->lv2) || + (dm->lv3 != idm->lv3) || (dm->lv4 != idm->lv4) || + (dm->enote != idm->enote) || (dm->mute != idm->mute) || + _drummap_hidden[i] ) + { + xml.tag(level++, "entry pitch=\"%d\"", i); + + // when any of these "if"s changes, also update the large "if" + // above (this scope's parent) + if (dm->name != idm->name) xml.strTag(level, "name", dm->name); + if (dm->vol != idm->vol) xml.intTag(level, "vol", dm->vol); + if (dm->quant != idm->quant) xml.intTag(level, "quant", dm->quant); + if (dm->len != idm->len) xml.intTag(level, "len", dm->len); + if (dm->lv1 != idm->lv1) xml.intTag(level, "lv1", dm->lv1); + if (dm->lv2 != idm->lv2) xml.intTag(level, "lv2", dm->lv2); + if (dm->lv3 != idm->lv3) xml.intTag(level, "lv3", dm->lv3); + if (dm->lv4 != idm->lv4) xml.intTag(level, "lv4", dm->lv4); + if (dm->enote != idm->enote) xml.intTag(level, "enote", dm->enote); + if (dm->mute != idm->mute) xml.intTag(level, "mute", dm->mute); + if (_drummap_hidden[i]) xml.intTag(level, "hide", _drummap_hidden[i]); + + // anote is ignored anyway, as dm->anote == i, and this is + // already stored in the begin tag (pitch=...) + + // channel and port are ignored as well, as they're not used + // in new-style-drum-mode + + xml.tag(level--, "/entry"); + } + } + } + + xml.etag(level, "our_drummap"); +} + //--------------------------------------------------------- // MidiTrack::read //--------------------------------------------------------- @@ -852,6 +930,8 @@ void MidiTrack::read(Xml& xml) setAutomationType(AutomationType(xml.parseInt())); else if (tag == "clef") clefType = (clefTypes)xml.parseInt(); + else if (tag == "our_drum_settings") + readOurDrumSettings(xml); else if (Track::readProperties(xml, tag)) { // version 1.0 compatibility: if (tag == "track" && xml.majorVersion() == 1 && xml.minorVersion() == 0) @@ -873,6 +953,129 @@ void MidiTrack::read(Xml& xml) } } +void MidiTrack::readOurDrumSettings(Xml& xml) +{ + 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 == "tied") + _drummap_tied_to_patch = xml.parseInt(); + else if (tag == "our_drummap") + readOurDrumMap(xml); + else + xml.unknown("MidiTrack::readOurDrumSettings"); + break; + + case Xml::TagEnd: + if (tag == "our_drum_settings") + return; + + default: + break; + } + } +} + +void MidiTrack::readOurDrumMap(Xml& xml) +{ + init_drummap(false); + + 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") // then read that entry with a nested loop + { + DrumMap* dm=NULL; + bool* hidden=NULL; + for (;;) // nested loop + { + Xml::Token token = xml.parse(); + const QString& tag = xml.s1(); + switch (token) + { + case Xml::Error: + case Xml::End: + goto end_of_nested_for; + + case Xml::Attribut: + if (tag == "pitch") + { + int pitch = xml.s2().toInt() & 0x7f; + if (pitch < 0 || pitch > 127) + printf("ERROR: THIS SHOULD NEVER HAPPEN: invalid pitch in MidiTrack::readOurDrumMap()!\n"); + else + { + dm = &_drummap[pitch]; + hidden = &_drummap_hidden[pitch]; + } + } + break; + + case Xml::TagStart: + if (dm==NULL) + printf("ERROR: THIS SHOULD NEVER HAPPEN: no valid 'pitch' attribute in tag, but sub-tags follow in MidiTrack::readOurDrumMap()!\n"); + else if (tag == "name") + dm->name = xml.parse(QString("name")); + else if (tag == "vol") + dm->vol = (unsigned char)xml.parseInt(); + else if (tag == "quant") + dm->quant = xml.parseInt(); + else if (tag == "len") + dm->len = xml.parseInt(); + else if (tag == "lv1") + dm->lv1 = xml.parseInt(); + else if (tag == "lv2") + dm->lv2 = xml.parseInt(); + else if (tag == "lv3") + dm->lv3 = xml.parseInt(); + else if (tag == "lv4") + dm->lv4 = xml.parseInt(); + else if (tag == "enote") + dm->enote = xml.parseInt(); + else if (tag == "mute") + dm->mute = xml.parseInt(); + else if (tag == "hide") + *hidden = xml.parseInt(); + else + xml.unknown("MidiTrack::readOurDrumMap"); + break; + + case Xml::TagEnd: + if (tag == "entry") + goto end_of_nested_for; + + default: + break; + } + } // end of nested loop + end_of_nested_for: ; + } // end of 'if (tag == "entry")' + else + xml.unknown("MidiTrack::readOurDrumMap"); + break; + + case Xml::TagEnd: + if (tag == "our_drummap") + return; + + default: + break; + } + } +} + //--------------------------------------------------------- // addPart diff --git a/muse2/muse/track.h b/muse2/muse/track.h index 0911b4f1..a958ca74 100644 --- a/muse2/muse/track.h +++ b/muse2/muse/track.h @@ -230,10 +230,17 @@ class MidiTrack : public Track { clefTypes clefType; DrumMap* _drummap; // _drummap[foo].anote is always equal to foo + bool* _drummap_hidden; // _drummap und _drummap_hidden will be an array[128] bool _drummap_tied_to_patch; //if true, changing patch also changes drummap - bool* _drummap_hidden; void init(); + void init_drummap(bool write_ordering=false); + void remove_ourselves_from_drum_ordering(); + + void writeOurDrumSettings(int level, Xml& xml) const; + void writeOurDrumMap(int level, Xml& xml) const; + void readOurDrumSettings(Xml& xml); + void readOurDrumMap(Xml& xml); public: MidiTrack(); -- cgit v1.2.3 From 9a4a4ee6fd5c2a73216240da912f7273aacaa11e Mon Sep 17 00:00:00 2001 From: Florian Jung Date: Sun, 9 Oct 2011 16:02:35 +0000 Subject: recording and importing midi now works for new style drum tracks plus fixes for old-style drum tracks --- muse2/muse/importmidi.cpp | 14 +++++++++----- muse2/muse/midi.cpp | 17 ++++++++--------- muse2/muse/midiedit/dcanvas.cpp | 6 +++++- muse2/muse/midiedit/dcanvas.h | 2 +- muse2/muse/midiedit/dlist.cpp | 6 +++--- muse2/muse/track.cpp | 14 ++++++++++++-- muse2/muse/track.h | 5 ++++- 7 files changed, 42 insertions(+), 22 deletions(-) (limited to 'muse2') diff --git a/muse2/muse/importmidi.cpp b/muse2/muse/importmidi.cpp index 593ddb79..90e8cecb 100644 --- a/muse2/muse/importmidi.cpp +++ b/muse2/muse/importmidi.cpp @@ -181,7 +181,8 @@ bool MusE::importMidi(const QString name, bool merge) MusECore::MidiTrack* track = new MusECore::MidiTrack(); if ((*t)->isDrumTrack) - track->setType(MusECore::Track::DRUM); //FINDMICHJETZT + track->setType(MusECore::Track::NEW_DRUM); //FINDMICHJETZT config option + //track->setType(MusECore::Track::DRUM); track->setOutChannel(channel); track->setOutPort(port); @@ -200,15 +201,17 @@ bool MusE::importMidi(const QString name, bool merge) // Hmm. buildMidiEventList already takes care of this. // But it seems to work. How? Must test. if (channel == 9 && MusEGlobal::song->mtype() != MT_UNKNOWN) { - track->setType(MusECore::Track::DRUM); //FINDMICHJETZT + track->setType(MusECore::Track::NEW_DRUM); //FINDMICHJETZT config option + /* + track->setType(MusECore::Track::DRUM); // - // remap drum pitch with drumInmap + // remap drum pitch with drumOutmap // MusECore::EventList* tevents = track->events(); for (MusECore::iEvent i = tevents->begin(); i != tevents->end(); ++i) { MusECore::Event ev = i->second; if (ev.isNote()) { - int pitch = MusEGlobal::drumInmap[ev.pitch()]; + int pitch = MusEGlobal::drumOutmap[ev.pitch()]; ev.setPitch(pitch); } else @@ -217,9 +220,10 @@ bool MusE::importMidi(const QString name, bool merge) int ctl = ev.dataA(); MusECore::MidiController *mc = mport->drumController(ctl); if(mc) - ev.setA((ctl & ~0xff) | MusEGlobal::drumInmap[ctl & 0x7f]); + ev.setA((ctl & ~0xff) | MusEGlobal::drumOutmap[ctl & 0x7f]); } } + */ } processTrack(track); diff --git a/muse2/muse/midi.cpp b/muse2/muse/midi.cpp index 65bccc70..0138f1d8 100644 --- a/muse2/muse/midi.cpp +++ b/muse2/muse/midi.cpp @@ -262,9 +262,7 @@ void buildMidiEventList(EventList* del, const MPEventList* el, MidiTrack* track, e.setPitch(instr); } else - { e.setPitch(ev.dataA()); - } e.setVelo(ev.dataB()); e.setLenTick(0); @@ -277,6 +275,7 @@ void buildMidiEventList(EventList* del, const MPEventList* el, MidiTrack* track, } else e.setPitch(ev.dataA()); + e.setVelo(0); e.setVeloOff(ev.dataB()); e.setLenTick(0); @@ -751,19 +750,15 @@ void Audio::collectEvents(MusECore::MidiTrack* track, unsigned int cts, unsigned int pitch = ev.pitch(); int velo = ev.velo(); if (track->type() == Track::DRUM) { - // // Map drum-notes to the drum-map values - // int instr = ev.pitch(); pitch = MusEGlobal::drumMap[instr].anote; port = MusEGlobal::drumMap[instr].port; //This changes to non-default port channel = MusEGlobal::drumMap[instr].channel; velo = int(double(velo) * (double(MusEGlobal::drumMap[instr].vol) / 100.0)) ; } - else { //FINDMICHJETZT don't transpose for new style drum tracks - // + else if (track->type() != Track::NEW_DRUM) { // transpose non drum notes - // pitch += (track->transposition + MusEGlobal::song->globalPitchShift()); } @@ -985,7 +980,7 @@ void Audio::processMidi() // //Apply drum inkey: - if (track->type() == Track::DRUM) //FINDMICHJETZT schwierig... + if (track->type() == Track::DRUM) //FINDMICHJETZT does this work? { int pitch = event.dataA(); //Map note that is played according to MusEGlobal::drumInmap @@ -996,7 +991,11 @@ void Audio::processMidi() event.setA(MusEGlobal::drumMap[(unsigned int)MusEGlobal::drumInmap[pitch]].anote); event.setChannel(channel); } - else + else if (track->type() == Track::NEW_DRUM) + { + event.setA(track->map_drum_in(event.dataA())); + } + else { //Track transpose if non-drum prePitch = event.dataA(); int pitch = prePitch + track->transposition; diff --git a/muse2/muse/midiedit/dcanvas.cpp b/muse2/muse/midiedit/dcanvas.cpp index 22db70d0..7daaff29 100644 --- a/muse2/muse/midiedit/dcanvas.cpp +++ b/muse2/muse/midiedit/dcanvas.cpp @@ -1306,13 +1306,17 @@ int DrumCanvas::pitch_and_track_to_instrument(int pitch, MusECore::Track* track) return -1; } -void DrumCanvas::propagate_drummap_change(int instr) +void DrumCanvas::propagate_drummap_change(int instr, bool update_druminmap) { const QSet& tracks=instrument_map[instr].tracks; int index=instrument_map[instr].pitch; for (QSet::const_iterator it = tracks.begin(); it != tracks.end(); it++) + { dynamic_cast(*it)->drummap()[index] = ourDrumMap[instr]; + if (update_druminmap) + dynamic_cast(*it)->update_drum_in_map(); + } } diff --git a/muse2/muse/midiedit/dcanvas.h b/muse2/muse/midiedit/dcanvas.h index 581de9d7..2911862e 100644 --- a/muse2/muse/midiedit/dcanvas.h +++ b/muse2/muse/midiedit/dcanvas.h @@ -166,7 +166,7 @@ class DrumCanvas : public EventCanvas { MusECore::DrumMap* getOurDrumMap() { return ourDrumMap; } //FINDMICH UGLY int getOurDrumMapSize() { return instrument_map.size(); } //FINDMICH UGLY QVector& get_instrument_map() { return instrument_map; } //FINDMICH UGLY - void propagate_drummap_change(int instrument); //FINDMICH move to drumedit + void propagate_drummap_change(int instrument, bool update_druminmap); //FINDMICH move to drumedit void rebuildOurDrumMap(); }; diff --git a/muse2/muse/midiedit/dlist.cpp b/muse2/muse/midiedit/dlist.cpp index 4ad971e7..3399b78e 100644 --- a/muse2/muse/midiedit/dlist.cpp +++ b/muse2/muse/midiedit/dlist.cpp @@ -517,7 +517,7 @@ void DList::viewMousePressEvent(QMouseEvent* ev) } if (!old_style_drummap_mode && dm_old != *dm) //something changed and we're in new style mode? - dcanvas->propagate_drummap_change(dm-ourDrumMap); + dcanvas->propagate_drummap_change(dm-ourDrumMap, (dm_old.enote != dm->enote)); MusEGlobal::song->update(SC_DRUMMAP); //redraw(); //this is done by the songChanged slot @@ -787,7 +787,7 @@ void DList::returnPressed() } if (editEntryOld != *editEntry) - dcanvas->propagate_drummap_change(editEntry-ourDrumMap); + dcanvas->propagate_drummap_change(editEntry-ourDrumMap, false); selectedColumn = -1; editor->hide(); @@ -854,7 +854,7 @@ void DList::pitchEdited() } if (editEntryOld != *editEntry) - dcanvas->propagate_drummap_change(editEntry-ourDrumMap); + dcanvas->propagate_drummap_change(editEntry-ourDrumMap, (editEntryOld.enote!=editEntry->enote)); selectedColumn = -1; pitch_editor->hide(); diff --git a/muse2/muse/track.cpp b/muse2/muse/track.cpp index e24ddad9..8f213616 100644 --- a/muse2/muse/track.cpp +++ b/muse2/muse/track.cpp @@ -431,6 +431,7 @@ 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)); + update_drum_in_map(); for (MusEGlobal::global_drum_ordering_t::iterator it=MusEGlobal::global_drum_ordering.begin(); it!=MusEGlobal::global_drum_ordering.end(); it++) if (it->first == &mt) @@ -495,11 +496,17 @@ void MidiTrack::init_drummap(bool write_ordering) MusEGlobal::global_drum_ordering.push_back(std::pair(this,idx)); } + update_drum_in_map(); + for (int i=0;i<128;i++) _drummap_hidden[i]=false; } - +void MidiTrack::update_drum_in_map() +{ + for (int i=0;i<127;i++) + drum_in_map[_drummap[i].enote]=i; +} //--------------------------------------------------------- // height @@ -966,7 +973,7 @@ void MidiTrack::readOurDrumSettings(Xml& xml) case Xml::TagStart: if (tag == "tied") _drummap_tied_to_patch = xml.parseInt(); - else if (tag == "our_drummap") + else if (tag == "our_drummap") readOurDrumMap(xml); else xml.unknown("MidiTrack::readOurDrumSettings"); @@ -1068,7 +1075,10 @@ void MidiTrack::readOurDrumMap(Xml& xml) case Xml::TagEnd: if (tag == "our_drummap") + { + update_drum_in_map(); return; + } default: break; diff --git a/muse2/muse/track.h b/muse2/muse/track.h index a958ca74..73f18cc2 100644 --- a/muse2/muse/track.h +++ b/muse2/muse/track.h @@ -232,7 +232,8 @@ class MidiTrack : public Track { DrumMap* _drummap; // _drummap[foo].anote is always equal to foo bool* _drummap_hidden; // _drummap und _drummap_hidden will be an array[128] bool _drummap_tied_to_patch; //if true, changing patch also changes drummap - + int drum_in_map[128]; + void init(); void init_drummap(bool write_ordering=false); void remove_ourselves_from_drum_ordering(); @@ -311,6 +312,8 @@ class MidiTrack : public Track { DrumMap* drummap() { return _drummap; } bool* drummap_hidden() { return _drummap_hidden; } + int map_drum_in(int enote) { return drum_in_map[enote]; } + void update_drum_in_map(); }; } // namespace MusECore -- cgit v1.2.3 From 0e67ba1af056a0df0b6b01c70bb6cb12063479a8 Mon Sep 17 00:00:00 2001 From: Florian Jung Date: Sun, 9 Oct 2011 17:10:21 +0000 Subject: settings for importing midi --- muse2/muse/conf.cpp | 3 + muse2/muse/gconfig.cpp | 1 + muse2/muse/gconfig.h | 1 + muse2/muse/importmidi.cpp | 21 +- muse2/muse/midiedit/scoreedit.cpp | 3 + muse2/muse/widgets/configmidifilebase.ui | 491 +++++++++++++++++-------------- muse2/muse/widgets/musewidgetsplug.cpp | 1 + 7 files changed, 285 insertions(+), 236 deletions(-) (limited to 'muse2') diff --git a/muse2/muse/conf.cpp b/muse2/muse/conf.cpp index 027ad431..22259041 100644 --- a/muse2/muse/conf.cpp +++ b/muse2/muse/conf.cpp @@ -1610,6 +1610,8 @@ void MidiFileConfig::updateValues() optNoteOffs->setChecked(MusEGlobal::config.expOptimNoteOffs); twoByteTimeSigs->setChecked(MusEGlobal::config.exp2ByteTimeSigs); splitPartsCheckBox->setChecked(MusEGlobal::config.importMidiSplitParts); + newDrumsCheckbox->setChecked(MusEGlobal::config.importMidiNewStyleDrum); + oldDrumsCheckbox->setChecked(!MusEGlobal::config.importMidiNewStyleDrum); } //--------------------------------------------------------- @@ -1629,6 +1631,7 @@ void MidiFileConfig::okClicked() MusEGlobal::config.expOptimNoteOffs = optNoteOffs->isChecked(); MusEGlobal::config.exp2ByteTimeSigs = twoByteTimeSigs->isChecked(); MusEGlobal::config.importMidiSplitParts = splitPartsCheckBox->isChecked(); + MusEGlobal::config.importMidiNewStyleDrum = newDrumsCheckbox->isChecked(); MusEGlobal::muse->changeConfig(true); // write config file close(); diff --git a/muse2/muse/gconfig.cpp b/muse2/muse/gconfig.cpp index 65397fe4..8aff870d 100644 --- a/muse2/muse/gconfig.cpp +++ b/muse2/muse/gconfig.cpp @@ -140,6 +140,7 @@ MusEGui::GlobalConfigValues config = { false, // midi export file 2 byte timesigs instead of 4 true, // optimize midi export file note offs true, // Split imported tracks into multiple parts. + true, // importMidiNewStyleDrum 1, // startMode QString(""), // start song path 384, // gui division diff --git a/muse2/muse/gconfig.h b/muse2/muse/gconfig.h index a6b55557..cf205eba 100644 --- a/muse2/muse/gconfig.h +++ b/muse2/muse/gconfig.h @@ -121,6 +121,7 @@ struct GlobalConfigValues { bool exp2ByteTimeSigs; // Export 2 byte time sigs instead of 4 bytes bool expOptimNoteOffs; // Save space by replacing note offs with note on velocity 0 bool importMidiSplitParts; // Split imported tracks into multiple parts. + bool importMidiNewStyleDrum; // Use new style drum tracks int startMode; // 0 - start with last song // 1 - start with default template diff --git a/muse2/muse/importmidi.cpp b/muse2/muse/importmidi.cpp index 90e8cecb..86738fe4 100644 --- a/muse2/muse/importmidi.cpp +++ b/muse2/muse/importmidi.cpp @@ -181,8 +181,12 @@ bool MusE::importMidi(const QString name, bool merge) MusECore::MidiTrack* track = new MusECore::MidiTrack(); if ((*t)->isDrumTrack) - track->setType(MusECore::Track::NEW_DRUM); //FINDMICHJETZT config option - //track->setType(MusECore::Track::DRUM); + { + if (MusEGlobal::config.importMidiNewStyleDrum) + track->setType(MusECore::Track::NEW_DRUM); + else + track->setType(MusECore::Track::DRUM); + } track->setOutChannel(channel); track->setOutPort(port); @@ -201,12 +205,13 @@ bool MusE::importMidi(const QString name, bool merge) // Hmm. buildMidiEventList already takes care of this. // But it seems to work. How? Must test. if (channel == 9 && MusEGlobal::song->mtype() != MT_UNKNOWN) { - track->setType(MusECore::Track::NEW_DRUM); //FINDMICHJETZT config option - /* + if (MusEGlobal::config.importMidiNewStyleDrum) + track->setType(MusECore::Track::NEW_DRUM); + else + { track->setType(MusECore::Track::DRUM); - // + // remap drum pitch with drumOutmap - // MusECore::EventList* tevents = track->events(); for (MusECore::iEvent i = tevents->begin(); i != tevents->end(); ++i) { MusECore::Event ev = i->second; @@ -222,9 +227,9 @@ bool MusE::importMidi(const QString name, bool merge) if(mc) ev.setA((ctl & ~0xff) | MusEGlobal::drumOutmap[ctl & 0x7f]); } - } - */ } + } + } processTrack(track); diff --git a/muse2/muse/midiedit/scoreedit.cpp b/muse2/muse/midiedit/scoreedit.cpp index 8f647966..cf436465 100644 --- a/muse2/muse/midiedit/scoreedit.cpp +++ b/muse2/muse/midiedit/scoreedit.cpp @@ -4603,6 +4603,9 @@ void ScoreCanvas::add_new_parts(const std::map< MusECore::Part*, std::set o drum editor: channel-stuff * o clearly state in the changelog: when having multiple drumeditors open, diff --git a/muse2/muse/widgets/configmidifilebase.ui b/muse2/muse/widgets/configmidifilebase.ui index 920596ec..c050450c 100644 --- a/muse2/muse/widgets/configmidifilebase.ui +++ b/muse2/muse/widgets/configmidifilebase.ui @@ -1,238 +1,273 @@ - - - - - ConfigMidiFileBase - - - - 0 - 0 - 548 - 353 - - - - MusE: Config Midi File Import/Export - - - true - - + + ConfigMidiFileBase + + + + 0 + 0 + 548 + 346 + + + + MusE: Config Midi File Import/Export + + + true + + + + + + + 0 + 0 + + + + Import: + + - - - - 5 - 1 - 0 - 0 - - - - Import: - - - - - - Split tracks into &parts - - - Alt+P - - - Split tracks into parts, or one single part - - - - - + + + Split tracks into parts, or one single part + + + Split tracks into &parts + + + Alt+P + + - - - - 5 - 7 - 0 - 0 - + + + + + Use new-style drum tracks - - Export: + + true - - - - - - - - - 96 - - - - - 192 - - - - - 384 - - - - - - - - true - - - Enable extended smf format (currently not implemented) - - - - - - - Use &2-byte time signatures instead of standard 4 - - - Alt+2 - - - - - - - Copyright: - - - false - - - - - - - Format: - - - false - - - - - - - Division: - - - false - - - - - - - Save space by replacing note-offs with &zero velocity note-ons - - - Alt+Z - - - - - - - - 0 (single track) - - - - - 1 (multiple tracks) - - - - - - - - - - - 0 + + + + + + Use old-style drum tracks - - 6 - - - - - - 20 - 20 - - - - QSizePolicy::Expanding - - - Qt::Horizontal - - - - - - - &OK - - - - - - true - - - true - - - - - - - &Cancel - - - - - - true - - - - + + + + + + + + + + + + 0 + 0 + + + + Export: + + + + + + + + + + 96 + + + + + 192 + + + + + 384 + + + + + + + + true + + + Enable extended smf format (currently not implemented) + + + + + + + Use &2-byte time signatures instead of standard 4 + + + Alt+2 + + + + + + + Copyright: + + + false + + + + + + + Format: + + + false + + + + + + + Division: + + + false + + + + + + + Save space by replacing note-offs with &zero velocity note-ons + + + Alt+Z + + + + + + + + 0 (single track) + + + + + 1 (multiple tracks) + + + + + + + + + + 6 + + + 0 + + + + + Qt::Horizontal + + + QSizePolicy::Expanding + + + + 20 + 20 + + + + + + + + &OK + + + + + + true + + + true + + + + + + + &Cancel + + + + + + true + + + - - - - - buttonOk - clicked() - ConfigMidiFileBase - accept() - - - buttonCancel - clicked() - ConfigMidiFileBase - reject() - - + + + + + + + + buttonOk + clicked() + ConfigMidiFileBase + accept() + + + 20 + 20 + + + 20 + 20 + + + + + buttonCancel + clicked() + ConfigMidiFileBase + reject() + + + 20 + 20 + + + 20 + 20 + + + + diff --git a/muse2/muse/widgets/musewidgetsplug.cpp b/muse2/muse/widgets/musewidgetsplug.cpp index 26a3054d..c1674e75 100644 --- a/muse2/muse/widgets/musewidgetsplug.cpp +++ b/muse2/muse/widgets/musewidgetsplug.cpp @@ -167,6 +167,7 @@ GlobalConfigValues config = { false, // midi export file 2 byte timesigs instead of 4 true, // optimize midi export file note offs true, // Split imported tracks into multiple parts. + true, // importMidiNewStyleDrum 1, // startMode QString(""), // start song path 384, // gui division -- cgit v1.2.3 From 182474fce42414f8f8c5545c4ce822aa5ce73c2c Mon Sep 17 00:00:00 2001 From: Florian Jung Date: Mon, 10 Oct 2011 12:00:09 +0000 Subject: steprec and dlist-enote-changing fixes steprec now works for new style drum tracks --- muse2/muse/midiedit/dcanvas.cpp | 42 +++++++++++++++++++++++++++------------ muse2/muse/midiedit/dlist.cpp | 34 ++++++++++++++++++++++++++++++- muse2/muse/midiedit/scoreedit.cpp | 11 +++++----- muse2/muse/steprec.cpp | 9 ++++++--- muse2/muse/steprec.h | 2 +- 5 files changed, 75 insertions(+), 23 deletions(-) (limited to 'muse2') diff --git a/muse2/muse/midiedit/dcanvas.cpp b/muse2/muse/midiedit/dcanvas.cpp index 7daaff29..3431eabf 100644 --- a/muse2/muse/midiedit/dcanvas.cpp +++ b/muse2/muse/midiedit/dcanvas.cpp @@ -158,7 +158,8 @@ DrumCanvas::~DrumCanvas() if (must_delete_our_drum_map && ourDrumMap!=NULL) delete [] ourDrumMap; - delete steprec; + + delete steprec; } //--------------------------------------------------------- @@ -808,19 +809,22 @@ void DrumCanvas::dragLeaveEvent(QDragLeaveEvent*) // keyPressed - called from DList //--------------------------------------------------------- -void DrumCanvas::keyPressed(int index, int velocity) //FINDMICH later +void DrumCanvas::keyPressed(int index, int velocity) { + using MusECore::MidiTrack; + // called from DList - play event - int port = ourDrumMap[index].port; - int channel = ourDrumMap[index].channel; - int pitch = ourDrumMap[index].anote; + int port = old_style_drummap_mode ? ourDrumMap[index].port : dynamic_cast(*instrument_map[index].tracks.begin())->outPort(); + int channel = old_style_drummap_mode ? ourDrumMap[index].channel : dynamic_cast(*instrument_map[index].tracks.begin())->outChannel(); + int pitch = old_style_drummap_mode ? ourDrumMap[index].anote : instrument_map[index].pitch; // play note: MusECore::MidiPlayEvent e(0, port, channel, 0x90, pitch, velocity); MusEGlobal::audio->msgPlayMidiEvent(&e); - if (_steprec && pos[0] >= start_tick /* && pos[0] < end_tick [removed by flo93: this is handled in steprec->record] */ && curPart) - steprec->record(curPart,index,ourDrumMap[index].len,editor->raster(),velocity,MusEGlobal::globalKeyState&Qt::ControlModifier,MusEGlobal::globalKeyState&Qt::ShiftModifier); + if (_steprec && pos[0] >= start_tick /* && pos[0] < end_tick [removed by flo93: this is handled in steprec->record] */ && + curPart && instrument_map[index].tracks.contains(curPart->track()) ) + steprec->record(curPart,instrument_map[index].pitch,ourDrumMap[index].len,editor->raster(),velocity,MusEGlobal::globalKeyState&Qt::ControlModifier,MusEGlobal::globalKeyState&Qt::ShiftModifier, -1 /* invalid pitch as "really played" -> the "insert rest" feature is never triggered */); } @@ -828,12 +832,14 @@ void DrumCanvas::keyPressed(int index, int velocity) //FINDMICH later // keyReleased //--------------------------------------------------------- -void DrumCanvas::keyReleased(int index, bool) //FINDMICH later +void DrumCanvas::keyReleased(int index, bool) { + using MusECore::MidiTrack; + // called from DList - silence playing event - int port = ourDrumMap[index].port; - int channel = ourDrumMap[index].channel; - int pitch = ourDrumMap[index].anote; + int port = old_style_drummap_mode ? ourDrumMap[index].port : dynamic_cast(*instrument_map[index].tracks.begin())->outPort(); + int channel = old_style_drummap_mode ? ourDrumMap[index].channel : dynamic_cast(*instrument_map[index].tracks.begin())->outChannel(); + int pitch = old_style_drummap_mode ? ourDrumMap[index].anote : instrument_map[index].pitch; // release note: MusECore::MidiPlayEvent e(0, port, channel, 0x90, pitch, 0); @@ -1283,7 +1289,7 @@ void DrumCanvas::moveAwayUnused() //--------------------------------------------------------- // midiNote //--------------------------------------------------------- -void DrumCanvas::midiNote(int pitch, int velo) //FINDMICH later. +void DrumCanvas::midiNote(int pitch, int velo) { if (debugMsg) printf("DrumCanvas::midiNote: pitch=%i, velo=%i\n", pitch, velo); @@ -1291,7 +1297,17 @@ void DrumCanvas::midiNote(int pitch, int velo) //FINDMICH later. && !MusEGlobal::audio->isPlaying() && velo && pos[0] >= start_tick /* && pos[0] < end_tick [removed by flo93: this is handled in steprec->record()] */ && !(MusEGlobal::globalKeyState & Qt::AltModifier)) { - steprec->record(curPart,MusEGlobal::drumInmap[pitch],ourDrumMap[(int)MusEGlobal::drumInmap[pitch]].len,editor->raster(),velo,MusEGlobal::globalKeyState&Qt::ControlModifier,MusEGlobal::globalKeyState&Qt::ShiftModifier); + + int ourDrumMapSize=getOurDrumMapSize(); + int i; + for (i=0;itrack()) && ourDrumMap[i].enote==pitch) + break; + } + + if (i!=ourDrumMapSize) + steprec->record(curPart,instrument_map[i].pitch,ourDrumMap[i].len,editor->raster(),velo,MusEGlobal::globalKeyState&Qt::ControlModifier,MusEGlobal::globalKeyState&Qt::ShiftModifier, pitch); } } diff --git a/muse2/muse/midiedit/dlist.cpp b/muse2/muse/midiedit/dlist.cpp index 3399b78e..1d8436b6 100644 --- a/muse2/muse/midiedit/dlist.cpp +++ b/muse2/muse/midiedit/dlist.cpp @@ -372,8 +372,25 @@ void DList::viewMousePressEvent(QMouseEvent* ev) //TODO: Set all the notes on the track with instrument=dm->enote to instrument=val MusEGlobal::drumInmap[val] = instrument; } + else + { + //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 + for (QSet::iterator it = dcanvas->get_instrument_map()[instrument].tracks.begin(); it!=dcanvas->get_instrument_map()[instrument].tracks.end(); it++) + { + MusECore::MidiTrack* mt = dynamic_cast(*it); + mt->drummap()[mt->map_drum_in(val)].enote=dm->enote; + } + // propagating this is unneccessary as it's already done. + // updating the drumInmap is unneccessary, as the propagate call below + // does this for us. + // updating ourDrumMap is unneccessary because the song->update(SC_DRUMMAP) + // does this for us. + } + dm->enote = val; break; + case COL_NOTELENGTH: val = dm->len + incVal; if (val < 0) @@ -844,7 +861,22 @@ void DList::pitchEdited() } //TODO: Set all the notes on the track with instrument=dm->enote to instrument=val MusEGlobal::drumInmap[val] = instrument; - } + } + else + { + //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 + for (QSet::iterator it = dcanvas->get_instrument_map()[instrument].tracks.begin(); it!=dcanvas->get_instrument_map()[instrument].tracks.end(); it++) + { + MusECore::MidiTrack* mt = dynamic_cast(*it); + mt->drummap()[mt->map_drum_in(val)].enote=editEntry->enote; + } + // propagating this is unneccessary as it's already done. + // updating the drumInmap is unneccessary, as the propagate call below + // does this for us. + // updating ourDrumMap is unneccessary because the song->update(SC_DRUMMAP) + // does this for us. + } editEntry->enote = val; break; diff --git a/muse2/muse/midiedit/scoreedit.cpp b/muse2/muse/midiedit/scoreedit.cpp index cf436465..5fa117f5 100644 --- a/muse2/muse/midiedit/scoreedit.cpp +++ b/muse2/muse/midiedit/scoreedit.cpp @@ -4592,8 +4592,11 @@ void ScoreCanvas::add_new_parts(const std::map< MusECore::Part*, std::set