protected MajorOrMinorScale(Step step, MajorAndMinorScaleFlags flags)
            : base(GetMode(flags.IsMinor), Pitch.FromStep(step).MidiPitch, flags.IsFlat ? Pitch.MidiPitchTranslationMode.Flats : Pitch.MidiPitchTranslationMode.Sharps)
        {
            Fifths = CircleOfFifths.CalculateFifths(step, flags);
            if (CircleOfFifths.GetAlterOfStepFromNumberOfFifths(step, Fifths) != step.Alter)
            {
                throw new MalformedScaleException(string.Format("There is no {0} {1} scale beginning on step {2}.",
                                                                flags.IsMinor ? "minor" : "major", flags.IsFlat ? "flat" : (Math.Abs(Fifths) > 0 ? "sharp" : "natural"), step));
            }

            Tonic = step;
        }
 protected MajorOrMinorScale(int midiPitch, MajorAndMinorScaleFlags flags)
     : base(GetMode(flags.IsMinor), midiPitch, flags.IsFlat ? Pitch.MidiPitchTranslationMode.Flats : Pitch.MidiPitchTranslationMode.Sharps)
 {
     Tonic  = Pitch.FromMidiPitch(midiPitch, MidiPitchTranslationMode);
     Fifths = CircleOfFifths.CalculateFifths(Tonic, flags);
 }
Exemple #3
0
 /// <summary>
 /// Creates a new instance of Key from given midi pitch.
 /// </summary>
 /// <param name="midiPitch">Midi pitch</param>
 /// <param name="flags">Flags</param>
 /// <returns>Key</returns>
 public static Key FromMidiPitch(int midiPitch, MajorAndMinorScaleFlags flags)
 {
     return(new Key(CircleOfFifths.CalculateFifths(midiPitch, flags)));
 }
Exemple #4
0
 /// <summary>
 /// Creates a new instance of Key from given step.
 /// </summary>
 /// <param name="step"></param>
 /// <param name="flags"></param>
 /// <returns></returns>
 public static Key FromTonic(Step step, MajorAndMinorScaleFlags flags)
 {
     return(new Key(CircleOfFifths.CalculateFifths(step, flags)));
 }
Exemple #5
0
 /// <summary>
 /// Returns the alteration of specific step.
 /// </summary>
 /// <param name="step"></param>
 /// <returns></returns>
 public int StepToAlter(string step)
 {
     return(CircleOfFifths.GetAlterOfStepFromNumberOfFifths(step, Fifths));
 }