diff options
author | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2010-03-01 18:37:05 +0000 |
---|---|---|
committer | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2010-03-01 18:37:05 +0000 |
commit | 145364a8af6a1fec06556221e66d4b724a62fc9a (patch) | |
tree | 53bd71a544008c518034f208d64c932dc2883f50 /src/base/TriggerSegment.cpp | |
download | rosegarden-145364a8af6a1fec06556221e66d4b724a62fc9a.tar.gz rosegarden-145364a8af6a1fec06556221e66d4b724a62fc9a.zip |
Added old abandoned KDE3 version of the RoseGarden MIDI tool
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/applications/rosegarden@1097595 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'src/base/TriggerSegment.cpp')
-rw-r--r-- | src/base/TriggerSegment.cpp | 130 |
1 files changed, 130 insertions, 0 deletions
diff --git a/src/base/TriggerSegment.cpp b/src/base/TriggerSegment.cpp new file mode 100644 index 0000000..c4c29de --- /dev/null +++ b/src/base/TriggerSegment.cpp @@ -0,0 +1,130 @@ +// -*- c-basic-offset: 4 -*- + +/* + Rosegarden + A sequencer and musical notation editor. + + This program is Copyright 2000-2008 + Guillaume Laurent <[email protected]>, + Chris Cannam <[email protected]>, + Richard Bown <[email protected]> + + The moral right of the authors to claim authorship of this work + has been asserted. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. See the file + COPYING included with this distribution for more information. +*/ + +#include "TriggerSegment.h" + +#include "Segment.h" +#include "Composition.h" +#include "BaseProperties.h" + +namespace Rosegarden +{ + +TriggerSegmentRec::~TriggerSegmentRec() +{ + // nothing -- we don't delete the segment here +} + +TriggerSegmentRec::TriggerSegmentRec(TriggerSegmentId id, + Segment *segment, + int basePitch, + int baseVelocity, + std::string timeAdjust, + bool retune) : + m_id(id), + m_segment(segment), + m_basePitch(basePitch), + m_baseVelocity(baseVelocity), + m_defaultTimeAdjust(timeAdjust), + m_defaultRetune(retune) +{ + if (m_defaultTimeAdjust == "") { + m_defaultTimeAdjust = BaseProperties::TRIGGER_SEGMENT_ADJUST_SQUISH; + } + + calculateBases(); + updateReferences(); +} + +TriggerSegmentRec::TriggerSegmentRec(const TriggerSegmentRec &rec) : + m_id(rec.m_id), + m_segment(rec.m_segment), + m_basePitch(rec.m_basePitch), + m_baseVelocity(rec.m_baseVelocity), + m_defaultTimeAdjust(rec.m_defaultTimeAdjust), + m_defaultRetune(rec.m_defaultRetune), + m_references(rec.m_references) +{ + // nothing else +} + +TriggerSegmentRec & +TriggerSegmentRec::operator=(const TriggerSegmentRec &rec) +{ + if (&rec == this) return *this; + m_id = rec.m_id; + m_segment = rec.m_segment; + m_basePitch = rec.m_basePitch; + m_baseVelocity = rec.m_baseVelocity; + m_references = rec.m_references; + return *this; +} + +void +TriggerSegmentRec::updateReferences() +{ + if (!m_segment) return; + + Composition *c = m_segment->getComposition(); + if (!c) return; + + m_references.clear(); + + for (Composition::iterator i = c->begin(); i != c->end(); ++i) { + for (Segment::iterator j = (*i)->begin(); j != (*i)->end(); ++j) { + if ((*j)->has(BaseProperties::TRIGGER_SEGMENT_ID) && + (*j)->get<Int>(BaseProperties::TRIGGER_SEGMENT_ID) == long(m_id)) { + m_references.insert((*i)->getRuntimeId()); + break; // from inner loop only: go on to next segment + } + } + } +} + +void +TriggerSegmentRec::calculateBases() +{ + if (!m_segment) return; + + for (Segment::iterator i = m_segment->begin(); + m_segment->isBeforeEndMarker(i); ++i) { + + if (m_basePitch >= 0 && m_baseVelocity >= 0) return; + + if (m_basePitch < 0) { + if ((*i)->has(BaseProperties::PITCH)) { + m_basePitch = (*i)->get<Int>(BaseProperties::PITCH); + } + } + + if (m_baseVelocity < 0) { + if ((*i)->has(BaseProperties::VELOCITY)) { + m_baseVelocity = (*i)->get<Int>(BaseProperties::VELOCITY); + } + } + } + + if (m_basePitch < 0) m_basePitch = 60; + if (m_baseVelocity < 0) m_baseVelocity = 100; +} + +} + |