Пример #1
0
//---------------------------------------------------------------------------------------
wxString IdfyTonalityCtrol::prepare_score(EClef nClef, EKeySignature nKey,
                                          ImoScore** pProblemScore)
{
    //delete the previous score
    if (*pProblemScore)
    {
        delete *pProblemScore;
        *pProblemScore = NULL;
    }

    //determine tonic note
    //                        1 1 1 1 1 2 2 2 2 2 3 3 3 3 3 4 4 4 4 4 5 5 5 5 5 6 6 6 6 6
    //              0 2 4 6 8 0 2 4 6 8 0 2 4 6 8 0 2 4 6 8 0 2 4 6 8 0 2 4 6 8 0 2 4 6 8
    string notes = "c2d2e2f2g2a2b2c3d3e3f3g3a3b3c4d4e4f4g4a4b4c5d5e5f5g5a5b5c6d6e6f6g6a6b6";
    int nRoot = get_step_for_root_note(nKey)* 2 + 14;  //note in octave 3
    string note[16];  //4 notes per chord

    if (RandomGenerator::flip_coin())
    {
        //Marcelo Galvez. Tónica en los extremos
        //I
        note[0] = notes.substr(nRoot, 2);       //I
        note[1] = notes.substr(nRoot+8, 2);     //V
        note[2] = notes.substr(nRoot+18, 2);    //III
        note[3] = notes.substr(nRoot+28, 2);    //I
        //IV
        note[4] = notes.substr(nRoot-8, 2);     //IV
        note[5] = notes.substr(nRoot+10, 2);    //VI
        note[6] = notes.substr(nRoot+20, 2);    //IV
        note[7] = notes.substr(nRoot+28, 2);    //I
        //V
        note[8] = notes.substr(nRoot-6, 2);     //V
        note[9] = notes.substr(nRoot+8, 2);     //V
        note[10] = notes.substr(nRoot+16, 2);   //II
        note[11] = notes.substr(nRoot+26, 2);   //VII
    }
    else
    {
        //Marcelo Galvez. Tónica en los extremos. Opción 2
        //I
        note[0] = notes.substr(nRoot, 2);       //I
        note[1] = notes.substr(nRoot+4, 2);     //III
        note[2] = notes.substr(nRoot+22, 2);    //V
        note[3] = notes.substr(nRoot+28, 2);    //I
        //IV
        note[4] = notes.substr(nRoot-8, 2);     //IV
        note[5] = notes.substr(nRoot+6, 2);     //IV
        note[6] = notes.substr(nRoot+24, 2);    //VI
        note[7] = notes.substr(nRoot+28, 2);    //I
        //V
        note[8] = notes.substr(nRoot-6, 2);     //V
        note[9] = notes.substr(nRoot+2, 2);     //II
        note[10] = notes.substr(nRoot+22, 2);   //V
        note[11] = notes.substr(nRoot+26, 2);   //VII
    }
    //I
    note[12] = note[0];     //I
    note[13] = note[1];     //V
    note[14] = note[2];     //I
    note[15] = note[3];     //III

//    //Emilio Mesias
//    //I
//    note[0] = notes.substr(nRoot, 2);       //I
//    note[1] = notes.substr(nRoot+8, 2);     //V
//    note[2] = notes.substr(nRoot+14, 2);    //I
//    note[3] = notes.substr(nRoot+18, 2);    //III
//    //IV
//    note[4] = notes.substr(nRoot-8, 2);     //IV
//    note[5] = notes.substr(nRoot, 2);       //I
//    note[6] = notes.substr(nRoot+6, 2);     //IV
//    note[7] = notes.substr(nRoot+10, 2);    //VI
//    //V
//    note[8] = notes.substr(nRoot-6, 2);     //V
//    note[9] = notes.substr(nRoot+2, 2);     //II
//    note[10] = notes.substr(nRoot+8, 2);    //V
//    note[11] = notes.substr(nRoot+12, 2);   //VII
//    //I
//    note[12] = notes.substr(nRoot, 2);       //I
//    note[13] = notes.substr(nRoot+8, 2);     //V
//    note[14] = notes.substr(nRoot+14, 2);    //I
//    note[15] = notes.substr(nRoot+18, 2);    //III

    //create the score
    string sPattern;

    *pProblemScore = static_cast<ImoScore*>(ImFactory::inject(k_imo_score, m_pDoc));
    (*pProblemScore)->set_long_option("Render.SpacingMethod", long(k_spacing_fixed));
    ImoInstrument* pInstr = (*pProblemScore)->add_instrument();
    // (g_pMidi->DefaultVoiceChannel(), g_pMidi->DefaultVoiceInstr(), "");
    ImoSystemInfo* pInfo = (*pProblemScore)->get_first_system_info();
    pInfo->set_top_system_distance( pInstr->tenths_to_logical(30) );     // 3 lines
    pInstr->add_staff();                       //add second staff: five lines, standard size
    pInstr->add_clef( k_clef_G2, 1 );
    pInstr->add_clef( k_clef_F4, 2 );
    pInstr->add_key_signature( nKey );
    pInstr->add_time_signature(2 ,4);

    //add A4 note
    pInstr->add_object("(n =a4 w p1)");
    pInstr->add_barline(k_barline_simple);

    pInstr->add_object("(r w)");

    // Loop to add chords
    int i=0;
    for (int iC=0; iC < 4; iC++)
    {
        pInstr->add_spacer(15);
        pInstr->add_barline(k_barline_simple);

        sPattern = "(chord (n " + note[i++] + " w p2)";
        sPattern += "(n " + note[i++] + " w p2)";
        for (int iN=2; iN < 4; iN++)
            sPattern += "(n " + note[i++] + " w p1)";
        sPattern += ")";
        pInstr->add_staff_objects( sPattern );
    }
    pInstr->add_spacer(20);
    pInstr->add_barline(k_barline_end);

    (*pProblemScore)->close();      //for generating StaffObjs collection

    //return key signature name
    return get_key_signature_name(nKey);
}
Пример #2
0
//---------------------------------------------------------------------------------------
wxString IdfyScalesCtrol::prepare_score(EClef nClef, EScaleType nType, ImoScore** pScore)
{
    //create the scale
    Scale scale(m_fpRootNote, nType, m_nKey);

    ////dbg------------------------------------------------------
    //g_pLogger->LogTrace("IdfyScalesCtrol", "nClef = %d, nType = %d, m_sRootNote='%s', m_nKey=%d",
    //                nClef, nType, m_sRootNote.wx_str(), m_nKey );
    ////end dbg------------------------------------------------


    //delete the previous score
    if (*pScore)
    {
        delete *pScore;
        *pScore = NULL;
    }

    //create a score with the scale
    string sPattern;

    int nNumNotes = scale.get_num_notes();
    *pScore = static_cast<ImoScore*>(ImFactory::inject(k_imo_score, m_pDoc));
    (*pScore)->set_long_option("Render.SpacingMethod", long(k_spacing_fixed));
    //if (nType == est_Chromatic)
        (*pScore)->set_long_option("Render.SpacingValue", 20L);
    ImoInstrument* pInstr = (*pScore)->add_instrument();
    // (g_pMidi->DefaultVoiceChannel(), g_pMidi->DefaultVoiceInstr(), "");
    ImoSystemInfo* pInfo = (*pScore)->get_first_system_info();
    pInfo->set_top_system_distance( pInstr->tenths_to_logical(30) );     // 3 lines
    pInstr->add_clef( k_clef_G2 );
    pInstr->add_key_signature( m_nKey );
    pInstr->add_time_signature(4 ,4, k_no_visible );

    int i = (m_fAscending ? 0 : nNumNotes-1);
    sPattern = "(n " + scale.rel_ldp_name_for_note(i) + " w)";
    pInstr->add_object( sPattern );
    pInstr->add_spacer(10);       // 1 lines
    pInstr->add_barline(k_barline_simple, k_no_visible);   //so accidentals doesn't affect a 2nd note
    for (i=1; i < nNumNotes; i++)
    {
        sPattern = "(n ";
        sPattern += scale.rel_ldp_name_for_note((m_fAscending ? i : nNumNotes-1-i));
        sPattern +=  " w)";
//            wxLogMessage("[] i=%d, pattern=%s", i, to_wx_string(sPattern).wx_str());
        pInstr->add_object( sPattern );
        pInstr->add_spacer(10);       // 1 lines
        pInstr->add_barline(k_barline_simple, k_no_visible);   //so accidentals doesn't affect a 2nd note
    }
    pInstr->add_barline(k_barline_end, k_no_visible);

    (*pScore)->close();

    //(*pScore)->Dump("IdfyScalesCtrol.prepare_score.ScoreDump.txt");  //dbg

    //set metronome. As the problem score is built using whole notes, we will
    //set metronome at MM=400 so the resulting note rate will be 100.
    m_nPlayMM = 400;

    //return the scale name
    return scale.get_name();
}