Skip to content

Commit

Permalink
Merge branch 'stakira:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
oxygen-dioxide authored Nov 15, 2023
2 parents 284575a + 01f1728 commit 36208fd
Show file tree
Hide file tree
Showing 44 changed files with 11,074 additions and 493 deletions.
4 changes: 2 additions & 2 deletions OpenUtau.Core/Classic/ClassicRenderer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public Task<RenderResult> RenderInternal(RenderPhrase phrase, Progress progress,
VoicebankFiles.Inst.CopyBackMetaFiles(item.inputFile, item.inputTemp);
}
}
progress.Complete(1, $"Track {trackNo}: {item.resampler} \"{item.phone.phoneme}\"");
progress.Complete(1, $"Track {trackNo + 1}: {item.resampler} \"{item.phone.phoneme}\"");
});
var result = Layout(phrase);
var wavtool = new SharpWavtool(true);
Expand All @@ -97,7 +97,7 @@ public Task<RenderResult> RenderExternal(RenderPhrase phrase, Progress progress,
resamplerItems.Add(new ResamplerItem(phrase, phone));
}
var task = Task.Run(() => {
string progressInfo = $"Track {trackNo} : {phrase.wavtool} \"{string.Join(" ", phrase.phones.Select(p => p.phoneme))}\"";
string progressInfo = $"Track {trackNo + 1} : {phrase.wavtool} \"{string.Join(" ", phrase.phones.Select(p => p.phoneme))}\"";
progress.Complete(0, progressInfo);
var wavPath = Path.Join(PathManager.Inst.CachePath, $"cat-{phrase.hash:x16}.wav");
var result = Layout(phrase);
Expand Down
3 changes: 3 additions & 0 deletions OpenUtau.Core/Classic/Ust.cs
Original file line number Diff line number Diff line change
Expand Up @@ -341,9 +341,12 @@ public static List<UNote> WritePlugin(UProject project, UVoicePart part, UNote f
var note = first;
while (note != last.Next) {
if (note.position < position) {
//Ignore current note if it is overlapped with previous note
note = note.Next;
continue;
}
if (note.position > position) {
//Insert R note if there is space between two notes
writer.WriteLine($"[#{sequence.Count:D4}]");
var spacer = UNote.Create();
spacer.position = position;
Expand Down
2 changes: 1 addition & 1 deletion OpenUtau.Core/Classic/WorldlineRenderer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public Task<RenderResult> Render(RenderPhrase phrase, Progress progress, int tra
var task = Task.Run(() => {
var result = Layout(phrase);
var wavPath = Path.Join(PathManager.Inst.CachePath, $"wdl-{phrase.hash:x16}.wav");
string progressInfo = $"Track {trackNo}: {this} {string.Join(" ", phrase.phones.Select(p => p.phoneme))}";
string progressInfo = $"Track {trackNo + 1}: {this} {string.Join(" ", phrase.phones.Select(p => p.phoneme))}";
progress.Complete(0, progressInfo);
if (File.Exists(wavPath)) {
try {
Expand Down
7 changes: 7 additions & 0 deletions OpenUtau.Core/Commands/Notifications.cs
Original file line number Diff line number Diff line change
Expand Up @@ -201,4 +201,11 @@ public GotoOtoNotification(USinger singer, UOto oto) {
}
public override string ToString() => "Goto oto.";
}

public class NotePresetChangedNotification : UNotification {
public NotePresetChangedNotification() {

}
public override string ToString() => "Note preset changed.";
}
}
2 changes: 1 addition & 1 deletion OpenUtau.Core/DiffSinger/DiffSingerRenderer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ public Task<RenderResult> Render(RenderPhrase phrase, Progress progress, int tra
? $"ds-{phrase.hash:x16}-depth{depth}-{speedup}x.wav" // if the depth changes, phrase should be re-rendered
: $"ds-{phrase.hash:x16}-{speedup}x.wav"; // preserve this for not invalidating cache from older versions
var wavPath = Path.Join(PathManager.Inst.CachePath, wavName);
string progressInfo = $"{this}{speedup}x \"{string.Join(" ", phrase.phones.Select(p => p.phoneme))}\"";
string progressInfo = $"Track {trackNo + 1}: {this}{speedup}x \"{string.Join(" ", phrase.phones.Select(p => p.phoneme))}\"";
if (File.Exists(wavPath)) {
try {
using (var waveStream = Wave.OpenFile(wavPath)) {
Expand Down
2 changes: 1 addition & 1 deletion OpenUtau.Core/DocManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ public void SearchAllPlugins() {

public bool ChangesSaved {
get {
return (Project.Saved || Project.tracks.Count == 0) &&
return (Project.Saved || (Project.tracks.Count <= 1 && Project.parts.Count == 0)) &&
(undoQueue.Count > 0 && savedPoint == undoQueue.Last() || undoQueue.Count == 0 && savedPoint == null);
}
}
Expand Down
40 changes: 40 additions & 0 deletions OpenUtau.Core/Editing/NoteBatchEdits.cs
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,46 @@ public void Run(UProject project, UVoicePart part, List<UNote> selectedNotes, Do
}
}

public class FixOverlap: BatchEdit {
/// <summary>
/// Fix overlapping notes.
/// If multiple notes start at the same time, only the one with the highest tone will be kept
/// If one notes's end is overlapped by another note, the end will be moved to the start of the next note
/// </summary>
public virtual string Name => name;

private string name;

public FixOverlap() {
name = $"pianoroll.menu.notes.fixoverlap";
}

public void Run(UProject project, UVoicePart part, List<UNote> selectedNotes, DocManager docManager) {
var notes = selectedNotes.Count > 0 ? selectedNotes : part.notes.ToList();
if(notes.Count == 0){
return;
}
docManager.StartUndoGroup();
var currentNote = notes[0];
foreach(var note in notes.Skip(1)){
if(note.position == currentNote.position){
if(note.tone > currentNote.tone){
docManager.ExecuteCmd(new RemoveNoteCommand(part, currentNote));
currentNote = note;
}else{
docManager.ExecuteCmd(new RemoveNoteCommand(part, note));
}
}else if(note.position < currentNote.End){
docManager.ExecuteCmd(new ResizeNoteCommand(part, currentNote, note.position - currentNote.End));
currentNote = note;
}else{
currentNote = note;
}
}
docManager.EndUndoGroup();
}
}

public class HanziToPinyin : BatchEdit {
public virtual string Name => name;

Expand Down
2 changes: 1 addition & 1 deletion OpenUtau.Core/Enunu/EnunuRenderer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public Task<RenderResult> Render(RenderPhrase phrase, Progress progress, int tra
if (cancellation.IsCancellationRequested) {
return new RenderResult();
}
string progressInfo = $"Track {trackNo}: {this} \"{string.Join(" ", phrase.phones.Select(p => p.phoneme))}\"";
string progressInfo = $"Track {trackNo + 1}: {this} \"{string.Join(" ", phrase.phones.Select(p => p.phoneme))}\"";
progress.Complete(0, progressInfo);
var tmpPath = Path.Join(PathManager.Inst.CachePath, $"enu-{phrase.preEffectHash:x16}");
var ustPath = tmpPath + ".tmp";
Expand Down
2 changes: 1 addition & 1 deletion OpenUtau.Core/Vogen/VogenRenderer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public Task<RenderResult> Render(RenderPhrase phrase, Progress progress, int tra
}
var result = Layout(phrase);
var wavPath = Path.Join(PathManager.Inst.CachePath, $"vog-{phrase.hash:x16}.wav");
string progressInfo = $"Track {trackNo}: {this} \"{string.Join(" ", phrase.phones.Select(p => p.phoneme))}\"";
string progressInfo = $"Track {trackNo + 1}: {this} \"{string.Join(" ", phrase.phones.Select(p => p.phoneme))}\"";
progress.Complete(0, progressInfo);
if (File.Exists(wavPath)) {
try {
Expand Down
11 changes: 8 additions & 3 deletions OpenUtau.Plugin.Builtin/ChineseCVVCPhonemizer.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
Expand Down Expand Up @@ -44,11 +44,16 @@ public override Result Process(Note[] notes, Note? prev, Note? next, Note? prevN
vcLen = Math.Min(120, vcLen * 2); // explosive consonant with short preutter.
}
}
if (singer.TryGetMappedOto($"{prevVowel} {consonant}", notes[0].tone + attr0.toneShift, attr0.voiceColor, out oto)) {
var vcPhoneme = $"{prevVowel} {consonant}";
if (singer.TryGetMappedOto(vcPhoneme, prevNeighbour.Value.tone + attr0.toneShift, attr0.voiceColor, out oto)) {
vcPhoneme = oto.Alias;
}

if (singer.TryGetMappedOto(vcPhoneme, prevNeighbour.Value.tone + attr0.toneShift, attr0.voiceColor, out oto)) {
return new Result {
phonemes = new Phoneme[] {
new Phoneme() {
phoneme = oto.Alias,
phoneme = vcPhoneme,
position = -vcLen,
},
new Phoneme() {
Expand Down
6 changes: 2 additions & 4 deletions OpenUtau.Plugin.Builtin/JapaneseCVVCPhonemizer.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.Linq;
using OpenUtau.Api;
Expand Down Expand Up @@ -131,11 +131,9 @@ private bool checkOtoUntilHit(string[] input, Note note, out UOto oto) {

// checking VCs
// when VC does not exist, it will not be inserted
// TODO: fix duplicate voice color fallback bug (for now, this is better than nothing)
private bool checkOtoUntilHitVc(string[] input, Note note, out UOto oto) {
oto = default;
var attr = note.phonemeAttributes?.FirstOrDefault(attr => attr.index == 0) ?? default;
var attr1 = note.phonemeAttributes?.FirstOrDefault(attr => attr.index == 1) ?? default;
var attr = note.phonemeAttributes?.FirstOrDefault(attr => attr.index == 1) ?? default;

var otos = new List<UOto>();
foreach (string test in input) {
Expand Down
3 changes: 1 addition & 2 deletions OpenUtau.Plugin.Builtin/JapanesePresampPhonemizer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -334,10 +334,9 @@ private bool checkOtoUntilHit(List<string> input, Note note, out UOto oto) {

// checking VCs
// when VC does not exist, it will not be inserted
// TODO: fix duplicate voice color fallback bug (for now, this is better than nothing)
private bool checkOtoUntilHitVc(List<string> input, Note note, out UOto oto) {
oto = default;
var attr = note.phonemeAttributes?.FirstOrDefault(attr => attr.index == 0) ?? default;
var attr = note.phonemeAttributes?.FirstOrDefault(attr => attr.index == 1) ?? default;

var otos = new List<UOto>();
foreach (string test in input) {
Expand Down
63 changes: 49 additions & 14 deletions OpenUtau.Plugin.Builtin/KoreanVCVPhonemizer.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
Expand Down Expand Up @@ -115,26 +115,34 @@ public string GetLastSoundOfAlias(string lyric)

// Store singer
public override void SetSinger(USinger singer) => this.singer = singer;

// Legacy mapping. Might adjust later to new mapping style.
public override bool LegacyMapping => true;

public override Result Process(Note[] notes, Note? prev, Note? next, Note? prevNeighbour, Note? nextNeighbour, Note[] prevNeighbours)
{
Note note = notes[0];
string color = string.Empty;
int shift = 0;
int? alt;

PhonemeAttributes attr = note.phonemeAttributes.FirstOrDefault(a => a.index == 0);
string color1 = string.Empty;
int shift1 = 0;
int? alt1;

PhonemeAttributes attr = note.phonemeAttributes.FirstOrDefault(a => a.index == 0);
color = attr.voiceColor;
shift = attr.toneShift;
alt = attr.alternate;

PhonemeAttributes attr1 = note.phonemeAttributes.FirstOrDefault(a => a.index == 1);
color1 = attr1.voiceColor;
shift1 = attr1.toneShift;
alt1 = attr1.alternate;

string[] currIMF;
string currPhoneme;
string[] prevIMF;

// Check if lyric is R, - or an end breath and return appropriate Result; otherwise, move to next steps
if (note.lyric == "R" || note.lyric == "-" || note.lyric == "H" || note.lyric == "B" || note.lyric == "bre")
if (note.lyric == "R" || note.lyric == "R2" || note.lyric == "-" || note.lyric == "H" || note.lyric == "B" || note.lyric == "bre")
{
currPhoneme = note.lyric;

Expand Down Expand Up @@ -169,8 +177,15 @@ public override Result Process(Note[] notes, Note? prev, Note? next, Note? prevN
if (string.IsNullOrEmpty(prevIMF[2])) currPhoneme = $"{((prevIMF[1][0] == 'w' || prevIMF[1][0] == 'y' || prevIMF[1] == "oi") ? prevIMF[1].Remove(0, 1) : ((prevIMF[1] == "eui" || prevIMF[1] == "ui") ? "i" : prevIMF[1]))} {currPhoneme}";
else currPhoneme = $"{(!singer.TryGetMappedOto($"{prevIMF[2]} {currPhoneme}", note.tone, color, out _) ? prevIMF[2].ToUpper() : prevIMF[2])} {currPhoneme}";
}

return new Result {

// Map alias (apply shift + color)
if (singer.TryGetMappedOto(currPhoneme + alt, note.tone + shift, color, out var otoAlt)) {
currPhoneme = otoAlt.Alias;
} else if (singer.TryGetMappedOto(currPhoneme, note.tone + shift, color, out var oto)) {
currPhoneme = oto.Alias;
}

return new Result {
phonemes = new Phoneme[] {
new Phoneme { phoneme = currPhoneme }
}
Expand Down Expand Up @@ -209,7 +224,7 @@ public override Result Process(Note[] notes, Note? prev, Note? next, Note? prevN
if (prevNeighbour != null && prevNeighbour?.lyric != "bre" && singer.TryGetMappedOto(prevNeighbour?.lyric, note.tone + shift, color, out _)) currPhoneme = $"{GetLastSoundOfAlias(prevNeighbour?.lyric)} {currPhoneme}";
else
{
if (prevNeighbour == null || prevNeighbour?.lyric == "R" || prevNeighbour?.lyric == "-" || prevNeighbour?.lyric == "H" || prevNeighbour?.lyric == "B" || prevNeighbour?.lyric == "bre") currPhoneme = $"- {currPhoneme}";
if (prevNeighbour == null || prevNeighbour?.lyric == "R" || prevNeighbour?.lyric == "R2" || prevNeighbour?.lyric == "-" || prevNeighbour?.lyric == "H" || prevNeighbour?.lyric == "B" || prevNeighbour?.lyric == "bre") currPhoneme = $"- {currPhoneme}";
else
{
if (string.IsNullOrEmpty(prevNeighbour?.phoneticHint))
Expand Down Expand Up @@ -251,7 +266,14 @@ public override Result Process(Note[] notes, Note? prev, Note? next, Note? prevN
// Return Result now if note has no batchim
if (string.IsNullOrEmpty(currIMF[2]))
{
return new Result
// Map alias (apply shift + color)
if (singer.TryGetMappedOto(currPhoneme + alt, note.tone + shift, color, out var otoAlt)) {
currPhoneme = otoAlt.Alias;
} else if (singer.TryGetMappedOto(currPhoneme, note.tone + shift, color, out var oto)) {
currPhoneme = oto.Alias;
}

return new Result
{
phonemes = new Phoneme[] {
new Phoneme { phoneme = currPhoneme }
Expand All @@ -269,13 +291,13 @@ public override Result Process(Note[] notes, Note? prev, Note? next, Note? prevN
if (string.IsNullOrEmpty(currIMF[2])) secondPhoneme += " R";
else
{
if (singer.TryGetMappedOto($"{secondPhoneme} {currIMF[2]}", note.tone + shift, color, out _)) secondPhoneme += $" {currIMF[2]}";
if (singer.TryGetMappedOto($"{secondPhoneme} {currIMF[2]}", note.tone + shift1, color1, out _)) secondPhoneme += $" {currIMF[2]}";
else secondPhoneme += $" {currIMF[2].ToUpper()}";
}
}
else if (!string.IsNullOrEmpty(currIMF[2]))
{
if (singer.TryGetMappedOto($"{secondPhoneme} {currIMF[2]}", note.tone + shift, color, out _)) secondPhoneme += $" {currIMF[2]}";
if (singer.TryGetMappedOto($"{secondPhoneme} {currIMF[2]}", note.tone + shift1, color1, out _)) secondPhoneme += $" {currIMF[2]}";
else secondPhoneme += $" {currIMF[2].ToUpper()}";
}

Expand All @@ -284,8 +306,21 @@ public override Result Process(Note[] notes, Note? prev, Note? next, Note? prevN

int secondPosition = Math.Max(noteLength - (nextNeighbour == null ? 120 : 180), noteLength / 2);

// Return Result
return new Result
// Map alias (apply shift + color)
if (singer.TryGetMappedOto(currPhoneme + alt, note.tone + shift, color, out var otoAlt)) {
currPhoneme = otoAlt.Alias;
} else if (singer.TryGetMappedOto(currPhoneme, note.tone + shift, color, out var oto)) {
currPhoneme = oto.Alias;
}

if (singer.TryGetMappedOto(secondPhoneme + alt1, note.tone + shift1, color1, out var otoAlt1)) {
secondPhoneme = otoAlt1.Alias;
} else if (singer.TryGetMappedOto(secondPhoneme, note.tone + shift1, color1, out var oto)) {
secondPhoneme = oto.Alias;
}

// Return Result
return new Result
{
phonemes = new Phoneme[] {
new Phoneme { phoneme = currPhoneme },
Expand Down
Loading

0 comments on commit 36208fd

Please sign in to comment.