private void DiscoverBeamGroups(Staff staff) { staff.BeamGroups.Clear(); BeamGroup beamGroup = null; foreach (var nr in staff.Elements.OfType <NoteOrRest>()) { var note = nr as Note; if (note != null && note.BeamList.Any()) { if (note.BeamList.First() == NoteBeamType.Start) { beamGroup = new BeamGroup(staff); beamGroup.Start = note.StemEndLocation; staff.BeamGroups.Add(beamGroup); } if (beamGroup != null) { beamGroup.Members.Add(nr); } if (note.BeamList.First() == NoteBeamType.End) { beamGroup.End = note.StemEndLocation; beamGroup = null; } } } }
private void DiscoverBeamGroups(Staff staff, ScoreRendererBase renderer) { staff.BeamGroups.Clear(); BeamGroup beamGroup = null; foreach (var nr in staff.Elements.OfType <NoteOrRest>()) { var note = nr as Note; if (note != null && note.BeamList.Any()) { if (note.BeamList.Count == 1 && note.BeamList[0] == NoteBeamType.Single) { continue; //Problem with beams in chords } if (note.BeamList.First() == NoteBeamType.Start) { beamGroup = new BeamGroup(staff); beamGroup.Start = note.StemEndLocation; staff.BeamGroups.Add(beamGroup); } if (beamGroup != null) { beamGroup.Members.Add(nr); } if (note.BeamList.First() == NoteBeamType.End) { if (beamGroup == null) { renderer.Exceptions.Add(new ScoreException(note, $"Encountered beam group end without corresponding beam group start.")); } else { beamGroup.End = note.StemEndLocation; beamGroup = null; } } } } }