public void MajorScaleStepTest() { Assert.AreEqual(MidiPitch.E0, ScaleLibrary.Step(Pitch.C, ScaleType.Major, MidiPitch.A0, -3)); Assert.AreEqual(MidiPitch.GNeg1, ScaleLibrary.Step(Pitch.C, ScaleType.Major, MidiPitch.C0, -3)); Assert.AreEqual(MidiPitch.D1, ScaleLibrary.Step(Pitch.C, ScaleType.Major, MidiPitch.A0, 3)); Assert.AreEqual(MidiPitch.A1, ScaleLibrary.Step(Pitch.C, ScaleType.Major, MidiPitch.A0, 7)); Assert.AreEqual(MidiPitch.D1, ScaleLibrary.Step(Pitch.C, ScaleType.Major, MidiPitch.B0, 2)); }
public void MinorScaleStepTest() { Assert.AreEqual(MidiPitch.GSharpNeg1, ScaleLibrary.Step(Pitch.C, ScaleType.Minor, MidiPitch.D0, -3)); Assert.AreEqual(MidiPitch.D4, ScaleLibrary.Step(Pitch.C, ScaleType.Minor, MidiPitch.G4, -3)); Assert.AreEqual(MidiPitch.F2, ScaleLibrary.Step(Pitch.C, ScaleType.Minor, MidiPitch.DSharp2, 1)); Assert.AreEqual(MidiPitch.D1, ScaleLibrary.Step(Pitch.E, ScaleType.Minor, MidiPitch.G1, -3)); Assert.AreEqual(MidiPitch.C3, ScaleLibrary.Step(Pitch.E, ScaleType.Minor, MidiPitch.B3, -6)); Assert.AreEqual(MidiPitch.FSharp5, ScaleLibrary.Step(Pitch.E, ScaleType.Minor, MidiPitch.D5, 2)); }
private static List <MidiPitch> GetPitches(Chord chord, ScaleType scaleType, int count, int octave) { var interval = 0; var pitchesInChord = chord.Pitches(octave).Select(p => p.FromMidiPitch()).ToList(); var pitches = new List <MidiPitch>(); var stdDev = 0.5; for (var i = 0; i < count; i++) { interval = Randomizer.Clamp(interval + Randomizer.Clamp(Randomizer.NextNormalized(0, stdDev), -4, 4), -7, 7); var pitch = ScaleLibrary.Step(chord.BasePitch, scaleType, chord.BasePitch.ToMidiPitch(octave), interval); pitches.Add(pitch); stdDev = pitchesInChord.Contains(pitch.FromMidiPitch()) ? 0.75 : 2; } return(pitches); }