How to change key label from major to minor

• Mar 7, 2020 - 08:14

Hello everyone, I have a question: how to label the key signature as major or minor?

It's because when I save the score to midi file, synthesia recognizes it as a major song. But it's actually a minor song. Although the song play the sound as minor, the key label is wrong.

When I create the score, I don't find the feature which can label it as major or minor, neither in advanced edited. Maybe I find the wrong feature...

I upload an E-minor scale midi file. Hope somebody can help me. Thank you.
e minor 1.png
e minor 2.png
e minor 3.png
test.mid


Comments

MIDI doesn't carry this type of information. And if is set to unknown in MuseSAcore, even less so., but IIRC this setting was mainly for MusicXML im- and export

In reply to by Jojo-Schmitz

I believe whether or not a key signature describes a major or minor key is specified in the last byte of the two-byte key signature meta-event "FF 59" defined by MIDI. Opening up a MIDI file generated by Musescore in a hex editor seems to always shows "FF 59 02 [XY 00]", where XY is a signed 8-bit number representing the number of sharps or flats. Here the last byte is 00 for major but should be 01 for minor.

In reply to by jmensah

Interesting. Feel free to enter this into the issue tracker as a Suggestion.
Can that byte also carry the other possible types, dorian, phrygian etc.?
Hmm, apparently not

But indeed MuseScore's MIDI export explicitly sets that by to 0 (in audio/exports/exportmidi.cpp):

                  for (auto ik = sk; ik != ek; ++ik) {
                        MidiEvent ev;
                        ev.setType(ME_META);
                        Key key       = ik->second.key();   // -7 -- +7
                        ev.setMetaType(META_KEY_SIGNATURE);
                        ev.setLen(2);
                        unsigned char* data = new unsigned char[2];
                        data[0]   = int(key);
                        data[1]   = 0;  // major
                        ev.setEData(data);
                        int tick = ik->first + tickOffset;
                        track1.insert(pauseMap.addPauseTicks(tick), ev);
                        if (tick == 0)
                              initialKeySigFound = true;
                        }
                  }

MuseScore seems to read them though on import, (in audio/midi/event.cpp):

                       case META_KEY_SIGNATURE:
                              {
                              const char* keyTable[] = {
                                    "Ces", "Ges", "Des", "As", "Es", "Bes", "F",
                                    "C",
                                    "G", "D", "A", "E", "B", "Fis", "Cis"
                                    };
                              int key = (char)(_edata[0]) + 7;
                              if (key < 0 || key > 14) {
                                    qDebug("bad key signature %d", key);
                                    key = 0;
                                    }
                              QString sex(_edata[1] ? "Minor" : "Major");
                              QString keyName(keyTable[key]);
                              xml.tag(QString("Key tick=\"%1\" key=\"%2\" sex=\"%3\"").arg(ontime()).arg(_edata[0]).arg(_edata[1]),
                                 QString("%1 %2").arg(keyName).arg(sex));
                              }
                              break;

(I wonder why it uses German notenames there? Seems it's been that way ever since, at least since 2012-05-26)
But is also has (in importexport/midiimport/importmidi.cpp):

            case META_KEY_SIGNATURE:
                  {
                  const signed char key = ((const signed char*)data)[0];
                  if (key < -7 || key > 7) {
                        qDebug("ImportMidi: illegal key %d", key);
                        break;
                        }
                  KeySigEvent ke;
                  ke.setKey(Key(key));
                  staff->setKey(Fraction::fromTicks(tick), ke);
                  hasKey = true;
                  }
                  break;

Here ignoring the mode

Do you still have an unanswered question? Please log in first to post your question.