public Pitch TranslatePitch(Pitch pitch, DiatonicInterval interval) { var stepNumber = StepToStepNumber(pitch.ToStep()); var halfTones = 0; if (interval.Steps == 0) { throw new ArithmeticException("There is no interval with 0 steps."); } if (interval.Steps > 0) { for (var i = 0; i < interval.Steps - 1; i++) { halfTones += Mode.GetIntervalAfterStep(stepNumber + i); } } else if (interval.Steps < 0) { for (var i = 0; i > interval.Steps + 1; i--) { halfTones -= Mode.GetIntervalBeforeStep(stepNumber + i); } } return(Pitch.FromMidiPitch(pitch.MidiPitch + halfTones, MidiPitchTranslationMode)); }
public IEnumerable <Pitch> BuildScale(int startingMidiPitch, Pitch.MidiPitchTranslationMode translationMode, int startingStep, int numberOfSteps) { if (startingStep < 1) { throw new ArgumentException("Starting step must be greater than 0.", "startingStep"); } if (numberOfSteps < 1) { throw new ArgumentException("Number of steps must be greater than 0.", "numberOfSteps"); } var pitches = new List <Pitch>(); var midiPitch = startingMidiPitch; for (int step = startingStep; step < startingStep + numberOfSteps; step++) { pitches.Add(Pitch.FromMidiPitch(midiPitch, translationMode)); midiPitch = midiPitch + GetIntervalAfterStep(step); } return(pitches); }
public Pitch TranslatePitch(Pitch pitch, Interval interval) { return(Pitch.FromMidiPitch(pitch.MidiPitch + interval.Halftones, MidiPitchTranslationMode)); }