|
@@ -95,6 +95,29 @@ void BeatSequence::print(std::ostream& stream) const
|
|
stream << "\n";
|
|
stream << "\n";
|
|
stream.flush();
|
|
stream.flush();
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+void BeatSequence::reduceToNeighbour(BeatIndex factor)
|
|
|
|
+{
|
|
|
|
+ reduce(factor, moveReducationConflictToNextNeighbour, 0);
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+void BeatSequence::moveReducationConflictToNextNeighbour(BeatSequence& sequence, BeatIndex factor, BeatIndex beatIndex, void* data)
|
|
|
|
+{
|
|
|
|
+ BeatSequence::BeatIndex previousIndex = beatIndex / factor * factor;
|
|
|
|
+
|
|
|
|
+ BeatSequence::BeatIndex targetIndex;
|
|
|
|
+ if((beatIndex - previousIndex) * 2 <= factor) {
|
|
|
|
+ targetIndex = previousIndex;
|
|
|
|
+ } else {
|
|
|
|
+ targetIndex = previousIndex + factor;
|
|
|
|
+ if(targetIndex >= sequence.size()) {
|
|
|
|
+ targetIndex = 0;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ MessageList& targetBeat = sequence[targetIndex];
|
|
|
|
+ targetBeat.splice(targetBeat.end(), sequence[beatIndex]);
|
|
|
|
+}
|
|
|
|
|
|
UnresolvedBeatSequenceReducationConflict::UnresolvedBeatSequenceReducationConflict(BeatSequence::BeatIndex beatIndex)
|
|
UnresolvedBeatSequenceReducationConflict::UnresolvedBeatSequenceReducationConflict(BeatSequence::BeatIndex beatIndex)
|
|
: parent("unresolved beat sequence reducation conflict"), beatIndex(beatIndex)
|
|
: parent("unresolved beat sequence reducation conflict"), beatIndex(beatIndex)
|