/// <summary> /// Resets the selected note value to QuarterNote when a new score is created or loaded. /// </summary> private void NoteSelectionReset() { object PreviousSelected = SelectedNote; if (DottedSelected != null) { ((Rectangle)DottedSelected).Stroke = Brushes.White; DottedSelected = null; noteLength.Dots = 0; } SelectedNote = QuarterNote; HoldSelected = ""; Selected = "QuarterNote"; if (SelectedNote != PreviousSelected) { ((Rectangle)PreviousSelected).Stroke = Brushes.White; ((Rectangle)SelectedNote).Stroke = Brushes.Yellow; noteLength = RhythmicDuration.Quarter; Selected = "QuarterNote"; } else { return; } }
/// <summary> /// Creates a new instance of Note from given pitch and duration. /// </summary> /// <param name="midiPitch">Pitch</param> /// <param name="duration">Duration</param> public static Note FromPitch(Pitch pitch, RhythmicDuration duration) { Note note = new Note(duration); note.Pitch = pitch; return(note); }
/// <summary> /// Creates a new instance of Note from given midi pitch and duration. /// </summary> /// <param name="midiPitch">Midi pitch</param> /// <param name="duration">Duration</param> /// <returns></returns> public static Note FromMidiPitch(int midiPitch, RhythmicDuration duration) { Note note = new Note(duration); note.ApplyMidiPitch(midiPitch); return(note); }
/// <summary> /// Builds playback information for JS based MIDI players for a specific MusicalSymbol /// </summary> /// <param name="element"></param> /// <returns></returns> protected Dictionary <string, string> BuildPlaybackAttributes(MusicalSymbol element) { var dict = new Dictionary <string, string>(); var durationElement = element as IHasDuration; if (durationElement != null) { var timelineElements = currentPlaybackTimeline.Where(p => p.What == durationElement).ToArray(); if (timelineElements.Any()) { //In most cases there will be one start point for one element. The next ones are for repetitions. var playbackStartPoints = string.Join(" ", timelineElements.Select(te => (long)te.When.TotalMilliseconds)); var duration = new RhythmicDuration(durationElement.BaseDuration.DenominatorAsPowerOfTwo, durationElement.NumberOfDots).ToTimeSpan(new Tempo(RhythmicDuration.Quarter, TypedSettings.PlaybackTempo)); dict.Add("data-playback-start", playbackStartPoints); dict.Add("data-playback-duration", ((long)duration.TotalMilliseconds).ToString()); } } var midiPitchElement = element as IHasPitch; if (midiPitchElement != null) { dict.Add("data-midi-pitch", midiPitchElement.Pitch.MidiPitch.ToString()); } return(dict); }
/// <summary> /// Creates a new instance of a Note. /// </summary> /// <param name="notePitch">Pitch</param> /// <param name="noteDuration">Duration</param> /// <param name="noteStemDirection">Stem direction</param> /// <param name="noteTieType">Tie type</param> /// <param name="noteBeamList">Beam list</param> public Note(Pitch notePitch, RhythmicDuration noteDuration, VerticalDirection noteStemDirection, NoteTieType noteTieType, List <NoteBeamType> noteBeamList) { Duration = noteDuration; pitch = notePitch; stemDirection = noteStemDirection; beamList = noteBeamList; tieType = noteTieType; Lyrics = new LyricsCollection(this); Ornaments = new List <Ornament>(); DetermineMusicalCharacter(); }
/// <summary> /// Converts a RhythmicDuration object to a double. This function supports dotted values, /// unlike RhythmicDuration.ToDouble(). /// </summary> /// <param name="rd"></param> /// <returns>A double that corresponds to the value of rd.</returns> private double DottedValue(RhythmicDuration rd) { double d = rd.WithoutDots.ToDouble(); double dot = d / 2; for (int i = 0; i < rd.Dots; i++) { d += dot; dot = dot / 2; } return(d); }
/**** The code in this region handles events from duration, key signature, time signature, and * any other controls that change the score except for the piano keys. ****/ /// <summary> /// Note length Combo Box /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void NoteLengthSelection(object sender, MouseButtonEventArgs e) { string NoteName = (((FrameworkElement)e.Source).Name); ((Rectangle)sender).Stroke = Brushes.Yellow; if (NoteName == "Dot") { dotted = true; } else { noteLength = NoteLengths[NoteName]; } }
/// <summary> /// Adds the selected Rest to the score. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void NoteRestSelection(object sender, MouseButtonEventArgs e) { string NoteRestName = (((FrameworkElement)e.Source).Name); RhythmicDuration previousNoteLength = noteLength; // Update note value to match the rest switch (NoteRestName) { case "WholeRest": noteLength = RhythmicDuration.Whole; break; case "HalfRest": noteLength = RhythmicDuration.Half; break; case "QuarterRest": noteLength = RhythmicDuration.Quarter; break; case "EighthRest": noteLength = RhythmicDuration.Eighth; break; case "SixteenthRest": noteLength = RhythmicDuration.Sixteenth; break; case "ThirtySecondRest": noteLength = RhythmicDuration.D32nd; break; default: break; } noteLength.Dots = 0; // Add the rest to the score addNoteOrRestToStaff(new Rest(noteLength)); // Restore to previous value noteLength = previousNoteLength; }
/**** The code in this region handles events from duration, key signature, time signature, and * any other controls that change the score except for the piano keys. ****/ /// <summary> /// Sets the default note value to the selected note type. Called when any /// of the note value buttons are clicked. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void NoteLengthSelection(object sender, MouseButtonEventArgs e) { string NoteName = (((FrameworkElement)e.Source).Name); if (DottedSelected != null) { if (DottedSelected != sender) { ((Rectangle)DottedSelected).Stroke = Brushes.White; DottedSelected = null; } } if (NoteName == "Dot") { //hold previous selected note for color object HoldSelectedwithDot = SelectedNote; ((Rectangle)HoldSelectedwithDot).Stroke = Brushes.Yellow; HoldSelected = (((FrameworkElement)HoldSelectedwithDot).Name); //bring in dot and hold color DottedSelected = sender; noteLength.Dots++; ((Rectangle)DottedSelected).Stroke = Brushes.Yellow; Selected = (((FrameworkElement)e.Source).Name); } else { noteLength = NoteLengths[NoteName]; noteLength.Dots = 0; //Change previos selected note outline to white if (SelectedNote != sender) { ((Rectangle)SelectedNote).Stroke = Brushes.White; } SelectedNote = sender; Selected = (((FrameworkElement)e.Source).Name); ((Rectangle)sender).Stroke = Brushes.Yellow; } }
/// <summary> /// Starts building a Staff with a set of rhythmic durations expressed by string (rhythm-first approach) /// </summary> /// <param name="durations"></param> /// <returns></returns> public static IEnumerable <RhythmicDuration> FromRhythm(string durations) { return(RhythmicDuration.Parse(durations, " ")); }
/// <summary> /// Initializes a new Rest with specific duration /// </summary> /// <param name="restDuration">Duration</param> public Rest(RhythmicDuration restDuration) { Duration = restDuration; }
/// <summary> /// Create a new A4 note with a specific duration. /// </summary> /// <param name="noteDuration">Duration</param> public Note(RhythmicDuration noteDuration) : this("A", 0, 4, noteDuration, VerticalDirection.Up, NoteTieType.None, new List <NoteBeamType>() { NoteBeamType.Single }) { }
public void LoadTestData(HookDirectionAlgorithm hookDirectionAlgorithm) { var rd = new RhythmicDuration(2, 0).ToProportion(); rd = new RhythmicDuration(2, 1).ToProportion(); rd = new RhythmicDuration(2, 2).ToProportion(); rd = new RhythmicDuration(2, 3).ToProportion(); var score = Score.CreateOneStaffScore(Clef.Alto, new MajorScale(Step.C, false)); var firstStaff = score.FirstStaff; firstStaff.Elements.Add(new TimeSignature(TimeSignatureType.Numbers, 4, 4)); firstStaff.Elements.AddRange(StaffBuilder .FromPitches(Pitch.C4, Pitch.C4, Pitch.C4, Pitch.C4) .AddRhythm("16. 32 16 16") .ApplyStemDirection(VerticalDirection.Up) .Rebeam()); firstStaff.Elements.AddRange(StaffBuilder .FromPitches(Pitch.C4, Pitch.E4, Pitch.G4, Pitch.C4, Pitch.E4, Pitch.G4, Pitch.C4) .AddRhythm(16, 32, 16, 32, 8, 8, 16) .ApplyStemDirection(VerticalDirection.Up) .AddLyrics("Wlazł ko-tek na pło-tek")); firstStaff.Elements.Add(new MetronomeDirection(Tempo.Allegro, DirectionPlacementType.Above)); firstStaff.Elements.Add(new Barline()); firstStaff.Elements.AddRange(StaffBuilder .FromPitches(Pitch.C4, Pitch.E4) .AddRhythm("8.. 32") .ApplyStemDirection(VerticalDirection.Up) .AddLyrics("i mru-")); firstStaff.Elements.AddRange(StaffBuilder .FromRhythm(8, 8) .AddPitches(Pitch.C4, Pitch.E4) .ApplyStemDirection(VerticalDirection.Up)); firstStaff.Elements.AddRange(StaffBuilder .FromPitches(Pitch.C4, Pitch.E4, Pitch.G4, Pitch.C4, Pitch.E4, Pitch.G4) .AddRhythm(32, 32, 32, 16, 16, 32) .ApplyStemDirection(VerticalDirection.Up)); firstStaff.Elements.AddRange(StaffBuilder .FromPitches(Pitch.C4, Pitch.E4, Pitch.G4, Pitch.C4) .AddRhythm(8, 32, 16, 32) .ApplyStemDirection(VerticalDirection.Up)); firstStaff.Elements.Add(new Barline()); firstStaff.Elements.AddRange(StaffBuilder .FromPitches(Pitch.C4, Pitch.E4) .AddRhythm(8, 32) .ApplyStemDirection(VerticalDirection.Up) .AddDots(2, 0)); firstStaff.Elements.AddRange(StaffBuilder .FromPitches(Pitch.C4, Pitch.E4) .AddRhythm(8, 8) .ApplyStemDirection(VerticalDirection.Up)); firstStaff.Elements.Add(new Barline()); firstStaff.Elements.AddRange(StaffBuilder .FromPitches(Pitch.C4, Pitch.E4, Pitch.G4, Pitch.C4, Pitch.E4) .AddRhythm(32, 32, 32, 32, 8) .ApplyStemDirection(VerticalDirection.Up)); firstStaff.Elements.AddRange(StaffBuilder .FromPitches(Pitch.C4, Pitch.E4, Pitch.G4) .AddRhythm(8, 16, 16) .ApplyStemDirection(VerticalDirection.Up)); firstStaff.Elements.AddRange(StaffBuilder .FromPitches(Pitch.C4, Pitch.E4, Pitch.G4, Pitch.C4) .AddRhythm(8, 16, 32, 32) .ApplyStemDirection(VerticalDirection.Up)); firstStaff.Elements.AddRange(StaffBuilder .FromPitches(Pitch.C4, Pitch.E4) .AddRhythm(8, 16) .ApplyStemDirection(VerticalDirection.Up) .AddDots(1, 0)); firstStaff.Elements.AddRange(StaffBuilder .FromPitches(Pitch.C4, Pitch.E4) .AddRhythm(8, 32) .ApplyStemDirection(VerticalDirection.Up) .AddDots(2, 0)); firstStaff.Elements.AddRange(StaffBuilder .FromPitches(Pitch.C4, Pitch.E4, Pitch.G4) .AddRhythm(32, 16, 8) .ApplyStemDirection(VerticalDirection.Up) .AddDots(0, 1, 0)); firstStaff.Elements.OfType <Note>().FirstOrDefault(n => n.Pitch == Pitch.E4 && n.BaseDuration == RhythmicDuration.D32nd).DesiredHookDirection = DesiredHookDirections.ForwardHook; firstStaff.Elements.OfType <NoteOrRest>().Rebeam(RebeamMode.ToBeats, hookDirectionAlgorithm); /* * firstStaff.Elements.Add(new TimeSignature(TimeSignatureType.Numbers, 3, 4)); * firstStaff.Elements.Add(new Note(Pitch.C4, RhythmicDuration.Half.AddDots(1)) { TieType = NoteTieType.Start }); * firstStaff.Elements.Add(new Barline() { CustomColor = KolbergColors.OsterodeWheat }); * firstStaff.Elements.Add(new Note(Pitch.C4, RhythmicDuration.Half.AddDots(1)) { CustomColor = Color.Red, TieType = NoteTieType.Stop }); * firstStaff.Elements.Add(new Barline()); * firstStaff.Elements.Add(new Note(Pitch.C4, RhythmicDuration.Half.AddDots(1))); * firstStaff.Elements.Add(new Barline(BarlineStyle.LightHeavy)); * * score.FirstStaff.Elements.Add(new Note(Pitch.C5, RhythmicDuration.Sixteenth, VerticalDirection.Up, NoteTieType.None, new List<NoteBeamType>() { NoteBeamType.Start, NoteBeamType.ForwardHook })); * score.FirstStaff.Elements.Add(new Note(Pitch.F4, RhythmicDuration.Eighth, VerticalDirection.Up, NoteTieType.None, new List<NoteBeamType>() { NoteBeamType.Continue })); * score.FirstStaff.Elements.Add(new Note(Pitch.D4, RhythmicDuration.Sixteenth, VerticalDirection.Up, NoteTieType.None, new List<NoteBeamType>() { NoteBeamType.End, NoteBeamType.BackwardHook })); * score.FirstStaff.Elements.Add(new MetronomeDirection(new Tempo(RhythmicDuration.Eighth, 120), DirectionPlacementType.Above)); * * var secondStaff = new Staff(); * score.Staves.Add(secondStaff); * secondStaff.Elements.Add(Clef.Bass); * secondStaff.Elements.Add(new Key(0)); * secondStaff.Elements.Add(new TimeSignature(TimeSignatureType.Numbers, 3, 4)); * secondStaff.Elements.Add(new Note(Pitch.C3, RhythmicDuration.Eighth) { Tuplet = TupletType.Start, TupletWeightOverride = 1 }); * secondStaff.Elements.Add(new Note(Pitch.D3, RhythmicDuration.Sixteenth) { TupletWeightOverride = 0.5 }); * secondStaff.Elements.Add(new Note(Pitch.F3, RhythmicDuration.Sixteenth) { TupletWeightOverride = 0.5}); * secondStaff.Elements.Add(new Note(Pitch.E3, RhythmicDuration.Eighth) { Tuplet = TupletType.Stop, TupletWeightOverride = 1 } ); * secondStaff.Elements.Add(new Barline()); * secondStaff.Elements.Add(new Note(Pitch.C3, RhythmicDuration.Quarter)); * secondStaff.Elements.Add(new Note(Pitch.C3, RhythmicDuration.Quarter)); * secondStaff.Elements.Add(new Note(Pitch.C3, RhythmicDuration.Quarter)); * secondStaff.Elements.Add(new Barline()); * secondStaff.Elements.Add(new Note(Pitch.C3, RhythmicDuration.Half.AddDots(1))); * secondStaff.Elements.Add(new Barline(BarlineStyle.LightHeavy)); */ var secondStaff = new Staff(); score.Staves.Add(secondStaff); secondStaff.Elements.Add(Clef.Bass); secondStaff.Elements.Add(new Key(0)); secondStaff.Elements.Add(new TimeSignature(TimeSignatureType.Numbers, 3, 4)); secondStaff.Elements.Add(new Note(Pitch.C3, RhythmicDuration.Eighth) { Tuplet = TupletType.Start }); secondStaff.Elements.Add(new Note(Pitch.D3, RhythmicDuration.Eighth)); secondStaff.Elements.Add(new Note(Pitch.E3, RhythmicDuration.Eighth) { Tuplet = TupletType.Stop }); secondStaff.Elements.Add(new Barline()); secondStaff.Elements.Add(new Note(Pitch.C3, RhythmicDuration.Quarter)); secondStaff.Elements.Add(new Note(Pitch.C3, RhythmicDuration.Quarter)); secondStaff.Elements.Add(new Note(Pitch.C3, RhythmicDuration.Quarter)); secondStaff.Elements.Add(new Barline()); secondStaff.Elements.Add(new Note(Pitch.C3, RhythmicDuration.Half.AddDots(1))); secondStaff.Elements.Add(new Barline(BarlineStyle.LightHeavy)); var nn = secondStaff.Elements.OfType <Note>().Last(); var timeSignature = secondStaff.Peek <TimeSignature>(nn, Model.PeekStrategies.PeekType.PreviousElement); Data = score; var part = new Part(firstStaff) { PartId = "1" }; part.Staves.Add(secondStaff); score.Parts.Add(part); //part = new Part(secondStaff) { PartId = "2" }; //score.Parts.Add(part); //Z Xamarina: /* * score = Score.CreateOneStaffScore(Clef.Treble, new MajorScale(Step.C, false)); * firstStaff = score.FirstStaff; * firstStaff.Elements.Add(new TimeSignature(TimeSignatureType.Numbers, 3, 4)); * firstStaff.Elements.Add(new Note(Pitch.C4, RhythmicDuration.Half.AddDots(1)) { TieType = NoteTieType.Start }); * firstStaff.Elements.Add(new Barline() { CustomColor = KolbergColors.OsterodeWheat }); * firstStaff.Elements.Add(new Note(Pitch.C4, RhythmicDuration.Half.AddDots(1)) { CustomColor = Color.Red, TieType = NoteTieType.Stop }); * firstStaff.Elements.Add(new Barline()); * firstStaff.Elements.Add(new Note(Pitch.C4, RhythmicDuration.Half.AddDots(1))); * firstStaff.Elements.Add(new Barline(BarlineStyle.LightHeavy)); * * var note = new Note(Pitch.A5, RhythmicDuration.Eighth, VerticalDirection.Up, NoteTieType.None, new List<NoteBeamType>() { NoteBeamType.Start }); * note.Lyrics.Clear(); * note.Lyrics.Add(new Lyrics() { Syllables = new List<Lyrics.Syllable>() { new Lyrics.Syllable(SyllableType.Begin, "xxx") } }); * score.FirstStaff.Elements.Add(note); * score.FirstStaff.Elements.Add(new Note(Pitch.C5, RhythmicDuration.Sixteenth.AddDots(1), VerticalDirection.Up, NoteTieType.None, new List<NoteBeamType>() { NoteBeamType.Continue, NoteBeamType.Start })); * score.FirstStaff.Elements.Add(new Note(Pitch.D4, RhythmicDuration.D32nd, VerticalDirection.Up, NoteTieType.None, new List<NoteBeamType>() { NoteBeamType.End, NoteBeamType.End, NoteBeamType.BackwardHook })); * * secondStaff = new Staff(); * score.Staves.Add(secondStaff); * secondStaff.Elements.Add(Clef.Bass); * secondStaff.Elements.Add(new Key(0)); * secondStaff.Elements.Add(new TimeSignature(TimeSignatureType.Numbers, 3, 4)); * secondStaff.Elements.Add(new Note(Pitch.C3, RhythmicDuration.Eighth) { Tuplet = TupletType.Start }); * secondStaff.Elements.Add(new Note(Pitch.D3, RhythmicDuration.Eighth)); * secondStaff.Elements.Add(new Note(Pitch.E3, RhythmicDuration.Eighth) { Tuplet = TupletType.Stop }); * secondStaff.Elements.Add(new Barline()); * secondStaff.Elements.Add(new Note(Pitch.C3, RhythmicDuration.Quarter)); * secondStaff.Elements.Add(new Note(Pitch.C3, RhythmicDuration.Quarter)); * secondStaff.Elements.Add(new Note(Pitch.C3, RhythmicDuration.Quarter)); * secondStaff.Elements.Add(new Barline()); * secondStaff.Elements.Add(new Note(Pitch.C3, RhythmicDuration.Half.AddDots(1))); * secondStaff.Elements.Add(new Barline(BarlineStyle.LightHeavy)); * * Data = score;*/ }
public static IEnumerable <Note> AddUniformRhythm(this IEnumerable <Pitch> pitches, RhythmicDuration duration) { return(pitches.Select(p => new Note(p, duration)).ToArray()); }
internal Note(string noteStep, int noteAlter, int noteOctave, RhythmicDuration noteDuration, VerticalDirection noteStemDirection, NoteTieType noteTieType, List <NoteBeamType> noteBeamList) : this(new Pitch(noteStep, noteAlter, noteOctave), noteDuration, noteStemDirection, noteTieType, noteBeamList) { }
/// <summary> /// Starts building a Staff with a set of rhythmic durations expressed by numbers (rhythm-first approach) /// </summary> /// <param name="durations"></param> /// <returns></returns> public static IEnumerable <RhythmicDuration> FromRhythm(params int[] durations) { return(RhythmicDuration.Parse(durations)); }
public void LoadTestData() { string xml; var names = GetType().GetTypeInfo().Assembly.GetManifestResourceNames(); using (var reader = new StreamReader(GetType().GetTypeInfo().Assembly.GetManifestResourceStream("Manufaktura.Controls.Xamarin.Test.Assets.005 Bogurodzica [1].xml"))) { xml = reader.ReadToEnd(); } var rd = new RhythmicDuration(2, 0).ToProportion(); rd = new RhythmicDuration(2, 1).ToProportion(); rd = new RhythmicDuration(2, 2).ToProportion(); rd = new RhythmicDuration(2, 3).ToProportion(); var score = Score.CreateOneStaffScore(Clef.Alto, new MajorScale(Step.C, false)); var firstStaff = score.FirstStaff; firstStaff.Elements.Add(new TimeSignature(TimeSignatureType.Numbers, 4, 4)); firstStaff.Elements.AddRange(StaffBuilder .FromPitches(Pitch.C4, Pitch.C4, Pitch.C4, Pitch.C4) .AddRhythm("16. 32 16 16") .ApplyStemDirection(VerticalDirection.Up) .Rebeam()); firstStaff.Elements.AddRange(StaffBuilder .FromPitches(Pitch.C4, Pitch.E4, Pitch.G4, Pitch.C4, Pitch.E4, Pitch.G4, Pitch.C4) .AddRhythm(16, 32, 16, 32, 8, 8, 16) .ApplyStemDirection(VerticalDirection.Up) .AddLyrics("Wlazł ko-tek na pło-tek")); firstStaff.Elements.Add(new MetronomeDirection(Tempo.Allegro, DirectionPlacementType.Above)); firstStaff.Elements.Add(new Barline()); firstStaff.Elements.AddRange(StaffBuilder .FromPitches(Pitch.C4, Pitch.E4) .AddRhythm("8.. 32") .ApplyStemDirection(VerticalDirection.Up) .AddLyrics("i mru-")); firstStaff.Elements.AddRange(StaffBuilder .FromRhythm(8, 8) .AddPitches(Pitch.C4, Pitch.E4) .ApplyStemDirection(VerticalDirection.Up)); firstStaff.Elements.AddRange(StaffBuilder .FromPitches(Pitch.C4, Pitch.E4, Pitch.G4, Pitch.C4, Pitch.E4, Pitch.G4) .AddRhythm(32, 32, 32, 16, 16, 32) .ApplyStemDirection(VerticalDirection.Up)); firstStaff.Elements.AddRange(StaffBuilder .FromPitches(Pitch.C4, Pitch.E4, Pitch.G4, Pitch.C4) .AddRhythm(8, 32, 16, 32) .ApplyStemDirection(VerticalDirection.Up)); firstStaff.Elements.Add(new Barline()); firstStaff.Elements.AddRange(StaffBuilder .FromPitches(Pitch.C4, Pitch.E4) .AddRhythm(8, 32) .ApplyStemDirection(VerticalDirection.Up) .AddDots(2, 0)); firstStaff.Elements.AddRange(StaffBuilder .FromPitches(Pitch.C4, Pitch.E4) .AddRhythm(8, 8) .ApplyStemDirection(VerticalDirection.Up)); firstStaff.Elements.Add(new Barline()); firstStaff.Elements.AddRange(StaffBuilder .FromPitches(Pitch.C4, Pitch.E4, Pitch.G4, Pitch.C4, Pitch.E4) .AddRhythm(32, 32, 32, 32, 8) .ApplyStemDirection(VerticalDirection.Up)); firstStaff.Elements.AddRange(StaffBuilder .FromPitches(Pitch.C4, Pitch.E4, Pitch.G4) .AddRhythm(8, 16, 16) .ApplyStemDirection(VerticalDirection.Up)); firstStaff.Elements.AddRange(StaffBuilder .FromPitches(Pitch.C4, Pitch.E4, Pitch.G4, Pitch.C4) .AddRhythm(8, 16, 32, 32) .ApplyStemDirection(VerticalDirection.Up)); firstStaff.Elements.AddRange(StaffBuilder .FromPitches(Pitch.C4, Pitch.E4) .AddRhythm(8, 16) .ApplyStemDirection(VerticalDirection.Up) .AddDots(1, 0)); firstStaff.Elements.AddRange(StaffBuilder .FromPitches(Pitch.C4, Pitch.E4) .AddRhythm(8, 32) .ApplyStemDirection(VerticalDirection.Up) .AddDots(2, 0)); firstStaff.Elements.AddRange(StaffBuilder .FromPitches(Pitch.C4, Pitch.E4, Pitch.G4) .AddRhythm(32, 16, 8) .ApplyStemDirection(VerticalDirection.Up) .AddDots(0, 1, 0)); firstStaff.Elements.OfType <Note>().FirstOrDefault(n => n.Pitch == Pitch.E4 && n.BaseDuration == RhythmicDuration.D32nd).DesiredHookDirection = DesiredHookDirections.ForwardHook; firstStaff.Elements.OfType <NoteOrRest>().Rebeam(RebeamMode.ToBeats, HookDirectionAlgorithm.ProductionCandidate); var secondStaff = new Staff(); score.Staves.Add(secondStaff); secondStaff.Elements.Add(Clef.Bass); secondStaff.Elements.Add(new Key(0)); secondStaff.Elements.Add(new TimeSignature(TimeSignatureType.Numbers, 3, 4)); secondStaff.Elements.Add(new Note(Pitch.C3, RhythmicDuration.Eighth) { Tuplet = TupletType.Start }); secondStaff.Elements.Add(new Note(Pitch.D3, RhythmicDuration.Eighth)); secondStaff.Elements.Add(new Note(Pitch.E3, RhythmicDuration.Eighth) { Tuplet = TupletType.Stop }); secondStaff.Elements.Add(new Barline()); secondStaff.Elements.Add(new Note(Pitch.C3, RhythmicDuration.Quarter)); secondStaff.Elements.Add(new Note(Pitch.C3, RhythmicDuration.Quarter)); secondStaff.Elements.Add(new Note(Pitch.C3, RhythmicDuration.Quarter)); secondStaff.Elements.Add(new Barline()); secondStaff.Elements.Add(new Note(Pitch.C3, RhythmicDuration.Half.AddDots(1))); secondStaff.Elements.Add(new Barline(BarlineStyle.LightHeavy)); var nn = secondStaff.Elements.OfType <Note>().Last(); var timeSignature = secondStaff.Peek <TimeSignature>(nn, Model.PeekStrategies.PeekType.PreviousElement); Data = score; Data2 = xml.ToScore(); }
public Staff AddNote(Pitch pitch, RhythmicDuration duration) { Elements.Add(new Note(pitch, duration)); return(this); }
/// <summary> /// Creates a new note with specific pitch, duration and stem direction. /// </summary> /// <param name="notePitch">Pitch</param> /// <param name="noteDuration">Duration</param> /// <param name="noteStemDirection">Stem direction</param> public Note(Pitch notePitch, RhythmicDuration noteDuration, VerticalDirection noteStemDirection) : this(notePitch, noteDuration, noteStemDirection, NoteTieType.None, new List <NoteBeamType>() { NoteBeamType.Single }) { }
/// <summary> /// Initializes a new Rest with specific duration /// </summary> /// <param name="restDuration">Duration</param> public Rest(RhythmicDuration restDuration) { Duration = restDuration; DetermineMusicalCharacter(); }
/// <summary> /// Creates a new note with specific pitch and duration. Stem direction can be automatically determined upon adding the note to a staff. /// </summary> /// <param name="notePitch">Pitch</param> /// <param name="noteDuration">Duration</param> /// <param name="determineStemDirectionOnAddingToStaff">If true, stem direction will be automatically determined when note is added to a staff.</param> public Note(Pitch notePitch, RhythmicDuration noteDuration, bool determineStemDirectionOnAddingToStaff = true) : this(notePitch, noteDuration, VerticalDirection.Up, NoteTieType.None, new List <NoteBeamType>() { NoteBeamType.Single }) { SubjectToNoteStemRule = determineStemDirectionOnAddingToStaff; }