void ParseBrokenRhythm() { if (voice == null || voice.items.Count == 0) { throw new ParseException($"Illegal broken Rhythm marker at {lineNum}, {index}"); } char symbol = currentLine[index]; brokenRhythm = symbol == '>' ? BrokenRhythm.DotHalf : BrokenRhythm.HalfDot; ReadUntil((char ch) => { return(ch != symbol); }, out string brokenRhythmStr); brokenRhythmCount = brokenRhythmStr.Length; }
void UpdateBrokenRhythm() { if (brokenRhythm == BrokenRhythm.None) { return; } if (voice.items.Count < 2) { throw new ParseException($"Unable to apply broken rhythm to item near {lineNum}, {index}"); } var itemA = voice.items[voice.items.Count - 2] as Duration; var itemB = voice.items[voice.items.Count - 1] as Duration; if (itemA == null || itemB == null) { throw new ParseException($"Unable to apply broken rhythm to item near {lineNum}, {index}"); } Duration halfItem, dotItem; if (brokenRhythm == BrokenRhythm.DotHalf) { dotItem = itemA; halfItem = itemB; } else { dotItem = itemB; halfItem = itemA; } dotItem.dotCount = brokenRhythmCount; var duration = ParserUtil.lengthDurations[halfItem.length] * (1.0f / (1 << brokenRhythmCount)); ParserUtil.ParseDuration(duration, out Length l, out int dots); halfItem.length = l; halfItem.dotCount = dots; brokenRhythm = BrokenRhythm.None; }