Lines 349-355
Link Here
|
349 |
m_final = m_baseIterator; |
349 |
m_final = m_baseIterator; |
350 |
sample(m_baseIterator, true); |
350 |
sample(m_baseIterator, true); |
351 |
|
351 |
|
352 |
if (getAsEvent(m_baseIterator)->isa(Note::EventType)) { |
352 |
if (AbstractSet::getAsEvent(m_baseIterator)->isa(Note::EventType)) { |
353 |
m_initialNote = m_baseIterator; |
353 |
m_initialNote = m_baseIterator; |
354 |
m_finalNote = m_baseIterator; |
354 |
m_finalNote = m_baseIterator; |
355 |
} |
355 |
} |
Lines 362-368
Link Here
|
362 |
for (i = j = m_baseIterator; i != getContainer().begin() && test(--j); i = j){ |
362 |
for (i = j = m_baseIterator; i != getContainer().begin() && test(--j); i = j){ |
363 |
if (sample(j, false)) { |
363 |
if (sample(j, false)) { |
364 |
m_initial = j; |
364 |
m_initial = j; |
365 |
if (getAsEvent(j)->isa(Note::EventType)) { |
365 |
if (AbstractSet::getAsEvent(j)->isa(Note::EventType)) { |
366 |
m_initialNote = j; |
366 |
m_initialNote = j; |
367 |
if (m_finalNote == getContainer().end()) { |
367 |
if (m_finalNote == getContainer().end()) { |
368 |
m_finalNote = j; |
368 |
m_finalNote = j; |
Lines 379-385
Link Here
|
379 |
for (i = j = m_baseIterator; ++j != getContainer().end() && test(j); i = j) { |
379 |
for (i = j = m_baseIterator; ++j != getContainer().end() && test(j); i = j) { |
380 |
if (sample(j, true)) { |
380 |
if (sample(j, true)) { |
381 |
m_final = j; |
381 |
m_final = j; |
382 |
if (getAsEvent(j)->isa(Note::EventType)) { |
382 |
if (AbstractSet::getAsEvent(j)->isa(Note::EventType)) { |
383 |
m_finalNote = j; |
383 |
m_finalNote = j; |
384 |
if (m_initialNote == getContainer().end()) { |
384 |
if (m_initialNote == getContainer().end()) { |
385 |
m_initialNote = j; |
385 |
m_initialNote = j; |
Lines 397-413
Link Here
|
397 |
AbstractSet<Element, Container>::sample(const Iterator &i, bool) |
397 |
AbstractSet<Element, Container>::sample(const Iterator &i, bool) |
398 |
{ |
398 |
{ |
399 |
const Quantizer &q(getQuantizer()); |
399 |
const Quantizer &q(getQuantizer()); |
400 |
Event *e = getAsEvent(i); |
400 |
Event *e = AbstractSet::getAsEvent(i); |
401 |
timeT d(q.getQuantizedDuration(e)); |
401 |
timeT d(q.getQuantizedDuration(e)); |
402 |
|
402 |
|
403 |
if (e->isa(Note::EventType) || d > 0) { |
403 |
if (e->isa(Note::EventType) || d > 0) { |
404 |
if (m_longest == getContainer().end() || |
404 |
if (m_longest == getContainer().end() || |
405 |
d > q.getQuantizedDuration(getAsEvent(m_longest))) { |
405 |
d > q.getQuantizedDuration(AbstractSet::getAsEvent(m_longest))) { |
406 |
// std::cerr << "New longest in set at duration " << d << " and time " << e->getAbsoluteTime() << std::endl; |
406 |
// std::cerr << "New longest in set at duration " << d << " and time " << e->getAbsoluteTime() << std::endl; |
407 |
m_longest = i; |
407 |
m_longest = i; |
408 |
} |
408 |
} |
409 |
if (m_shortest == getContainer().end() || |
409 |
if (m_shortest == getContainer().end() || |
410 |
d < q.getQuantizedDuration(getAsEvent(m_shortest))) { |
410 |
d < q.getQuantizedDuration(AbstractSet::getAsEvent(m_shortest))) { |
411 |
// std::cerr << "New shortest in set at duration " << d << " and time " << e->getAbsoluteTime() << std::endl; |
411 |
// std::cerr << "New shortest in set at duration " << d << " and time " << e->getAbsoluteTime() << std::endl; |
412 |
m_shortest = i; |
412 |
m_shortest = i; |
413 |
} |
413 |
} |
Lines 417-428
Link Here
|
417 |
long p = get__Int(e, BaseProperties::PITCH); |
417 |
long p = get__Int(e, BaseProperties::PITCH); |
418 |
|
418 |
|
419 |
if (m_highest == getContainer().end() || |
419 |
if (m_highest == getContainer().end() || |
420 |
p > get__Int(getAsEvent(m_highest), BaseProperties::PITCH)) { |
420 |
p > get__Int(AbstractSet::getAsEvent(m_highest), BaseProperties::PITCH)) { |
421 |
// std::cerr << "New highest in set at pitch " << p << " and time " << e->getAbsoluteTime() << std::endl; |
421 |
// std::cerr << "New highest in set at pitch " << p << " and time " << e->getAbsoluteTime() << std::endl; |
422 |
m_highest = i; |
422 |
m_highest = i; |
423 |
} |
423 |
} |
424 |
if (m_lowest == getContainer().end() || |
424 |
if (m_lowest == getContainer().end() || |
425 |
p < get__Int(getAsEvent(m_lowest), BaseProperties::PITCH)) { |
425 |
p < get__Int(AbstractSet::getAsEvent(m_lowest), BaseProperties::PITCH)) { |
426 |
// std::cerr << "New lowest in set at pitch " << p << " and time " << e->getAbsoluteTime() << std::endl; |
426 |
// std::cerr << "New lowest in set at pitch " << p << " and time " << e->getAbsoluteTime() << std::endl; |
427 |
m_lowest = i; |
427 |
m_lowest = i; |
428 |
} |
428 |
} |
Lines 441-448
Link Here
|
441 |
PropertyName stemUpProperty) : |
441 |
PropertyName stemUpProperty) : |
442 |
AbstractSet<Element, Container>(c, i, q), |
442 |
AbstractSet<Element, Container>(c, i, q), |
443 |
m_stemUpProperty(stemUpProperty), |
443 |
m_stemUpProperty(stemUpProperty), |
444 |
m_time(q->getQuantizedAbsoluteTime(getAsEvent(i))), |
444 |
m_time(q->getQuantizedAbsoluteTime(GenericChord::getAsEvent(i))), |
445 |
m_subordering(getAsEvent(i)->getSubOrdering()), |
445 |
m_subordering(GenericChord::getAsEvent(i)->getSubOrdering()), |
446 |
m_firstReject(c.end()) |
446 |
m_firstReject(c.end()) |
447 |
{ |
447 |
{ |
448 |
// initialise must be called in individual derived classes. If we |
448 |
// initialise must be called in individual derived classes. If we |
Lines 471-477
Link Here
|
471 |
bool |
471 |
bool |
472 |
GenericChord<Element, Container, singleStaff>::test(const Iterator &i) |
472 |
GenericChord<Element, Container, singleStaff>::test(const Iterator &i) |
473 |
{ |
473 |
{ |
474 |
Event *e = getAsEvent(i); |
474 |
Event *e = GenericChord::getAsEvent(i); |
475 |
if (AbstractSet<Element, Container>:: |
475 |
if (AbstractSet<Element, Container>:: |
476 |
getQuantizer().getQuantizedAbsoluteTime(e) != m_time) { |
476 |
getQuantizer().getQuantizedAbsoluteTime(e) != m_time) { |
477 |
return false; |
477 |
return false; |
Lines 507-513
Link Here
|
507 |
GenericChord<Element, Container, singleStaff>::sample(const Iterator &i, |
507 |
GenericChord<Element, Container, singleStaff>::sample(const Iterator &i, |
508 |
bool goingForwards) |
508 |
bool goingForwards) |
509 |
{ |
509 |
{ |
510 |
Event *e1 = getAsEvent(i); |
510 |
Event *e1 = GenericChord::getAsEvent(i); |
511 |
if (!e1->isa(Note::EventType)) { |
511 |
if (!e1->isa(Note::EventType)) { |
512 |
if (goingForwards && m_firstReject == AbstractSet<Element, Container>::getContainer().end()) m_firstReject = i; |
512 |
if (goingForwards && m_firstReject == AbstractSet<Element, Container>::getContainer().end()) m_firstReject = i; |
513 |
return false; |
513 |
return false; |
Lines 527-533
Link Here
|
527 |
|
527 |
|
528 |
if (AbstractSet<Element, Container>::m_baseIterator != AbstractSet<Element, Container>::getContainer().end()) { |
528 |
if (AbstractSet<Element, Container>::m_baseIterator != AbstractSet<Element, Container>::getContainer().end()) { |
529 |
|
529 |
|
530 |
Event *e0 = getAsEvent(AbstractSet<Element, Container>::m_baseIterator); |
530 |
Event *e0 = GenericChord::getAsEvent(AbstractSet<Element, Container>::m_baseIterator); |
531 |
|
531 |
|
532 |
if (!(m_stemUpProperty == PropertyName::EmptyPropertyName)) { |
532 |
if (!(m_stemUpProperty == PropertyName::EmptyPropertyName)) { |
533 |
|
533 |
|
Lines 573-579
Link Here
|
573 |
} |
573 |
} |
574 |
|
574 |
|
575 |
AbstractSet<Element, Container>::sample(i, goingForwards); |
575 |
AbstractSet<Element, Container>::sample(i, goingForwards); |
576 |
push_back(i); |
576 |
this->push_back(i); |
577 |
return true; |
577 |
return true; |
578 |
} |
578 |
} |
579 |
|
579 |
|
Lines 615-621
Link Here
|
615 |
|
615 |
|
616 |
for (unsigned int i = 0; i < std::vector<typename Container::iterator>::size(); ++i) { |
616 |
for (unsigned int i = 0; i < std::vector<typename Container::iterator>::size(); ++i) { |
617 |
|
617 |
|
618 |
Event *e = getAsEvent((*this)[i]); |
618 |
Event *e = GenericChord::getAsEvent((*this)[i]); |
619 |
std::vector<Mark> marks(Marks::getMarks(*e)); |
619 |
std::vector<Mark> marks(Marks::getMarks(*e)); |
620 |
|
620 |
|
621 |
for (std::vector<Mark>::iterator j = marks.begin(); j != marks.end(); ++j) { |
621 |
for (std::vector<Mark>::iterator j = marks.begin(); j != marks.end(); ++j) { |
Lines 635-641
Link Here
|
635 |
|
635 |
|
636 |
for (unsigned int i = 0; i < std::vector<typename Container::iterator>::size(); ++i) { |
636 |
for (unsigned int i = 0; i < std::vector<typename Container::iterator>::size(); ++i) { |
637 |
|
637 |
|
638 |
Event *e = getAsEvent((*this)[i]); |
638 |
Event *e = GenericChord::getAsEvent((*this)[i]); |
639 |
std::vector<Mark> marks(Marks::getMarks(*e)); |
639 |
std::vector<Mark> marks(Marks::getMarks(*e)); |
640 |
|
640 |
|
641 |
|
641 |
|
Lines 662-670
Link Here
|
662 |
|
662 |
|
663 |
for (typename std::vector<typename Container::iterator>::const_iterator |
663 |
for (typename std::vector<typename Container::iterator>::const_iterator |
664 |
i = std::vector<typename Container::iterator>::begin(); i != std::vector<typename Container::iterator>::end(); ++i) { |
664 |
i = std::vector<typename Container::iterator>::begin(); i != std::vector<typename Container::iterator>::end(); ++i) { |
665 |
if (getAsEvent(*i)->has(BaseProperties::PITCH)) { |
665 |
if (GenericChord::getAsEvent(*i)->has(BaseProperties::PITCH)) { |
666 |
int pitch = get__Int |
666 |
int pitch = get__Int |
667 |
(getAsEvent(*i), BaseProperties::PITCH); |
667 |
(GenericChord::getAsEvent(*i), BaseProperties::PITCH); |
668 |
if (pitches.size() > 0 && pitches[pitches.size()-1] == pitch) |
668 |
if (pitches.size() > 0 && pitches[pitches.size()-1] == pitch) |
669 |
continue; |
669 |
continue; |
670 |
pitches.push_back(pitch); |
670 |
pitches.push_back(pitch); |
Lines 696-702
Link Here
|
696 |
while (1) { |
696 |
while (1) { |
697 |
if (i == AbstractSet<Element, Container>::getContainer().begin()) return AbstractSet<Element, Container>::getContainer().end(); |
697 |
if (i == AbstractSet<Element, Container>::getContainer().begin()) return AbstractSet<Element, Container>::getContainer().end(); |
698 |
--i; |
698 |
--i; |
699 |
if (getAsEvent(i)->isa(Note::EventType)) { |
699 |
if (GenericChord::getAsEvent(i)->isa(Note::EventType)) { |
700 |
return i; |
700 |
return i; |
701 |
} |
701 |
} |
702 |
} |
702 |
} |
Lines 710-716
Link Here
|
710 |
Iterator i(AbstractSet<Element, Container>::getFinalElement()); |
710 |
Iterator i(AbstractSet<Element, Container>::getFinalElement()); |
711 |
while ( i != AbstractSet<Element, Container>::getContainer().end() && |
711 |
while ( i != AbstractSet<Element, Container>::getContainer().end() && |
712 |
++i != AbstractSet<Element, Container>::getContainer().end()) { |
712 |
++i != AbstractSet<Element, Container>::getContainer().end()) { |
713 |
if (getAsEvent(i)->isa(Note::EventType)) { |
713 |
if (GenericChord::getAsEvent(i)->isa(Note::EventType)) { |
714 |
return i; |
714 |
return i; |
715 |
} |
715 |
} |
716 |
} |
716 |
} |
Lines 732-739
Link Here
|
732 |
const Iterator &b) |
732 |
const Iterator &b) |
733 |
{ |
733 |
{ |
734 |
try { |
734 |
try { |
735 |
long ap = get__Int(getAsEvent(a), BaseProperties::PITCH); |
735 |
long ap = get__Int(GenericChord::getAsEvent(a), BaseProperties::PITCH); |
736 |
long bp = get__Int(getAsEvent(b), BaseProperties::PITCH); |
736 |
long bp = get__Int(GenericChord::getAsEvent(b), BaseProperties::PITCH); |
737 |
return (ap < bp); |
737 |
return (ap < bp); |
738 |
} catch (Event::NoData) { |
738 |
} catch (Event::NoData) { |
739 |
std::cerr << "Bad karma: PitchGreater failed to find one or both pitches" << std::endl; |
739 |
std::cerr << "Bad karma: PitchGreater failed to find one or both pitches" << std::endl; |