Skip to content

Commit

Permalink
Merge pull request #56 from oxygen-dioxide/insider
Browse files Browse the repository at this point in the history
Insider to diffsinger
  • Loading branch information
oxygen-dioxide authored Oct 3, 2023
2 parents e88d5b1 + 0ceb7a0 commit a8f3b03
Show file tree
Hide file tree
Showing 87 changed files with 2,178 additions and 714 deletions.
14 changes: 14 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"name": "openutau-devcontainer",
"image": "mcr.microsoft.com/devcontainers/dotnet:6.0", // Any generic, debian-based image.
"features": {
"ghcr.io/devcontainers/features/desktop-lite:1": {}
},
"customizations": {
"vscode": {
"extensions": [
"ms-dotnettools.csdevkit"
]
}
}
}
2 changes: 2 additions & 0 deletions LICENSE.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,5 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

This license covers both OpenUtau source code and Worldline prebuilt binaries.
2 changes: 2 additions & 0 deletions OpenUtau.Core/Classic/ClassicSinger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ public class ClassicSinger : USinger {
public override byte[] AvatarData => avatarData;
public override string Portrait => voicebank.Portrait == null ? null : Path.Combine(Location, voicebank.Portrait);
public override float PortraitOpacity => voicebank.PortraitOpacity;
public override int PortraitHeight => voicebank.PortraitHeight;
public override string DefaultPhonemizer => voicebank.DefaultPhonemizer;
public override string Sample => voicebank.Sample == null ? null : Path.Combine(Location, voicebank.Sample);
public override Encoding TextFileEncoding => voicebank.TextFileEncoding;
public override IList<USubbank> Subbanks => subbanks;
public override IList<UOto> Otos => otos;
Expand Down
1 change: 1 addition & 0 deletions OpenUtau.Core/Classic/Plugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ public class Plugin : IPlugin {
public bool AllNotes;
public bool UseShell;
private string encoding = "shift_jis";
public string Shortcut;

public string Encoding { get => encoding; set => encoding = value; }

Expand Down
12 changes: 10 additions & 2 deletions OpenUtau.Core/Classic/PluginLoader.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
using System;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using Serilog;

namespace OpenUtau.Classic {
Expand Down Expand Up @@ -30,7 +31,14 @@ private static Plugin ParsePluginTxt(string filePath, Encoding encoding) {
if (s.Length == 2) {
s[0] = s[0].ToLowerInvariant();
if (s[0] == "name") {
plugin.Name = s[1];
Regex reg = new Regex("(.+)\\(&([A-Za-z0-9])\\)");
var match = reg.Match(s[1]);
if (match.Success) {
plugin.Shortcut = match.Groups[2].Value;
plugin.Name = match.Groups[1].Value + " (" + plugin.Shortcut + ")";
} else {
plugin.Name = s[1];
}
} else if (s[0] == "execute") {
string execute = s[1];
if (execute.StartsWith(".\\")) {
Expand Down
4 changes: 2 additions & 2 deletions OpenUtau.Core/Classic/PluginRunner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public class PluginRunner {
private readonly PathManager PathManager;

public static PluginRunner from(PathManager pathManager, DocManager docManager) {
return new PluginRunner(pathManager, ReplaceNoteMethod(docManager), ShowErrorMessageMEthod(docManager));
return new PluginRunner(pathManager, ReplaceNoteMethod(docManager), ShowErrorMessageMethod(docManager));
}

private static Action<ReplaceNoteEventArgs> ReplaceNoteMethod(DocManager docManager) {
Expand All @@ -26,7 +26,7 @@ private static Action<ReplaceNoteEventArgs> ReplaceNoteMethod(DocManager docMana
});
}

private static Action<PluginErrorEventArgs> ShowErrorMessageMEthod(DocManager docManager) {
private static Action<PluginErrorEventArgs> ShowErrorMessageMethod(DocManager docManager) {
return new Action<PluginErrorEventArgs>((args) => {
docManager.ExecuteCmd(new ErrorMessageNotification(args.Message, args.Exception));
});
Expand Down
5 changes: 4 additions & 1 deletion OpenUtau.Core/Classic/Presamp.cs
Original file line number Diff line number Diff line change
Expand Up @@ -662,7 +662,10 @@ public partial class Presamp {
{ "zyi", "じ" },
{ "zyo", "じょ" },
{ "zyu", "じゅ" },
{ "を", "お" } };
{ "を", "お" },
{ "ぢ", "じ" },
{ "づ", "ず" }
};

private readonly static List<string> defNums = new List<string> { "1", "2", "3", "4", "5", "6", "7", "8", "9", "0" };
private readonly static List<string> defAppends = new List<string> {
Expand Down
5 changes: 5 additions & 0 deletions OpenUtau.Core/Classic/VoiceBank.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Collections.Generic;
using System.Drawing;
using System.Text;
using OpenUtau.Core.Ustx;

Expand All @@ -10,10 +11,12 @@ public class Voicebank {
public string Image;
public string Portrait;
public float PortraitOpacity;
public int PortraitHeight;
public string Author;
public string Voice;
public string Web;
public string Version;
public string Sample;
public string OtherInfo;
public string DefaultPhonemizer;
public Encoding TextFileEncoding;
Expand All @@ -27,10 +30,12 @@ public void Reload() {
Image = null;
Portrait = null;
PortraitOpacity = 0;
PortraitHeight = 0;
Author = null;
Voice = null;
Web = null;
Version = null;
Sample = null;
OtherInfo = null;
TextFileEncoding = null;
SingerType = USingerType.Classic;
Expand Down
2 changes: 2 additions & 0 deletions OpenUtau.Core/Classic/VoicebankConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,12 @@ public class VoicebankConfig {
public string Image;
public string Portrait;
public float PortraitOpacity = 0.67f;
public int PortraitHeight = 0;
public string Author;
public string Voice;
public string Web;
public string Version;
public string Sample;
public string DefaultPhonemizer;
public SymbolSet SymbolSet { get; set; }
public Subbank[] Subbanks { get; set; }
Expand Down
6 changes: 3 additions & 3 deletions OpenUtau.Core/Classic/VoicebankInstaller.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public void Install(string path, string singerType) {
AdjustBasePath(archive, path, touches);
int total = archive.Entries.Count();
int count = 0;
bool hasCharacterYaml = archive.Entries.Any(e => e.Key.EndsWith(kCharacterYaml));
bool hasCharacterYaml = archive.Entries.Any(e => Path.GetFileName(e.Key) == kCharacterYaml);
foreach (var entry in archive.Entries) {
progress.Invoke(100.0 * ++count / total, entry.Key);
if (entry.Key.Contains("..")) {
Expand All @@ -54,7 +54,7 @@ public void Install(string path, string singerType) {
Directory.CreateDirectory(Path.GetDirectoryName(filePath));
if (!entry.IsDirectory && entry.Key != kInstallTxt) {
entry.WriteToFile(Path.Combine(basePath, entry.Key), extractionOptions);
if (!hasCharacterYaml && filePath.EndsWith(kCharacterTxt)) {
if (!hasCharacterYaml && Path.GetFileName(filePath) == kCharacterTxt) {
var config = new VoicebankConfig() {
TextFileEncoding = textEncoding.WebName,
SingerType = singerType,
Expand All @@ -63,7 +63,7 @@ public void Install(string path, string singerType) {
config.Save(stream);
}
}
if (hasCharacterYaml && filePath.EndsWith(kCharacterYaml)) {
if (hasCharacterYaml && Path.GetFileName(filePath) == kCharacterYaml) {
VoicebankConfig? config = null;
using (var stream = File.Open(filePath, FileMode.Open)) {
config = VoicebankConfig.Load(stream);
Expand Down
7 changes: 6 additions & 1 deletion OpenUtau.Core/Classic/VoicebankLoader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ public static void ParseCharacterTxt(Voicebank voicebank, Stream stream, string
} else if (s[0].StartsWith("voice") || s[0] == "cv") {
voicebank.Voice = s[1];
} else if (s[0] == "sample") {
voicebank.Sample = s[1];
} else if (s[0] == "web") {
voicebank.Web = s[1];
} else if (s[0] == "version") {
Expand Down Expand Up @@ -194,6 +195,7 @@ public static void ApplyConfig(Voicebank bank, VoicebankConfig bankConfig) {
if (!string.IsNullOrWhiteSpace(bankConfig.Portrait)) {
bank.Portrait = bankConfig.Portrait;
bank.PortraitOpacity = bankConfig.PortraitOpacity;
bank.PortraitHeight = bankConfig.PortraitHeight;
}
if (!string.IsNullOrWhiteSpace(bankConfig.Author)) {
bank.Author = bankConfig.Author;
Expand All @@ -207,6 +209,9 @@ public static void ApplyConfig(Voicebank bank, VoicebankConfig bankConfig) {
if (!string.IsNullOrWhiteSpace(bankConfig.Version)) {
bank.Version = bankConfig.Version;
}
if (!string.IsNullOrWhiteSpace(bankConfig.Sample)) {
bank.Sample = bankConfig.Sample;
}
if (!string.IsNullOrWhiteSpace(bankConfig.DefaultPhonemizer)) {
bank.DefaultPhonemizer = bankConfig.DefaultPhonemizer;
}
Expand Down Expand Up @@ -416,7 +421,7 @@ public static void WriteOtoSets(Voicebank voicebank) {
public static void WriteOtoSet(OtoSet otoSet, Stream stream, Encoding encoding) {
using (var writer = new StreamWriter(stream, encoding)) {
foreach (var oto in otoSet.Otos) {
if (!oto.IsValid) {
if (!oto.IsValid && (oto.FileTrace != null)) {
writer.Write(oto.FileTrace.line);
writer.Write('\n');
continue;
Expand Down
50 changes: 49 additions & 1 deletion OpenUtau.Core/Commands/NoteCommands.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using System;
using System.Collections.Generic;
using System.Linq;

using OpenUtau.Core.Ustx;

namespace OpenUtau.Core {
Expand Down Expand Up @@ -310,6 +309,55 @@ public override void Unexecute() {
}
}

public class VibratoDriftCommand : VibratoCommand {
readonly UNote note;
readonly float newDrift;
readonly float oldDrift;
public VibratoDriftCommand(UVoicePart part, UNote note, float drift) : base(part, note) {
this.note = note;
newDrift = drift;
oldDrift = note.vibrato.drift;
}
public override string ToString() {
return "Change vibrato drift";
}
public override void Execute() {
lock (Part) {
note.vibrato.drift = newDrift;
}
}
public override void Unexecute() {
lock (Part) {
note.vibrato.drift = oldDrift;
}
}
}

public class VibratoVolumeLinkCommand : VibratoCommand {
readonly UNote note;
readonly float newVolLink;
readonly float oldVolLink;
public VibratoVolumeLinkCommand(UVoicePart part, UNote note, float volLink) : base(part, note) {
this.note = note;
newVolLink = volLink;
oldVolLink = note.vibrato.volLink;
}
public override string ToString() {
return "Change vibrato volume link";
}
public override void Execute() {
lock (Part) {
note.vibrato.volLink = newVolLink;
}
}
public override void Unexecute() {
lock (Part) {
note.vibrato.volLink = oldVolLink;
}
}
}


public class PhonemeOffsetCommand : NoteCommand {
readonly UNote note;
readonly int index;
Expand Down
10 changes: 10 additions & 0 deletions OpenUtau.Core/Commands/Notifications.cs
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,16 @@ public SingersRefreshedNotification() { }
public override string ToString() => "Singers refreshed.";
}

public class VoiceColorRemappingNotification : UNotification {
public int TrackNo;
public bool Validate;
public VoiceColorRemappingNotification(int trackNo, bool validate) {
TrackNo = trackNo;
Validate = validate;
}
public override string ToString() => "Voice color remapping.";
}

public class OtoChangedNotification : UNotification {
public readonly bool external;
public OtoChangedNotification(bool external = false) {
Expand Down
27 changes: 27 additions & 0 deletions OpenUtau.Core/Editing/LyricBatchEdits.cs
Original file line number Diff line number Diff line change
Expand Up @@ -170,4 +170,31 @@ protected override string Transform(string lyric) {
}
}
}

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

public InsertSlur() {
name = "pianoroll.menu.lyrics.insertslur";
}

public void Run(UProject project, UVoicePart part, List<UNote> selectedNotes, DocManager docManager) {
if(selectedNotes.Count == 0){
return;
}
var startPos = selectedNotes.First().position;
Queue<string> lyricsQueue = new Queue<string>();
docManager.StartUndoGroup(true);
foreach(var note in part.notes.Where(n => n.position >= startPos)){
lyricsQueue.Enqueue(note.lyric);
if(selectedNotes.Contains(note)){
docManager.ExecuteCmd(new ChangeNoteLyricCommand(part, note, "+~"));
} else {
docManager.ExecuteCmd(new ChangeNoteLyricCommand(part, note, lyricsQueue.Dequeue()));
}
}
docManager.EndUndoGroup();
}
}
}
1 change: 1 addition & 0 deletions OpenUtau.Core/Editing/NoteBatchEdits.cs
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,7 @@ public void Run(UProject project, UVoicePart part, List<UNote> selectedNotes, Do
docManager.ExecuteCmd(new VibratoFadeInCommand(part, note, NotePresets.Default.DefaultVibrato.VibratoIn));
docManager.ExecuteCmd(new VibratoFadeOutCommand(part, note, NotePresets.Default.DefaultVibrato.VibratoOut));
docManager.ExecuteCmd(new VibratoShiftCommand(part, note, NotePresets.Default.DefaultVibrato.VibratoShift));
docManager.ExecuteCmd(new VibratoDriftCommand(part, note, NotePresets.Default.DefaultVibrato.VibratoDrift));
if (NotePresets.Default.AutoVibratoToggle && note.duration >= NotePresets.Default.AutoVibratoNoteDuration) {
docManager.ExecuteCmd(new VibratoLengthCommand(part, note, NotePresets.Default.DefaultVibrato.VibratoLength));
} else {
Expand Down
12 changes: 6 additions & 6 deletions OpenUtau.Core/Enunu/EnunuRenderer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,13 @@ struct AcousticResponse {
public AcousticResult result;
}

struct VocoderResult {
struct SyntheResult {
public string path_wav;
}

struct VocoderResponse {
struct SyntheResponse {
public string error;
public VocoderResult result;
public SyntheResult result;
}

static readonly object lockObj = new object();
Expand Down Expand Up @@ -83,12 +83,12 @@ public Task<RenderResult> Render(RenderPhrase phrase, Progress progress, Cancell
var result = Layout(phrase);
if (!File.Exists(wavPath)) {
var config = EnunuConfig.Load(phrase.singer);
if (config.extensions.wav_synthesizer.Contains("vocoder")) {
Log.Information($"Starting enunu vocoder synthesis \"{ustPath}\"");
if (config.extensions.wav_synthesizer.Contains("synthe")) {
Log.Information($"Starting enunu synthesis \"{ustPath}\"");
var enunuNotes = PhraseToEnunuNotes(phrase);
// TODO: using first note tempo as ust tempo.
EnunuUtils.WriteUst(enunuNotes, phrase.phones.First().tempo, phrase.singer, ustPath);
var response = EnunuClient.Inst.SendRequest<VocoderResponse>(new string[] { "vocoder", ustPath, wavPath });
var response = EnunuClient.Inst.SendRequest<SyntheResponse>(new string[] { "synthe", ustPath, wavPath });
if (response.error != null) {
throw new Exception(response.error);
}
Expand Down
8 changes: 8 additions & 0 deletions OpenUtau.Core/Enunu/EnunuSinger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ public class EnunuSinger : USinger {
public override byte[] AvatarData => avatarData;
public override string Portrait => voicebank.Portrait == null ? null : Path.Combine(Location, voicebank.Portrait);
public override float PortraitOpacity => voicebank.PortraitOpacity;
public override int PortraitHeight => voicebank.PortraitHeight;
public override string Sample => voicebank.Sample == null ? null : Path.Combine(Location, voicebank.Sample);
public override string DefaultPhonemizer => voicebank.DefaultPhonemizer;
public override Encoding TextFileEncoding => voicebank.TextFileEncoding;
public override IList<USubbank> Subbanks => subbanks;
Expand Down Expand Up @@ -189,5 +191,11 @@ public override byte[] LoadPortrait() {
? null
: File.ReadAllBytes(Portrait);
}

public override byte[] LoadSample() {
return string.IsNullOrEmpty(Sample)
? null
: File.ReadAllBytes(Sample);
}
}
}
3 changes: 3 additions & 0 deletions OpenUtau.Core/Format/Wave.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ public static WaveStream OpenFile(string filepath) {
if (tag == "fLaC") {
return new FlacReader(filepath);
}
if (ext == ".aiff" || ext == ".aif" || ext == ".aifc") {
return new AiffFileReader(filepath);
}
throw new Exception("Unsupported audio file format.");
}

Expand Down
Loading

0 comments on commit a8f3b03

Please sign in to comment.