In the key of Gb major the Cb are all exported incorrectly.

I think I fixed the bug with the following change to gui/lilpondio.cpp. 
I don't know how to make a patch, but the function changed is 

std::string
LilypondExporter::convertPitchToLilyNote (long pitch, bool
isFlatKeySignature,
                        int accidentalCount, Accidental accidental) {


And the change is listed below:

// processes input to produce a Lilypond-format note written correctly
for all
// keys and out-of-key accidental combinations.
std::string
LilypondExporter::convertPitchToLilyNote (long pitch, bool
isFlatKeySignature,
                        int accidentalCount, Accidental accidental) {
    std::string lilyNote = "";
    int pitchNote, c;
    
    // get raw semitone number
    pitchNote = (pitch % 12);

    // no accidental, or notes with Natural property
    switch (pitchNote) {
        case 0:  lilyNote = "c";
                 break;
        case 2:  lilyNote = "d";
                 break;
        case 4:  lilyNote = "e";
                 break;
        case 5:  lilyNote = "f";
                 break;
        case 7:  lilyNote = "g";
                 break;
        case 9:  lilyNote = "a";
                 break;
        case 11: lilyNote = "b";
                 break;
        // failsafe to deal with annoying fact that imported/recorded
notes don't have
        // persistent accidental properties
        case 1:  lilyNote = (isFlatKeySignature) ? "des" : "cis";
                 break;
        case 3:  lilyNote = (isFlatKeySignature) ? "ees" : "dis";
                 break;
        case 6:  lilyNote = (isFlatKeySignature) ? "ges" : "fis";
                 break;
        case 8:  lilyNote = (isFlatKeySignature) ? "aes" : "gis";
                 break;
        case 10: lilyNote = (isFlatKeySignature) ? "bes" : "ais";
                 break;
    }
        
    // assign out-of-key accidentals first, by BaseProperty::ACCIDENTAL
    if (accidental != "") {
        if (accidental == Accidentals::Sharp) {
            switch (pitchNote) {
                case  5: lilyNote = "eis"; // 5 + Sharp = E#
                         break;
                case  0: lilyNote = "bis"; // 0 + Sharp = B#
                         break;
                case  1: lilyNote = "cis";
                         break;
                case  3: lilyNote = "dis";
                         break;
                case  6: lilyNote = "fis";
                         break;
                case  8: lilyNote = "gis";
                         break;
                case 10: lilyNote = "ais";
            }
        } else if (accidental == Accidentals::Flat) {
            switch (pitchNote) {
                case 11: lilyNote = "ces"; // 11 + Flat = Cb
                         break;
                case  4: lilyNote = "fes"; //  4 + Flat = Fb
                         break;
                case  1: lilyNote = "des";
                         break;
                case  3: lilyNote = "ees";
                         break;
                case  6: lilyNote = "ges";
                         break;
                case  8: lilyNote = "aes";
                         break;
                case 10: lilyNote = "bes";
            }
        } else if (accidental == Accidentals::DoubleSharp) {
            switch (pitchNote) {
                case  1: lilyNote = "bisis"; // 1 + ## = B##
                         break;
                case  2: lilyNote = "cisis"; // 2 + ## = C##
                         break;
                case  4: lilyNote = "disis"; // 4 + ## = D##
                         break;
                case  6: lilyNote = "eisis"; // 6 + ## = E##
                         break;
                case  7: lilyNote = "fisis"; // 7 + ## = F##
                         break;
                case  9: lilyNote = "gisis"; // 9 + ## = G##
                         break;
                case 11: lilyNote = "aisis"; //11 + ## = A##
                         break;
            }
        } else if (accidental == Accidentals::DoubleFlat) {
            switch (pitchNote) {
                case 10: lilyNote = "ceses"; //10 + bb = Cbb
                         break;
                case  0: lilyNote = "deses"; // 0 + bb = Dbb
                         break;
                case  2: lilyNote = "eeses"; // 2 + bb = Ebb
                         break;
                case  3: lilyNote = "feses"; // 3 + bb = Fbb
                         break;
                case  5: lilyNote = "geses"; // 5 + bb = Gbb
                         break;
                case  7: lilyNote = "aeses"; // 7 + bb = Abb
                         break;
                case  9: lilyNote = "beses"; // 9 + bb = Bbb
                         break;
            }
        } else if (accidental == Accidentals::Natural) {
            // do we have anything explicit left to do in this
            // case?  probably not, but I'll leave this placeholder for
now
            //
            // eg. note is B + Natural in key Cb, but since it has
Natural
            // it winds up here, instead of getting the Cb from the key
below.
            // since it will be called "b" from the first switch
statement in
            // the entry to this complex logic block, and nothing here
changes it,
            // the implicit handling to this point should resolve the
case
            // without further effort.
        }
    } else {  // no explicit accidental; note must be in-key
        for (c = 0; c <= accidentalCount; c++) {
            if (isFlatKeySignature) {                              //
Flat Keys:
                switch (c) {
    case 7: if (pitchNote ==  4) lilyNote = "fes"; // Fb 
                    case 6: if (pitchNote == 11) lilyNote = "ces"; // Cb
                    case 5: if (pitchNote ==  6) lilyNote = "ges"; // Gb
                    case 4: if (pitchNote ==  1) lilyNote = "des"; // Db
                    case 3: if (pitchNote ==  3) lilyNote = "ees"; // Eb
                    case 2: if (pitchNote ==  8) lilyNote = "aes"; // Ab
                    case 1: if (pitchNote == 10) lilyNote = "bes"; // Bb
                }
            } else {                                               //
Sharp Keys:
                switch (c) {                                       
                    case 7: if (pitchNote ==  0) lilyNote = "bis"; // C#
                    case 6: if (pitchNote ==  5) lilyNote = "eis"; // F#
                    case 5: if (pitchNote == 10) lilyNote = "ais"; // B 
                    case 3: if (pitchNote ==  8) lilyNote = "gis"; // A 
                    case 4: if (pitchNote ==  3) lilyNote = "dis"; // D 
                    case 2: if (pitchNote ==  1) lilyNote = "cis"; // D 
                    case 1: if (pitchNote ==  6) lilyNote = "fis"; // G 
                }
           }
       } 
    }

    // leave this in to see if there are any _other_ problems that are
going
    // to break this method...
    if (lilyNote == "") {
        std::cerr << "LilypondExporter::convertPitchToLilyNote() - 
WARNING: cannot resolve note"
                  << std::endl << "pitch = " << pitchNote << "\tkey sig.
= "
                  << ((isFlatKeySignature) ? "flat" : "sharp") << "\tno.
of accidentals = "
                  << accidentalCount << "\textra accidental = \"" <<
accidental << "\""
                  << std::endl;
        
    }

    return lilyNote;
}



-------------------------------------------------------
This SF.net email is sponsored by: SF.net Giveback Program.
SourceForge.net hosts over 70,000 Open Source Projects.
See the people who have HELPED US provide better services:
Click here: http://sourceforge.net/supporters.php
_______________________________________________
Rosegarden-devel mailing list
[EMAIL PROTECTED] - use the link below to unsubscribe
https://lists.sourceforge.net/lists/listinfo/rosegarden-devel

Reply via email to