Exemplo n.º 1
0
        public AcademicChord(Note root, Note[] notes)
        {
            this.root  = root;
            this.notes = notes;

            StringBuilder builder = new StringBuilder();

            builder.Append(NoteNames.Get(root));
            if (notes.Length >= 3)
            {
                int diff1 = Operators.GetAbsSemitonesDifference(notes[1], notes[0]);
                int diff2 = Operators.GetAbsSemitonesDifference(notes[2], notes[0]);
                switch (diff1)
                {
                case 4 when diff2 == 7:
                    chordType = ChordType.Major;
                    builder.Append(ChordNames.Get(ChordType.Major));
                    break;

                case 3 when diff2 == 7:
                    chordType = ChordType.Minor;
                    builder.Append(ChordNames.Get(ChordType.Minor));
                    break;

                case 3 when diff2 == 6:
                    chordType = ChordType.Diminished;
                    builder.Append(ChordNames.Get(ChordType.Diminished));
                    break;

                default:
                    chordType = ChordType.Undefined;
                    break;
                }
            }
            _name = builder.ToString();
        }
Exemplo n.º 2
0
 public override string ToString()
 {
     return(NoteNames.Get(_note) + octave);
 }