예제 #1
0
 public static Chord Xmaj7sus4(NoteName root)
 {
     return(Chord.Construct($"{root}maj7sus4", root, Intervals.M3, Intervals.P4, Intervals.M7));
 }
예제 #2
0
        public bool TryParse(string chordName, out Chord chord)
        {
            chord = null;

            _scanner = new Scanner(chordName.Trim());
            NoteNameNode noteNameNode;

            if (!new NoteNameParser {
                SupressMessages = true
            }.TryParse(_scanner, out noteNameNode))
            {
                return(false);
            }

            var root = noteNameNode.ToNoteName();

            if (_scanner.EndOfInput)
            {
                chord = Chord.Construct(chordName, root, M3, P5);
                return(true);
            }

            _intervals = new List <Interval>();

            var isFifth = false;

            if (_scanner.Expect("5")) // 5th
            {
                this.AddIntervals(P5);
                isFifth = true;
            }
            else if (_scanner.Expect("ø7")) // half diminished seventh
            {
                this.AddIntervals(m3, d5, m7);
            }
            else
            {
                if (!this.ReadDominant())
                {
                    if (_hasError)
                    {
                        return(false);
                    }

                    if (this.ReadTriad())
                    {
                        if (!this.ReadSeventh())
                        {
                            this.ReadExtended();
                        }
                    }
                    else
                    {
                        if (_hasError)
                        {
                            return(false);
                        }

                        this.ReadSimplifiedAddedTone();
                    }
                }
            }

            if (_hasError)
            {
                return(false);
            }

            NoteName?bass = null;

            if (!isFifth)
            {
                this.ReadSuspended();
                if (_hasError)
                {
                    return(false);
                }

                if (!_addedToneRead)
                {
                    this.ReadAddedTone();
                    if (_hasError)
                    {
                        return(false);
                    }
                }

                this.ReadAltered();
                if (_hasError)
                {
                    return(false);
                }

                this.ReadBass(out bass);
                if (_hasError)
                {
                    return(false);
                }
            }

            _scanner.SkipWhitespaces();
            if (!_scanner.EndOfInput)
            {
                _hasError = true;   //unexpected
                return(false);
            }

            chord      = Chord.Construct(chordName, root, _intervals.ToArray());
            chord.Bass = bass;

            return(true);
        }
예제 #3
0
 public static Chord Xdim7(NoteName root)
 {
     return(Chord.Construct($"{root}dim7", root, Intervals.m3, Intervals.d5, Intervals.d7));
 }
예제 #4
0
 public static Chord Xmaj7sus2(NoteName root)
 {
     return(Chord.Construct($"{root}maj7sus2", root, Intervals.M2, Intervals.P5, Intervals.M7));
 }
예제 #5
0
 public static Chord XmM7(NoteName root)
 {
     return(Chord.Construct($"{root}mM7", root, Intervals.m3, Intervals.P5, Intervals.M7));
 }
예제 #6
0
 public static Chord X6(NoteName root)
 {
     return(Chord.Construct($"{root}6", root, Intervals.M3, Intervals.P5, Intervals.M6));
 }
예제 #7
0
 public static Chord Xsus4(NoteName root)
 {
     return(Chord.Construct($"{root}sus4", root, Intervals.P4, Intervals.P5));
 }
예제 #8
0
 public static Chord Xaug(NoteName root)
 {
     return(Chord.Construct($"{root}aug", root, Intervals.M3, Intervals.A5));
 }
예제 #9
0
 public static Chord X(NoteName root)
 {
     return(Chord.Construct(root.ToString(), root, Intervals.M3, Intervals.P5));
 }