Skip to content

Commit

Permalink
Merge pull request #895 from yqzhishen/fix-rest-group
Browse files Browse the repository at this point in the history
[DiffSinger] Fix note pitch masked unexpectedly when applying nearest interpolation
  • Loading branch information
stakira authored Oct 22, 2023
2 parents 13058df + 495e012 commit 96f2cf6
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 96f2cf6

Please sign in to comment.