Exemplo n.º 1
0
int Note::PrepareTieAttr( ArrayPtrVoid *params )
{
    // param 0: std::vector<Note*>* that holds the current notes with open ties
    // param 1: Chord** currentChord for the current chord if in a chord
    std::vector<Note*> *currentNotes = static_cast<std::vector<Note*>*>((*params).at(0));
    Chord **currentChord = static_cast<Chord**>((*params).at(1));
    
    AttTiepresent *check = this;
    // Use the parent chord if there is no @tie on the note
    if (!this->HasTie() && (*currentChord)) {
        check = (*currentChord);
    }
    assert(check);
    
    std::vector<Note*>::iterator iter = currentNotes->begin();
    while ( iter != currentNotes->end()) {
        // same octave and same pitch - this is the one!
        if ((this->GetOct()==(*iter)->GetOct()) && (this->GetPname()==(*iter)->GetPname())) {
            // right flag
            if ((check->GetTie()==TIE_m) || (check->GetTie()==TIE_t)) {
                assert( (*iter)->GetDrawingTieAttr() );
                (*iter)->GetDrawingTieAttr()->SetEnd(this);
            }
            else {
                LogWarning("Expected @tie median or terminal in note '%s', skipping it", this->GetUuid().c_str());
                (*iter)->ResetDrawingTieAttr();
            }
            iter = currentNotes->erase( iter );
            // we are done for this note
            break;
        }
        iter++;
    }

    if ((check->GetTie()==TIE_m) || (check->GetTie()==TIE_i)) {
        this->SetDrawingTieAttr();
        currentNotes->push_back(this);
    }
    
    return FUNCTOR_CONTINUE;
}
Exemplo n.º 2
0
int Note::PrepareTieAttr(FunctorParams *functorParams)
{
    PrepareTieAttrParams *params = dynamic_cast<PrepareTieAttrParams *>(functorParams);
    assert(params);

    AttTiepresent *check = this;
    // Use the parent chord if there is no @tie on the note
    if (!this->HasTie() && params->m_currentChord) {
        check = params->m_currentChord;
    }
    assert(check);

    std::vector<Note *>::iterator iter = params->m_currentNotes.begin();
    while (iter != params->m_currentNotes.end()) {
        // same octave and same pitch - this is the one!
        if ((this->GetOct() == (*iter)->GetOct()) && (this->GetPname() == (*iter)->GetPname())) {
            // right flag
            if ((check->GetTie() == TIE_m) || (check->GetTie() == TIE_t)) {
                assert((*iter)->GetDrawingTieAttr());
                (*iter)->GetDrawingTieAttr()->SetEnd(this);
            }
            else {
                LogWarning("Expected @tie median or terminal in note '%s', skipping it", this->GetUuid().c_str());
                (*iter)->ResetDrawingTieAttr();
            }
            iter = params->m_currentNotes.erase(iter);
            // we are done for this note
            break;
        }
        iter++;
    }

    if ((check->GetTie() == TIE_m) || (check->GetTie() == TIE_i)) {
        this->SetDrawingTieAttr();
        params->m_currentNotes.push_back(this);
    }

    return FUNCTOR_CONTINUE;
}