~s-cecilio/lomse/master

« back to all changes in this revision

Viewing changes to src/parser/ldp/lomse_ldp_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:
3925
3925
        //tuplet
3926
3926
        if (fAddOldTuplet)
3927
3927
            set_old_tuplet(pNR);
3928
 
        else if (m_pTupletInfo==NULL
3929
 
                 && m_pAnalyser->is_tuplet_open()
3930
 
                 && m_pAnalyser->get_score_version() <= 107
3931
 
                )
3932
 
            add_to_current_tuplet(pNR);
3933
 
 
3934
 
        add_tuplet_info(pNR);
 
3928
        else
 
3929
            add_tuplet_info(pNR);
3935
3930
 
3936
3931
        //time modification
3937
3932
        if (m_pTimeModifDto != NULL)
3969
3964
      //  }
3970
3965
 
3971
3966
            ImoTreeAlgoritms::add_note_to_chord(pStartOfChordNote, pNote, pDoc);
3972
 
 
3973
 
//            ImoChord* pChord;
3974
 
//            if (pStartOfChordNote->is_in_chord())
3975
 
//            {
3976
 
//                //chord already created. just add note to it
3977
 
//                pChord = pStartOfChordNote->get_chord();
3978
 
//            }
3979
 
//            else
3980
 
//            {
3981
 
//                //previous note is the base note. Create the chord
3982
 
//                pChord = static_cast<ImoChord*>(ImFactory::inject(k_imo_chord, pDoc));
3983
 
//                pStartOfChordNote->include_in_relation(pDoc, pChord);
3984
 
//            }
3985
 
//
3986
 
//            //add current note to chord
3987
 
//            pNote->include_in_relation(pDoc, pChord);
3988
3967
        }
3989
3968
 
3990
3969
        //save this note as last note
4159
4138
        }
4160
4139
    }
4161
4140
 
4162
 
    void add_to_current_tuplet(ImoNoteRest* pNR)
4163
 
    {
4164
 
        ImoTupletDto* pInfo = LOMSE_NEW ImoTupletDto();
4165
 
        pInfo->set_note_rest(pNR);
4166
 
        pInfo->set_tuplet_type(ImoTupletDto::k_continue);
4167
 
        m_pAnalyser->add_relation_info(pInfo);
4168
 
    }
4169
 
 
4170
4141
    void set_old_tuplet(ImoNoteRest* pNR)
4171
4142
    {
4172
4143
        string value = m_srcOldTuplet;
4212
4183
            {
4213
4184
                report_msg(m_pParamToAnalyse->get_line_number(),
4214
4185
                    "Requesting to start a tuplet but there is already an open tuplet. Tuplet ignored.");
4215
 
                add_to_current_tuplet(pNR);
4216
4186
            }
4217
4187
            else
4218
4188
            {
4249
4219
            //    pInfo->set_normal_number(0);  //required
4250
4220
        }
4251
4221
        ImoTupletDto* pInfo = LOMSE_NEW ImoTupletDto();
 
4222
        pInfo->set_tuplet_type(ImoTupletDto::k_start);
4252
4223
        pInfo->set_note_rest(pNR);
4253
4224
        pInfo->set_actual_number(actual);
4254
4225
        pInfo->set_normal_number(normal);
4285
4256
    {
4286
4257
        if (m_pTupletInfo)
4287
4258
        {
 
4259
            if (m_pTupletInfo->is_start_of_tuplet())
 
4260
                m_pAnalyser->add_to_open_tuplets(pNR);
 
4261
 
4288
4262
            m_pTupletInfo->set_note_rest(pNR);
4289
4263
            m_pAnalyser->add_relation_info(m_pTupletInfo);
 
4264
 
 
4265
            if (m_pTupletInfo->is_end_of_tuplet())
 
4266
                m_pAnalyser->add_to_open_tuplets(pNR);
4290
4267
        }
 
4268
        else
 
4269
            m_pAnalyser->add_to_open_tuplets(pNR);
4291
4270
    }
4292
4271
 
4293
4272
    void add_beam_info(ImoNoteRest* pNR)
6078
6057
        set_default_values(pInfo);
6079
6058
 
6080
6059
        // [<tupletID>]     //optional. Only required for nested tuplets
6081
 
        if (get_optional(k_number))
6082
 
            set_tuplet_id(pInfo);
 
6060
        // <tupletID>   Mandatory since 2.1, for nested tuplets
 
6061
        // if (m_pAnalyser->get_score_version() > 200)
 
6062
        //{
 
6063
        //    if (get_mandatory(k_number))
 
6064
        //        set_tuplet_id(pInfo);
 
6065
        //    else
 
6066
        //    {
 
6067
        //        error_msg("Missing or invalid tuplet number. Tuplet ignored.");
 
6068
        //        delete pInfo;
 
6069
        //        return;
 
6070
        //    }
 
6071
        //}
 
6072
        //else
 
6073
        {
 
6074
            if (get_optional(k_number))
 
6075
                set_tuplet_id(pInfo);
 
6076
        }
6083
6077
 
6084
6078
        // { + | - }
6085
6079
        if (!get_mandatory(k_label) || !set_tuplet_type(pInfo))
7467
7461
    ImoTupletDto* pStartDto = m_matches.front();
7468
7462
    m_pTuplet = ImFactory::inject_tuplet(pDoc, pStartDto);
7469
7463
 
7470
 
    //if not only graphical (LDP < 2.0) add time modification to all note/rest
7471
 
    if (!pStartDto->is_only_graphical())
 
7464
    //loop for including the tuplet in all note/rest
 
7465
    std::list<ImoTupletDto*>::iterator it;
 
7466
    for (it = m_matches.begin(); it != m_matches.end(); ++it)
7472
7467
    {
7473
 
        std::list<ImoTupletDto*>::iterator it;
7474
 
        for (it = m_matches.begin(); it != m_matches.end(); ++it)
7475
 
        {
7476
 
            ImoNoteRest* pNR = (*it)->get_note_rest();
 
7468
        //add tuplet to the note/rest
 
7469
        ImoNoteRest* pNR = (*it)->get_note_rest();
 
7470
        pNR->include_in_relation(pDoc, m_pTuplet, NULL);
 
7471
 
 
7472
        //if not only graphical (LDP < 2.0) add time modification the note/rest
 
7473
        if (!pStartDto->is_only_graphical())
7477
7474
            pNR->set_time_modification( m_pTuplet->get_normal_number(),
7478
7475
                                        m_pTuplet->get_actual_number() );
7479
 
        }
7480
 
    }
7481
 
 
7482
 
    //create tuplet data and add tuplet to start and end note/rest
7483
 
    ImoNoteRest* pNR = pStartDto->get_note_rest();
7484
 
    pNR->include_in_relation(pDoc, m_pTuplet, NULL);
7485
 
 
7486
 
    pNR = pEndDto->get_note_rest();
7487
 
    pNR->include_in_relation(pDoc, m_pTuplet, NULL);
 
7476
    }
 
7477
}
 
7478
 
 
7479
//---------------------------------------------------------------------------------------
 
7480
void TupletsBuilder::add_to_open_tuplets(ImoNoteRest* pNR)
 
7481
{
 
7482
    if (m_pendingItems.size() > 0)
 
7483
    {
 
7484
        ListIterator it;
 
7485
        for(it=m_pendingItems.begin(); it != m_pendingItems.end(); ++it)
 
7486
        {
 
7487
            if ((*it)->is_start_of_relation() )
 
7488
            {
 
7489
                ImoTupletDto* pInfo = LOMSE_NEW ImoTupletDto();
 
7490
                pInfo->set_tuplet_number( (*it)->get_item_number() );
 
7491
                pInfo->set_tuplet_type(ImoTupletDto::k_continue);
 
7492
                pInfo->set_note_rest(pNR);
 
7493
                save_item_info(pInfo);
 
7494
            }
 
7495
        }
 
7496
    }
7488
7497
}
7489
7498
 
7490
7499