Пример #1
0
        static List <GenericToken <MusicToken> > GetChordTok(GenericToken <MusicToken> chord, ref int key, int durms, ref StringBuilder song)
        {
            if (!chord.isValid || ((chord.type != MusicToken.Chord) && (chord.type != MusicToken.ChordScale)))
            {
                return(new List <GenericToken <MusicToken> >());
            }
            ChordTokens ct = ChordTokens.None;

            if (Enum.TryParse <ChordTokens>(chord.data, true, out ct))
            {
                var gtc = new GenericToken <ChordTokens>(ct, ct.ToString());
                return(GetChordToks(gtc, ref key, durms, ref song));
            }

            throw new Exception("Unknown chord: " + chord.ToString() + ", please implement this chord.");
        }
Пример #2
0
        /// <summary>
        /// convert chord tokens to musictokens
        /// </summary>
        /// <param name="chord"></param>
        /// <param name="key"></param>
        /// <param name="durms"></param>
        /// <param name="song"></param>
        /// <returns></returns>
        static List <GenericToken <MusicToken> > MusicChord2MusicNotes(GenericToken <MusicToken> tok, ref int key, int durms, ref StringBuilder song)
        {
            ChordTokens chordtoken = ChordTokens.None;

            if (!tok.isValid || ((tok.type != MusicToken.Chord) && (tok.type != MusicToken.ChordScale)))
            {
                return(new List <GenericToken <MusicToken> >());
            }
            if (!Enum.TryParse <ChordTokens>(tok.data, true, out chordtoken))
            {
                return(new List <GenericToken <MusicToken> >());
            }

            string[] notes = new string[0];
            switch (chordtoken)
            {
            case ChordTokens.A: notes = new string[] { "a", "cs", "e" }; break;

            case ChordTokens.Am: notes = new string[] { "a", "c", "e" }; break;

            case ChordTokens.Af: notes = new string[] { "af", "c", "ef" }; break;

            case ChordTokens.B: notes = new string[] { "b", "ds", "fs" }; break;

            case ChordTokens.Bm: notes = new string[] { "b", "d", "fs" }; break;

            case ChordTokens.Bf: notes = new string[] { "bf", "d", "f" }; break;

            case ChordTokens.C: notes = new string[] { "c", "e", "g" }; break;

            case ChordTokens.Cm: notes = new string[] { "c", "ef", "g" }; break;

            case ChordTokens.Cf: notes = new string[] { "c", "e", "gf" }; break;

            case ChordTokens.D: notes = new string[] { "d", "fs", "a" }; break;

            case ChordTokens.Dm: notes = new string[] { "d", "f", "a" }; break;

            case ChordTokens.Df: notes = new string[] { "df", "f", "af" }; break;

            case ChordTokens.E: notes = new string[] { "e", "gs", "b" }; break;

            case ChordTokens.Em: notes = new string[] { "e", "g", "b" }; break;

            case ChordTokens.Ef: notes = new string[] { "ef", "g", "bf" }; break;

            case ChordTokens.F: notes = new string[] { "f", "a", "c" }; break;

            case ChordTokens.Fm: notes = new string[] { "f", "af", "c" }; break;

            case ChordTokens.Ff: notes = new string[] { "f", "af", "c" }; break;

            case ChordTokens.G: notes = new string[] { "g", "b", "d" }; break;

            case ChordTokens.Gm: notes = new string[] { "g", "bf", "d" }; break;

            case ChordTokens.Gf: notes = new string[] { "gf", "bf", "df" }; break;
            }
            List <GenericToken <MusicToken> > toknotes = new List <GenericToken <MusicToken> >();

            foreach (var note in notes)
            {
                toknotes.Add(new GenericToken <MusicToken>(MusicToken.Note, note));
            }
            return(toknotes);
        }