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; }
public override void Render(Key element, ScoreRendererBase renderer) { scoreService.CurrentKey = element; double flatOrSharpPositionY = 0; bool jumpFourth = false; int jumpDirection = 1; int octaveShiftSharp = 0; //In G clef sharps (not flats) should be written an octave higher / W kluczu g krzyżyki (bemole nie) powinny być zapisywane o oktawę wyżej if (scoreService.CurrentClef.TypeOfClef == ClefType.GClef) { octaveShiftSharp = 1; } int octaveShiftFlat = 0; if (scoreService.CurrentClef.TypeOfClef == ClefType.FClef) { octaveShiftFlat = -1; } if (scoreService.CurrentKey.Fifths > 0) { flatOrSharpPositionY = scoreService.CurrentClef.TextBlockLocation.Y + Pitch.StepDistance(scoreService.CurrentClef, Pitch.FromStep(Step.F, scoreService.CurrentClef.Pitch.Octave + octaveShiftSharp)) * (renderer.Settings.LineSpacing / 2); jumpFourth = true; jumpDirection = 1; } else if (scoreService.CurrentKey.Fifths < 0) { flatOrSharpPositionY = scoreService.CurrentClef.TextBlockLocation.Y + Pitch.StepDistance(scoreService.CurrentClef, Pitch.FromStep(Step.B, scoreService.CurrentClef.Pitch.Octave + octaveShiftFlat)) * (renderer.Settings.LineSpacing / 2); jumpFourth = true; jumpDirection = -1; } for (int i = 0; i < Math.Abs(scoreService.CurrentKey.Fifths); i++) { renderer.DrawString(element.MusicalCharacter, MusicFontStyles.MusicFont, scoreService.CursorPositionX, flatOrSharpPositionY, element); if (jumpFourth) { flatOrSharpPositionY += 3 * 3 * jumpDirection; } else { flatOrSharpPositionY += 3 * 4 * jumpDirection; } jumpFourth = !jumpFourth; jumpDirection *= -1; scoreService.CursorPositionX += 8; } scoreService.CursorPositionX += 10; }
/// <summary> /// Initializes a new instance of Clef. /// </summary> /// <param name="clefType">Type of clef (C, F, G)</param> /// <param name="whichLine">Line</param> public Clef(ClefType clefType, int whichLine, int octaveShift = 0) { typeOfClef = clefType; line = whichLine; if (typeOfClef == ClefType.GClef) { musicalCharacter = MusicFont.GClef; Pitch = Pitch.FromStep(Step.G, 4 + octaveShift); } else if (typeOfClef == ClefType.FClef) { musicalCharacter = MusicFont.FClef; Pitch = Pitch.FromStep(Step.F, 3 + octaveShift); } else if (typeOfClef == ClefType.CClef) { musicalCharacter = MusicFont.CClef; Pitch = Pitch.FromStep(Step.C, 4 + octaveShift); } }
/// <summary> /// Initializes a new instance of Clef. /// </summary> /// <param name="clefType">Type of clef (C, F, G)</param> /// <param name="whichLine">Line</param> public Clef(ClefType clefType, int whichLine, int octaveShift = 0) { typeOfClef = clefType; line = whichLine; if (typeOfClef == ClefType.GClef) { Pitch = Pitch.FromStep(Step.G, 4 + octaveShift); } else if (typeOfClef == ClefType.FClef) { Pitch = Pitch.FromStep(Step.F, 3 + octaveShift); } else if (typeOfClef == ClefType.CClef) { Pitch = Pitch.FromStep(Step.C, 4 + octaveShift); } else if (typeOfClef == ClefType.Percussion) { Pitch = Pitch.FromStep(Step.G, 4 + octaveShift); } }
private Pitch NormalizePitch(Pitch p) { return(Pitch.FromStep(p.ToStep(), 4)); }
public override void Render(Key element, ScoreRendererBase renderer, FontProfile fontProfile) { if (element.Fifths != 0 && element.Measure.Elements.FirstOrDefault() == element) { scoreService.CursorPositionX += renderer.LinespacesToPixels(1); //Żeby był lekki margines między kreską taktową a symbolem. Być może ta linijka będzie do usunięcia } scoreService.CurrentKey = element; double flatOrSharpPositionY = 0; bool jumpFourth = false; int jumpDirection = 1; int octaveShiftSharp = 0; //In G clef sharps (not flats) should be written an octave higher / W kluczu g krzyżyki (bemole nie) powinny być zapisywane o oktawę wyżej if (scoreService.CurrentClef.TypeOfClef == ClefType.GClef) { octaveShiftSharp = 1; } int octaveShiftFlat = 0; if (scoreService.CurrentClef.TypeOfClef == ClefType.FClef) { octaveShiftFlat = -1; } if (!IsVirtualKey) { element.TextBlockLocation = new Primitives.Point(scoreService.CursorPositionX, scoreService.CurrentLinePositions[0]); } if (scoreService.CurrentKey.Fifths > 0) { flatOrSharpPositionY = scoreService.CurrentClef.TextBlockLocation.Y + Pitch.StepDistance(scoreService.CurrentClef, Pitch.FromStep(Step.F, scoreService.CurrentClef.Pitch.Octave + octaveShiftSharp)) * (renderer.Settings.LineSpacing / 2); jumpFourth = true; jumpDirection = 1; } else if (scoreService.CurrentKey.Fifths < 0) { flatOrSharpPositionY = scoreService.CurrentClef.TextBlockLocation.Y + Pitch.StepDistance(scoreService.CurrentClef, Pitch.FromStep(Step.B, scoreService.CurrentClef.Pitch.Octave + octaveShiftFlat)) * (renderer.Settings.LineSpacing / 2); jumpFourth = true; jumpDirection = -1; } for (int i = 0; i < Math.Abs(scoreService.CurrentKey.Fifths); i++) { renderer.DrawCharacter(element.GetCharacter(fontProfile.MusicFont), MusicFontStyles.MusicFont, scoreService.CursorPositionX, flatOrSharpPositionY, element); if (jumpFourth) { flatOrSharpPositionY += 3 * 3 * jumpDirection; } else { flatOrSharpPositionY += 3 * 4 * jumpDirection; } jumpFourth = !jumpFourth; jumpDirection *= -1; scoreService.CursorPositionX += 8; } scoreService.CursorPositionX += 10; }