~s-cecilio/lomse/master

« back to all changes in this revision

Viewing changes to src/parser/mxl/lomse_mxl_analyser.cpp

  • Committer: cecilios
  • Date: 2016-09-13 14:57:54 UTC
  • mto: This revision was merged to the branch mainline in revision 203.
  • Revision ID: git-v1:a5a4c98e1e43e6e727a2f2d22a87b01344b6239c
Draw nested tuplets

Show diffs side-by-side

added added

removed removed

Lines of Context:
2897
2897
        {
2898
2898
        }
2899
2899
 
 
2900
        //add note/rest to open tuplets
 
2901
        m_pAnalyser->add_to_open_tuplets(pNR);
 
2902
 
2900
2903
        // [<staff>]
2901
2904
        if (get_optional("staff"))
2902
2905
            set_staff(pNR);
4906
4909
 
4907
4910
        if (m_pInfo->is_start_of_tuplet())
4908
4911
        {
4909
 
            m_pInfo->set_actual_number( pNR->get_time_modifier_bottom() );
4910
 
            m_pInfo->set_normal_number( pNR->get_time_modifier_top() );
 
4912
            int top, bottom;
 
4913
            get_factors_for_nested_tuplets(pNR, &top, &bottom);
 
4914
            m_pInfo->set_actual_number( pNR->get_time_modifier_bottom() / bottom );
 
4915
            m_pInfo->set_normal_number( pNR->get_time_modifier_top() / top );
4911
4916
        }
4912
4917
 
4913
4918
        m_pInfo->set_note_rest(pNR);
5002
5007
 
5003
5008
    }
5004
5009
 
 
5010
    void get_factors_for_nested_tuplets(ImoNoteRest* pNR, int* pTop, int* pBottom)
 
5011
    {
 
5012
        *pTop = 1;
 
5013
        *pBottom = 1;
 
5014
        if (pNR->get_num_relations() > 0)
 
5015
        {
 
5016
            ImoRelations* pRelObjs = pNR->get_relations();
 
5017
            int size = pRelObjs->get_num_items();
 
5018
            for (int i=0; i < size; ++i)
 
5019
            {
 
5020
                ImoRelObj* pRO = pRelObjs->get_item(i);
 
5021
                if (pRO->is_tuplet())
 
5022
                {
 
5023
                    if (pRO->get_start_object() == pNR)
 
5024
                    {
 
5025
                        ImoTuplet* pTuplet = static_cast<ImoTuplet*>(pRO);
 
5026
                        *pTop *= pTuplet->get_normal_number();
 
5027
                        *pBottom *= pTuplet->get_actual_number();
 
5028
                    }
 
5029
                }
 
5030
            }
 
5031
        }
 
5032
    }
 
5033
 
5005
5034
};
5006
5035
 
5007
5036
 
5812
5841
//=======================================================================================
5813
5842
// MxlTupletsBuilder implementation
5814
5843
//=======================================================================================
5815
 
void MxlTupletsBuilder::add_relation_to_notes_rests(ImoTupletDto* pEndDto)
 
5844
void MxlTupletsBuilder::add_relation_to_notes_rests(ImoTupletDto* UNUSED(pEndDto))
5816
5845
{
5817
 
    m_matches.push_back(pEndDto);
5818
5846
    Document* pDoc = m_pAnalyser->get_document_being_analysed();
5819
5847
 
5820
5848
    ImoTupletDto* pStartDto = m_matches.front();
5828
5856
    }
5829
5857
}
5830
5858
 
 
5859
//---------------------------------------------------------------------------------------
 
5860
void MxlTupletsBuilder::add_to_open_tuplets(ImoNoteRest* pNR)
 
5861
{
 
5862
    if (m_pendingItems.size() > 0)
 
5863
    {
 
5864
        ListIterator it;
 
5865
        for(it=m_pendingItems.begin(); it != m_pendingItems.end(); ++it)
 
5866
        {
 
5867
            if ((*it)->is_start_of_relation() )
 
5868
            {
 
5869
                ImoTupletDto* pInfo = LOMSE_NEW ImoTupletDto();
 
5870
                pInfo->set_tuplet_number( (*it)->get_item_number() );
 
5871
                pInfo->set_tuplet_type(ImoTupletDto::k_continue);
 
5872
                pInfo->set_note_rest(pNR);
 
5873
                save_item_info(pInfo);
 
5874
            }
 
5875
        }
 
5876
    }
 
5877
}
 
5878
 
5831
5879
//=======================================================================================
5832
5880
//// MxlAutoBeamer implementation
5833
5881
////=======================================================================================