Esempio n. 1
0
        // 主調mainKeyと内属記号keyRelationのペアから調keyを決定する
        public static MusicKey MainKeyAndKeyRelationToKey(MusicKey mainKey, KeyRelation keyRelation)
        {
            for (int internalKey = 0; internalKey < (int)MusicKey.NUM; ++internalKey)
            {
                if (keyRelation == mainKeyInternalKeyToKeyRelation[(int)mainKey * (int)MusicKey.NUM + internalKey])
                {
                    return((MusicKey)internalKey);
                }
            }

            System.Console.WriteLine("MainKeyAndKeyRelationToKey not found {0} {1}", mainKey, keyRelation);
            return(MusicKey.Invalid);
        }
Esempio n. 2
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);
        }
Esempio n. 3
0
        /// <summary>
        /// 和音の属する内部調と、和音の音度から、その和音がIの和音である調を得る。
        /// </summary>
        public static MusicKey MusicKeyAndChordDegreeToInternalKey(MusicKey key, CD chordDegree)
        {
            System.Diagnostics.Debug.Assert(key != MusicKey.Invalid);

            KeyRelation desirableKR = MusicKeyAndChordDegreeToKeyRelation(key, chordDegree);

            MusicKey result = MusicKey.Invalid;

            for (int internalKey = 0; internalKey < (int)MusicKey.NUM; ++internalKey)
            {
                if (desirableKR == mainKeyInternalKeyToKeyRelation[(int)key * (int)MusicKey.NUM + internalKey])
                {
                    result = (MusicKey)internalKey;
                    break;
                }
            }

            return(result);
        }
Esempio n. 4
0
 /// <summary>
 /// こちらのctorはあまり用いない方が良い。
 /// </summary>
 public MusicKeyInfo(MusicKey mainKey, KeyRelation keyRelation)
 {
     this.mainKey     = mainKey;
     this.internalKey = MainKeyAndKeyRelationToKey(mainKey, keyRelation);
 }
Esempio n. 5
0
 public KeyRelationInfo(KeyRelation chordKey)
 {
     this.keyRelation = chordKey;
 }