Example #1
0
//=======================================================================================
// PitchAssigner implementation
//=======================================================================================
void PitchAssigner::assign_pitch(ImoScore* pScore)
{
    StaffObjsCursor cursor(pScore);

    ImoKeySignature* pKey = NULL;
    reset_accidentals(pKey);

    while(!cursor.is_end())
    {
        ImoStaffObj* pSO = cursor.get_staffobj();
        if (pSO->is_note())
        {
            ImoNote* pNote = static_cast<ImoNote*>(pSO);
            compute_pitch(pNote);
        }
        else if (pSO->is_barline())
        {
            reset_accidentals(pKey);
        }
        else if (pSO->is_key_signature())
        {
            pKey = static_cast<ImoKeySignature*>( pSO );
            reset_accidentals(pKey);
        }

        cursor.move_next();
    }
}
Example #2
0
//---------------------------------------------------------------------------------------
ImoObj* Linker::add_relation(ImoRelObj* pRelObj)
{
    if (m_pParent && m_pParent->is_staffobj())
    {
        ImoStaffObj* pSO = static_cast<ImoStaffObj*>(m_pParent);
        pSO->add_relation(m_pDoc, pRelObj);
        return NULL;
    }
    return pRelObj;
}
Example #3
0
//---------------------------------------------------------------------------------------
void ScoreComparer::mark_score(ImoScore* pScore, int** X)
{
    //add color to inserted/deleted staffobjs

    ColStaffObjs* pCol = pScore->get_staffobjs_table();
    ColStaffObjsIterator it;
    int i=0;
    for (it = pCol->begin(); it != pCol->end(); ++it, ++i)
    {
        ImoStaffObj* pSO = static_cast<ImoStaffObj*>( (*it)->imo_object() );
        if (*(*X+i) == 1)
            pSO->set_color( Color(255,0,0) );
    }
    pScore->set_dirty(true);

}
Example #4
0
//---------------------------------------------------------------------------------------
void AutoClef::find_staves_needing_clef()
{
    //An staff needs clef if it has pitched notes before finding a clef.
    //This method saves data for each staff in vectors m_fNeedsClef, m_pAt,
    //m_maxPitch, m_minPitch

    int staves = m_pCursor->get_num_staves();
    int stavesWithNotes = 0;

    m_fNeedsClef.assign(staves, false);
    m_pAt.assign(staves, (ImoStaffObj*)nullptr);
    m_maxPitch.assign(staves, k_undefined_fpitch);
    m_minPitch.assign(staves, k_undefined_fpitch);
    m_numNotes.assign(staves, 0);

    vector<bool> fHasNotes;         //true if staff i has pitched notes
    fHasNotes.assign(staves, false);

    while(!m_pCursor->is_end())
    {
        ImoStaffObj* pSO = m_pCursor->get_staffobj();
        int iStaff = m_pCursor->staff_index();

        if (m_pAt[iStaff] == nullptr)
            m_pAt[iStaff] = pSO;

        if (pSO->is_note())
        {
            ImoNote* pN = static_cast<ImoNote*>(pSO);
            if (!m_fNeedsClef[iStaff] && !fHasNotes[iStaff])
            {
                if (pN->is_pitch_defined())
                {
                    int clefType = m_pCursor->get_applicable_clef_type();
                    if (clefType == k_clef_undefined)
                        m_fNeedsClef[iStaff] = true;
                    fHasNotes[iStaff] = true;
                }
            }

            if (m_fNeedsClef[iStaff])
            {
                if (pN->is_pitch_defined())
                {
                    FPitch fp = pN->get_fpitch();
                    if (m_maxPitch[iStaff] == k_undefined_fpitch || m_maxPitch[iStaff] < fp)
                        m_maxPitch[iStaff] = fp;
                    if (m_minPitch[iStaff] == k_undefined_fpitch || m_minPitch[iStaff] > fp)
                        m_minPitch[iStaff] = fp;
                    ++m_numNotes[iStaff];

                     if (m_numNotes[iStaff] == 10)
                        ++stavesWithNotes;
                     if (stavesWithNotes == staves)
                        break;
               }
            }
        }
        m_pCursor->move_next();
    }
}