public void TwelveToneSetScaleTest() { // Check major and minor scale Assert.AreEqual(new TwelveToneSet(new int[] { 0, 2, 4, 5, 7, 9, 11 }), TwelveToneSet.majorScale); Assert.AreEqual(new TwelveToneSet(new int[] { 0, 2, 3, 5, 7, 8, 10 }), TwelveToneSet.minorScale); //// Major and minor scale are different but similar Assert.AreNotEqual(TwelveToneSet.majorScale, TwelveToneSet.minorScale); Assert.IsTrue(TwelveToneSet.majorScale.IsSimilar(TwelveToneSet.minorScale)); // Minor, minor harmonic, minor melodic are NOT similar Assert.IsFalse(TwelveToneSet.minorScale.IsSimilar(TwelveToneSet.minorHarmonicScale)); Assert.IsFalse(TwelveToneSet.minorScale.IsSimilar(TwelveToneSet.minorMelodicScale)); Assert.IsFalse(TwelveToneSet.minorHarmonicScale.IsSimilar(TwelveToneSet.minorMelodicScale)); // Ionian, Dorian, Phrygian, Lydian, Mixolydian, Aoelian, Locrian for (MusicalModes mode = MusicalModes.Ionian; mode <= MusicalModes.Locrian; mode++) { TwelveToneSet set = new TwelveToneSet(mode); Assert.IsTrue(set.IsSimilar(TwelveToneSet.majorScale)); Assert.IsFalse(set.IsSimilar(TwelveToneSet.minorHarmonicScale)); Assert.IsFalse(set.IsSimilar(TwelveToneSet.minorMelodicScale)); } }
public TwelveToneSet(MusicalModes mode) : this(majorScale) { if (mode == MusicalModes.Chromatic) { tones = 1 + 2 + 4 + 8 + 16 + 32 + 64 + 128 + 256 + 512 + 1024 + 2048; return; } if (mode >= MusicalModes.Dorian && mode <= MusicalModes.Locrian) { int shift = FindNth((int)mode - (int)MusicalModes.Ionian); this = ShiftLeft(shift); return; } MusicalModes modeShift = mode; if (mode == MusicalModes.MinorHarmonic || mode == MusicalModes.MinorMelodic) { modeShift = MusicalModes.Minor; } int tone = FindNth((int)(modeShift) - 1); ShiftLeft(tone); if (mode == MusicalModes.MinorMelodic) { MakeSharp(4); MakeSharp(5); } if (mode == MusicalModes.MinorHarmonic) { MakeSharp(5); } }