diff --git a/OpenUtau.Core/DiffSinger/DiffSingerPitch.cs b/OpenUtau.Core/DiffSinger/DiffSingerPitch.cs index 7cbec606d..22177a696 100644 --- a/OpenUtau.Core/DiffSinger/DiffSingerPitch.cs +++ b/OpenUtau.Core/DiffSinger/DiffSingerPitch.cs @@ -162,21 +162,13 @@ public RenderPitchResult Process(RenderPhrase phrase){ .Prepend((float)phrase.notes[0].tone) .ToArray(); //get the index of groups of consecutive rest notes - int restGroupStart = 0; - var restGroups = new List>{}; - foreach(int noteIndex in Enumerable.Range(1,note_rest.Count - 1)) { - if(!note_rest[noteIndex-1] && note_rest[noteIndex]) { - //start a new rest group - restGroupStart = noteIndex; - } - if(note_rest[noteIndex-1] && !note_rest[noteIndex]) { - //end the current rest group - restGroups.Add(new Tuple(restGroupStart,noteIndex)); - } - } - if(!note_rest[^1]) { - //end the last rest group - restGroups.Add(new Tuple(restGroupStart,note_rest.Count)); + var restGroups = new List>(); + for (var i = 0; i < note_rest.Count; ++i) { + if (!note_rest[i]) continue; + var j = i + 1; + for (; j < note_rest.Count && note_rest[j]; ++j) { } + restGroups.Add(new Tuple(i, j)); + i = j; } //Set tone for each rest group foreach(var restGroup in restGroups){