Commit c448d43e authored by Florent Jacquemard's avatar Florent Jacquemard
Browse files

revision of Table importer into SM : use terminal runs indicating the real number of input points

parent 2171b3c5
......@@ -162,8 +162,27 @@ private:
size_t mult,
size_t b,
int voiceNb,
mtu_t len);
mtu_t dur);
template<class K>
size_t readTreeInnner(ScoringEnv& env,
Parsing::TableA<K>& tab,
const K& k,
const Parsing::RunInner<K>* r,
size_t mult,
size_t b,
int voiceNb,
mtu_t dur);
template<class K>
size_t readTreeTerm(ScoringEnv& env,
Parsing::TableA<K>& tab,
const K& k,
const Parsing::RunTerm<K>* r,
size_t mult,
size_t b,
int voiceNb,
mtu_t dur);
/// add one Node in the tree of the current Sequence
/// @param b position of first point to read in input segment.
......@@ -176,7 +195,7 @@ private:
size_t b,
size_t n,
int voiceNb,
mtu_t len);
mtu_t dur);
/// subcase of readSymbol
size_t readContinuation(size_t multiplicity,
......@@ -232,7 +251,7 @@ private:
size_t readTuple(label_t a,
size_t arity, size_t multiplicity,
size_t b,
mtu_t len);
mtu_t dur);
/// cast given ornament into appropriate subtype
/// @param o ornament to cast
......
......@@ -275,53 +275,116 @@ size_t TableMonoImporter::readTree(ScoringEnv& env,
size_t mult,
size_t b,
int voiceNb,
mtu_t len)
mtu_t dur)
{
assert(r);
assert(r->fail() || r->complete());
TRACE("TableImporter[{}]: read tree: {}", b, *r);
if (r->terminal())
{
return readTreeTerminal(env, tab, k,
(const Parsing::RunTerm<K>*) r,
mult, b, voiceNb, dur);
// const Parsing::RunTerm<K>* rt =
// dynamic_cast<const Parsing::RunTerm<K>*>(r);
// assert(rt);
// return readTreeTerminal(env, tab, k, rt, mult, b, voiceNb, dur);
}
else
{
assert(r->inner());
return readTreeTerminal(env, tab, k,
(const Parsing::RunInner<K>*) r,
mult, b, voiceNb, dur);
// const const Parsing::RunInner<K>* ri =
// dynamic_cast<const Parsing::RunInner<K>*>(r);
// assert(ri);
// return readTreeTerminal(env, tab, k, ri, mult, b, voiceNb, dur);
}
}
template<class K>
size_t TableMonoImporter::readTreeTerm(ScoringEnv& env,
Parsing::TableA<K>& tab,
const K& k,
const Parsing::RunTerm<K>* r,
size_t mult,
size_t b,
int voiceNb,
mtu_t dur)
{
assert(r);
size_t j = b;
size_t ar = r->arity();
label_t a = r->label();
label_t ar = r->arity();
assert(ar == 0);
assert(SymbLabel::fail(a) || SymbLabel::inside(a));
// incoming multiplicity (number of edges incoming to top node)
assert(SymbLabel::fail(a) || (SymbLabel::inmultiplicity(a) == mult));
// Preorder Traversal
// push top symbol to the tree stack of builder
size_t n = SymbLabel::nbEvents(a); // k.size();
// if (SymbLabel::terminal(a))
// n = k.pointsTerminalLabel(a, env);
size_t n = SymbLabel::nbEvents(a); // k.size(); k.pointsTerminalLabel(a, env);
if (SymbLabel::fail(a))
{
assert(ar == 0); // we do not go in the case inner below
INFO("TableImporter[({}) {}]: read FAIL symbol",
k.pre(), loc(j, n));
}
else if (SymbLabel::terminal(a))
{
assert(ar == 0);
INFO("TableImporter[({}) {}]: read terminal symbol {}",
k.pre(), loc(j, n), SymbLabel::to_string(a));
}
else
{
assert(ar > 0);
TRACE("TableImporter[({}) {}]: read symbol {} of arity {}",
ERROR("TableImporter[({}) {}]: unexpected symbol {} of arity {}",
k.pre(), loc(j, n), SymbLabel::to_string(a), ar);
}
// push top symbol to the tree stack of builder
return readSymbol(env, a, ar, mult, j, n, voiceNb, dur);
}
template<class K>
size_t TableMonoImporter::readTreeInnner(ScoringEnv& env,
Parsing::TableA<K>& tab,
const K& k,
const Parsing::RunInner<K>* r,
size_t mult,
size_t b,
int voiceNb,
mtu_t dur)
{
size_t j = b;
size_t ar = r->arity();
assert(ar > 0);
label_t a = r->label();
assert(SymbLabel::fail(a) || SymbLabel::inside(a));
// incoming multiplicity (number of edges incoming to top node)
assert(SymbLabel::fail(a) || (SymbLabel::inmultiplicity(a) == mult));
size_t n = 0; // only for terminal runs
if (SymbLabel::inner(a))
{
INFO("TableImporter[({}) {}]: read symbol {} of arity {}",
k.pre(), loc(j, n), SymbLabel::to_string(a), ar);
}
else
{
ERROR("TableImporter[({}) {}]: unexpected symbol {} of arity {}",
k.pre(), loc(j, n), SymbLabel::to_string(a), ar);
}
j = readSymbol(env, a, ar, mult, j, n, voiceNb, len);
// case of terminal symbol
if (ar == 0) return j;
// Preorder Traversal
// push top symbol to the tree stack of builder
j = readSymbol(env, a, ar, mult, j, n, voiceNb, dur);
// case of inner symbol
// recurse in every subrun of r // cf. LRTFactory and LRT
mtu_t leni = len / MTU::of_int(ar);
mtu_t duri = dur / MTU::of_int(ar);
Inner* tree = _builder.parent(); // top node of the tree in construction
assert(tree);
//size_t i = 0; // number of current sub-run
......@@ -341,7 +404,7 @@ size_t TableMonoImporter::readTree(ScoringEnv& env,
// i++;
if (! ri->fail())
{
j = readTree(env, tab, *ki, ri, multi, j, voiceNb, leni);
j = readTree(env, tab, *ki, ri, multi, j, voiceNb, duri);
}
// parse fail
else if (_unfailing) // skip this subrun and continue
......@@ -350,14 +413,14 @@ size_t TableMonoImporter::readTree(ScoringEnv& env,
/// @todo j should advance! wee need a run with a special symbol FAIL
/// containing number of events to skip
WARN("TableImporter[{}]: NULL subrun - unfailing mode", j);
WARN("TableImporter[{}]: FAILED subrun - unfailing mode", j);
/// @todo TBC only 1 staff for mono case?
int staff = 0;
j = readFail(multi, j, SymbLabel::nbEvents(ai), staff);
}
else // fail when NULL subrun
{
ERROR("TableImporter[{}]: NULL subrun - failing mode", j);
ERROR("TableImporter[{}]: FAILED subrun - failing mode", j);
/// @todo behaviour undefined if we close the tree now
return j;
}
......@@ -372,9 +435,9 @@ size_t TableMonoImporter::readSymbol(ScoringEnv& env,
size_t arity,
size_t mult,
size_t b,
size_t n,
size_t n, // nb of input symbols read
int voiceNb,
mtu_t len)
mtu_t dur)
{
TRACE("TableImporter[{}]: read symbol: {}",
loc(b, n), SymbLabel::to_string(a));
......@@ -426,7 +489,7 @@ size_t TableMonoImporter::readSymbol(ScoringEnv& env,
}
else if (SymbLabel::tuple(a))
{
return readTuple(a, arity, mult, b, len);
return readTuple(a, arity, mult, b, dur);
}
else if (SymbLabel::fail(a)) // parse fail
{
......@@ -708,7 +771,7 @@ size_t
TableMonoImporter::readTuple(label_t a,
size_t arity, size_t mult,
size_t b,
mtu_t len)
mtu_t dur)
{
assert(SymbLabel::inner(a));
assert(SymbLabel::tuple(a));
......@@ -727,7 +790,7 @@ TableMonoImporter::readTuple(label_t a,
assert(cm);
const MeterSig* ts = cm->meterSignature();
assert(ts);
TupletLabel lab(arity, mult, len, *ts);
TupletLabel lab(arity, mult, dur, *ts);
Tuplet* tn = _builder.pushTuplet(arity, mult, beam, lab);
assert(tn);
TRACE("TableImporter[{}]: read {}-uplet (push {} to Builder tree stack)",
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment