summaryrefslogtreecommitdiffstats
path: root/src/base/NotationQuantizer.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/base/NotationQuantizer.cpp')
-rw-r--r--src/base/NotationQuantizer.cpp70
1 files changed, 35 insertions, 35 deletions
diff --git a/src/base/NotationQuantizer.cpp b/src/base/NotationQuantizer.cpp
index 9e76a94..8f4b1e7 100644
--- a/src/base/NotationQuantizer.cpp
+++ b/src/base/NotationQuantizer.cpp
@@ -37,7 +37,7 @@ using std::cout;
using std::cerr;
using std::endl;
-//#define DEBUG_NOTATION_QUANTIZER 1
+//#define DEBUG_NOTATION_TQUANTIZER 1
namespace Rosegarden {
@@ -83,7 +83,7 @@ public:
}
virtual timeT getQuantizedAbsoluteTime(const Event *e) const {
timeT t = m_impl->getProvisional((Event *)e, AbsoluteTimeValue);
-#ifdef DEBUG_NOTATION_QUANTIZER
+#ifdef DEBUG_NOTATION_TQUANTIZER
cout << "ProvisionalQuantizer::getQuantizedAbsoluteTime: returning " << t << endl;
#endif
return t;
@@ -295,7 +295,7 @@ NotationQuantizer::Impl::quantizeAbsoluteTime(Segment *s, Segment::iterator i) c
long bestScore = 0;
bool bestRight = false;
-#ifdef DEBUG_NOTATION_QUANTIZER
+#ifdef DEBUG_NOTATION_TQUANTIZER
cout << "quantizeAbsoluteTime: t is " << t << ", d is " << d << endl;
#endif
@@ -321,7 +321,7 @@ NotationQuantizer::Impl::quantizeAbsoluteTime(Segment *s, Segment::iterator i) c
}
}
-#ifdef DEBUG_NOTATION_QUANTIZER
+#ifdef DEBUG_NOTATION_TQUANTIZER
if (n != s->end() && n != nprime) {
cout << "found n (distinct from nprime) at " << (*n)->getAbsoluteTime() << endl;
}
@@ -340,7 +340,7 @@ NotationQuantizer::Impl::quantizeAbsoluteTime(Segment *s, Segment::iterator i) c
t, d, noteType, n, nprime, right);
if (depth == 0 || score < bestScore) {
-#ifdef DEBUG_NOTATION_QUANTIZER
+#ifdef DEBUG_NOTATION_TQUANTIZER
cout << " [*]";
#endif
bestBase = base;
@@ -348,13 +348,13 @@ NotationQuantizer::Impl::quantizeAbsoluteTime(Segment *s, Segment::iterator i) c
bestRight = right;
}
-#ifdef DEBUG_NOTATION_QUANTIZER
+#ifdef DEBUG_NOTATION_TQUANTIZER
cout << endl;
#endif
}
if (bestBase == -2) {
-#ifdef DEBUG_NOTATION_QUANTIZER
+#ifdef DEBUG_NOTATION_TQUANTIZER
cout << "Quantizer::quantizeAbsoluteTime: weirdness: no snap found" << endl;
#endif
} else {
@@ -373,7 +373,7 @@ NotationQuantizer::Impl::quantizeAbsoluteTime(Segment *s, Segment::iterator i) c
t += sigTime;
-#ifdef DEBUG_NOTATION_QUANTIZER
+#ifdef DEBUG_NOTATION_TQUANTIZER
cout << "snap base is " << bestBase << ", snapped to " << t << endl;
#endif
}
@@ -457,7 +457,7 @@ NotationQuantizer::Impl::scoreAbsoluteTimeForBase(Segment *s,
}
}
-#ifdef DEBUG_NOTATION_QUANTIZER
+#ifdef DEBUG_NOTATION_TQUANTIZER
cout << " depth/eff/dist/t/score/pen1/pen2/res: " << depth << "/" << effectiveDepth << "/" << distance << "/" << (right ? t + distance : t - distance) << "/" << score << "/" << penalty1 << "/" << penalty2 << "/" << (score * penalty1 * penalty2);
if (right) cout << " -> ";
else cout << " <- ";
@@ -553,7 +553,7 @@ NotationQuantizer::Impl::quantizeDuration(Segment *s, Chord &c) const
Profiler profiler("NotationQuantizer::Impl::quantizeDuration");
-#ifdef DEBUG_NOTATION_QUANTIZER
+#ifdef DEBUG_NOTATION_TQUANTIZER
cout << "quantizeDuration: chord has " << c.size() << " notes" << endl;
#endif
@@ -584,7 +584,7 @@ NotationQuantizer::Impl::quantizeDuration(Segment *s, Chord &c) const
if ((**ci)->has(m_provisionalDuration) &&
(**ci)->has(BEAMED_GROUP_TUPLET_BASE)) {
// dealt with already in tuplet code, we'd only mess it up here
-#ifdef DEBUG_NOTATION_QUANTIZER
+#ifdef DEBUG_NOTATION_TQUANTIZER
cout << "not recalculating duration for tuplet" << endl;
#endif
continue;
@@ -595,7 +595,7 @@ NotationQuantizer::Impl::quantizeDuration(Segment *s, Chord &c) const
if (!m_contrapuntal) {
// if not contrapuntal, give all notes in chord equal duration
if (nonContrapuntalDuration > 0) {
-#ifdef DEBUG_NOTATION_QUANTIZER
+#ifdef DEBUG_NOTATION_TQUANTIZER
cout << "setting duration trivially to " << nonContrapuntalDuration << endl;
#endif
setProvisional(**ci, DurationValue, nonContrapuntalDuration);
@@ -613,7 +613,7 @@ NotationQuantizer::Impl::quantizeDuration(Segment *s, Chord &c) const
timeT qt = getProvisional(**ci, AbsoluteTimeValue);
-#ifdef DEBUG_NOTATION_QUANTIZER
+#ifdef DEBUG_NOTATION_TQUANTIZER
cout << "note at time " << (**ci)->getAbsoluteTime() << " (provisional time " << qt << ")" << endl;
#endif
@@ -626,7 +626,7 @@ NotationQuantizer::Impl::quantizeDuration(Segment *s, Chord &c) const
base /= divisions[depth];
}
-#ifdef DEBUG_NOTATION_QUANTIZER
+#ifdef DEBUG_NOTATION_TQUANTIZER
cout << "duration is " << ud << ", probably between "
<< bases.first << " and " << bases.second << endl;
#endif
@@ -645,7 +645,7 @@ NotationQuantizer::Impl::quantizeDuration(Segment *s, Chord &c) const
qd = Note::getNearestNote(spaceAvailable).getDuration();
-#ifdef DEBUG_NOTATION_QUANTIZER
+#ifdef DEBUG_NOTATION_TQUANTIZER
cout << "non-contrapuntal segment, rounded duration down to "
<< qd << " (as only " << spaceAvailable << " available)"
<< endl;
@@ -675,7 +675,7 @@ NotationQuantizer::Impl::quantizeDuration(Segment *s, Chord &c) const
bases.second == absTimeBase) {
if (nextNoteTime >= qt + bases.second) {
-#ifdef DEBUG_NOTATION_QUANTIZER
+#ifdef DEBUG_NOTATION_TQUANTIZER
cout << "We rounded to " << qd
<< " but we're on " << absTimeBase << " absTimeBase"
<< " and the next base is " << bases.second
@@ -699,14 +699,14 @@ NotationQuantizer::Impl::quantizeDuration(Segment *s, Chord &c) const
if (note.getNoteType() < Note::Longest) {
if (bases.second <= spaceAvailable) {
-#ifdef DEBUG_NOTATION_QUANTIZER
+#ifdef DEBUG_NOTATION_TQUANTIZER
cout << "We rounded down to " << qd
<< " but have room for " << bases.second
<< ", rounding up again" << endl;
#endif
qd = bases.second;
} else {
-#ifdef DEBUG_NOTATION_QUANTIZER
+#ifdef DEBUG_NOTATION_TQUANTIZER
cout << "We rounded down to " << qd
<< "; can't fit " << bases.second << endl;
#endif
@@ -720,7 +720,7 @@ NotationQuantizer::Impl::quantizeDuration(Segment *s, Chord &c) const
if (!m_contrapuntal) nonContrapuntalDuration = qd;
}
-#ifdef DEBUG_NOTATION_QUANTIZER
+#ifdef DEBUG_NOTATION_TQUANTIZER
cout << "totalFrac " << totalFrac << ", totalFracCount " << totalFracCount << ", avg " << (totalFracCount > 0 ? (totalFrac / totalFracCount) : 0) << endl;
#endif
}
@@ -746,7 +746,7 @@ NotationQuantizer::Impl::scanTupletsInBar(Segment *s,
if (depth >= 0) base /= divisions[depth];
if (base <= Note(Note::Semiquaver).getDuration()) break;
-#ifdef DEBUG_NOTATION_QUANTIZER
+#ifdef DEBUG_NOTATION_TQUANTIZER
cout << "\nscanTupletsInBar: trying at depth " << depth << " (base " << base << ")" << endl;
#endif
@@ -766,7 +766,7 @@ NotationQuantizer::Impl::scanTupletsInBar(Segment *s,
continue;
}
-#ifdef DEBUG_NOTATION_QUANTIZER
+#ifdef DEBUG_NOTATION_TQUANTIZER
cout << "scanTupletsInBar: testing " << tupletStart << "," << base << " at tuplet base " << tupletBase << endl;
#endif
@@ -786,7 +786,7 @@ NotationQuantizer::Impl::scanTupletsInBar(Segment *s,
}
if (jTime >= tupletEnd) { // nothing to make tuplets of
-#ifdef DEBUG_NOTATION_QUANTIZER
+#ifdef DEBUG_NOTATION_TQUANTIZER
cout << "scanTupletsInBar: nothing here" << endl;
#endif
tupletStart = tupletEnd;
@@ -827,14 +827,14 @@ NotationQuantizer::Impl::scanTupletsAt(Segment *s,
if (!(*j)->isa(Note::EventType)) { ++j; continue; }
-#ifdef DEBUG_NOTATION_QUANTIZER
+#ifdef DEBUG_NOTATION_TQUANTIZER
cout << "scanTupletsAt time " << jTime << " (unquantized "
<< (*j)->getAbsoluteTime() << "), found note" << endl;
#endif
// reject any group containing anything already a tuplet
if ((*j)->has(BEAMED_GROUP_TUPLET_BASE)) {
-#ifdef DEBUG_NOTATION_QUANTIZER
+#ifdef DEBUG_NOTATION_TQUANTIZER
cout << "already made tuplet here" << endl;
#endif
return;
@@ -843,19 +843,19 @@ NotationQuantizer::Impl::scanTupletsAt(Segment *s,
timeT originalBase;
if (!(*j)->get<Int>(m_provisionalBase, originalBase)) {
-#ifdef DEBUG_NOTATION_QUANTIZER
+#ifdef DEBUG_NOTATION_TQUANTIZER
cout << "some notes not provisionally quantized, no good" << endl;
#endif
return;
}
if (originalBase == base) {
-#ifdef DEBUG_NOTATION_QUANTIZER
+#ifdef DEBUG_NOTATION_TQUANTIZER
cout << "accepting note at original base" << endl;
#endif
candidates.push_back(*j);
} else if (((jTime - sigTime) % base) == 0) {
-#ifdef DEBUG_NOTATION_QUANTIZER
+#ifdef DEBUG_NOTATION_TQUANTIZER
cout << "accepting note that happens to lie on original base" << endl;
#endif
candidates.push_back(*j);
@@ -867,7 +867,7 @@ NotationQuantizer::Impl::scanTupletsAt(Segment *s,
// any of the likelihood tests for tuplets.
if (!isValidTupletAt(s, j, depth, base, sigTime, tupletBase)) {
-#ifdef DEBUG_NOTATION_QUANTIZER
+#ifdef DEBUG_NOTATION_TQUANTIZER
cout << "no good" << endl;
#endif
return;
@@ -883,13 +883,13 @@ NotationQuantizer::Impl::scanTupletsAt(Segment *s,
// must have at least one note that is not already quantized to the
// original base
if (count < 1) {
-#ifdef DEBUG_NOTATION_QUANTIZER
+#ifdef DEBUG_NOTATION_TQUANTIZER
cout << "scanTupletsAt: found no note not already quantized to " << base << endl;
#endif
return;
}
-#ifdef DEBUG_NOTATION_QUANTIZER
+#ifdef DEBUG_NOTATION_TQUANTIZER
cout << "scanTupletsAt: Tuplet group of duration " << base << " starting at " << tupletStart << endl;
#endif
@@ -970,7 +970,7 @@ NotationQuantizer::Impl::isValidTupletAt(Segment *s,
timeT ud = m_q->getFromSource(*i, DurationValue);
if (ud > (tupletBase * 5 / 4)) {
-#ifdef DEBUG_NOTATION_QUANTIZER
+#ifdef DEBUG_NOTATION_TQUANTIZER
cout << "\nNotationQuantizer::isValidTupletAt: note too long at "
<< (*i)->getDuration() << " (tupletBase is " << tupletBase << ")"
<< endl;
@@ -981,7 +981,7 @@ NotationQuantizer::Impl::isValidTupletAt(Segment *s,
//!!! This bit is a cop-out. It means we reject anything that looks
// like it's going to have rests in it. Bah.
if (ud <= (tupletBase * 3 / 8)) {
-#ifdef DEBUG_NOTATION_QUANTIZER
+#ifdef DEBUG_NOTATION_TQUANTIZER
cout << "\nNotationQuantizer::isValidTupletAt: note too short at "
<< (*i)->getDuration() << " (tupletBase is " << tupletBase << ")"
<< endl;
@@ -1000,7 +1000,7 @@ NotationQuantizer::Impl::isValidTupletAt(Segment *s,
bool dummy;
long tupletScore = scoreAbsoluteTimeForBase
(s, i, depth, tupletBase, sigTime, t, d, noteType, s->end(), s->end(), dummy);
-#ifdef DEBUG_NOTATION_QUANTIZER
+#ifdef DEBUG_NOTATION_TQUANTIZER
cout << "\nNotationQuantizer::isValidTupletAt: score " << score
<< " vs tupletScore " << tupletScore << endl;
#endif
@@ -1027,7 +1027,7 @@ NotationQuantizer::Impl::quantizeRange(Segment *s,
int events = 0, notes = 0, passes = 0;
int setGood = 0, setBad = 0;
-#ifdef DEBUG_NOTATION_QUANTIZER
+#ifdef DEBUG_NOTATION_TQUANTIZER
cout << "NotationQuantizer::Impl::quantizeRange: from time "
<< (from == s->end() ? -1 : (*from)->getAbsoluteTime())
<< " to "
@@ -1177,7 +1177,7 @@ NotationQuantizer::Impl::quantizeRange(Segment *s,
(*i)->getDuration() == d) ++setBad;
else ++setGood;
-#ifdef DEBUG_NOTATION_QUANTIZER
+#ifdef DEBUG_NOTATION_TQUANTIZER
cout << "Setting to target at " << t << "," << d << endl;
#endif