diff options
-rw-r--r-- | muse2/muse/midiedit/dcanvas.cpp | 315 | ||||
-rw-r--r-- | muse2/muse/midiedit/dlist.cpp | 21 | ||||
-rw-r--r-- | muse2/muse/midiedit/prcanvas.cpp | 291 | ||||
-rw-r--r-- | muse2/muse/part.cpp | 243 |
4 files changed, 2 insertions, 868 deletions
diff --git a/muse2/muse/midiedit/dcanvas.cpp b/muse2/muse/midiedit/dcanvas.cpp index fa7da753..a7e33bd1 100644 --- a/muse2/muse/midiedit/dcanvas.cpp +++ b/muse2/muse/midiedit/dcanvas.cpp @@ -138,34 +138,6 @@ void DrumCanvas::moveCanvasItems(CItemList& items, int dp, int dx, DragType dtyp if(npartoffset > 0) { - // Create new part... - // if there are several events that are moved outside the part, it will be recreated for each - // so the part _in_ the event will not be valid, ask the authority. -// Part* newPart = part->clone(); - //Part* newPart = Canvas::part()->clone(); - -// newPart->setLenTick(newPart->lenTick() + npartoffset); - //audio->msgChangePart(part, newPart,false); - -// modified = SC_PART_MODIFIED; - - // BUG FIX: #1650953 - // Added by T356. - // Fixes posted "select and drag past end of part - crashing" bug -// for(iPart ip = editor->parts()->begin(); ip != editor->parts()->end(); ++ip) -// { -// if(ip->second == part) -// { -// editor->parts()->erase(ip); -// break; -// } -// } - -// editor->parts()->add(newPart); -// audio->msgChangePart(part, newPart,false); - -// if(parts2change.find(part) == parts2change.end()) -// parts2change.insert(std::pair<Part*, Part*> (part, newPart)); iPartToChange ip2c = parts2change.find(part); if(ip2c == parts2change.end()) { @@ -174,14 +146,6 @@ void DrumCanvas::moveCanvasItems(CItemList& items, int dp, int dx, DragType dtyp } else ip2c->second.xdiff = npartoffset; - - - //part = newPart; // reassign - //item->setPart(part); - //item->setEvent(newEvent); - //curPart = part; - //curPartId = curPart->sn(); - } } @@ -210,7 +174,6 @@ void DrumCanvas::moveCanvasItems(CItemList& items, int dp, int dx, DragType dtyp editor->parts()->add(newPart); // Indicate no undo, and do port controller values but not clone parts. - //audio->msgChangePart(opart, newPart, false); audio->msgChangePart(opart, newPart, false, true, false); ip2c->second.npart = newPart; @@ -251,7 +214,6 @@ void DrumCanvas::moveCanvasItems(CItemList& items, int dp, int dx, DragType dtyp break; // Do not process if the event has already been processed (meaning it's an event in a clone part)... - //if(moveItem(ci, newpos, dtype)) if(idl != doneList.end()) // Just move the canvas item. ci->move(newpos); @@ -282,14 +244,10 @@ void DrumCanvas::moveCanvasItems(CItemList& items, int dp, int dx, DragType dtyp // moveItem //--------------------------------------------------------- -// Changed by T356. -//bool DrumCanvas::moveItem(CItem* item, const QPoint& pos, DragType dtype, int* pflags) bool DrumCanvas::moveItem(CItem* item, const QPoint& pos, DragType dtype) { DEvent* nevent = (DEvent*) item; - // Changed by T356. - //MidiPart* part = (MidiPart*)Canvas::part(); // part can be dynamically recreated, ask the authority MidiPart* part = (MidiPart*)nevent->part(); Event event = nevent->event(); @@ -305,40 +263,6 @@ bool DrumCanvas::moveItem(CItem* item, const QPoint& pos, DragType dtype) newEvent.setPitch(npitch); newEvent.setTick(ntick); - // Removed by T356. - /* - // Added by T356. - int modified = 0; - //song->startUndo(); - int diff = newEvent.endTick()-part->lenTick(); - if (diff > 0) // too short part? extend it - { - // if there are several events that are moved outside the part, it will be recreated for each - // so the part _in_ the event will not be valid, ask the authority. - //Part* newPart = part->clone(); - MidiPart* newPart = (MidiPart*)Canvas::part()->clone(); - newPart->setLenTick(newPart->lenTick()+diff); - audio->msgChangePart(Canvas::part(), newPart,false); - - modified = SC_PART_MODIFIED; - part = newPart; // reassign - for(iPart i = editor->parts()->begin(); i != editor->parts()->end(); ++i) - { - if(i->second == Canvas::part()) - { - editor->parts()->erase(i); - break; - } - } - editor->parts()->add(part); - item->setPart(part); - item->setEvent(newEvent); - curPart = part; - curPartId = curPart->sn(); - } - */ - - // Added by T356. // msgAddEvent and msgChangeEvent (below) will set these, but set them here first? //item->setPart(part); item->setEvent(newEvent); @@ -349,19 +273,13 @@ bool DrumCanvas::moveItem(CItem* item, const QPoint& pos, DragType dtype) if (dtype == MOVE_COPY || dtype == MOVE_CLONE) { // Indicate no undo, and do not do port controller values and clone parts. - //audio->msgAddEvent(newEvent, part, false); audio->msgAddEvent(newEvent, part, false, false, false); } else { // Indicate no undo, and do not do port controller values and clone parts. - //audio->msgChangeEvent(event, newEvent, part, false); audio->msgChangeEvent(event, newEvent, part, false, false, false); } - // Removed by T356. - //if(pflags) - // *pflags = modified; - return true; } @@ -407,7 +325,6 @@ void DrumCanvas::resizeItem(CItem* item, bool) DEvent* nevent = (DEvent*) item; Event ev = nevent->event(); // Indicate do undo, and do not do port controller values and clone parts. - //audio->msgDeleteEvent(ev, nevent->part()); audio->msgDeleteEvent(ev, nevent->part(), true, false, false); } @@ -426,7 +343,6 @@ void DrumCanvas::newItem(CItem* item, bool noSnap, bool replace) if (!noSnap) x = editor->rasterVal(x); event.setTick(x - nevent->part()->tick()); - //int npitch = drumMap[y2pitch(item->y())].enote; int npitch = event.pitch(); event.setPitch(npitch); @@ -446,7 +362,6 @@ void DrumCanvas::newItem(CItem* item, bool noSnap, bool replace) if (ev.pitch() == npitch) { // Indicate do undo, and do not do port controller values and clone parts. - //audio->msgDeleteEvent(ev, nevent->part()); audio->msgDeleteEvent(ev, nevent->part(), true, false, false); if (replace) break; @@ -465,13 +380,11 @@ void DrumCanvas::newItem(CItem* item, bool noSnap, bool replace) Part* newPart = part->clone(); newPart->setLenTick(newPart->lenTick()+diff); // Indicate no undo, and do port controller values but not clone parts. - //audio->msgChangePart(part, newPart,false); audio->msgChangePart(part, newPart, false, true, false); modified=modified|SC_PART_MODIFIED; part = newPart; // reassign } // Indicate no undo, and do not do port controller values and clone parts. - //audio->msgAddEvent(event, part,false); audio->msgAddEvent(event, part, false, false, false); song->endUndo(modified); @@ -485,7 +398,6 @@ bool DrumCanvas::deleteItem(CItem* item) { Event ev = ((DEvent*)item)->event(); // Indicate do undo, and do not do port controller values and clone parts. - //audio->msgDeleteEvent(ev, ((DEvent*)item)->part()); audio->msgDeleteEvent(ev, ((DEvent*)item)->part(), true, false, false); return false; } @@ -554,10 +466,6 @@ void DrumCanvas::drawItem(QPainter&p, const CItem*item, const QRect& rect) void DrumCanvas::drawMoving(QPainter& p, const CItem* item, const QRect& rect) { - //if(((DEvent*)item)->part() != curPart) - // return; - //if(!item->isMoving()) - // return; QPolygon pa(4); QPoint pt = map(item->mp()); int x = pt.x(); @@ -658,7 +566,6 @@ void DrumCanvas::cmd(int cmd) DEvent* e = (DEvent*)(i->second); Event event = e->event(); // Indicate no undo, and do not do port controller values and clone parts. - //audio->msgDeleteEvent(event, e->part(), false); audio->msgDeleteEvent(event, e->part(), false, false, false); } song->endUndo(SC_EVENT_REMOVED); @@ -760,7 +667,6 @@ void DrumCanvas::cmd(int cmd) Event newEvent = event.clone(); newEvent.setLenTick(drumMap[event.pitch()].len); // Indicate no undo, and do not do port controller values and clone parts. - //audio->msgChangeEvent(event, newEvent, devent->part() , false); audio->msgChangeEvent(event, newEvent, devent->part(), false, false, false); } } @@ -800,8 +706,6 @@ void DrumCanvas::cmd(int cmd) case CMD_RIGHT_NOSNAP: { Pos p(pos[0] + editor->rasterStep(pos[0]), true); - //if (p > part->tick()) - // p = part->tick(); song->setPos(0, p, true, true, true); //CDW } break; @@ -810,68 +714,6 @@ void DrumCanvas::cmd(int cmd) redraw(); } -/* -//--------------------------------------------------------- -// getTextDrag -//--------------------------------------------------------- - -Q3TextDrag* DrumCanvas::getTextDrag(QWidget* parent) - { - //--------------------------------------------------- - // generate event list from selected events - //--------------------------------------------------- - - EventList el; - unsigned startTick = MAXINT; - for (iCItem i = items.begin(); i != items.end(); ++i) { - if (!i->second->isSelected()) - continue; - DEvent* ne = (DEvent*)(i->second); - Event e = ne->event(); - if (startTick == MAXINT) - startTick = e.tick(); - el.add(e); - } - - //--------------------------------------------------- - // write events as XML into tmp file - //--------------------------------------------------- - - FILE* tmp = tmpfile(); - if (tmp == 0) { - fprintf(stderr, "EventCanvas::copy() fopen failed: %s\n", - strerror(errno)); - return 0; - } - Xml xml(tmp); - - int level = 0; - for (ciEvent e = el.begin(); e != el.end(); ++e) - e->second.write(level, xml, -startTick); - - //--------------------------------------------------- - // read tmp file into QTextDrag Object - //--------------------------------------------------- - - fflush(tmp); - struct stat f_stat; - if (fstat(fileno(tmp), &f_stat) == -1) { - fprintf(stderr, "EventCanvas::copy() fstat failes:<%s>\n", - strerror(errno)); - fclose(tmp); - return 0; - } - int n = f_stat.st_size; - char* fbuf = (char*)mmap(0, n+1, PROT_READ|PROT_WRITE, - MAP_PRIVATE, fileno(tmp), 0); - fbuf[n] = 0; - Q3TextDrag* drag = new Q3TextDrag(QString(fbuf), parent); - drag->setSubtype("eventlist"); - munmap(fbuf, n); - fclose(tmp); - return drag; - } -*/ //--------------------------------------------------------- // copy @@ -886,67 +728,6 @@ void DrumCanvas::copy() QApplication::clipboard()->setMimeData(md, QClipboard::Clipboard); } -/* -//--------------------------------------------------------- -// paste -//--------------------------------------------------------- - -int DrumCanvas::pasteAt(const QString& pt, int pos) - { - QByteArray ba = pt.toLatin1(); - const char* p = ba.constData(); - Xml xml(p); - - // Added by T356. - int modified = SC_EVENT_INSERTED; - - song->startUndo(); - for (;;) { - Xml::Token token = xml.parse(); - QString tag = xml.s1(); - switch (token) { - case Xml::Error: - case Xml::End: - song->endUndo(modified); - return pos; - case Xml::TagStart: - if (tag == "event") { - Event e(Note); - e.read(xml); - - // Added by T356. - int tick = e.tick() + pos - curPart->tick(); - if (tick<0) { - printf("DrumCanvas::pasteAt ERROR: trying to add event before current part!\n"); - song->endUndo(SC_EVENT_INSERTED); - //delete el; - return pos; - } - e.setTick(tick); - int diff = e.endTick() - curPart->lenTick(); - if (diff > 0) {// too short part? extend it - Part* newPart = curPart->clone(); - newPart->setLenTick(newPart->lenTick()+diff); - // Indicate no undo, and do port controller values but not clone parts. - audio->msgChangePart(curPart, newPart, false, true, false); - - modified=modified|SC_PART_MODIFIED; - curPart = newPart; // reassign - } - - // Indicate no undo, and do not do port controller values and clone parts. - audio->msgAddEvent(e, curPart, false, false, false); - } - else - xml.unknown("DCanvas::pasteAt"); - break; - case Xml::TagEnd: - default: - break; - } - } - } -*/ //--------------------------------------------------------- // paste @@ -972,10 +753,6 @@ void DrumCanvas::startDrag(CItem* /* item*/, bool copymode) QMimeData* md = getTextDrag(); if (md) { -// QApplication::clipboard()->setData(drag, QClipboard::Clipboard); // This line NOT enabled in muse-1 - //QApplication::clipboard()->setMimeData(md); // TODO CHECK Tim. - //QApplication::clipboard()->setMimeData(drag->mimeData()); // - // "Note that setMimeData() assigns ownership of the QMimeData object to the QDrag object. // The QDrag must be constructed on the heap with a parent QWidget to ensure that Qt can // clean up after the drag and drop operation has been completed. " @@ -1014,40 +791,6 @@ void DrumCanvas::dragLeaveEvent(QDragLeaveEvent*) { } -/* -//--------------------------------------------------------- -// dropEvent -//--------------------------------------------------------- - -void DrumCanvas::viewDropEvent(QDropEvent* event) - { - QString text; - if (event->source() == this) { - printf("local DROP\n"); - //event->acceptProposedAction(); - //event->ignore(); // TODO CHECK Tim. - return; - } - //if (event->mimeData()->hasText()) { - if (event->mimeData()->hasFormat("text/x-muse-eventlist")) { - - //text = event->mimeData()->text(); - text = QString(event->mimeData()->data("text/x-muse-eventlist")); - -// printf("drop <%s>\n", text.ascii()); - int x = editor->rasterVal(event->pos().x()); - if (x < 0) - x = 0; - pasteAt(text, x); - //event->accept(); // TODO - } - else { - printf("cannot decode drop\n"); - //event->acceptProposedAction(); - //event->ignore(); // TODO CHECK Tim. - } - } -*/ //--------------------------------------------------------- // keyPressed - called from DList @@ -1099,26 +842,7 @@ void DrumCanvas::mapChanged(int spitch, int dpitch) typedef std::vector< std::pair<Part*, Event*> >::iterator idel_ev; typedef std::vector< std::pair<Part*, Event> >::iterator iadd_ev; - - /* - class delete_events : public std::vector< Part*, Event* > - { - public: - idel_ev find(Part* p, Event* e) - { - - }; - }; - class add_events : public std::vector< Part*, Event > - { - public: - iadd_ev find(Part* p, Event& e) - { - - }; - }; - */ - + MidiTrackList* tracks = song->midis(); for (ciMidiTrack t = tracks->begin(); t != tracks->end(); t++) { MidiTrack* curTrack = *t; @@ -1169,13 +893,9 @@ void DrumCanvas::mapChanged(int spitch, int dpitch) song->startUndo(); for (idel_ev i = delete_events.begin(); i != delete_events.end(); i++) { - //std::pair<Part*, Event*> pair = *i; - //Part* thePart = pair.first; - //Event* theEvent = pair.second; Part* thePart = (*i).first; Event* theEvent = (*i).second; // Indicate no undo, and do port controller values but not clone parts. - //audio->msgDeleteEvent(*theEvent, thePart, false); audio->msgDeleteEvent(*theEvent, thePart, false, true, false); } @@ -1188,13 +908,9 @@ void DrumCanvas::mapChanged(int spitch, int dpitch) drumOutmap[int(drumMap[int(dpitch)].anote)] = dpitch; for (iadd_ev i = add_events.begin(); i != add_events.end(); i++) { - //std::pair<Part*, Event> pair = *i; - //Part* thePart = pair.first; - //Event& theEvent = pair.second; Part* thePart = (*i).first; Event& theEvent = (*i).second; // Indicate no undo, and do port controller values but not clone parts. - //audio->msgAddEvent(theEvent, thePart, false); audio->msgAddEvent(theEvent, thePart, false, true, false); } @@ -1243,40 +959,12 @@ void DrumCanvas::modifySelected(NoteInfo::ValType type, int delta) } break; case NoteInfo::VAL_LEN: - /* - { - int len = event.lenTick() + delta; - if (len < 1) - len = 1; - newEvent.setLenTick(len); - } - */ printf("DrumCanvas::modifySelected - NoteInfo::VAL_LEN not implemented\n"); break; case NoteInfo::VAL_VELON: - /* - { - int velo = event->velo() + delta; - if (velo > 127) - velo = 127; - else if (velo < 0) - velo = 0; - newEvent.setVelo(velo); - } - */ printf("DrumCanvas::modifySelected - NoteInfo::VAL_VELON not implemented\n"); break; case NoteInfo::VAL_VELOFF: - /* - { - int velo = event.veloOff() + delta; - if (velo > 127) - velo = 127; - else if (velo < 0) - velo = 0; - newEvent.setVeloOff(velo); - } - */ printf("DrumCanvas::modifySelected - NoteInfo::VAL_VELOFF not implemented\n"); break; case NoteInfo::VAL_PITCH: @@ -1292,7 +980,6 @@ void DrumCanvas::modifySelected(NoteInfo::ValType type, int delta) } song->changeEvent(event, newEvent, part); // Indicate do not do port controller values and clone parts. - //song->addUndo(UndoOp(UndoOp::ModifyEvent, newEvent, event, part)); song->addUndo(UndoOp(UndoOp::ModifyEvent, newEvent, event, part, false, false)); } song->endUndo(SC_EVENT_MODIFIED); diff --git a/muse2/muse/midiedit/dlist.cpp b/muse2/muse/midiedit/dlist.cpp index 3b8670db..0b8bf3aa 100644 --- a/muse2/muse/midiedit/dlist.cpp +++ b/muse2/muse/midiedit/dlist.cpp @@ -23,9 +23,6 @@ #include "song.h" #include "scrollscale.h" -// enum DCols { COL_MUTE=0, COL_NAME, COL_QNT, COL_ENOTE, COL_LEN, -// COL_ANOTE, COL_CHANNEL, COL_PORT, -// COL_LV1, COL_LV2, COL_LV3, COL_LV4, COL_NONE=-1}; //--------------------------------------------------------- // draw @@ -51,7 +48,6 @@ void DList::draw(QPainter& p, const QRect& rect) if (yy > y + h) break; DrumMap* dm = &drumMap[i]; -// if (dm->selected) if (dm == currentlySelected) p.fillRect(x, yy, w, TH, Qt::yellow); // else @@ -60,13 +56,11 @@ void DList::draw(QPainter& p, const QRect& rect) for (int k = 0; k < h->count(); ++k) { int x = h->sectionPosition(k); int w = h->sectionSize(k); - ///QRect r = p.xForm(QRect(x+2, yy, w-4, TH)); QRect r = p.combinedTransform().mapRect(QRect(x+2, yy, w-4, TH)); QString s; int align = Qt::AlignVCenter | Qt::AlignHCenter; p.save(); - ///p.setWorldXForm(false); p.setWorldMatrixEnabled(false); switch (k) { case COL_VOL: @@ -149,16 +143,13 @@ void DList::draw(QPainter& p, const QRect& rect) // vertical Lines //--------------------------------------------------- - ///p.setWorldXForm(false); p.setWorldMatrixEnabled(false); int n = header->count(); x = 0; for (int i = 0; i < n; i++) { - //x += header->sectionSize(i); x += header->sectionSize(header->visualIndex(i)); p.drawLine(x, 0, x, height()); } - ///p.setWorldXForm(true); p.setWorldMatrixEnabled(true); } @@ -178,7 +169,6 @@ void DList::devicesPopupMenu(DrumMap* t, int x, int y, bool changeAll) if(n != t->port) { audio->msgIdle(true); - //audio->msgRemapPortDrumCtlEvents(getSelectedInstrument(), -1, -1, n); song->remapPortDrumCtrlEvents(getSelectedInstrument(), -1, -1, n); audio->msgIdle(false); t->port = n; @@ -188,13 +178,11 @@ void DList::devicesPopupMenu(DrumMap* t, int x, int y, bool changeAll) else { audio->msgIdle(true); // Delete all port controller events. - //audio->msgChangeAllPortDrumCtrlEvents(false); song->changeAllPortDrumCtrlEvents(false); for (int i = 0; i < DRUM_MAPSIZE; i++) drumMap[i].port = n; // Add all port controller events. - //audio->msgChangeAllPortDrumCtrlEvents(true); song->changeAllPortDrumCtrlEvents(true); audio->msgIdle(false); @@ -328,13 +316,11 @@ void DList::viewMousePressEvent(QMouseEvent* ev) if (ev->modifiers() & Qt::ControlModifier) { audio->msgIdle(true); // Delete all port controller events. - //audio->msgChangeAllPortDrumCtrlEvents(false); song->changeAllPortDrumCtrlEvents(false, true); for (int i = 0; i < DRUM_MAPSIZE; i++) drumMap[i].channel = val; // Add all port controller events. - //audio->msgChangeAllPortDrumCtrlEvents(true); song->changeAllPortDrumCtrlEvents(true, true); audio->msgIdle(false); song->update(SC_DRUMMAP); @@ -344,7 +330,6 @@ void DList::viewMousePressEvent(QMouseEvent* ev) if(val != dm->channel) { audio->msgIdle(true); - //audio->msgRemapPortDrumCtlEvents(pitch, -1, val, -1); song->remapPortDrumCtrlEvents(pitch, -1, val, -1); audio->msgIdle(false); dm->channel = val; @@ -419,7 +404,6 @@ void DList::viewMouseDoubleClickEvent(QMouseEvent* ev) { int x = ev->x(); int y = ev->y(); -// int button = ev->button(); unsigned pitch = y / TH; int section = header->logicalIndexAt(x); @@ -485,7 +469,6 @@ void DList::lineEdit(int line, int section) break; } - // editor->setText(dm->name); editor->end(false); editor->setGeometry(colx, coly, colw, colh); // In all cases but the column name, select all text: @@ -648,7 +631,7 @@ DList::DList(QHeaderView* h, QWidget* parent, int ymag) { setBg(Qt::white); if (!h){ - h = new QHeaderView(Qt::Horizontal, parent);} + h = new QHeaderView(Qt::Horizontal, parent);} header = h; scroll = 0; //ORCAN- CHECK if really needed: header->setTracking(true); @@ -670,8 +653,6 @@ DList::DList(QHeaderView* h, QWidget* parent, int ymag) DList::~DList() { -// if (currentlySelected != 0) -// currentlySelected->selected = false; //Reset the global thingie } //--------------------------------------------------------- diff --git a/muse2/muse/midiedit/prcanvas.cpp b/muse2/muse/midiedit/prcanvas.cpp index e59e8beb..a38e0ee1 100644 --- a/muse2/muse/midiedit/prcanvas.cpp +++ b/muse2/muse/midiedit/prcanvas.cpp @@ -300,34 +300,6 @@ void PianoCanvas::moveCanvasItems(CItemList& items, int dp, int dx, DragType dty if(npartoffset > 0) { - // Create new part... - // if there are several events that are moved outside the part, it will be recreated for each - // so the part _in_ the event will not be valid, ask the authority. -// Part* newPart = part->clone(); - //Part* newPart = Canvas::part()->clone(); - -// newPart->setLenTick(newPart->lenTick() + npartoffset); - //audio->msgChangePart(part, newPart,false); - -// modified = SC_PART_MODIFIED; - - // BUG FIX: #1650953 - // Added by T356. - // Fixes posted "select and drag past end of part - crashing" bug -// for(iPart ip = editor->parts()->begin(); ip != editor->parts()->end(); ++ip) -// { -// if(ip->second == part) -// { -// editor->parts()->erase(ip); -// break; -// } -// } - -// editor->parts()->add(newPart); -// audio->msgChangePart(part, newPart,false); - - //if(parts2change.find(part) == parts2change.end()) - // parts2change.insert(std::pair<Part*, Part*> (part, newPart)); iPartToChange ip2c = parts2change.find(part); if(ip2c == parts2change.end()) { @@ -336,13 +308,6 @@ void PianoCanvas::moveCanvasItems(CItemList& items, int dp, int dx, DragType dty } else ip2c->second.xdiff = npartoffset; - - //part = newPart; // reassign - //item->setPart(part); - //item->setEvent(newEvent); - //curPart = part; - //curPartId = curPart->sn(); - } } @@ -474,46 +439,6 @@ bool PianoCanvas::moveItem(CItem* item, const QPoint& pos, DragType dtype) newEvent.setTick(ntick); newEvent.setLenTick(event.lenTick()); - // Removed by T356. - /* - int modified=0; - //song->startUndo(); - int diff = newEvent.endTick()-part->lenTick(); - if (diff > 0){// too short part? extend it - // if there are several events that are moved outside the part, it will be recreated for each - // so the part _in_ the event will not be valid, ask the authority. - //Part* newPart = part->clone(); - Part* newPart = Canvas::part()->clone(); - - newPart->setLenTick(newPart->lenTick()+diff); - audio->msgChangePart(Canvas::part(), newPart,false); - - modified = SC_PART_MODIFIED; - part = newPart; // reassign - - // BUG FIX: #1650953 - // Added by T356. - // Fixes posted "select and drag past end of part - crashing" bug - for(iPart i = editor->parts()->begin(); i != editor->parts()->end(); ++i) - { - if(i->second == Canvas::part()) - { - editor->parts()->erase(i); - break; - } - } - editor->parts()->add(part); - item->setPart(part); - item->setEvent(newEvent); - curPart = part; - curPartId = curPart->sn(); - - } - */ - - // Added by T356. - // msgAddEvent and msgChangeEvent (below) will set these, but set them here first? - //item->setPart(part); item->setEvent(newEvent); // Added by T356. @@ -521,19 +446,11 @@ bool PianoCanvas::moveItem(CItem* item, const QPoint& pos, DragType dtype) printf("PianoCanvas::moveItem Error! New event end:%d exceeds length:%d of part:%s\n", newEvent.endTick(), part->lenTick(), part->name().toLatin1().constData()); if (dtype == MOVE_COPY || dtype == MOVE_CLONE) - // Indicate no undo, and do not do port controller values and clone parts. - //audio->msgAddEvent(newEvent, part, false); audio->msgAddEvent(newEvent, part, false, false, false); else - // Indicate no undo, and do not do port controller values and clone parts. - //audio->msgChangeEvent(event, newEvent, part, false); audio->msgChangeEvent(event, newEvent, part, false, false, false); //song->endUndo(modified); - // Removed by T356. - //if(pflags) - // *pflags = modified; - return true; } @@ -587,7 +504,6 @@ void PianoCanvas::newItem(CItem* item, bool noSnap) Part* newPart = part->clone(); newPart->setLenTick(newPart->lenTick()+diff); // Indicate no undo, and do port controller values but not clone parts. - //audio->msgChangePart(part, newPart,false); audio->msgChangePart(part, newPart, false, true, false); modified=modified|SC_PART_MODIFIED; part = newPart; // reassign @@ -623,14 +539,12 @@ void PianoCanvas::resizeItem(CItem* item, bool noSnap) // experimental c } song->startUndo(); int modified=SC_EVENT_MODIFIED; - //printf("event.tick()=%d len=%d part->lenTick()=%d\n",event.endTick(),len,part->lenTick()); int diff = event.tick()+len-part->lenTick(); if (diff > 0) {// too short part? extend it //printf("extend Part!\n"); Part* newPart = part->clone(); newPart->setLenTick(newPart->lenTick()+diff); // Indicate no undo, and do port controller values but not clone parts. - //audio->msgChangePart(part, newPart,false); audio->msgChangePart(part, newPart, false, true, false); modified=modified|SC_PART_MODIFIED; part = newPart; // reassign @@ -638,7 +552,6 @@ void PianoCanvas::resizeItem(CItem* item, bool noSnap) // experimental c newEvent.setLenTick(len); // Indicate no undo, and do not do port controller values and clone parts. - //audio->msgChangeEvent(event, newEvent, nevent->part(),false); audio->msgChangeEvent(event, newEvent, nevent->part(), false, false, false); song->endUndo(modified); } @@ -653,7 +566,6 @@ bool PianoCanvas::deleteItem(CItem* item) if (nevent->part() == curPart) { Event ev = nevent->event(); // Indicate do undo, and do not do port controller values and clone parts. - //audio->msgDeleteEvent(ev, curPart); audio->msgDeleteEvent(ev, curPart, true, false, false); return true; } @@ -700,8 +612,6 @@ void PianoCanvas::pianoCmd(int cmd) case CMD_RIGHT_NOSNAP: { Pos p(pos[0] + editor->rasterStep(pos[0]), true); - //if (p > part->tick()) - // p = part->tick(); song->setPos(0, p, true, true, true); //CDW } break; @@ -724,7 +634,6 @@ void PianoCanvas::pianoCmd(int cmd) Event newEvent = event.clone(); newEvent.setTick(event.tick() + editor->raster());// - part->tick()); // Indicate no undo, and do not do port controller values and clone parts. - //audio->msgChangeEvent(event, newEvent, part, false); audio->msgChangeEvent(event, newEvent, part, false, false, false); } song->endUndo(SC_EVENT_MODIFIED); @@ -750,7 +659,6 @@ void PianoCanvas::pianoCmd(int cmd) Event newEvent = event.clone(); newEvent.setTick(event.tick() - editor->raster() - part->tick()); // Indicate no undo, and do not do port controller values and clone parts. - //audio->msgChangeEvent(event, newEvent, part, false); audio->msgChangeEvent(event, newEvent, part, false, false, false); } song->endUndo(SC_EVENT_MODIFIED); @@ -772,7 +680,6 @@ void PianoCanvas::pianoPressed(int pitch, int velocity, bool shift) pitch += track()->transposition; // play note: - //MidiPlayEvent e(0, port, channel, 0x90, pitch, 127); MidiPlayEvent e(0, port, channel, 0x90, pitch, velocity); audio->msgPlayMidiEvent(&e); @@ -788,7 +695,6 @@ void PianoCanvas::pianoPressed(int pitch, int velocity, bool shift) e.setVelo(127); e.setLenTick(len); // Indicate do undo, and do not do port controller values and clone parts. - //audio->msgAddEvent(e, curPart); audio->msgAddEvent(e, curPart, true, false, false); tick += editor->rasterStep(tick) + curPart->tick(); if (tick != song->cpos()) { @@ -838,14 +744,6 @@ void drawTickRaster(QPainter& p, int x, int y, int w, int h, int raster) int qq = raster; if (q < 8) // grid too dense qq *= 2; - //switch (quant) { - // case 32: - // case 48: - // case 64: - // case 96: - // case 192: // 8tel - // case 128: // 8tel Triolen - // case 288: p.setPen(Qt::lightGray); if (raster>=4) { int xx = x + qq; @@ -856,10 +754,6 @@ void drawTickRaster(QPainter& p, int x, int y, int w, int h, int raster) } xx = xxx; } - // break; - // default: - // break; - // } p.setPen(Qt::gray); for (int beat = 1; beat < z; beat++) { int xx = AL::sigmap.bar2tick(bar, beat, 0); @@ -894,9 +788,7 @@ void PianoCanvas::drawCanvas(QPainter& p, const QRect& rect) p.drawLine(x, yy, x + w, yy); break; default: - //p.setPen(lightGray); p.fillRect(x, yy-3, w, 6, QBrush(QColor(230,230,230))); - //p.drawLine(x, yy, x + w, yy); break; } --key; @@ -926,7 +818,6 @@ void PianoCanvas::cmd(int cmd) NEvent* e = (NEvent*)(i->second); Event ev = e->event(); // Indicate no undo, and do not do port controller values and clone parts. - //audio->msgDeleteEvent(ev, e->part(), false); audio->msgDeleteEvent(ev, e->part(), false, false, false); } song->endUndo(SC_EVENT_REMOVED); @@ -1023,7 +914,6 @@ void PianoCanvas::cmd(int cmd) Event newEvent = event.clone(); newEvent.setLenTick(editor->raster()); // Indicate no undo, and do not do port controller values and clone parts. - //audio->msgChangeEvent(event, newEvent, nevent->part() , false); audio->msgChangeEvent(event, newEvent, nevent->part(), false, false, false); } } @@ -1082,7 +972,6 @@ void PianoCanvas::midiNote(int pitch, int velo) Event e = ev.clone(); e.setLenTick(ev.lenTick() + editor->rasterStep(starttick)); // Indicate do undo, and do not do port controller values and clone parts. - //audio->msgChangeEvent(ev, e, curPart); audio->msgChangeEvent(ev, e, curPart, true, false, false); if (! (globalKeyState & Qt::ShiftModifier)) { @@ -1102,7 +991,6 @@ void PianoCanvas::midiNote(int pitch, int velo) Event ev = i->second; if (ev.isNote() && ev.pitch() == pitch) { // Indicate do undo, and do not do port controller values and clone parts. - //audio->msgDeleteEvent(ev, curPart); audio->msgDeleteEvent(ev, curPart, true, false, false); if (! (globalKeyState & Qt::ShiftModifier)) { @@ -1119,7 +1007,6 @@ void PianoCanvas::midiNote(int pitch, int velo) e.setVelo(velo); e.setLenTick(len); // Indicate do undo, and do not do port controller values and clone parts. - //audio->msgAddEvent(e, curPart); audio->msgAddEvent(e, curPart, true, false, false); if (! (globalKeyState & Qt::ShiftModifier)) { @@ -1138,71 +1025,6 @@ void PianoCanvas::chordTimerTimedOut() } } -/* -//--------------------------------------------------------- -// getTextDrag -//--------------------------------------------------------- - -Q3TextDrag* PianoCanvas::getTextDrag(QWidget* parent) - { - //--------------------------------------------------- - // generate event list from selected events - //--------------------------------------------------- - - EventList el; - unsigned startTick = MAXINT; - for (iCItem i = items.begin(); i != items.end(); ++i) { - if (!i->second->isSelected()) - continue; - NEvent* ne = (NEvent*)(i->second); - Event e = ne->event(); - if (startTick == MAXINT) - startTick = e.tick(); - el.add(e); - } - - //--------------------------------------------------- - // write events as XML into tmp file - //--------------------------------------------------- - - FILE* tmp = tmpfile(); - if (tmp == 0) { - fprintf(stderr, "PianoCanvas::copy() fopen failed: %s\n", - strerror(errno)); - return 0; - } - Xml xml(tmp); - - int level = 0; - xml.tag(level++, "eventlist"); - for (ciEvent e = el.begin(); e != el.end(); ++e) - e->second.write(level, xml, -startTick); - xml.etag(--level, "eventlist"); - - //--------------------------------------------------- - // read tmp file into QTextDrag Object - //--------------------------------------------------- - - fflush(tmp); - struct stat f_stat; - if (fstat(fileno(tmp), &f_stat) == -1) { - fprintf(stderr, "PianoCanvas::copy() fstat failes:<%s>\n", - strerror(errno)); - fclose(tmp); - return 0; - } - int n = f_stat.st_size; - char* fbuf = (char*)mmap(0, n+1, PROT_READ|PROT_WRITE, - MAP_PRIVATE, fileno(tmp), 0); - fbuf[n] = 0; - Q3TextDrag* drag = new Q3TextDrag(QString(fbuf), parent); - drag->setSubtype("eventlist"); - munmap(fbuf, n); - fclose(tmp); - return drag; - } -*/ - //--------------------------------------------------------- // copy // cut copy paste @@ -1217,68 +1039,6 @@ void PianoCanvas::copy() QApplication::clipboard()->setMimeData(drag, QClipboard::Clipboard); } -/* -//--------------------------------------------------------- -// pasteAt -//--------------------------------------------------------- - -void PianoCanvas::pasteAt(const QString& pt, int pos) - { - QByteArray ba = pt.toLatin1(); - const char* p = ba.constData(); - Xml xml(p); - for (;;) { - Xml::Token token = xml.parse(); - const QString& tag = xml.s1(); - switch (token) { - case Xml::Error: - case Xml::End: - return; - case Xml::TagStart: - if (tag == "eventlist") { - song->startUndo(); - EventList* el = new EventList(); - el->read(xml, "eventlist", true); - int modified = SC_EVENT_INSERTED; - for (iEvent i = el->begin(); i != el->end(); ++i) { - Event e = i->second; - int tick = e.tick() + pos - curPart->tick(); - if (tick<0) { - printf("ERROR: trying to add event before current part!\n"); - song->endUndo(SC_EVENT_INSERTED); - delete el; - return; - } - - e.setTick(tick); - int diff = e.endTick()-curPart->lenTick(); - if (diff > 0) {// too short part? extend it - Part* newPart = curPart->clone(); - newPart->setLenTick(newPart->lenTick()+diff); - // Indicate no undo, and do port controller values but not clone parts. - audio->msgChangePart(curPart, newPart, false, true, false); - modified=modified|SC_PART_MODIFIED; - curPart = newPart; // reassign - } - // Indicate no undo, and do not do port controller values and clone parts. - audio->msgAddEvent(e, curPart, false, false, false); - } - song->endUndo(modified); - delete el; - return; - } - else - xml.unknown("pasteAt"); - break; - case Xml::Attribut: - case Xml::TagEnd: - default: - break; - } - } - } -*/ - //--------------------------------------------------------- // paste // paste events @@ -1286,17 +1046,6 @@ void PianoCanvas::pasteAt(const QString& pt, int pos) void PianoCanvas::paste() { -/* - //Q3CString subtype("eventlist"); ddskrjo - QString subtype("eventlist"); - QMimeSource* ms = QApplication::clipboard()->data(QClipboard::Clipboard); - QString pt; - if (!Q3TextDrag::decode(ms, pt, subtype)) { - printf("cannot paste: bad data type\n"); - return; - } - pasteAt(pt, song->cpos()); -*/ QString stype("x-muse-eventlist"); //QString s = QApplication::clipboard()->text(stype, QClipboard::Selection); @@ -1312,13 +1061,8 @@ void PianoCanvas::paste() void PianoCanvas::startDrag(CItem* /* item*/, bool copymode) { QMimeData* md = getTextDrag(); - //QDrag* drag = getTextDrag(); if (md) { -// QApplication::clipboard()->setData(drag, QClipboard::Clipboard); // This line NOT enabled in muse-1 - //QApplication::clipboard()->setMimeData(md); // TODO CHECK Tim. - //QApplication::clipboard()->setMimeData(drag->mimeData()); // - // "Note that setMimeData() assigns ownership of the QMimeData object to the QDrag object. // The QDrag must be constructed on the heap with a parent QWidget to ensure that Qt can // clean up after the drag and drop operation has been completed. " @@ -1362,41 +1106,6 @@ void PianoCanvas::dragLeaveEvent(QDragLeaveEvent*) //event->acceptProposedAction(); } -/* -//--------------------------------------------------------- -// dropEvent -//--------------------------------------------------------- - -void PianoCanvas::viewDropEvent(QDropEvent* event) - { - QString text; - if (event->source() == this) { - printf("local DROP\n"); - //event->acceptProposedAction(); - //event->ignore(); // TODO CHECK Tim. - return; - } - ///if (Q3TextDrag::decode(event, text)) { - //if (event->mimeData()->hasText()) { - if (event->mimeData()->hasFormat("text/x-muse-eventlist")) { - - //text = event->mimeData()->text(); - text = QString(event->mimeData()->data("text/x-muse-eventlist")); - - int x = editor->rasterVal(event->pos().x()); - if (x < 0) - x = 0; - pasteAt(text, x); - //event->accept(); // TODO - } - else { - printf("cannot decode drop\n"); - //event->acceptProposedAction(); - //event->ignore(); // TODO CHECK Tim. - } - } -*/ - //--------------------------------------------------------- // itemPressed //--------------------------------------------------------- diff --git a/muse2/muse/part.cpp b/muse2/muse/part.cpp index 99f070b2..d9346fbe 100644 --- a/muse2/muse/part.cpp +++ b/muse2/muse/part.cpp @@ -85,9 +85,6 @@ void chainCloneInternal(Part* p) const PartList* pl = mt->cparts(); for(ciPart ip = pl->begin(); ip != pl->end(); ++ip) { - // Added by Tim. p3.3.6 - //printf("chainCloneInternal track %p %s part %p %s evlist %p\n", (*imt), (*imt)->name().toLatin1().constData(), ip->second, ip->second->name().toLatin1().constData(), ip->second->cevents()); - if(ip->second != p && ip->second->cevents() == p->cevents()) { p1 = ip->second; @@ -224,16 +221,9 @@ void replaceClone(Part* p1, Part* p2) else p2->setNextClone(p2); - // Link the replacement... - //p2->setPrevClone(p1->prevClone()); - //p2->setNextClone(p1->nextClone()); - // Isolate the replaced part. p1->setNextClone(p1); p1->setPrevClone(p1); - // Added by Tim. p3.3.6 - //printf("replaceClone p1: %s %p arefs:%d p2: %s %p arefs:%d\n", p1->name().toLatin1().constData(), p1, ); - } //--------------------------------------------------------- @@ -278,9 +268,6 @@ void chainTrackParts(Track* t, bool incRefCount) if(incRefCount) p->events()->incARef(1); - // Added by Tim. p3.3.6 - //printf("chainTrackParts track %p %s part %p %s evlist %p\n", t, t->name().toLatin1().constData(), p, p->name().toLatin1().constData(), p->cevents()); - Part* p1 = 0; // Look for a part with the same event list, that we can chain to. @@ -296,9 +283,6 @@ void chainTrackParts(Track* t, bool incRefCount) const PartList* pl = mt->cparts(); for(ciPart ip = pl->begin(); ip != pl->end(); ++ip) { - // Added by Tim. p3.3.6 - //printf("chainTrackParts track %p %s part %p %s evlist %p\n", mt, mt->name().toLatin1().constData(), ip->second, ip->second->name().toLatin1().constData(), ip->second->cevents()); - if(ip->second != p && ip->second->cevents() == p->cevents()) { p1 = ip->second; @@ -381,21 +365,12 @@ void addPortCtrlEvents(Event& event, Part* part, bool doClones) //for(int i = 0; i < j; ++i) while(1) { - // Added by Tim. p3.3.6 - //printf("addPortCtrlEvents i:%d %s %p events %p refs:%d arefs:%d\n", i, p->name().toLatin1().constData(), p, part->cevents(), part->cevents()->refCount(), j); - Track* t = p->track(); if(t && t->isMidiTrack()) { MidiTrack* mt = (MidiTrack*)t; int port = mt->outPort(); - //const EventList* el = p->cevents(); unsigned len = p->lenTick(); - //for(ciEvent ie = el->begin(); ie != el->end(); ++ie) - //{ - //const Event& ev = ie->second; - // Added by Tim. p3.3.6 - //printf("addPortCtrlEvents %s len:%d end:%d etick:%d\n", p->name().toLatin1().constData(), p->lenTick(), p->endTick(), event.tick()); // Do not add events which are past the end of the part. if(event.tick() >= len) @@ -425,7 +400,6 @@ void addPortCtrlEvents(Event& event, Part* part, bool doClones) mp->setControllerVal(ch, tck, cntrl, val, p); } - //} } if(!doClones) @@ -456,9 +430,6 @@ void addPortCtrlEvents(Part* part, bool doClones) //for(int i = 0; i < j; ++i) while(1) { - // Added by Tim. p3.3.6 - //printf("addPortCtrlEvents i:%d %s %p events %p refs:%d arefs:%d\n", i, p->name().toLatin1().constData(), p, part->cevents(), part->cevents()->refCount(), j); - Track* t = p->track(); if(t && t->isMidiTrack()) { @@ -532,16 +503,6 @@ void removePortCtrlEvents(Event& event, Part* part, bool doClones) { MidiTrack* mt = (MidiTrack*)t; int port = mt->outPort(); - //const EventList* el = p->cevents(); - //unsigned len = p->lenTick(); - //for(ciEvent ie = el->begin(); ie != el->end(); ++ie) - //{ - //const Event& ev = ie->second; - // Added by T356. Do not remove events which are past the end of the part. - // No, actually, do remove ALL of them belonging to the part. - // Just in case there are stray values left after the part end. - //if(ev.tick() >= len) - // break; if(event.type() == Controller) { @@ -566,7 +527,6 @@ void removePortCtrlEvents(Event& event, Part* part, bool doClones) mp->deleteController(ch, tck, cntrl, p); } - //} } if(!doClones) @@ -734,14 +694,6 @@ MidiPart::MidiPart(const MidiPart& p) : Part(p) { _prevClone = this; _nextClone = this; - //setSn(newSn()); - //_sn = p._sn; - //_name = p._name; - //_selected = p._selected; - //_mute = p._mute; - //_colorIndex = p._colorIndex; - //_track = p._track; - //_events = p._events; } //--------------------------------------------------------- @@ -769,14 +721,6 @@ WavePart::WavePart(const WavePart& p) : Part(p) { _prevClone = this; _nextClone = this; - //setSn(newSn()); - //_sn = p._sn; - //_name = p._name; - //_selected = p._selected; - //_mute = p._mute; - //_colorIndex = p._colorIndex; - //_track = p._track; - //_events = p._events; } //--------------------------------------------------------- @@ -790,139 +734,6 @@ Part::~Part() delete _events; } -/* -//--------------------------------------------------------- -// unchainClone -//--------------------------------------------------------- - -void Part::unchainClone() -{ - chainCheckErr(); - - _prevClone->setNextClone(_nextClone); - _nextClone->setPrevClone(_prevClone); - - _prevClone = this; - _nextClone = this; -} - -//--------------------------------------------------------- -// chainClone -// The quick way - if part to chain to is known... -//--------------------------------------------------------- - -void Part::chainClone(const Part* p) -{ - chainCheckErr(); - - // Make sure the part is unchained first. - p->prevClone()->setNextClone(p->nextClone()); - p->nextClone()->setPrevClone(p->prevClone()); - - p->setPrevClone(this); - p->setNextClone(_nextClone->prevClone()); - - _nextClone->setPrevClone(p); - _nextClone = (Part*)p; -} - -//--------------------------------------------------------- -// chainClone -// The slow way - if part to chain to is not known... -//--------------------------------------------------------- - -void Part::chainClone() -{ - chainCheckErr(); - - // Look for a part with the same event list, that we can chain to... - Part* p = 0; - if(!_track || (_track && _track->isMidiTrack())) - { - MidiTrackList* mtl = song->midis(); - for(ciMidiTrack imt = mtl->begin(); imt != mtl->end(); ++imt) - { - const PartList* pl = (*imt)->cparts(); - for(ciPart ip = pl->begin(); ip != pl->end(); ++ip) - { - if(ip->second != this && ip->second->events() == _events) - { - p = ip->second; - break; - } - } - } - } - - if((!p && !_track) || (_track && _track->type() == Track::WAVE)) - { - WaveTrackList* wtl = song->waves(); - for(ciWaveTrack iwt = wtl->begin(); iwt != wtl->end(); ++iwt) - { - const PartList* pl = (*iwt)->cparts(); - for(ciPart ip = pl->begin(); ip != pl->end(); ++ip) - { - if(ip->second != this && ip->second->events() == _events) - { - p = ip->second; - break; - } - } - } - } - - // No part found with same event list? Done. - if(!p) - return; - - // Make sure this part is unchained first. - _prevClone->setNextClone(_nextClone); - _nextClone->setPrevClone(_prevClone); - - _prevClone = p; - _nextClone = p->nextClone(); - - p->nextClone()->setPrevClone(this); - p->setNextClone(this); -} - -//--------------------------------------------------------- -// replaceClone -//--------------------------------------------------------- - -void Part::replaceClone(const Part* p) -{ - chainCheckErr(); - - // Make sure the part is unchained first. - p->prevClone()->setNextClone(p->nextClone()); - p->nextClone()->setPrevClone(p->prevClone()); - - // If this part is a clone, not a single lone part... - if(_prevClone != this) - _prevClone->setNextClone(p); - if(_nextClone != this) - _nextClone->setPrevClone(p); - - p->setPrevClone(_prevClone); - p->setNextClone(_nextClone); - - _nextClone = this; - _prevClone = this; -} - -//--------------------------------------------------------- -// chainCheckErr -//--------------------------------------------------------- - -void Part::chainCheckErr() -{ - if(_nextClone->prevClone() != this) - printf("Part::chainCheckErr Error! Next clone:%s %x prev clone:%s %x != this:%s %x\n", _nextClone->name().toLatin1().constData(), _nextClone, _nextClone->prevClone()->name().toLatin1().constData(), _nextClone->prevClone(), name().toLatin1().constData(), this); - if(_prevClone->nextClone() != this) - printf("Part::chainCheckErr Error! Prev clone:%s %x next clone:%s %x != this:%s %x\n", _prevClone->name().toLatin1().constData(), _prevClone, _prevClone->nextClone()->name().toLatin1().constData(), _prevClone->nextClone(), name().toLatin1().constData(), this); -} -*/ //--------------------------------------------------------- // findPart @@ -988,7 +799,6 @@ void Song::addPart(Part* part) _len = epos; part->track()->addPart(part); - //part->addPortCtrlEvents(); // Indicate do not do clones. addPortCtrlEvents(part, false); } @@ -999,9 +809,7 @@ void Song::addPart(Part* part) void Song::removePart(Part* part) { - //part->removePortCtrlEvents(); // Indicate do not do clones. - //removePortCtrlEvents(part); removePortCtrlEvents(part, false); Track* track = part->track(); track->parts()->remove(part); @@ -1124,28 +932,6 @@ void Song::cmdResizePart(Track* track, Part* oPart, unsigned int len) } } - /* - // cut Events in nPart - // Changed by T356. Don't delete events if this is a clone part. - // The other clones might be longer than this one and need these events. - if(oPart->cevents()->arefCount() <= 1) - { - if (oPart->lenTick() > len) { - EventList* el = nPart->events(); - iEvent ie = el->lower_bound(len); - for (; ie != el->end();) { - iEvent i = ie; - ++ie; - // Indicate no undo, and do not do port controller values and clone parts. - //audio->msgDeleteEvent(i->second, nPart, false); - audio->msgDeleteEvent(i->second, nPart, false, false, false); - } - } - } - // Indicate no undo, and do port controller values but not clone parts. - //audio->msgChangePart(oPart, nPart, false); - audio->msgChangePart(oPart, nPart, false, true, false); - */ endUndo(SC_PART_MODIFIED); break; @@ -1281,27 +1067,9 @@ void Song::changePart(Part* oPart, Part* nPart) Track* oTrack = oPart->track(); Track* nTrack = nPart->track(); - // Added by Tim. p3.3.6 - //printf("Song::changePart before oPart->removePortCtrlEvents oldPart refs:%d Arefs:%d newPart refs:%d Arefs:%d\n", oPart->events()->refCount(), oPart->events()->arefCount(), nPart->events()->refCount(), nPart->events()->arefCount()); - - // Removed. Port controller events will have to be add/removed separately from this routine. - //oPart->removePortCtrlEvents(); - //removePortCtrlEvents(oPart); - - // Added by Tim. p3.3.6 - //printf("Song::changePart after oPart->removePortCtrlEvents oldPart refs:%d Arefs:%d newPart refs:%d Arefs:%d\n", oPart->events()->refCount(), oPart->events()->arefCount(), nPart->events()->refCount(), nPart->events()->arefCount()); - oTrack->parts()->remove(oPart); nTrack->parts()->add(nPart); - // Added by Tim. p3.3.6 - //printf("Song::changePart after add(nPart) oldPart refs:%d Arefs:%d newPart refs:%d Arefs:%d\n", oPart->events()->refCount(), oPart->events()->arefCount(), nPart->events()->refCount(), nPart->events()->arefCount()); - - //nPart->addPortCtrlEvents(); - //addPortCtrlEvents(nPart); - - // Added by Tim. p3.3.6 - //printf("Song::changePart after nPart->addPortCtrlEvents() oldPart refs:%d Arefs:%d newPart refs:%d Arefs:%d\n", oPart->events()->refCount(), oPart->events()->arefCount(), nPart->events()->refCount(), nPart->events()->arefCount()); // Added by T356. // adjust song len: @@ -1309,9 +1077,6 @@ void Song::changePart(Part* oPart, Part* nPart) if (epos > len()) _len = epos; - // Added by Tim. p3.3.6 - //printf("Song::changePart after len adjust oldPart refs:%d Arefs:%d newPart refs:%d Arefs:%d\n", oPart->events()->refCount(), oPart->events()->arefCount(), nPart->events()->refCount(), nPart->events()->arefCount()); - } //--------------------------------------------------------- @@ -1350,13 +1115,6 @@ void Song::cmdGluePart(Track* track, Part* oPart) EventList* sl2 = nextPart->events(); - //int frameOffset = nextPart->frame() - oPart->frame(); - //for (iEvent ie = sl2->begin(); ie != sl2->end(); ++ie) { - // Event event = ie->second.clone(); - // event.setFrame(event.frame() + frameOffset); - // dl->add(event); - // } - // p3.3.54 Changed. if(track->type() == Track::WAVE) { int frameOffset = nextPart->frame() - oPart->frame(); @@ -1382,7 +1140,6 @@ void Song::cmdGluePart(Track* track, Part* oPart) startUndo(); audio->msgRemovePart(nextPart, false); // Indicate no undo, and do port controller values but not clone parts. - //audio->msgChangePart(oPart, nPart, false); audio->msgChangePart(oPart, nPart, false, true, false); endUndo(SC_PART_MODIFIED | SC_PART_REMOVED); } |