Skip to content

Commit

Permalink
Fix wrong logic to get rest note groups
Browse files Browse the repository at this point in the history
  • Loading branch information
yqzhishen committed Oct 21, 2023
1 parent 4def4ca commit 495e012
Showing 1 changed file with 7 additions and 15 deletions.
22 changes: 7 additions & 15 deletions OpenUtau.Core/DiffSinger/DiffSingerPitch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Tuple<int,int>>{};
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<int,int>(restGroupStart,noteIndex));
}
}
if(!note_rest[^1]) {
//end the last rest group
restGroups.Add(new Tuple<int,int>(restGroupStart,note_rest.Count));
var restGroups = new List<Tuple<int,int>>();
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<int, int>(i, j));
i = j;
}
//Set tone for each rest group
foreach(var restGroup in restGroups){
Expand Down

0 comments on commit 495e012

Please sign in to comment.