From: Chris C. <ca...@us...> - 2005-04-29 16:53:26
|
Update of /cvsroot/rosegarden/gui In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21468/gui Modified Files: matrixcommands.cpp matrixcommands.h Log Message: * Fixes to percussion matrix insertion Index: matrixcommands.cpp =================================================================== RCS file: /cvsroot/rosegarden/gui/matrixcommands.cpp,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** matrixcommands.cpp 19 Apr 2005 21:49:59 -0000 1.8 --- matrixcommands.cpp 29 Apr 2005 16:53:17 -0000 1.9 *************** *** 23,26 **** --- 23,27 ---- #include "BaseProperties.h" #include "SegmentMatrixHelper.h" + #include "Segment.h" #include "Composition.h" *************** *** 32,37 **** using Rosegarden::Note; using Rosegarden::timeT; ! MatrixInsertionCommand::MatrixInsertionCommand(Rosegarden::Segment &segment, timeT time, timeT endTime, --- 33,41 ---- using Rosegarden::Note; using Rosegarden::timeT; + using Rosegarden::Segment; + using Rosegarden::Int; + using Rosegarden::BaseProperties; ! MatrixInsertionCommand::MatrixInsertionCommand(Segment &segment, timeT time, timeT endTime, *************** *** 55,60 **** MATRIX_DEBUG << "MatrixInsertionCommand::modifySegment()\n"; ! if (!m_event->has(Rosegarden::BaseProperties::VELOCITY)) { ! m_event->set<Rosegarden::Int>(Rosegarden::BaseProperties::VELOCITY, 100); } --- 59,64 ---- MATRIX_DEBUG << "MatrixInsertionCommand::modifySegment()\n"; ! if (!m_event->has(BaseProperties::VELOCITY)) { ! m_event->set<Int>(BaseProperties::VELOCITY, 100); } *************** *** 64,75 **** } ! MatrixPercussionInsertionCommand::MatrixPercussionInsertionCommand(Rosegarden::Segment &segment, timeT time, Event *event) : ! BasicCommand(i18n("Insert Percussion Note"), segment, time, ! getEndTime(segment, time)), ! m_event(0) { ! Rosegarden::timeT endTime = getEndTime(segment, time); m_event = new Event(*event, time, endTime - time); } --- 68,81 ---- } ! MatrixPercussionInsertionCommand::MatrixPercussionInsertionCommand(Segment &segment, timeT time, Event *event) : ! BasicCommand(i18n("Insert Percussion Note"), segment, ! getEffectiveStartTime(segment, time, *event), ! getEndTime(segment, time, *event)), ! m_event(0), ! m_time(time) { ! timeT endTime = getEndTime(segment, time, *event); m_event = new Event(*event, time, endTime - time); } *************** *** 85,110 **** MATRIX_DEBUG << "MatrixPercussionInsertionCommand::modifySegment()\n"; ! if (!m_event->has(Rosegarden::BaseProperties::VELOCITY)) { ! m_event->set<Rosegarden::Int>(Rosegarden::BaseProperties::VELOCITY, 100); } ! //!!! Absolutely need to truncate previous event on segment as well ! Rosegarden::SegmentMatrixHelper helper(getSegment()); m_lastInsertedEvent = new Event(*m_event); helper.insertNote(m_lastInsertedEvent); } ! Rosegarden::timeT ! MatrixPercussionInsertionCommand::getEndTime(Rosegarden::Segment &segment, ! Rosegarden::timeT time) { ! Rosegarden::timeT endTime = time; ! for (Rosegarden::Segment::iterator i = segment.findTime(time); segment.isBeforeEndMarker(i); ++i) { ! if ((*i)->getAbsoluteTime() > time) endTime = (*i)->getAbsoluteTime(); } - endTime = segment.getEndMarkerTime(); Rosegarden::Composition *comp = segment.getComposition(); --- 91,191 ---- MATRIX_DEBUG << "MatrixPercussionInsertionCommand::modifySegment()\n"; ! if (!m_event->has(BaseProperties::VELOCITY)) { ! m_event->set<Int>(BaseProperties::VELOCITY, 100); } ! Segment &s = getSegment(); ! Segment::iterator i = s.findTime(m_time); ! ! int pitch = 0; ! if (m_event->has(BaseProperties::PITCH)) { ! pitch = m_event->get<Int>(BaseProperties::PITCH); ! } ! ! while (i != s.begin()) { ! ! --i; ! ! if ((*i)->getAbsoluteTime() < m_time && ! (*i)->isa(Note::EventType)) { ! ! if ((*i)->has(BaseProperties::PITCH) && ! (*i)->get<Int>(BaseProperties::PITCH) == pitch) { ! ! if ((*i)->getAbsoluteTime() + (*i)->getDuration() > m_time) { ! Rosegarden::Event *newPrevious = new Rosegarden::Event ! (**i, (*i)->getAbsoluteTime(), m_time - (*i)->getAbsoluteTime()); ! s.erase(i); ! i = s.insert(newPrevious); ! } else { ! break; ! } ! } ! } ! } ! ! Rosegarden::SegmentMatrixHelper helper(s); m_lastInsertedEvent = new Event(*m_event); helper.insertNote(m_lastInsertedEvent); } ! timeT ! MatrixPercussionInsertionCommand::getEffectiveStartTime(Segment &segment, ! timeT time, ! Rosegarden::Event &event) { ! Rosegarden::timeT startTime = time; ! int pitch = 0; ! if (event.has(BaseProperties::PITCH)) { ! pitch = event.get<Int>(BaseProperties::PITCH); ! } ! ! Segment::iterator i = segment.findTime(time); ! while (i != segment.begin()) { ! --i; ! ! if ((*i)->has(BaseProperties::PITCH) && ! (*i)->get<Int>(BaseProperties::PITCH) == pitch) { ! ! if ((*i)->getAbsoluteTime() < time && ! (*i)->isa(Note::EventType)) { ! if ((*i)->getAbsoluteTime() + (*i)->getDuration() > time) { ! startTime = (*i)->getAbsoluteTime(); ! } else { ! break; ! } ! } ! } ! } ! ! return startTime; ! } ! ! timeT ! MatrixPercussionInsertionCommand::getEndTime(Segment &segment, ! Rosegarden::timeT time, ! Rosegarden::Event &event) ! { ! Rosegarden::timeT endTime = segment.getEndMarkerTime(); ! ! int pitch = 0; ! if (event.has(BaseProperties::PITCH)) { ! pitch = event.get<Int>(BaseProperties::PITCH); ! } ! ! for (Segment::iterator i = segment.findTime(time); segment.isBeforeEndMarker(i); ++i) { ! ! if ((*i)->has(BaseProperties::PITCH) && ! (*i)->get<Int>(BaseProperties::PITCH) == pitch) { ! ! if ((*i)->getAbsoluteTime() > time && ! (*i)->isa(Rosegarden::Note::EventType)) { ! endTime = (*i)->getAbsoluteTime(); ! } ! } } Rosegarden::Composition *comp = segment.getComposition(); *************** *** 122,126 **** ! MatrixEraseCommand::MatrixEraseCommand(Rosegarden::Segment &segment, Event *event) : BasicCommand(i18n("Erase Note"), --- 203,207 ---- ! MatrixEraseCommand::MatrixEraseCommand(Segment &segment, Event *event) : BasicCommand(i18n("Erase Note"), *************** *** 153,157 **** } ! MatrixModifyCommand::MatrixModifyCommand(Rosegarden::Segment &segment, Rosegarden::Event *oldEvent, Rosegarden::Event *newEvent, --- 234,238 ---- } ! MatrixModifyCommand::MatrixModifyCommand(Segment &segment, Rosegarden::Event *oldEvent, Rosegarden::Event *newEvent, *************** *** 187,191 **** m_oldEvent->getDuration()); ! Rosegarden::Segment &segment(getSegment()); segment.insert(m_newEvent); segment.eraseSingle(m_oldEvent); --- 268,272 ---- m_oldEvent->getDuration()); ! Segment &segment(getSegment()); segment.insert(m_newEvent); segment.eraseSingle(m_oldEvent); Index: matrixcommands.h =================================================================== RCS file: /cvsroot/rosegarden/gui/matrixcommands.h,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** matrixcommands.h 19 Apr 2005 21:49:59 -0000 1.7 --- matrixcommands.h 29 Apr 2005 16:53:17 -0000 1.8 *************** *** 59,66 **** virtual void modifySegment(); Rosegarden::timeT getEndTime(Rosegarden::Segment &segment, ! Rosegarden::timeT time); Rosegarden::Event *m_event; Rosegarden::Event *m_lastInsertedEvent; // an alias for another event }; --- 59,71 ---- virtual void modifySegment(); + Rosegarden::timeT getEffectiveStartTime(Rosegarden::Segment &segment, + Rosegarden::timeT startTime, + Rosegarden::Event &event); Rosegarden::timeT getEndTime(Rosegarden::Segment &segment, ! Rosegarden::timeT endTime, ! Rosegarden::Event &event); Rosegarden::Event *m_event; + Rosegarden::timeT m_time; Rosegarden::Event *m_lastInsertedEvent; // an alias for another event }; |