Exemple #1
0
        /**
         * コードの種類(T/SD/D)に応じて代理コードを返す。
         * <param name="key">キー</param>
         * <param name="chordType">コードの種類</param>
         * <returns>コード</returns>
         */
        protected Chord GetSubstituteChord(Key key, Chord.ChordTypes chordType)
        {
            short        degree = 0;
            List <short> degreeList;
            int          listCount = 0;

            switch (chordType)
            {
            case Chord.ChordTypes.TONIC:
                degreeList = key.GetTonicChordDegreeList();
                listCount  = degreeList.Count;
                degree     = degreeList[random.Next(listCount)];
                break;

            case Chord.ChordTypes.SUB_DOMINANT:
                degreeList = key.GetSubDominantChordDegreeList();
                listCount  = degreeList.Count;
                degree     = degreeList[random.Next(listCount)];
                break;

            case Chord.ChordTypes.DOMINANT:
                degreeList = key.GetDominantChordDegreeList();
                listCount  = degreeList.Count;
                degree     = degreeList[random.Next(listCount)];
                break;
            }

            Chord chord = key.GetChordByDegree(degree);

            return(chord);
        }
Exemple #2
0
        public Bar(Song song, short barIndex)
        {
            chordType     = Chord.ChordTypes.TONIC;
            chord         = null;
            this.song     = song;
            this.barIndex = barIndex;

            chordChangeHandlers = new List <IChordChangeHandler>();
        }
Exemple #3
0
        public void Map(Song song)
        {
            Bar    bar       = null;
            Random random    = new Random();
            int    randomVal = 0;
            short  barCount  = song.GetBarCount();

            Chord.ChordTypes oldType = Chord.ChordTypes.DOMINANT;

            for (short i = 0; i < barCount; i++)
            {
                bar = song.GetBarAt(i);

                //T/SD/Dへの振り分け処理。この部分を調整可能にすると個性が出せるかもしれない
                if (oldType == Chord.ChordTypes.DOMINANT || i == barCount - 1)
                {
                    bar.ChordType = Chord.ChordTypes.TONIC;
                }
                else
                {
                    randomVal = random.Next(3);
                    switch (randomVal)
                    {
                    case 0:
                        bar.ChordType = Chord.ChordTypes.TONIC;
                        break;

                    case 1:
                        bar.ChordType = Chord.ChordTypes.SUB_DOMINANT;
                        break;

                    case 2:
                        bar.ChordType = Chord.ChordTypes.DOMINANT;
                        break;
                    }
                }
                oldType = bar.ChordType;
            }
        }
Exemple #4
0
        /**
         * コードの種類(T/SD/D)に応じて決められたコードを返す。
         * <param name="key">キー</param>
         * <param name="chordType">コードの種類</param>
         * <returns>コード</returns>
         */
        protected Chord GetFixedChord(Key key, Chord.ChordTypes chordType)
        {
            short degree = 0;

            switch (chordType)
            {
            case Chord.ChordTypes.TONIC:
                degree = key.GetTonicChordDegree();
                break;

            case Chord.ChordTypes.SUB_DOMINANT:
                degree = key.GetSubDominantChordDegree();
                break;

            case Chord.ChordTypes.DOMINANT:
                degree = key.GetDominantChordDegree();
                break;
            }

            Chord chord = key.GetChordByDegree(degree);

            return(chord);
        }