Skip to content

Commit

Permalink
Fix VEL stretch minimum to 5 for extra short consonants
Browse files Browse the repository at this point in the history
  • Loading branch information
lottev1991 committed Oct 14, 2023
1 parent 298b303 commit 3dfea0d
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions KoreanCVVCPlusPhonemizer/KoreanCVVCPlusPhonemizer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -741,9 +741,8 @@ public override Result Process(Note[] notes, Note? prev, Note? next, Note? prevN
}

var nextAttr = nextNeighbour.Value.phonemeAttributes?.FirstOrDefault(attr => attr.index == 0) ?? default;
// Minimam is 30 tick, maximum is half of note

ccLength = Convert.ToInt32(Math.Min(totalDuration / 2, Math.Max(30, ccLength * (nextAttr.consonantStretchRatio ?? 1))));
// Minimum is 5 tick, maximum is half of note
ccLength = Convert.ToInt32(Math.Min(totalDuration / 2, Math.Max(5, ccLength * (nextAttr.consonantStretchRatio ?? 1))));

if (singer.TryGetMappedOto(CV, note.tone + attr0.toneShift, attr0.voiceColor, out var oto1) && singer.TryGetMappedOto(FC, note.tone + attr0.toneShift, attr0.voiceColor, out var oto2) && singer.TryGetMappedOto(CC, note.tone + attr0.toneShift, attr0.voiceColor, out var oto3)) {
CV = oto1.Alias;
Expand Down Expand Up @@ -782,8 +781,8 @@ public override Result Process(Note[] notes, Note? prev, Note? next, Note? prevN
}

var nextAttr = nextNeighbour.Value.phonemeAttributes?.FirstOrDefault(attr => attr.index == 0) ?? default;
// Minimam is 30 tick, maximum is half of note
ccLength = Convert.ToInt32(Math.Min(totalDuration / 2, Math.Max(30, ccLength * (nextAttr.consonantStretchRatio ?? 1))));
// Minimum is 5 tick, maximum is half of note
ccLength = Convert.ToInt32(Math.Min(totalDuration / 2, Math.Max(5, ccLength * (nextAttr.consonantStretchRatio ?? 1))));

if (singer.TryGetMappedOto(CV, note.tone + attr0.toneShift, attr0.voiceColor, out var oto1) && singer.TryGetMappedOto(FC, note.tone + attr0.toneShift, attr0.voiceColor, out var oto2) && singer.TryGetMappedOto(CC, note.tone + attr0.toneShift, attr0.voiceColor, out var oto3)) {
CV = oto1.Alias;
Expand Down Expand Up @@ -861,7 +860,7 @@ public override Result Process(Note[] notes, Note? prev, Note? next, Note? prevN

var nextAttr = nextNeighbour.Value.phonemeAttributes?.FirstOrDefault(attr => attr.index == 0) ?? default;
// Minimam is 30 tick, maximum is half of note
vcLength = Convert.ToInt32(Math.Min(totalDuration / 2, Math.Max(30, vcLength * (nextAttr.consonantStretchRatio ?? 1))));
vcLength = Convert.ToInt32(Math.Min(totalDuration / 2, Math.Max(5, vcLength * (nextAttr.consonantStretchRatio ?? 1))));

if (singer.TryGetMappedOto(CV, note.tone + attr0.toneShift, attr0.voiceColor, out var oto1) && singer.TryGetMappedOto(VC, note.tone + attr0.toneShift, attr0.voiceColor, out var oto2)) {
CV = oto1.Alias;
Expand Down Expand Up @@ -892,8 +891,8 @@ public override Result Process(Note[] notes, Note? prev, Note? next, Note? prevN
}

var nextAttr = nextNeighbour.Value.phonemeAttributes?.FirstOrDefault(attr => attr.index == 0) ?? default;
// Minimam is 30 tick, maximum is half of note
vcLength = Convert.ToInt32(Math.Min(totalDuration / 2, Math.Max(30, vcLength * (nextAttr.consonantStretchRatio ?? 1))));
// Minimum is 5 tick, maximum is half of note
vcLength = Convert.ToInt32(Math.Min(totalDuration / 2, Math.Max(5, vcLength * (nextAttr.consonantStretchRatio ?? 1))));

if (singer.TryGetMappedOto(CV, note.tone + attr0.toneShift, attr0.voiceColor, out var oto1) && singer.TryGetMappedOto(VC, note.tone + attr0.toneShift, attr0.voiceColor, out var oto2)) {
CV = oto1.Alias;
Expand Down Expand Up @@ -1153,8 +1152,8 @@ public override Result Process(Note[] notes, Note? prev, Note? next, Note? prevN
vcLength = MsToTick(oto0.Preutter);
}
}
// Minimam is 30 tick, maximum is half of note
vcLength = Convert.ToInt32(Math.Min(totalDuration / 2, Math.Max(30, vcLength * (nextAttr.consonantStretchRatio ?? 1))));
// Minimum is 5 tick, maximum is half of note
vcLength = Convert.ToInt32(Math.Min(totalDuration / 2, Math.Max(5, vcLength * (nextAttr.consonantStretchRatio ?? 1))));

return new Result {
phonemes = new Phoneme[] {
Expand Down

0 comments on commit 3dfea0d

Please sign in to comment.