public void ChromaticIntervalTranslationsTest() { var scale = new MajorScale(Step.G, false); var pitches = scale.BuildScale(1, 8); var secondStep = pitches.ElementAt(1); var translatedPitch = scale.TranslatePitch(secondStep, Interval.MajorThird); Assert.AreEqual(translatedPitch, Step.CSharp); }
public static void Main(string[] args) { if (args.Length == 0) { Console.WriteLine("Here are some tests:"); MajorScale CSharpMajor = new MajorScale(Chromatic.Cs); CSharpMajor.PrintScale(); MajorScale FSharpMajor = new MajorScale(Chromatic.Fs); FSharpMajor.PrintScale(); NaturalMinorScale DMinor = new NaturalMinorScale(Chromatic.D); DMinor.PrintScale(); NaturalMinorScale AMinor = new NaturalMinorScale(Chromatic.A); AMinor.PrintScale(); } else if (args[0] == "--i") { bool running = true; while (running) { Console.WriteLine("Enter a musical note -- no flats! (Ex: Cs)"); string n = Console.ReadLine(); try { Chromatic note = (Chromatic)Enum.Parse(typeof(Chromatic), n); Console.WriteLine("Major (M) or minor (m)?"); string s = Console.ReadLine(); if (s == "M") { MajorScale scale = new MajorScale(note); scale.PrintScale(); } else if (s == "m") { NaturalMinorScale scale = new NaturalMinorScale(note); scale.PrintScale(); } else { throw new Exception(); } } catch { Console.WriteLine("Sorry, invalid note."); } Console.WriteLine("Want to try again? (y/n)"); string again = Console.ReadLine(); if (again == "n") { running = false; } } } }
public void EMajorScaleConsistsOfCorrectNotes() { var eMajorScale = MajorScale.For(Note.E).ToList(); Assert.Equal(eMajorScale[0], Note.E); Assert.Equal(eMajorScale[1], Note.FSharp); Assert.Equal(eMajorScale[2], Note.GSharp); Assert.Equal(eMajorScale[3], Note.A); Assert.Equal(eMajorScale[4], Note.B); Assert.Equal(eMajorScale[5], Note.CSharp); Assert.Equal(eMajorScale[6], Note.DSharp); }
public void CMajorScaleConsistsOfCorrectNotes() { var cMajorScale = MajorScale.For(Note.C).ToList(); Assert.Equal(cMajorScale[0], Note.C); Assert.Equal(cMajorScale[1], Note.D); Assert.Equal(cMajorScale[2], Note.E); Assert.Equal(cMajorScale[3], Note.F); Assert.Equal(cMajorScale[4], Note.G); Assert.Equal(cMajorScale[5], Note.A); Assert.Equal(cMajorScale[6], Note.B); }
public void TertianTuningTest() { var tuning = new TertianTuning(Pitch.C4); var comma = tuning.CommaBetweenLastIntervalAndPerfectOctave; var scale = new MajorScale(Step.G, false); foreach (var pitch in scale.BuildScale(1, 9)) { var tp = pitch.Tune(new TunedPitch(Pitch.A4, 440), tuning); Debug.WriteLine(tp.ToString()); } }
public void MelodyGenerationTest() { var scale = new MajorScale(Step.G, false); IMelodicTrail melodicTrail = new HeadMotiveTrail(Pitch.G3, Pitch.C6, 4, 8); var melody = melodicTrail.BuildMelody(scale, Pitch.G4); melody = melodicTrail.BuildMelody(scale, Pitch.G4); melody = melodicTrail.BuildMelody(scale, Pitch.G4); melodicTrail = new ConjunctMovementTrail(MovementType.Anabasis, Pitch.G3, Pitch.C6, 4, 8); melody = melodicTrail.BuildMelody(scale, Pitch.G4); melody = melodicTrail.BuildMelody(scale, Pitch.G4); melody = melodicTrail.BuildMelody(scale, Pitch.G4); }
public void BuildMajorScaleTest() { var scale = new MajorScale(Step.G, false); var steps = scale.BuildScale(1, 8); MusicalAssertions.StepsMatch(steps, Step.G, Step.A, Step.B, Step.C, Step.D, Step.E, Step.FSharp, Step.G).Assert(); scale = new MajorScale(Step.B, false); steps = scale.BuildScale(1, 8); MusicalAssertions.StepsMatch(steps, Step.B, Step.CSharp, Step.DSharp, Step.E, Step.FSharp, Step.GSharp, Step.ASharp, Step.B).Assert(); scale = new MajorScale(Step.Bb, true); steps = scale.BuildScale(1, 8); MusicalAssertions.StepsMatch(steps, Step.Bb, Step.C, Step.D, Step.Eb, Step.F, Step.G, Step.A, Step.Bb).Assert(); MusicalAssertions.ThrowsMalformedScaleException(() => scale = new MajorScale(Step.B, true)).Assert(); }
public void ScaleTest() { MajorScale cScale = new MajorScale(new Note(NoteType.C)); List <Note> notes = new List <Note>(); notes.Add(new Note("C3", 0)); notes.Add(new Note("E3", 0)); notes.Add(new Note("G3", 0)); notes.Add(new Note("B3", 0)); Assert.AreEqual(true, cScale.IsMatchingScale(notes)); notes.Add(new Note("C#3", 0)); Assert.AreEqual(false, cScale.IsMatchingScale(notes)); }
static void Main(string[] args) { var strNote = String.Empty; while (strNote.ToLower() != "exit") { Console.Write("Enter a note: "); strNote = Console.ReadLine(); var note = Note.For(strNote.ToUpper()); if (note == Note.Rest) { Console.WriteLine("Invalid Note."); continue; } var intervals = Interval.For(note); Console.WriteLine("\n=== INTERVALS ==="); PrintIntervals(intervals); Console.WriteLine("\n=== NOTES IN MAJOR SCALE ==="); var notesOfMajorScale = MajorScale.For(note); Console.WriteLine(String.Join <Note>(" - ", notesOfMajorScale)); Console.WriteLine("\n=== NOTES IN MAJOR CHORD ==="); var notesOfMajorChord = MajorChord.For(note); Console.WriteLine(String.Join <Note>(" - ", notesOfMajorChord)); Console.WriteLine("\n=== MAJOR CHORD NOTES ON GUITAR ==="); PrintChordNotesOnInstrument(StringedInstrument.Guitar, notesOfMajorChord); Console.WriteLine("\n=== NOTES IN MINOR SCALE ==="); var notesOfMinorScale = MinorScale.For(note); Console.WriteLine(String.Join <Note>(" - ", notesOfMinorScale)); Console.WriteLine("\n=== NOTES IN MINOR CHORD ==="); var notesOfMinorChord = MinorChord.For(note); Console.WriteLine(String.Join <Note>(" - ", notesOfMinorChord)); Console.WriteLine("\n=== MINOR CHORD NOTES ON GUITAR ==="); PrintChordNotesOnInstrument(StringedInstrument.Guitar, notesOfMinorChord); Console.WriteLine("=======================\n"); } }
public void DiatonicIntervalTranslationsTest() { var scale = new MajorScale(Step.G, false); var pitches = scale.BuildScale(1, 8); var secondStep = pitches.ElementAt(1); var translatedPitch = scale.TranslatePitch(secondStep, DiatonicInterval.Unison); Assert.AreEqual(translatedPitch, Step.A); translatedPitch = scale.TranslatePitch(secondStep, DiatonicInterval.Second); Assert.AreEqual(translatedPitch, Step.B); translatedPitch = scale.TranslatePitch(secondStep, DiatonicInterval.Third); Assert.AreEqual(translatedPitch, Step.C); translatedPitch = scale.TranslatePitch(secondStep, DiatonicInterval.Fourth); Assert.AreEqual(translatedPitch, Step.D); translatedPitch = scale.TranslatePitch(secondStep, DiatonicInterval.Fifth); Assert.AreEqual(translatedPitch, Step.E); translatedPitch = scale.TranslatePitch(secondStep, DiatonicInterval.Sixth); Assert.AreEqual(translatedPitch, Step.FSharp); translatedPitch = scale.TranslatePitch(secondStep, DiatonicInterval.Seventh); Assert.AreEqual(translatedPitch, Step.G); translatedPitch = scale.TranslatePitch(secondStep, DiatonicInterval.Octave); Assert.AreEqual(translatedPitch, Step.A); }
public void MajorScaleConsistsOf7Notes() { var aMajorScale = MajorScale.For(Note.A); Assert.Equal(7, aMajorScale.Count()); }