コード例 #1
0
        public static KeyRelation MusicKeyAndChordDegreeToKeyRelation(MusicKey key, CD chordDegree)
        {
            MusicKeyInfo mki = new MusicKeyInfo(key, KeyRelation.I調);

            KeyRelation kr = KeyRelation.Unknown;

            switch (chordDegree)
            {
            case CD.I: kr = KeyRelation.I調; break;

            case CD.II: /* 長調の時はII調、短調の時はない。 */
                if (mki.IsMajor())
                {
                    kr = KeyRelation.II調;
                }
                break;

            case CD.III: kr = KeyRelation.III調; break;

            case CD.IV: kr = KeyRelation.IV調; break;

            case CD.V: kr = KeyRelation.V調; break;

            case CD.VI: kr = KeyRelation.VI調; break;

            case CD.VII: /* 短調の時はVII調、長調の時はない。*/
                if (mki.IsMinor())
                {
                    kr = KeyRelation.VII調;
                }
                break;

            case CD.V_V:/* 長調のV調のV調は+II調、短調のV調のV調は△II調 */
                if (mki.IsMajor())
                {
                    kr = KeyRelation.PII調;
                }
                else
                {
                    kr = KeyRelation.TII調;
                }
                break;

            default: System.Diagnostics.Debug.Assert(false); break;
            }
            return(kr);
        }
コード例 #2
0
        private void MXOutputPartHeader(TextWriter w, string partId, ClefType clef)
        {
            w.WriteLine("  <part id=\"{0}\">", partId);
            w.WriteLine("    <measure number=\"0\">");
            w.WriteLine("      <attributes>");

            var mki = new MusicKeyInfo(chordSaves[0].musicKey, KeyRelation.I調);

            w.WriteLine("        <key>");
            w.WriteLine("          <fifths>{0}</fifths>", mki.FlatNum() - mki.SharpNum());
            w.WriteLine("          <mode>{0}</mode>", mki.IsMajor() ? "major" : "minor");
            w.WriteLine("        </key>");
            w.WriteLine("        <time>");
            w.WriteLine("          <beats>2</beats>");
            w.WriteLine("          <beat-type>2</beat-type>");
            w.WriteLine("        </time>");

            w.WriteLine("        <clef>");
            switch (clef)
            {
            case ClefType.G2:
                w.WriteLine("          <sign>G</sign>");
                w.WriteLine("          <line>2</line>");
                break;

            case ClefType.F4:
                w.WriteLine("          <sign>F</sign>");
                w.WriteLine("          <line>4</line>");
                break;

            default:
                System.Diagnostics.Debug.Assert(false);
                break;
            }
            w.WriteLine("        </clef>");

            w.WriteLine("      </attributes>");
            w.WriteLine("      <sound tempo=\"{0}\"/>", tempo);
        }