public void TabController_checkPitchRangeTest() { Assert.IsTrue(TabController.checkPitchRange(1, NoteFactory.getNoteByName("C"), guitar)); Assert.IsFalse(TabController.checkPitchRange(0, NoteFactory.getNoteByName("C"), guitar)); Assert.IsTrue(TabController.checkPitchRange(9, NoteFactory.getNoteByName("C"), guitar)); Assert.IsFalse(TabController.checkPitchRange(10, NoteFactory.getNoteByName("C"), guitar)); }
public void ChordFactoryTest_getChordRecomendationsByDegree() { Note key = NoteFactory.getNoteByName("C"); Note degree = NoteFactory.getNoteByName("G"); Mode mode = ModeFactory.getModeByName("Ionian"); List <Chord> recomendations = ChordFactory.getChordRecomendationsByTonic(key, degree, mode); Assert.IsTrue(recomendations.Count() > 1); }
public void ChordFactoryTest_getChordRecomendationsByLast() { Note key = NoteFactory.getNoteByName("C"); Mode mode = ModeFactory.getModeByName("Ionian"); Chord chord = ChordFactory.getChordByName("C"); List <Chord> recomendations = ChordFactory.getChordRecomendationsByLast(key, chord, mode); Assert.AreEqual("G", recomendations.ElementAt(0).getName()); }
public Guitar() { tuning.Add(NoteFactory.getNoteByName("E")); tuning.Add(NoteFactory.getNoteByName("B")); tuning.Add(NoteFactory.getNoteByName("G")); tuning.Add(NoteFactory.getNoteByName("D")); tuning.Add(NoteFactory.getNoteByName("A")); tuning.Add(NoteFactory.getNoteByName("E")); }
private static Note calculateNote(int distance, Note _key) { int next = _key.getValue() + distance; if (next > 12) { next = next - 12; } return(NoteFactory.getNoteByValue(next, _key)); }
public Note getNote(int guitarString, int fret, Note key) { int value = fret + tuning.ElementAt(guitarString - 1).getValue(); while (value > 12) { value = value - 12; } return(NoteFactory.getNoteByValue(value, key)); }
public Note getNote(int index, Note key) { int distance; Note note; distance = intervals.ElementAt(index).getIntervalValue() + key.getValue(); if (distance > 12) { distance = distance - 12; } note = NoteFactory.getNoteByValue(distance, key); return(note); }
public void Mode_containsNoteTest() { Mode mode = ModeFactory.getModeByName("Ionian"); Note key = NoteFactory.getNoteByName("C"); Assert.IsTrue(mode.containsNote(NoteFactory.getNoteByName("C"), key)); Assert.IsTrue(mode.containsNote(NoteFactory.getNoteByName("D"), key)); Assert.IsTrue(mode.containsNote(NoteFactory.getNoteByName("E"), key)); Assert.IsTrue(mode.containsNote(NoteFactory.getNoteByName("F"), key)); Assert.IsTrue(mode.containsNote(NoteFactory.getNoteByName("G"), key)); Assert.IsTrue(mode.containsNote(NoteFactory.getNoteByName("A"), key)); Assert.IsTrue(mode.containsNote(NoteFactory.getNoteByName("B"), key)); Assert.IsFalse(mode.containsNote(NoteFactory.getNoteByName("F#"), key)); }
public static List <Chord> getChordRecomendationsTriads(Note key, Mode mode) { int i; int tonicValueCheck; Note tonic; List <Chord> chords = new List <Chord>(); for (i = 0; i < 12; i++) { tonicValueCheck = key.getValue() + i; if (tonicValueCheck > 12) { tonicValueCheck = tonicValueCheck - 12; } tonic = NoteFactory.getNoteByValue(tonicValueCheck, key); if (mode.containsInterval(i)) { // augmented 0 4 8 if ((mode.containsInterval(4 + i) || (mode.containsInterval((4 + i) - 12))) && (mode.containsInterval(8 + i) || (mode.containsInterval((8 + i) - 12)))) { chords.Add(ChordFactory.getChordByName(tonic.getName() + "aug")); } // major 0 4 7 if ((mode.containsInterval(4 + i) || (mode.containsInterval((4 + i) - 12))) && (mode.containsInterval(7 + i) || (mode.containsInterval((7 + i) - 12)))) { chords.Add(ChordFactory.getChordByName(tonic.getName())); } // minor 0 3 7 if ((mode.containsInterval(3 + i) || (mode.containsInterval((3 + i) - 12))) && (mode.containsInterval(7 + i) || (mode.containsInterval((7 + i) - 12)))) { chords.Add(ChordFactory.getChordByName(tonic.getName() + "m")); } // diminished 0 3 6 if ((mode.containsInterval(3 + i) || (mode.containsInterval((3 + i) - 12))) && (mode.containsInterval(6 + i) || (mode.containsInterval((6 + i) - 12)))) { chords.Add(ChordFactory.getChordByName(tonic.getName() + "dim")); } } } return(chords); }
public void ProgressionTest_changeTuning() { Progression.clearProgression(); Progression.addChord(ChordFactory.getChordByName("E")); Assert.AreEqual("0", Progression.getTabNumber(1, 6)); Assert.AreEqual("2", Progression.getTabNumber(1, 5)); Assert.AreEqual("2", Progression.getTabNumber(1, 4)); Assert.AreEqual("1", Progression.getTabNumber(1, 3)); Assert.AreEqual("0", Progression.getTabNumber(1, 2)); Assert.AreEqual("0", Progression.getTabNumber(1, 1)); Progression.changeTuning(NoteFactory.getNoteByName("E"), NoteFactory.getNoteByName("A"), NoteFactory.getNoteByName("D"), NoteFactory.getNoteByName("G#"), NoteFactory.getNoteByName("B"), NoteFactory.getNoteByName("E")); Assert.AreEqual("E, A, D, Ab, B, E", Progression.getTuning()); Assert.AreEqual("0", Progression.getTabNumber(1, 6)); Assert.AreEqual("2", Progression.getTabNumber(1, 5)); Assert.AreEqual("2", Progression.getTabNumber(1, 4)); Assert.AreEqual("0", Progression.getTabNumber(1, 3)); Assert.AreEqual("0", Progression.getTabNumber(1, 2)); Assert.AreEqual("0", Progression.getTabNumber(1, 1)); }
public void NoteFactoryTest_getNoteByName() { _note = NoteFactory.getNoteByName("A"); Assert.AreEqual(1, _note.getValue()); _note = NoteFactory.getNoteByName("A#"); Assert.AreEqual(2, _note.getValue()); _note = NoteFactory.getNoteByName("Bb"); Assert.AreEqual(2, _note.getValue()); _note = NoteFactory.getNoteByName("B"); Assert.AreEqual(3, _note.getValue()); _note = NoteFactory.getNoteByName("C"); Assert.AreEqual(4, _note.getValue()); _note = NoteFactory.getNoteByName("C#"); Assert.AreEqual(5, _note.getValue()); _note = NoteFactory.getNoteByName("Db"); Assert.AreEqual(5, _note.getValue()); _note = NoteFactory.getNoteByName("D"); Assert.AreEqual(6, _note.getValue()); _note = NoteFactory.getNoteByName("D#"); Assert.AreEqual(7, _note.getValue()); _note = NoteFactory.getNoteByName("Eb"); Assert.AreEqual(7, _note.getValue()); _note = NoteFactory.getNoteByName("E"); Assert.AreEqual(8, _note.getValue()); _note = NoteFactory.getNoteByName("F"); Assert.AreEqual(9, _note.getValue()); _note = NoteFactory.getNoteByName("F#"); Assert.AreEqual(10, _note.getValue()); _note = NoteFactory.getNoteByName("Gb"); Assert.AreEqual(10, _note.getValue()); _note = NoteFactory.getNoteByName("G"); Assert.AreEqual(11, _note.getValue()); _note = NoteFactory.getNoteByName("G#"); Assert.AreEqual(12, _note.getValue()); _note = NoteFactory.getNoteByName("Ab"); Assert.AreEqual(12, _note.getValue()); //private NUnit.Framework.Constraints.IResolveConstraint _expression; //private TestDelegate _delegate = new TestDelegate(NoteFactory.getNoteByName("Z")); //Assert.Throws(_expression, _delegate); }
public void NoteFactoryTest_getNoteByValue() { Note _key = NoteFactory.getNoteByName("A"); _note = NoteFactory.getNoteByValue(1, _key); Assert.AreEqual("A", _note.getName()); _note = NoteFactory.getNoteByValue(2, _key); Assert.AreEqual("Bb", _note.getName()); _note = NoteFactory.getNoteByValue(3, _key); Assert.AreEqual("B", _note.getName()); _note = NoteFactory.getNoteByValue(4, _key); Assert.AreEqual("C", _note.getName()); _note = NoteFactory.getNoteByValue(5, _key); Assert.AreEqual("C#", _note.getName()); _note = NoteFactory.getNoteByValue(6, _key); Assert.AreEqual("D", _note.getName()); _note = NoteFactory.getNoteByValue(7, _key); Assert.AreEqual("Eb", _note.getName()); _note = NoteFactory.getNoteByValue(8, _key); Assert.AreEqual("E", _note.getName()); _note = NoteFactory.getNoteByValue(9, _key); Assert.AreEqual("F", _note.getName()); _note = NoteFactory.getNoteByValue(10, _key); Assert.AreEqual("F#", _note.getName()); _note = NoteFactory.getNoteByValue(11, _key); Assert.AreEqual("G", _note.getName()); _note = NoteFactory.getNoteByValue(12, _key); Assert.AreEqual("G#", _note.getName()); _key = NoteFactory.getNoteByName("A#"); _note = NoteFactory.getNoteByValue(1, _key); Assert.AreEqual("A", _note.getName()); _note = NoteFactory.getNoteByValue(2, _key); Assert.AreEqual("A#", _note.getName()); _note = NoteFactory.getNoteByValue(3, _key); Assert.AreEqual("B", _note.getName()); _note = NoteFactory.getNoteByValue(4, _key); Assert.AreEqual("C", _note.getName()); _note = NoteFactory.getNoteByValue(5, _key); Assert.AreEqual("C#", _note.getName()); _note = NoteFactory.getNoteByValue(6, _key); Assert.AreEqual("D", _note.getName()); _note = NoteFactory.getNoteByValue(7, _key); Assert.AreEqual("D#", _note.getName()); _note = NoteFactory.getNoteByValue(8, _key); Assert.AreEqual("E", _note.getName()); _note = NoteFactory.getNoteByValue(9, _key); Assert.AreEqual("F", _note.getName()); _note = NoteFactory.getNoteByValue(10, _key); Assert.AreEqual("F#", _note.getName()); _note = NoteFactory.getNoteByValue(11, _key); Assert.AreEqual("G", _note.getName()); _note = NoteFactory.getNoteByValue(12, _key); Assert.AreEqual("G#", _note.getName()); _key = NoteFactory.getNoteByName("Bb"); _note = NoteFactory.getNoteByValue(1, _key); Assert.AreEqual("A", _note.getName()); _note = NoteFactory.getNoteByValue(2, _key); Assert.AreEqual("Bb", _note.getName()); _note = NoteFactory.getNoteByValue(3, _key); Assert.AreEqual("B", _note.getName()); _note = NoteFactory.getNoteByValue(4, _key); Assert.AreEqual("C", _note.getName()); _note = NoteFactory.getNoteByValue(5, _key); Assert.AreEqual("Db", _note.getName()); _note = NoteFactory.getNoteByValue(6, _key); Assert.AreEqual("D", _note.getName()); _note = NoteFactory.getNoteByValue(7, _key); Assert.AreEqual("Eb", _note.getName()); _note = NoteFactory.getNoteByValue(8, _key); Assert.AreEqual("E", _note.getName()); _note = NoteFactory.getNoteByValue(9, _key); Assert.AreEqual("F", _note.getName()); _note = NoteFactory.getNoteByValue(10, _key); Assert.AreEqual("Gb", _note.getName()); _note = NoteFactory.getNoteByValue(11, _key); Assert.AreEqual("G", _note.getName()); _note = NoteFactory.getNoteByValue(12, _key); Assert.AreEqual("Ab", _note.getName()); _key = NoteFactory.getNoteByName("B"); _note = NoteFactory.getNoteByValue(1, _key); Assert.AreEqual("A", _note.getName()); _note = NoteFactory.getNoteByValue(2, _key); Assert.AreEqual("A#", _note.getName()); _note = NoteFactory.getNoteByValue(3, _key); Assert.AreEqual("B", _note.getName()); _note = NoteFactory.getNoteByValue(4, _key); Assert.AreEqual("C", _note.getName()); _note = NoteFactory.getNoteByValue(5, _key); Assert.AreEqual("C#", _note.getName()); _note = NoteFactory.getNoteByValue(6, _key); Assert.AreEqual("D", _note.getName()); _note = NoteFactory.getNoteByValue(7, _key); Assert.AreEqual("D#", _note.getName()); _note = NoteFactory.getNoteByValue(8, _key); Assert.AreEqual("E", _note.getName()); _note = NoteFactory.getNoteByValue(9, _key); Assert.AreEqual("F", _note.getName()); _note = NoteFactory.getNoteByValue(10, _key); Assert.AreEqual("F#", _note.getName()); _note = NoteFactory.getNoteByValue(11, _key); Assert.AreEqual("G", _note.getName()); _note = NoteFactory.getNoteByValue(12, _key); Assert.AreEqual("G#", _note.getName()); _key = NoteFactory.getNoteByName("C"); _note = NoteFactory.getNoteByValue(1, _key); Assert.AreEqual("A", _note.getName()); _note = NoteFactory.getNoteByValue(2, _key); Assert.AreEqual("Bb", _note.getName()); _note = NoteFactory.getNoteByValue(3, _key); Assert.AreEqual("B", _note.getName()); _note = NoteFactory.getNoteByValue(4, _key); Assert.AreEqual("C", _note.getName()); _note = NoteFactory.getNoteByValue(5, _key); Assert.AreEqual("Db", _note.getName()); _note = NoteFactory.getNoteByValue(6, _key); Assert.AreEqual("D", _note.getName()); _note = NoteFactory.getNoteByValue(7, _key); Assert.AreEqual("Eb", _note.getName()); _note = NoteFactory.getNoteByValue(8, _key); Assert.AreEqual("E", _note.getName()); _note = NoteFactory.getNoteByValue(9, _key); Assert.AreEqual("F", _note.getName()); _note = NoteFactory.getNoteByValue(10, _key); Assert.AreEqual("Gb", _note.getName()); _note = NoteFactory.getNoteByValue(11, _key); Assert.AreEqual("G", _note.getName()); _note = NoteFactory.getNoteByValue(12, _key); Assert.AreEqual("Ab", _note.getName()); _key = NoteFactory.getNoteByName("C#"); _note = NoteFactory.getNoteByValue(1, _key); Assert.AreEqual("A", _note.getName()); _note = NoteFactory.getNoteByValue(2, _key); Assert.AreEqual("A#", _note.getName()); _note = NoteFactory.getNoteByValue(3, _key); Assert.AreEqual("B", _note.getName()); _note = NoteFactory.getNoteByValue(4, _key); Assert.AreEqual("C", _note.getName()); _note = NoteFactory.getNoteByValue(5, _key); Assert.AreEqual("C#", _note.getName()); _note = NoteFactory.getNoteByValue(6, _key); Assert.AreEqual("D", _note.getName()); _note = NoteFactory.getNoteByValue(7, _key); Assert.AreEqual("D#", _note.getName()); _note = NoteFactory.getNoteByValue(8, _key); Assert.AreEqual("E", _note.getName()); _note = NoteFactory.getNoteByValue(9, _key); Assert.AreEqual("F", _note.getName()); _note = NoteFactory.getNoteByValue(10, _key); Assert.AreEqual("F#", _note.getName()); _note = NoteFactory.getNoteByValue(11, _key); Assert.AreEqual("G", _note.getName()); _note = NoteFactory.getNoteByValue(12, _key); Assert.AreEqual("G#", _note.getName()); _key = NoteFactory.getNoteByName("Db"); _note = NoteFactory.getNoteByValue(1, _key); Assert.AreEqual("A", _note.getName()); _note = NoteFactory.getNoteByValue(2, _key); Assert.AreEqual("Bb", _note.getName()); _note = NoteFactory.getNoteByValue(3, _key); Assert.AreEqual("B", _note.getName()); _note = NoteFactory.getNoteByValue(4, _key); Assert.AreEqual("C", _note.getName()); _note = NoteFactory.getNoteByValue(5, _key); Assert.AreEqual("Db", _note.getName()); _note = NoteFactory.getNoteByValue(6, _key); Assert.AreEqual("D", _note.getName()); _note = NoteFactory.getNoteByValue(7, _key); Assert.AreEqual("Eb", _note.getName()); _note = NoteFactory.getNoteByValue(8, _key); Assert.AreEqual("E", _note.getName()); _note = NoteFactory.getNoteByValue(9, _key); Assert.AreEqual("F", _note.getName()); _note = NoteFactory.getNoteByValue(10, _key); Assert.AreEqual("Gb", _note.getName()); _note = NoteFactory.getNoteByValue(11, _key); Assert.AreEqual("G", _note.getName()); _note = NoteFactory.getNoteByValue(12, _key); Assert.AreEqual("Ab", _note.getName()); _key = NoteFactory.getNoteByName("D"); _note = NoteFactory.getNoteByValue(1, _key); Assert.AreEqual("A", _note.getName()); _note = NoteFactory.getNoteByValue(2, _key); Assert.AreEqual("Bb", _note.getName()); _note = NoteFactory.getNoteByValue(3, _key); Assert.AreEqual("B", _note.getName()); _note = NoteFactory.getNoteByValue(4, _key); Assert.AreEqual("C", _note.getName()); _note = NoteFactory.getNoteByValue(5, _key); Assert.AreEqual("C#", _note.getName()); _note = NoteFactory.getNoteByValue(6, _key); Assert.AreEqual("D", _note.getName()); _note = NoteFactory.getNoteByValue(7, _key); Assert.AreEqual("Eb", _note.getName()); _note = NoteFactory.getNoteByValue(8, _key); Assert.AreEqual("E", _note.getName()); _note = NoteFactory.getNoteByValue(9, _key); Assert.AreEqual("F", _note.getName()); _note = NoteFactory.getNoteByValue(10, _key); Assert.AreEqual("F#", _note.getName()); _note = NoteFactory.getNoteByValue(11, _key); Assert.AreEqual("G", _note.getName()); _note = NoteFactory.getNoteByValue(12, _key); Assert.AreEqual("Ab", _note.getName()); _key = NoteFactory.getNoteByName("D#"); _note = NoteFactory.getNoteByValue(1, _key); Assert.AreEqual("A", _note.getName()); _note = NoteFactory.getNoteByValue(2, _key); Assert.AreEqual("A#", _note.getName()); _note = NoteFactory.getNoteByValue(3, _key); Assert.AreEqual("B", _note.getName()); _note = NoteFactory.getNoteByValue(4, _key); Assert.AreEqual("C", _note.getName()); _note = NoteFactory.getNoteByValue(5, _key); Assert.AreEqual("C#", _note.getName()); _note = NoteFactory.getNoteByValue(6, _key); Assert.AreEqual("D", _note.getName()); _note = NoteFactory.getNoteByValue(7, _key); Assert.AreEqual("D#", _note.getName()); _note = NoteFactory.getNoteByValue(8, _key); Assert.AreEqual("E", _note.getName()); _note = NoteFactory.getNoteByValue(9, _key); Assert.AreEqual("F", _note.getName()); _note = NoteFactory.getNoteByValue(10, _key); Assert.AreEqual("F#", _note.getName()); _note = NoteFactory.getNoteByValue(11, _key); Assert.AreEqual("G", _note.getName()); _note = NoteFactory.getNoteByValue(12, _key); Assert.AreEqual("G#", _note.getName()); _key = NoteFactory.getNoteByName("Eb"); _note = NoteFactory.getNoteByValue(1, _key); Assert.AreEqual("A", _note.getName()); _note = NoteFactory.getNoteByValue(2, _key); Assert.AreEqual("Bb", _note.getName()); _note = NoteFactory.getNoteByValue(3, _key); Assert.AreEqual("B", _note.getName()); _note = NoteFactory.getNoteByValue(4, _key); Assert.AreEqual("C", _note.getName()); _note = NoteFactory.getNoteByValue(5, _key); Assert.AreEqual("Db", _note.getName()); _note = NoteFactory.getNoteByValue(6, _key); Assert.AreEqual("D", _note.getName()); _note = NoteFactory.getNoteByValue(7, _key); Assert.AreEqual("Eb", _note.getName()); _note = NoteFactory.getNoteByValue(8, _key); Assert.AreEqual("E", _note.getName()); _note = NoteFactory.getNoteByValue(9, _key); Assert.AreEqual("F", _note.getName()); _note = NoteFactory.getNoteByValue(10, _key); Assert.AreEqual("Gb", _note.getName()); _note = NoteFactory.getNoteByValue(11, _key); Assert.AreEqual("G", _note.getName()); _note = NoteFactory.getNoteByValue(12, _key); Assert.AreEqual("Ab", _note.getName()); _key = NoteFactory.getNoteByName("E"); _note = NoteFactory.getNoteByValue(1, _key); Assert.AreEqual("A", _note.getName()); _note = NoteFactory.getNoteByValue(2, _key); Assert.AreEqual("Bb", _note.getName()); _note = NoteFactory.getNoteByValue(3, _key); Assert.AreEqual("B", _note.getName()); _note = NoteFactory.getNoteByValue(4, _key); Assert.AreEqual("C", _note.getName()); _note = NoteFactory.getNoteByValue(5, _key); Assert.AreEqual("C#", _note.getName()); _note = NoteFactory.getNoteByValue(6, _key); Assert.AreEqual("D", _note.getName()); _note = NoteFactory.getNoteByValue(7, _key); Assert.AreEqual("D#", _note.getName()); _note = NoteFactory.getNoteByValue(8, _key); Assert.AreEqual("E", _note.getName()); _note = NoteFactory.getNoteByValue(9, _key); Assert.AreEqual("F", _note.getName()); _note = NoteFactory.getNoteByValue(10, _key); Assert.AreEqual("F#", _note.getName()); _note = NoteFactory.getNoteByValue(11, _key); Assert.AreEqual("G", _note.getName()); _note = NoteFactory.getNoteByValue(12, _key); Assert.AreEqual("G#", _note.getName()); _key = NoteFactory.getNoteByName("F"); _note = NoteFactory.getNoteByValue(1, _key); Assert.AreEqual("A", _note.getName()); _note = NoteFactory.getNoteByValue(2, _key); Assert.AreEqual("Bb", _note.getName()); _note = NoteFactory.getNoteByValue(3, _key); Assert.AreEqual("B", _note.getName()); _note = NoteFactory.getNoteByValue(4, _key); Assert.AreEqual("C", _note.getName()); _note = NoteFactory.getNoteByValue(5, _key); Assert.AreEqual("Db", _note.getName()); _note = NoteFactory.getNoteByValue(6, _key); Assert.AreEqual("D", _note.getName()); _note = NoteFactory.getNoteByValue(7, _key); Assert.AreEqual("Eb", _note.getName()); _note = NoteFactory.getNoteByValue(8, _key); Assert.AreEqual("E", _note.getName()); _note = NoteFactory.getNoteByValue(9, _key); Assert.AreEqual("F", _note.getName()); _note = NoteFactory.getNoteByValue(10, _key); Assert.AreEqual("Gb", _note.getName()); _note = NoteFactory.getNoteByValue(11, _key); Assert.AreEqual("G", _note.getName()); _note = NoteFactory.getNoteByValue(12, _key); Assert.AreEqual("Ab", _note.getName()); _key = NoteFactory.getNoteByName("F#"); _note = NoteFactory.getNoteByValue(1, _key); Assert.AreEqual("A", _note.getName()); _note = NoteFactory.getNoteByValue(2, _key); Assert.AreEqual("A#", _note.getName()); _note = NoteFactory.getNoteByValue(3, _key); Assert.AreEqual("B", _note.getName()); _note = NoteFactory.getNoteByValue(4, _key); Assert.AreEqual("C", _note.getName()); _note = NoteFactory.getNoteByValue(5, _key); Assert.AreEqual("C#", _note.getName()); _note = NoteFactory.getNoteByValue(6, _key); Assert.AreEqual("D", _note.getName()); _note = NoteFactory.getNoteByValue(7, _key); Assert.AreEqual("D#", _note.getName()); _note = NoteFactory.getNoteByValue(8, _key); Assert.AreEqual("E", _note.getName()); _note = NoteFactory.getNoteByValue(9, _key); Assert.AreEqual("F", _note.getName()); _note = NoteFactory.getNoteByValue(10, _key); Assert.AreEqual("F#", _note.getName()); _note = NoteFactory.getNoteByValue(11, _key); Assert.AreEqual("G", _note.getName()); _note = NoteFactory.getNoteByValue(12, _key); Assert.AreEqual("G#", _note.getName()); _key = NoteFactory.getNoteByName("Gb"); _note = NoteFactory.getNoteByValue(1, _key); Assert.AreEqual("A", _note.getName()); _note = NoteFactory.getNoteByValue(2, _key); Assert.AreEqual("Bb", _note.getName()); _note = NoteFactory.getNoteByValue(3, _key); Assert.AreEqual("B", _note.getName()); _note = NoteFactory.getNoteByValue(4, _key); Assert.AreEqual("C", _note.getName()); _note = NoteFactory.getNoteByValue(5, _key); Assert.AreEqual("Db", _note.getName()); _note = NoteFactory.getNoteByValue(6, _key); Assert.AreEqual("D", _note.getName()); _note = NoteFactory.getNoteByValue(7, _key); Assert.AreEqual("Eb", _note.getName()); _note = NoteFactory.getNoteByValue(8, _key); Assert.AreEqual("E", _note.getName()); _note = NoteFactory.getNoteByValue(9, _key); Assert.AreEqual("F", _note.getName()); _note = NoteFactory.getNoteByValue(10, _key); Assert.AreEqual("Gb", _note.getName()); _note = NoteFactory.getNoteByValue(11, _key); Assert.AreEqual("G", _note.getName()); _note = NoteFactory.getNoteByValue(12, _key); Assert.AreEqual("Ab", _note.getName()); _key = NoteFactory.getNoteByName("G"); _note = NoteFactory.getNoteByValue(1, _key); Assert.AreEqual("A", _note.getName()); _note = NoteFactory.getNoteByValue(2, _key); Assert.AreEqual("Bb", _note.getName()); _note = NoteFactory.getNoteByValue(3, _key); Assert.AreEqual("B", _note.getName()); _note = NoteFactory.getNoteByValue(4, _key); Assert.AreEqual("C", _note.getName()); _note = NoteFactory.getNoteByValue(5, _key); Assert.AreEqual("Db", _note.getName()); _note = NoteFactory.getNoteByValue(6, _key); Assert.AreEqual("D", _note.getName()); _note = NoteFactory.getNoteByValue(7, _key); Assert.AreEqual("Eb", _note.getName()); _note = NoteFactory.getNoteByValue(8, _key); Assert.AreEqual("E", _note.getName()); _note = NoteFactory.getNoteByValue(9, _key); Assert.AreEqual("F", _note.getName()); _note = NoteFactory.getNoteByValue(10, _key); Assert.AreEqual("F#", _note.getName()); _note = NoteFactory.getNoteByValue(11, _key); Assert.AreEqual("G", _note.getName()); _note = NoteFactory.getNoteByValue(12, _key); Assert.AreEqual("Ab", _note.getName()); _key = NoteFactory.getNoteByName("G#"); _note = NoteFactory.getNoteByValue(1, _key); Assert.AreEqual("A", _note.getName()); _note = NoteFactory.getNoteByValue(2, _key); Assert.AreEqual("A#", _note.getName()); _note = NoteFactory.getNoteByValue(3, _key); Assert.AreEqual("B", _note.getName()); _note = NoteFactory.getNoteByValue(4, _key); Assert.AreEqual("C", _note.getName()); _note = NoteFactory.getNoteByValue(5, _key); Assert.AreEqual("C#", _note.getName()); _note = NoteFactory.getNoteByValue(6, _key); Assert.AreEqual("D", _note.getName()); _note = NoteFactory.getNoteByValue(7, _key); Assert.AreEqual("D#", _note.getName()); _note = NoteFactory.getNoteByValue(8, _key); Assert.AreEqual("E", _note.getName()); _note = NoteFactory.getNoteByValue(9, _key); Assert.AreEqual("F", _note.getName()); _note = NoteFactory.getNoteByValue(10, _key); Assert.AreEqual("F#", _note.getName()); _note = NoteFactory.getNoteByValue(11, _key); Assert.AreEqual("G", _note.getName()); _note = NoteFactory.getNoteByValue(12, _key); Assert.AreEqual("G#", _note.getName()); _key = NoteFactory.getNoteByName("Ab"); _note = NoteFactory.getNoteByValue(1, _key); Assert.AreEqual("A", _note.getName()); _note = NoteFactory.getNoteByValue(2, _key); Assert.AreEqual("Bb", _note.getName()); _note = NoteFactory.getNoteByValue(3, _key); Assert.AreEqual("B", _note.getName()); _note = NoteFactory.getNoteByValue(4, _key); Assert.AreEqual("C", _note.getName()); _note = NoteFactory.getNoteByValue(5, _key); Assert.AreEqual("Db", _note.getName()); _note = NoteFactory.getNoteByValue(6, _key); Assert.AreEqual("D", _note.getName()); _note = NoteFactory.getNoteByValue(7, _key); Assert.AreEqual("Eb", _note.getName()); _note = NoteFactory.getNoteByValue(8, _key); Assert.AreEqual("E", _note.getName()); _note = NoteFactory.getNoteByValue(9, _key); Assert.AreEqual("F", _note.getName()); _note = NoteFactory.getNoteByValue(10, _key); Assert.AreEqual("Gb", _note.getName()); _note = NoteFactory.getNoteByValue(11, _key); Assert.AreEqual("G", _note.getName()); _note = NoteFactory.getNoteByValue(12, _key); Assert.AreEqual("Ab", _note.getName()); }
public void ChordFactoryTest_getChordRecomendationsTriads() { Note key = NoteFactory.getNoteByName("C"); Mode mode = ModeFactory.getModeByName("Ionian"); List <Chord> recomendations = ChordFactory.getChordRecomendationsTriads(key, mode); Assert.AreEqual("C", recomendations.ElementAt(0).getName()); Assert.AreEqual("Dm", recomendations.ElementAt(1).getName()); Assert.AreEqual("Em", recomendations.ElementAt(2).getName()); Assert.AreEqual("F", recomendations.ElementAt(3).getName()); Assert.AreEqual("G", recomendations.ElementAt(4).getName()); Assert.AreEqual("Am", recomendations.ElementAt(5).getName()); Assert.AreEqual("Bdim", recomendations.ElementAt(6).getName()); key = NoteFactory.getNoteByName("F"); mode = ModeFactory.getModeByName("Lydian"); recomendations = ChordFactory.getChordRecomendationsTriads(key, mode); Assert.AreEqual("F", recomendations.ElementAt(0).getName()); Assert.AreEqual("G", recomendations.ElementAt(1).getName()); Assert.AreEqual("Am", recomendations.ElementAt(2).getName()); Assert.AreEqual("Bdim", recomendations.ElementAt(3).getName()); Assert.AreEqual("C", recomendations.ElementAt(4).getName()); Assert.AreEqual("Dm", recomendations.ElementAt(5).getName()); Assert.AreEqual("Em", recomendations.ElementAt(6).getName()); key = NoteFactory.getNoteByName("G"); mode = ModeFactory.getModeByName("Mixolydian"); recomendations = ChordFactory.getChordRecomendationsTriads(key, mode); Assert.AreEqual("G", recomendations.ElementAt(0).getName()); Assert.AreEqual("Am", recomendations.ElementAt(1).getName()); Assert.AreEqual("Bdim", recomendations.ElementAt(2).getName()); Assert.AreEqual("C", recomendations.ElementAt(3).getName()); Assert.AreEqual("Dm", recomendations.ElementAt(4).getName()); Assert.AreEqual("Em", recomendations.ElementAt(5).getName()); Assert.AreEqual("F", recomendations.ElementAt(6).getName()); key = NoteFactory.getNoteByName("D"); mode = ModeFactory.getModeByName("Dorian"); recomendations = ChordFactory.getChordRecomendationsTriads(key, mode); Assert.AreEqual("Dm", recomendations.ElementAt(0).getName()); Assert.AreEqual("Em", recomendations.ElementAt(1).getName()); Assert.AreEqual("F", recomendations.ElementAt(2).getName()); Assert.AreEqual("G", recomendations.ElementAt(3).getName()); Assert.AreEqual("Am", recomendations.ElementAt(4).getName()); Assert.AreEqual("Bdim", recomendations.ElementAt(5).getName()); Assert.AreEqual("C", recomendations.ElementAt(6).getName()); key = NoteFactory.getNoteByName("A"); mode = ModeFactory.getModeByName("Aeolian"); recomendations = ChordFactory.getChordRecomendationsTriads(key, mode); Assert.AreEqual("Am", recomendations.ElementAt(0).getName()); Assert.AreEqual("Bdim", recomendations.ElementAt(1).getName()); Assert.AreEqual("C", recomendations.ElementAt(2).getName()); Assert.AreEqual("Dm", recomendations.ElementAt(3).getName()); Assert.AreEqual("Em", recomendations.ElementAt(4).getName()); Assert.AreEqual("F", recomendations.ElementAt(5).getName()); Assert.AreEqual("G", recomendations.ElementAt(6).getName()); key = NoteFactory.getNoteByName("E"); mode = ModeFactory.getModeByName("Phrygian"); recomendations = ChordFactory.getChordRecomendationsTriads(key, mode); Assert.AreEqual("Em", recomendations.ElementAt(0).getName()); Assert.AreEqual("F", recomendations.ElementAt(1).getName()); Assert.AreEqual("G", recomendations.ElementAt(2).getName()); Assert.AreEqual("Am", recomendations.ElementAt(3).getName()); Assert.AreEqual("Bdim", recomendations.ElementAt(4).getName()); Assert.AreEqual("C", recomendations.ElementAt(5).getName()); Assert.AreEqual("Dm", recomendations.ElementAt(6).getName()); key = NoteFactory.getNoteByName("B"); mode = ModeFactory.getModeByName("Locrian"); recomendations = ChordFactory.getChordRecomendationsTriads(key, mode); Assert.AreEqual("Bdim", recomendations.ElementAt(0).getName()); Assert.AreEqual("C", recomendations.ElementAt(1).getName()); Assert.AreEqual("Dm", recomendations.ElementAt(2).getName()); Assert.AreEqual("Em", recomendations.ElementAt(3).getName()); Assert.AreEqual("F", recomendations.ElementAt(4).getName()); Assert.AreEqual("G", recomendations.ElementAt(5).getName()); Assert.AreEqual("Am", recomendations.ElementAt(6).getName()); }
public static List <Chord> getChordRecomendationsByLast(Note key, Chord lastChord, Mode mode) { List <Chord> chords = new List <Chord>(); List <Chord> fives = new List <Chord>(); List <Chord> sevens = new List <Chord>(); List <Chord> sixes = new List <Chord>(); int value; int distance; Note note; bool foundDegree; bool foundFifth = false; bool foundSeventh = false; bool foundSixth = false; // V -> I -> IV foundDegree = false; distance = lastChord.getNoteAt(0).getValue() - key.getValue(); if (distance < 12) { distance = distance + 12; } if (mode.containsInterval(7 + distance) || mode.containsInterval(7 + distance - 12)) { value = lastChord.getNoteAt(0).getValue() + 7; if (value > 12) { value = value - 12; } note = NoteFactory.getNoteByValue(value, key); foundDegree = true; } // May add b5 and #5 recomendations back in /* * else if (mode.containsInterval(6)) * { * value = lastChord.getNoteAt(0).getValue() + 6; * if (value > 12) { value = value - 12; } * note = NoteFactory.getNoteByValue(value, key); * foundDegree = true; * } * else if (mode.containsInterval(8)) * { * value = lastChord.getNoteAt(0).getValue() + 8; * if (value > 12) { value = value - 12; } * note = NoteFactory.getNoteByValue(value, key); * foundDegree = true; * } */ else { note = NoteFactory.getNoteByValue(key.getValue(), key); } if (foundDegree) { fives = ChordFactory.getChordRecomendationsByTonic(key, note, mode); foundFifth = true; } // VII -> I -> II foundDegree = false; distance = lastChord.getNoteAt(0).getValue() - key.getValue(); if (distance < 12) { distance = distance + 12; } if (mode.containsInterval(10 + distance) || mode.containsInterval(10 + distance - 12)) { value = lastChord.getNoteAt(0).getValue() + 10; if (value > 12) { value = value - 12; } note = NoteFactory.getNoteByValue(value, key); foundDegree = true; } else if (mode.containsInterval(11 + distance) || mode.containsInterval(11 + distance - 12)) { value = lastChord.getNoteAt(0).getValue() + 11; if (value > 12) { value = value - 12; } note = NoteFactory.getNoteByValue(value, key); foundDegree = true; } else { note = NoteFactory.getNoteByValue(key.getValue(), key); } if (foundDegree) { sevens = ChordFactory.getChordRecomendationsByTonic(key, note, mode); foundSeventh = true; } // VI -> I -> III foundDegree = false; distance = lastChord.getNoteAt(0).getValue() - key.getValue(); if (distance < 12) { distance = distance + 12; } if (mode.containsInterval(9 + distance) || mode.containsInterval(9 + distance - 12)) { value = lastChord.getNoteAt(0).getValue() + 9; if (value > 12) { value = value - 12; } note = NoteFactory.getNoteByValue(value, key); foundDegree = true; } else if (mode.containsInterval(8 + distance) || mode.containsInterval(8 + distance - 12)) { value = lastChord.getNoteAt(0).getValue() + 8; if (value > 12) { value = value - 12; } note = NoteFactory.getNoteByValue(value, key); foundDegree = true; } else { note = NoteFactory.getNoteByValue(key.getValue(), key); } if (foundDegree) { sixes = ChordFactory.getChordRecomendationsByTonic(key, note, mode); foundSixth = true; } if (foundFifth) { chords.AddRange(fives); } if (foundSeventh) { chords.AddRange(sevens); } if (foundSixth) { chords.AddRange(sixes); } return(chords); }
public static Chord getChordByName(string name) { if (!(ChordController.checkChordName(name))) { throw new System.ArgumentException("Parameter must have a valid name", "Chord Name: " + name); } int i = 0; bool needsMore = true; string tonicName; string slashBass; Note tonic; Chord chord = new Chord(); chord.setName(name); var chordName = name.ToCharArray(); tonicName = chordName[i].ToString(); i++; if (i + 1 <= chordName.Length && (chordName[i] == 'b' || chordName[i] == '#')) { tonicName = tonicName + chordName[i].ToString(); i++; } tonic = NoteFactory.getNoteByName(tonicName); chord.addNote(tonic); // Calculate first interval (dim3, m3, M3, aug3) if (needsMore) { // X5 if (i + 1 <= chordName.Length && chordName[i] == '5') { chord.addNote(calculateNote(7, tonic)); i++; needsMore = false; } // Xsus else if (i + 3 <= chordName.Length && chordName[i] == 's' && chordName[i + 1] == 'u' && chordName[i + 2] == 's') { i = i + 3; if (i + 1 <= chordName.Length && chordName[i] == '2') { chord.addNote(calculateNote(2, tonic)); i++; } else { chord.addNote(calculateNote(5, tonic)); } chord.addNote(calculateNote(7, tonic)); needsMore = false; } // X7sus else if (i + 4 <= chordName.Length && chordName[i] == '7' && chordName[i + 1] == 's' && chordName[i + 2] == 'u' && chordName[i + 3] == 's') { chord.addNote(calculateNote(5, tonic)); chord.addNote(calculateNote(7, tonic)); chord.addNote(calculateNote(10, tonic)); i = i + 4; needsMore = false; } // Xdim else if (i + 3 <= chordName.Length && chordName[i] == 'd' && chordName[i + 1] == 'i' && chordName[i + 2] == 'm') { chord.addNote(calculateNote(3, tonic)); chord.addNote(calculateNote(6, tonic)); i = i + 3; needsMore = false; } //Xm else if (i + 1 == chordName.Length && chordName[i] == 'm') { chord.addNote(calculateNote(3, tonic)); i++; } // Xm... else if (i + 1 <= chordName.Length && chordName[i] == 'm' && chordName[i + 1] != 'a') { chord.addNote(calculateNote(3, tonic)); i++; } // X... else { chord.addNote(calculateNote(4, tonic)); } } // Add next interval (dim5, P5, aug5) if (needsMore) { // X(b5) if (i + 4 <= chordName.Length && chordName[i] == '(' && chordName[i + 1] == 'b' && chordName[i + 2] == '5' && chordName[i + 3] == ')') { chord.addNote(calculateNote(6, tonic)); i = i + 4; needsMore = false; } // X7(b5) else if (i + 5 <= chordName.Length && chordName[i] == '7' && chordName[i + 1] == '(' && chordName[i + 2] == 'b' && chordName[i + 3] == '5' && chordName[i + 4] == ')') { chord.addNote(calculateNote(6, tonic)); chord.addNote(calculateNote(10, tonic)); i = i + 5; needsMore = false; } // Xmaj7(b5) else if (i + 8 <= chordName.Length && chordName[i] == 'm' && chordName[i + 1] == 'a' && chordName[i + 2] == 'j' && chordName[i + 3] == '7' && chordName[i + 4] == '(' && chordName[i + 5] == 'b' && chordName[i + 6] == '5') { chord.addNote(calculateNote(6, tonic)); chord.addNote(calculateNote(11, tonic)); i = i + 8; needsMore = false; } // X9(b5) else if (i + 5 <= chordName.Length && chordName[i] == '9' && chordName[i + 1] == '(' && chordName[i + 2] == 'b' && chordName[i + 3] == '5') { chord.addNote(calculateNote(6, tonic)); chord.addNote(calculateNote(10, tonic)); chord.addNote(calculateNote(2, tonic)); i = i + 5; needsMore = false; } // X13(b9b5) else if (i + 8 <= chordName.Length && chordName[i] == '1' && chordName[i + 1] == '3' && chordName[i + 2] == '(' && chordName[i + 3] == 'b' && chordName[i + 4] == '9' && chordName[i + 5] == 'b' && chordName[i + 6] == '5') { chord.addNote(calculateNote(6, tonic)); chord.addNote(calculateNote(10, tonic)); chord.addNote(calculateNote(1, tonic)); chord.addNote(calculateNote(9, tonic)); i = i + 8; needsMore = false; } // Xaug else if (i + 3 <= chordName.Length && chordName[i] == 'a' && chordName[i + 1] == 'u' && chordName[i + 2] == 'g') { chord.addNote(calculateNote(8, tonic)); i = i + 3; needsMore = false; } // X7+ else if (i + 2 <= chordName.Length && chordName[i] == '7' && chordName[i + 1] == '+') { chord.addNote(calculateNote(8, tonic)); chord.addNote(calculateNote(10, tonic)); i = i + 2; // X7+(b9) if (i + 4 <= chordName.Length && chordName[i] == '(' && chordName[i + 1] == 'b' && chordName[i + 2] == '9') { chord.addNote(calculateNote(1, tonic)); i = i + 4; } needsMore = false; } // X9+ else if (i + 2 <= chordName.Length && chordName[i] == '9' && chordName[i + 1] == '+') { chord.addNote(calculateNote(8, tonic)); chord.addNote(calculateNote(10, tonic)); chord.addNote(calculateNote(2, tonic)); i = i + 2; needsMore = false; } // X... else { chord.addNote(calculateNote(7, tonic)); } } // Add final intervals (M6, m7, M7) if (needsMore) { // X(add9) if (i + 6 <= chordName.Length && chordName[i] == '(' && chordName[i + 1] == 'a' && chordName[i + 2] == 'd' && chordName[i + 3] == 'd' && chordName[i + 4] == '9') { chord.addNote(calculateNote(2, tonic)); i = i + 6; needsMore = false; } // X6 else if (i + 1 <= chordName.Length && chordName[i] == '6') { chord.addNote(calculateNote(9, tonic)); i++; // X6/9 if (i + 2 <= chordName.Length && chordName[i] == '/' && chordName[i + 1] == '9') { chord.addNote(calculateNote(2, tonic)); i = i + 2; } needsMore = false; } // X13 else if (i + 2 <= chordName.Length && chordName[i] == '1' && chordName[i + 1] == '3') { chord.addNote(calculateNote(10, tonic)); i = i + 2; // X13(b9) if (i + 4 <= chordName.Length && chordName[i] == '(' && chordName[i + 1] == 'b' && chordName[i + 2] == '9') { chord.addNote(calculateNote(1, tonic)); i = i + 4; } // X13(#9) else if (i + 4 <= chordName.Length && chordName[i] == '(' && chordName[i + 1] == '#' && chordName[i + 2] == '9') { chord.addNote(calculateNote(3, tonic)); i = i + 4; } else { chord.addNote(calculateNote(2, tonic)); } chord.addNote(calculateNote(9, tonic)); needsMore = false; } // X7 else if (i + 1 <= chordName.Length && chordName[i] == '7') { chord.addNote(calculateNote(10, tonic)); i++; // X7(b9) if (i + 4 <= chordName.Length && chordName[i] == '(' && chordName[i + 1] == 'b' && chordName[i + 2] == '9') { chord.addNote(calculateNote(1, tonic)); i = i + 4; } // X7(#9) else if (i + 4 <= chordName.Length && chordName[i] == '(' && chordName[i + 1] == '#' && chordName[i + 2] == '9') { chord.addNote(calculateNote(3, tonic)); i = i + 4; } needsMore = false; } // X9 else if (i + 1 <= chordName.Length && chordName[i] == '9') { i++; // X9(#11) if (i + 5 <= chordName.Length && chordName[i] == '(' && chordName[i + 1] == '#' && chordName[i + 2] == '1' && chordName[i + 3] == '1') { chord.addNote(calculateNote(10, tonic)); chord.addNote(calculateNote(2, tonic)); chord.addNote(calculateNote(6, tonic)); i = i + 5; } // X9maj7 else if (i + 6 <= chordName.Length && chordName[i + 1] == 'm' && chordName[i + 2] == 'a' && chordName[i + 3] == 'j' && chordName[i + 4] == '7') { chord.addNote(calculateNote(11, tonic)); chord.addNote(calculateNote(2, tonic)); i = i + 6; needsMore = false; } else { chord.addNote(calculateNote(10, tonic)); chord.addNote(calculateNote(2, tonic)); } needsMore = false; } // X11 else if (i + 1 <= chordName.Length && chordName[i] == '1' && chordName[i + 1] == '1') { chord.addNote(calculateNote(10, tonic)); chord.addNote(calculateNote(2, tonic)); chord.addNote(calculateNote(5, tonic)); i = i + 2; needsMore = false; } // XM11 else if (i + 3 <= chordName.Length && chordName[i] == 'M' && chordName[i + 1] == '1' && chordName[i + 2] == '1') { chord.addNote(calculateNote(11, tonic)); chord.addNote(calculateNote(2, tonic)); chord.addNote(calculateNote(5, tonic)); i = i + 3; needsMore = false; } // Xmaj7 else if (i + 3 <= chordName.Length && chordName[i] == 'm' && chordName[i + 1] == 'a' && chordName[i + 2] == 'j') { chord.addNote(calculateNote(11, tonic)); i = i + 3; if (i + 1 <= chordName.Length && chordName[i] == '9') { chord.addNote(calculateNote(2, tonic)); } i++; needsMore = false; } // X(maj7) else if (i + 6 <= chordName.Length && chordName[i] == '(' && chordName[i + 1] == 'm' && chordName[i + 2] == 'a' && chordName[i + 3] == 'j' && chordName[i + 4] == '7') { chord.addNote(calculateNote(11, tonic)); i = i + 6; needsMore = false; } } // X/bassNote if (i < chordName.Count() && chordName[i] == '/') { i++; if (i < chordName.Count() && NoteController.checkNoteName(chordName[i].ToString())) { slashBass = chordName[i].ToString(); i++; } else { throw new System.ArgumentException("\nThe character length for " + name + " is: " + chordName.Length + "\nThe index for " + name + " is: " + i, "Chord Name: " + name); } if (i < chordName.Count() && (chordName[i] == 'b' || chordName[i] == '#')) { slashBass = slashBass + chordName[i].ToString(); i++; } chord.insertNote(NoteFactory.getNoteByName(slashBass), 0); } if (i < chordName.Length) { throw new System.ArgumentException("\nThe character length for " + name + " is: " + chordName.Length + "\nThe index for " + name + " is: " + i, "Chord Name: " + name); } chord.color = RandomColorFactory.GetRandomColor(); return(chord); }