From 678704cf0f9f5cc3598057629b6d4a0fe7d16cb2 Mon Sep 17 00:00:00 2001 From: Sugita Akira Date: Thu, 8 Oct 2020 20:38:06 -0700 Subject: [PATCH] Cleanup some unnecessary UI. --- .editorconfig | 1 + OpenUtau/App.config | 2 +- OpenUtau/App.xaml.cs | 5 +- OpenUtau/Classic/Character.cs | 74 ++++++ OpenUtau/Classic/Oto.cs | 46 ++++ OpenUtau/Classic/VoiceBank.cs | 91 +++++++ OpenUtau/Classic/VoicebankInstaller.cs | 35 +++ OpenUtau/Core/Formats/Ust.cs | 289 ++++++++++++---------- OpenUtau/Core/Util/UpdateChecker.cs | 33 --- OpenUtau/OpenUtau.csproj | 22 +- OpenUtau/Properties/Resources.Designer.cs | 2 +- OpenUtau/Properties/Settings.Designer.cs | 2 +- OpenUtau/UI/MainWindow.xaml | 17 -- OpenUtau/UI/MainWindow.xaml.cs | 29 +-- OpenUtau/UI/Strings.xaml | 2 - OpenUtau/UI/Strings.zh-CN.xaml | 2 - OpenUtau/packages.config | 10 +- 17 files changed, 426 insertions(+), 236 deletions(-) create mode 100644 OpenUtau/Classic/Character.cs create mode 100644 OpenUtau/Classic/Oto.cs create mode 100644 OpenUtau/Classic/VoiceBank.cs create mode 100644 OpenUtau/Classic/VoicebankInstaller.cs delete mode 100644 OpenUtau/Core/Util/UpdateChecker.cs diff --git a/.editorconfig b/.editorconfig index d582e365c..a219353e4 100644 --- a/.editorconfig +++ b/.editorconfig @@ -10,6 +10,7 @@ indent_style = space indent_size = 4 insert_final_newline = true charset = utf-8-bom +guidelines = 100 ############################### # .NET Coding Conventions # ############################### diff --git a/OpenUtau/App.config b/OpenUtau/App.config index 113baeee3..6eb6c18ca 100644 --- a/OpenUtau/App.config +++ b/OpenUtau/App.config @@ -3,6 +3,6 @@ - + diff --git a/OpenUtau/App.xaml.cs b/OpenUtau/App.xaml.cs index 4c35122e7..9b52e1a0e 100644 --- a/OpenUtau/App.xaml.cs +++ b/OpenUtau/App.xaml.cs @@ -1,5 +1,4 @@ using System; -using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.Linq; @@ -46,6 +45,10 @@ private static void Main() { NBug.Settings.StoragePath = NBug.Enums.StoragePath.CurrentDirectory; NBug.Settings.UIMode = NBug.Enums.UIMode.Full; + var characters = Classic.Character.SearchAndLoadCharacters(Core.Util.Preferences.GetSingerSearchPaths()); + + Classic.VoicebankInstaller.IndexAllArchive(Core.Util.Preferences.GetSingerSearchPaths()); + Core.DocManager.Inst.SearchAllSingers(); var pm = new Core.PartManager(); diff --git a/OpenUtau/Classic/Character.cs b/OpenUtau/Classic/Character.cs new file mode 100644 index 000000000..8efd70bea --- /dev/null +++ b/OpenUtau/Classic/Character.cs @@ -0,0 +1,74 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Text; +using OpenUtau.SimpleHelpers; +using Serilog; + +namespace OpenUtau.Classic { + + /// + /// A character. May contains multiple voice banks. + /// + public class Character { + + private Character() { + } + + public string Name { private set; get; } + public string DisplayName => Loaded ? Name : $"{Name}[Unloaded]"; + public string BasePath { private set; get; } + public string CharacterFile { private set; get; } + public string Author { private set; get; } + public string Website { private set; get; } + public string Language { private set; get; } + public List Voicebanks { private set; get; } + public bool Loaded { private set; get; } + + public static List SearchAndLoadCharacters(List searchPaths) { + const string CharacterFileName = "character.txt"; + var characterFiles = new HashSet(); + foreach (var searchPath in searchPaths) { + if (!Directory.Exists(searchPath)) { + continue; + } + var files = Directory.GetFiles(searchPath, CharacterFileName, + SearchOption.AllDirectories); + foreach (var file in files) { + characterFiles.Add(file); + } + } + var result = new List(); + foreach (var file in characterFiles) { + var character = new Character { + BasePath = Path.GetDirectoryName(file), + CharacterFile = file, + }; + character.LoadVoicebanks(); + result.Add(character); + } + return result; + } + + public void LoadVoicebanks() { + const string OtoFileName = "oto.ini"; + var otoFiles = Directory.GetFiles(BasePath, OtoFileName, SearchOption.AllDirectories); + var voicebanks = new List(); + foreach (var otoFile in otoFiles) { + try { + var voicebank = new Voicebank.Builder(otoFile) + .SetOtoEncoding(FileEncoding.DetectFileEncoding( + otoFile, Encoding.GetEncoding("shift_jis"))) + .SetPathEncoding(Encoding.Default) + .Build(); + voicebanks.Add(voicebank); + } catch (Exception e) { + Log.Error(e, "Failed to load {0}", otoFile); + } + } + Log.Information("Loaded {0} voicebanks from character {1}", voicebanks.Count, BasePath); + Voicebanks = voicebanks; + Loaded = true; + } + } +} diff --git a/OpenUtau/Classic/Oto.cs b/OpenUtau/Classic/Oto.cs new file mode 100644 index 000000000..84adc7cb0 --- /dev/null +++ b/OpenUtau/Classic/Oto.cs @@ -0,0 +1,46 @@ +using System.Linq; + +namespace OpenUtau.Classic { + + /// + /// A sound in a voice bank. Corresponds to one line in oto.ini file. + /// + public class Oto { + public string AudioFile; + public string Alias; + public int Offset; + public int Consonant; + public int Cutoff; + public int Preutter; + public int Overlap; + + public static Oto Parse(string line) { + if (!line.Contains('=')) { + return null; + } + var parts = line.Split('='); + if (parts.Length != 2) { + return null; + } + var audioClip = parts[0].Trim(); + parts = parts[1].Split(','); + if (parts.Length != 6) { + return null; + } + var result = new Oto { + AudioFile = audioClip, + Alias = parts[0].Trim() + }; + int.TryParse(parts[1], out result.Offset); + int.TryParse(parts[2], out result.Consonant); + int.TryParse(parts[3], out result.Cutoff); + int.TryParse(parts[4], out result.Preutter); + int.TryParse(parts[5], out result.Overlap); + return result; + } + + public override string ToString() { + return Alias; + } + } +} diff --git a/OpenUtau/Classic/VoiceBank.cs b/OpenUtau/Classic/VoiceBank.cs new file mode 100644 index 000000000..c4476b353 --- /dev/null +++ b/OpenUtau/Classic/VoiceBank.cs @@ -0,0 +1,91 @@ +using System.Collections.Generic; +using System.IO; +using System.Text; +using Serilog; + +namespace OpenUtau.Classic { + + /// + /// A sound bank. Corresponds to a single oto.ini file. + /// + public class Voicebank { + + private Voicebank() { + } + + public string BasePath { private set; get; } + public string OtoFile { private set; get; } + public List OtoList { private set; get; } + public Encoding OtoEncoding { private set; get; } + public Encoding PathEncoding { private set; get; } + + public class Builder { + private readonly Voicebank voicebank; + private readonly byte[] otoBytes; + private int audioFilesFound; + + public Builder(string otoFile) { + otoBytes = File.ReadAllBytes(otoFile); + voicebank = new Voicebank() { + OtoFile = otoFile, + BasePath = Path.GetDirectoryName(otoFile), + PathEncoding = Encoding.Default, + }; + } + + public string TestOtoEncoding(Encoding encoding) { + return encoding.GetString(otoBytes); + } + + public Builder SetOtoEncoding(Encoding encoding) { + voicebank.OtoEncoding = encoding; + var lines = new List(); + using (var stream = new StreamReader(new MemoryStream(otoBytes), encoding)) { + while (!stream.EndOfStream) { + lines.Add(stream.ReadLine()); + } + } + var otoList = new List(); + foreach (var line in lines) { + var oto = Oto.Parse(line); + if (oto != null) { + otoList.Add(oto); + } + } + voicebank.OtoList = otoList; + return this; + } + + public double TestPathEncoding(Encoding encoding) { + if (voicebank.OtoList == null) { + return 0; + } + if (voicebank.OtoList.Count == 0) { + return 1; + } + audioFilesFound = 0; + foreach (var oto in voicebank.OtoList) { + try { + var file = encoding.GetString(voicebank.OtoEncoding.GetBytes(oto.AudioFile)); + if (File.Exists(Path.Combine(voicebank.BasePath, file))) { + audioFilesFound++; + } + } catch { } + } + return (double)audioFilesFound / voicebank.OtoList.Count; + } + + public Builder SetPathEncoding(Encoding encoding) { + voicebank.PathEncoding = encoding; + return this; + } + + public Voicebank Build() { + var score = TestPathEncoding(voicebank.PathEncoding); + Log.Information("Loaded {0} otos and {1:F2}% audio files from {2}", + voicebank.OtoList.Count, score * 100, voicebank.OtoFile); + return voicebank; + } + } + } +} diff --git a/OpenUtau/Classic/VoicebankInstaller.cs b/OpenUtau/Classic/VoicebankInstaller.cs new file mode 100644 index 000000000..1eaa4c1bf --- /dev/null +++ b/OpenUtau/Classic/VoicebankInstaller.cs @@ -0,0 +1,35 @@ +using System.Collections.Generic; +using System.IO; +using System.IO.Compression; +using System.Text; +using Serilog; + +namespace OpenUtau.Classic { + + internal class VoicebankInstaller { + + public static void IndexAllArchive(IEnumerable searchPaths) { + foreach (var path in searchPaths) { + if (Directory.Exists(path)) { + var zips = Directory.GetFiles(path, "*.zip", SearchOption.AllDirectories); + foreach (var zip in zips) { + Log.Information($"{zip}"); + IndexArchive(zip); + } + } + } + } + + public static void IndexArchive(string path) { + using (var stream = new FileStream(path, FileMode.Open)) { + using (var archive = new ZipArchive(stream, ZipArchiveMode.Read, false, Encoding.GetEncoding("shift_jis"))) { + foreach (var entry in archive.Entries) { + if (entry.Name == "character.txt" || entry.Name == "oto.ini") { + Log.Information($"{entry.Name} {entry.FullName}"); + } + } + } + } + } + } +} diff --git a/OpenUtau/Core/Formats/Ust.cs b/OpenUtau/Core/Formats/Ust.cs index 1a54f9088..d411e283b 100644 --- a/OpenUtau/Core/Formats/Ust.cs +++ b/OpenUtau/Core/Formats/Ust.cs @@ -1,47 +1,41 @@ using System; using System.Collections.Generic; +using System.IO; using System.Linq; using System.Text; -using System.IO; - using OpenUtau.Core.USTx; using OpenUtau.SimpleHelpers; -namespace OpenUtau.Core.Formats -{ - public static class Ust - { - private enum UstVersion { Early, V1_0, V1_1, V1_2, Unknown }; - private enum UstBlock { Version, Setting, Note, Trackend, None }; +namespace OpenUtau.Core.Formats { + public static class Ust { private const string versionTag = "[#VERSION]"; private const string settingTag = "[#SETTING]"; private const string endTag = "[#TRACKEND]"; - static public void Load(string[] files) - { - bool ustTracks = true; - foreach (string file in files) - { - if (OpenUtau.Core.Formats.Formats.DetectProjectFormat(file) != Core.Formats.ProjectFormats.Ust) { ustTracks = false; break; } + private enum UstVersion { Early, V1_0, V1_1, V1_2, Unknown }; + + private enum UstBlock { Version, Setting, Note, Trackend, None }; + + public static void Load(string[] files) { + var ustTracks = true; + foreach (var file in files) { + if (Formats.DetectProjectFormat(file) != Core.Formats.ProjectFormats.Ust) { ustTracks = false; break; } } - if (!ustTracks) - { + if (!ustTracks) { DocManager.Inst.ExecuteCmd(new UserMessageNotification("Multiple files must be all Ust files")); return; } - List projects = new List(); - foreach (string file in files) - { + var projects = new List(); + foreach (var file in files) { projects.Add(Load(file)); } - double bpm = projects.First().BPM; - UProject project = new UProject() { BPM = bpm, Name = "Merged Project", Saved = false }; - foreach (UProject p in projects) - { + var bpm = projects.First().BPM; + var project = new UProject() { BPM = bpm, Name = "Merged Project", Saved = false }; + foreach (var p in projects) { var _track = p.Tracks[0]; var _part = p.Parts[0]; _track.TrackNo = project.Tracks.Count; @@ -50,32 +44,33 @@ static public void Load(string[] files) project.Parts.Add(_part); } - if (project != null) DocManager.Inst.ExecuteCmd(new LoadProjectNotification(project)); + if (project != null) { + DocManager.Inst.ExecuteCmd(new LoadProjectNotification(project)); + } } - static public UProject Load(string file, Encoding encoding = null) - { - int currentNoteIndex = 0; - UstVersion version = UstVersion.Early; - UstBlock currentBlock = UstBlock.None; + public static UProject Load(string file, Encoding encoding = null) { + var currentNoteIndex = 0; + var version = UstVersion.Early; + var currentBlock = UstBlock.None; string[] lines; - try - { - if (encoding == null) lines = File.ReadAllLines(file, FileEncoding.DetectFileEncoding(file)); - else lines = File.ReadAllLines(file, encoding); - } - catch (Exception e) - { + try { + if (encoding == null) { + lines = File.ReadAllLines(file, FileEncoding.DetectFileEncoding(file)); + } else { + lines = File.ReadAllLines(file, encoding); + } + } catch (Exception e) { DocManager.Inst.ExecuteCmd(new UserMessageNotification(e.GetType().ToString() + "\n" + e.Message)); return null; } - UProject project = new UProject() { Resolution = 480, FilePath = file, Saved = false }; - project.RegisterExpression(new IntExpression(null, "velocity","VEL") { Data = 100, Min = 0, Max = 200}); - project.RegisterExpression(new IntExpression(null, "volume","VOL") { Data = 100, Min = 0, Max = 200}); - project.RegisterExpression(new IntExpression(null, "gender","GEN") { Data = 0, Min = -100, Max = 100}); - project.RegisterExpression(new IntExpression(null, "lowpass","LPF") { Data = 0, Min = 0, Max = 100}); + var project = new UProject() { Resolution = 480, FilePath = file, Saved = false }; + project.RegisterExpression(new IntExpression(null, "velocity", "VEL") { Data = 100, Min = 0, Max = 200 }); + project.RegisterExpression(new IntExpression(null, "volume", "VOL") { Data = 100, Min = 0, Max = 200 }); + project.RegisterExpression(new IntExpression(null, "gender", "GEN") { Data = 0, Min = -100, Max = 100 }); + project.RegisterExpression(new IntExpression(null, "lowpass", "LPF") { Data = 0, Min = 0, Max = 100 }); project.RegisterExpression(new IntExpression(null, "highpass", "HPF") { Data = 0, Min = 0, Max = 100 }); project.RegisterExpression(new IntExpression(null, "accent", "ACC") { Data = 100, Min = 0, Max = 200 }); project.RegisterExpression(new IntExpression(null, "decay", "DEC") { Data = 0, Min = 0, Max = 100 }); @@ -83,166 +78,189 @@ static public UProject Load(string file, Encoding encoding = null) var _track = new UTrack(); project.Tracks.Add(_track); _track.TrackNo = 0; - UVoicePart part = new UVoicePart() { TrackNo = 0, PosTick = 0 }; + var part = new UVoicePart() { TrackNo = 0, PosTick = 0 }; project.Parts.Add(part); - List currentLines = new List(); - int currentTick = 0; + var currentLines = new List(); + var currentTick = 0; UNote currentNote = null; - foreach (string line in lines) - { - if (line.Trim().StartsWith(@"[#") && line.Trim().EndsWith(@"]")) - { - if (line.Equals(versionTag)) currentBlock = UstBlock.Version; - else if (line.Equals(settingTag)) currentBlock = UstBlock.Setting; - else - { - if (line.Equals(endTag)) currentBlock = UstBlock.Trackend; - else - { - try { currentNoteIndex = int.Parse(line.Replace("[#", string.Empty).Replace("]", string.Empty)); } - catch { DocManager.Inst.ExecuteCmd(new UserMessageNotification("Unknown ust format")); return null; } + foreach (var line in lines) { + if (line.Trim().StartsWith(@"[#") && line.Trim().EndsWith(@"]")) { + if (line.Equals(versionTag)) { + currentBlock = UstBlock.Version; + } else if (line.Equals(settingTag)) { + currentBlock = UstBlock.Setting; + } else { + if (line.Equals(endTag)) { + currentBlock = UstBlock.Trackend; + } else { + try { currentNoteIndex = int.Parse(line.Replace("[#", string.Empty).Replace("]", string.Empty)); } catch { DocManager.Inst.ExecuteCmd(new UserMessageNotification("Unknown ust format")); return null; } currentBlock = UstBlock.Note; } - if (currentLines.Count != 0) - { + if (currentLines.Count != 0) { currentNote = NoteFromUst(project.CreateNote(), currentLines, version); currentNote.PosTick = currentTick; - if (!currentNote.Lyric.Replace("R", string.Empty).Replace("r", string.Empty).Equals(string.Empty)) part.Notes.Add(currentNote); + if (!currentNote.Lyric.Replace("R", string.Empty).Replace("r", string.Empty).Equals(string.Empty)) { + part.Notes.Add(currentNote); + } + currentTick += currentNote.DurTick; currentLines.Clear(); } } - } - else - { + } else { if (currentBlock == UstBlock.Version) { - if (line.StartsWith("UST Version")) - { - string v = line.Trim().Replace("UST Version", string.Empty); - switch (v) - { + if (line.StartsWith("UST Version")) { + var v = line.Trim().Replace("UST Version", string.Empty); + switch (v) { case "1.0": version = UstVersion.V1_0; break; + case "1.1": version = UstVersion.V1_1; break; + case "1.2": version = UstVersion.V1_2; break; + default: version = UstVersion.Unknown; break; } } } - if (currentBlock == UstBlock.Setting) - { - if (line.StartsWith("Tempo=")) - { + if (currentBlock == UstBlock.Setting) { + if (line.StartsWith("Tempo=")) { project.BPM = double.Parse(line.Trim().Replace("Tempo=", string.Empty)); - if (project.BPM == 0) project.BPM = 120; + if (project.BPM == 0) { + project.BPM = 120; + } + } + if (line.StartsWith("ProjectName=")) { + project.Name = line.Trim().Replace("ProjectName=", string.Empty); } - if (line.StartsWith("ProjectName=")) project.Name = line.Trim().Replace("ProjectName=", string.Empty); - if (line.StartsWith("VoiceDir=")) - { - string singerpath = line.Trim().Replace("VoiceDir=", string.Empty); + + if (line.StartsWith("VoiceDir=")) { + var singerpath = line.Trim().Replace("VoiceDir=", string.Empty); var singer = UtauSoundbank.GetSinger(singerpath, FileEncoding.DetectFileEncoding(file), DocManager.Inst.Singers); - if (singer == null) singer = new USinger() { Name = "", Path = singerpath }; + if (singer == null) { + singer = new USinger() { Name = "", Path = singerpath }; + } + project.Singers.Add(singer); project.Tracks[0].Singer = singer; } - } - else if (currentBlock == UstBlock.Note) - { + } else if (currentBlock == UstBlock.Note) { currentLines.Add(line); - } - else if (currentBlock == UstBlock.Trackend) - { + } else if (currentBlock == UstBlock.Trackend) { break; } } } - if (currentBlock != UstBlock.Trackend) + if (currentBlock != UstBlock.Trackend) { DocManager.Inst.ExecuteCmd(new UserMessageNotification("Unexpected ust file end")); + } + part.DurTick = currentTick; return project; } - static UNote NoteFromUst(UNote note, List lines, UstVersion version) - { + private static UNote NoteFromUst(UNote note, List lines, UstVersion version) { string pbs = "", pbw = "", pby = "", pbm = ""; - foreach (string line in lines) - { - if (line.StartsWith("Lyric=")) - { + foreach (var line in lines) { + if (line.StartsWith("Lyric=")) { note.Phonemes[0].Phoneme = note.Lyric = line.Trim().Replace("Lyric=", string.Empty); - if (note.Phonemes[0].Phoneme.StartsWith("?")) - { + if (note.Phonemes[0].Phoneme.StartsWith("?")) { note.Phonemes[0].Phoneme = note.Phonemes[0].Phoneme.Substring(1); note.Phonemes[0].AutoRemapped = false; } } - if (line.StartsWith("Length=")) note.DurTick = int.Parse(line.Trim().Replace("Length=", string.Empty)); - if (line.StartsWith("NoteNum=")) note.NoteNum = int.Parse(line.Trim().Replace("NoteNum=", string.Empty)); - if (line.StartsWith("Velocity=")) note.Expressions["velocity"].Data = int.Parse(line.Trim().Replace("Velocity=", string.Empty)); - if (line.StartsWith("Intensity=")) note.Expressions["volume"].Data = int.Parse(line.Trim().Replace("Intensity=", string.Empty)); - if (line.StartsWith("PreUtterance=")) - { - if (line.Trim() == "PreUtterance=") note.Phonemes[0].AutoEnvelope = true; - else { note.Phonemes[0].AutoEnvelope = false; note.Phonemes[0].Preutter = double.Parse(line.Trim().Replace("PreUtterance=", "")); } + if (line.StartsWith("Length=")) { + note.DurTick = int.Parse(line.Trim().Replace("Length=", string.Empty)); + } + + if (line.StartsWith("NoteNum=")) { + note.NoteNum = int.Parse(line.Trim().Replace("NoteNum=", string.Empty)); } - if (line.StartsWith("VoiceOverlap=")) note.Phonemes[0].Overlap = double.Parse(line.Trim().Replace("VoiceOverlap=", string.Empty)); - if (line.StartsWith("Envelope=")) - { + + if (line.StartsWith("Velocity=")) { + note.Expressions["velocity"].Data = int.Parse(line.Trim().Replace("Velocity=", string.Empty)); + } + + if (line.StartsWith("Intensity=")) { + note.Expressions["volume"].Data = int.Parse(line.Trim().Replace("Intensity=", string.Empty)); + } + + if (line.StartsWith("PreUtterance=")) { + if (line.Trim() == "PreUtterance=") { + note.Phonemes[0].AutoEnvelope = true; + } else { note.Phonemes[0].AutoEnvelope = false; note.Phonemes[0].Preutter = double.Parse(line.Trim().Replace("PreUtterance=", "")); } + } + if (line.StartsWith("VoiceOverlap=")) { + note.Phonemes[0].Overlap = double.Parse(line.Trim().Replace("VoiceOverlap=", string.Empty)); + } + + if (line.StartsWith("Envelope=")) { var pts = line.Trim().Replace("Envelope=", string.Empty).Split(new[] { ',' }); - if (pts.Count() > 5) note.Expressions["decay"].Data = 100 - (int)double.Parse(pts[5]); + if (pts.Count() > 5) { + note.Expressions["decay"].Data = 100 - (int)double.Parse(pts[5]); + } + } + if (line.StartsWith("VBR=")) { + VibratoFromUst(note.Vibrato, line.Trim().Replace("VBR=", string.Empty)); + } + + if (line.StartsWith("PBS=")) { + pbs = line.Trim().Replace("PBS=", string.Empty); + } + + if (line.StartsWith("PBW=")) { + pbw = line.Trim().Replace("PBW=", string.Empty); + } + + if (line.StartsWith("PBY=")) { + pby = line.Trim().Replace("PBY=", string.Empty); + } + + if (line.StartsWith("PBM=")) { + pbm = line.Trim().Replace("PBM=", string.Empty); } - if (line.StartsWith("VBR=")) VibratoFromUst(note.Vibrato, line.Trim().Replace("VBR=", string.Empty)); - if (line.StartsWith("PBS=")) pbs = line.Trim().Replace("PBS=", string.Empty); - if (line.StartsWith("PBW=")) pbw = line.Trim().Replace("PBW=", string.Empty); - if (line.StartsWith("PBY=")) pby = line.Trim().Replace("PBY=", string.Empty); - if (line.StartsWith("PBM=")) pbm = line.Trim().Replace("PBM=", string.Empty); } - if (pbs != string.Empty) - { + if (pbs != string.Empty) { var pts = note.PitchBend.Data as List; pts.Clear(); // PBS - if (pbs.Contains(';')) - { + if (pbs.Contains(';')) { pts.Add(new PitchPoint(double.Parse(pbs.Split(new[] { ';' })[0]), double.Parse(pbs.Split(new[] { ';' })[1]))); - note.PitchBend.SnapFirst = false; - } - else - { + note.PitchBend.SnapFirst = false; + } else { pts.Add(new PitchPoint(double.Parse(pbs), 0)); note.PitchBend.SnapFirst = true; } - double x = pts.First().X; - if (pbw != string.Empty) - { - string[] w = pbw.Split(new[] { ',' }); + var x = pts.First().X; + if (pbw != string.Empty) { + var w = pbw.Split(new[] { ',' }); string[] y = null; - if (w.Count() > 1) y = pby.Split(new[] { ',' }); - for (int i = 0; i < w.Count() - 1; i++) - { + if (w.Count() > 1) { + y = pby.Split(new[] { ',' }); + } + + for (var i = 0; i < w.Count() - 1; i++) { x += string.IsNullOrEmpty(w[i]) ? 0 : float.Parse(w[i]); pts.Add(new PitchPoint(x, string.IsNullOrEmpty(y[i]) ? 0 : double.Parse(y[i]))); } pts.Add(new PitchPoint(x + double.Parse(w[w.Count() - 1]), 0)); } - if (pbm != string.Empty) - { - string[] m = pbw.Split(new[] { ',' }); - for (int i = 0; i < m.Count() - 1; i++) - { + if (pbm != string.Empty) { + var m = pbw.Split(new[] { ',' }); + for (var i = 0; i < m.Count() - 1; i++) { pts[i].Shape = m[i] == "r" ? PitchPointShape.o : m[i] == "s" ? PitchPointShape.l : m[i] == "j" ? PitchPointShape.i : PitchPointShape.io; @@ -252,11 +270,9 @@ static UNote NoteFromUst(UNote note, List lines, UstVersion version) return note; } - static void VibratoFromUst(VibratoExpression vibrato, string ust) - { + private static void VibratoFromUst(VibratoExpression vibrato, string ust) { var args = ust.Split(new[] { ',' }).Select(double.Parse).ToList(); - if (args.Count() >= 7) - { + if (args.Count() >= 7) { vibrato.Length = args[0]; vibrato.Period = args[1]; vibrato.Depth = args[2]; @@ -267,9 +283,8 @@ static void VibratoFromUst(VibratoExpression vibrato, string ust) } } - static String VibratoToUst(VibratoExpression vibrato) - { - List args = new List() + private static string VibratoToUst(VibratoExpression vibrato) { + var args = new List() { vibrato.Length, vibrato.Period, diff --git a/OpenUtau/Core/Util/UpdateChecker.cs b/OpenUtau/Core/Util/UpdateChecker.cs deleted file mode 100644 index f724d4b0c..000000000 --- a/OpenUtau/Core/Util/UpdateChecker.cs +++ /dev/null @@ -1,33 +0,0 @@ -using System; -using System.Diagnostics; -using System.Net; -using System.Reflection; -using Newtonsoft.Json; -using Newtonsoft.Json.Linq; - -namespace OpenUtau.Core { - - internal static class UpdateChecker { - private const string VersionUrl = "https://ci.appveyor.com/api/projects/stakira/openutau"; - - public static bool Check() { - try { - using (var client = new WebClient()) { - var result = client.DownloadString(VersionUrl); - var dict = JsonConvert.DeserializeObject(result); - var lastest = new Version(dict["build"]["version"].ToString()); - var info = FileVersionInfo.GetVersionInfo(Assembly.GetExecutingAssembly().Location); - var current = new Version(info.ProductVersion); - Console.WriteLine("current version {0}, latest version {1}", current, lastest); - return current.CompareTo(lastest) < 0; - } - } catch { - return false; - } - } - - public static string GetVersion() { - return FileVersionInfo.GetVersionInfo(Assembly.GetExecutingAssembly().Location).ProductVersion; - } - } -} diff --git a/OpenUtau/OpenUtau.csproj b/OpenUtau/OpenUtau.csproj index ad514a941..e9343da74 100644 --- a/OpenUtau/OpenUtau.csproj +++ b/OpenUtau/OpenUtau.csproj @@ -9,7 +9,7 @@ Properties OpenUtau OpenUtau - v4.6.2 + v4.8 512 {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} 4 @@ -55,27 +55,28 @@ ..\packages\Blend.Interctivity.WPF.v4.0.1.0.3\lib\net40\Microsoft.Expression.Interactions.dll - - ..\packages\NAudio.1.8.5\lib\net35\NAudio.dll + + ..\packages\NAudio.1.10.0\lib\net35\NAudio.dll ..\packages\NBug.1.2.2\lib\net40-client\NBug.dll - ..\packages\Newtonsoft.Json.12.0.1\lib\net45\Newtonsoft.Json.dll + ..\packages\Newtonsoft.Json.12.0.3\lib\net45\Newtonsoft.Json.dll - ..\packages\Serilog.2.8.0\lib\net46\Serilog.dll + ..\packages\Serilog.2.10.0\lib\net46\Serilog.dll ..\packages\Serilog.Sinks.Console.3.1.1\lib\net45\Serilog.Sinks.Console.dll - ..\packages\Serilog.Sinks.File.4.0.0\lib\net45\Serilog.Sinks.File.dll + ..\packages\Serilog.Sinks.File.4.1.0\lib\net45\Serilog.Sinks.File.dll + @@ -95,14 +96,17 @@ - - ..\packages\WriteableBitmapEx.1.6.2\lib\net40\WriteableBitmapEx.Wpf.dll + + ..\packages\WriteableBitmapEx.1.6.7\lib\net40\WriteableBitmapEx.Wpf.dll ..\packages\xxHashSharp.1.0.0\lib\net45\xxHashSharp.dll + + + @@ -141,13 +145,13 @@ - ExpComboBox.xaml + MSBuild:Compile Designer diff --git a/OpenUtau/Properties/Resources.Designer.cs b/OpenUtau/Properties/Resources.Designer.cs index 375f5a4eb..b2cb14fcd 100644 --- a/OpenUtau/Properties/Resources.Designer.cs +++ b/OpenUtau/Properties/Resources.Designer.cs @@ -19,7 +19,7 @@ namespace OpenUtau.Properties { // class via a tool like ResGen or Visual Studio. // To add or remove a member, edit your .ResX file then rerun ResGen // with the /str option, or rebuild your VS project. - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "15.0.0.0")] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] internal class Resources { diff --git a/OpenUtau/Properties/Settings.Designer.cs b/OpenUtau/Properties/Settings.Designer.cs index c9455f546..98eee5988 100644 --- a/OpenUtau/Properties/Settings.Designer.cs +++ b/OpenUtau/Properties/Settings.Designer.cs @@ -12,7 +12,7 @@ namespace OpenUtau.Properties { [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "15.8.0.0")] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "16.7.0.0")] internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); diff --git a/OpenUtau/UI/MainWindow.xaml b/OpenUtau/UI/MainWindow.xaml index 31262ee93..1f4c988d5 100644 --- a/OpenUtau/UI/MainWindow.xaml +++ b/OpenUtau/UI/MainWindow.xaml @@ -20,14 +20,6 @@ - - - - - - - - @@ -39,15 +31,6 @@ - - - - - - - - - diff --git a/OpenUtau/UI/MainWindow.xaml.cs b/OpenUtau/UI/MainWindow.xaml.cs index 1b4de1ff4..33869fb51 100644 --- a/OpenUtau/UI/MainWindow.xaml.cs +++ b/OpenUtau/UI/MainWindow.xaml.cs @@ -1,20 +1,10 @@ using System; -using System.Collections.Generic; using System.Linq; -using System.Text; -using System.Threading.Tasks; using System.Windows; using System.Windows.Controls; -using System.Windows.Data; -using System.Windows.Documents; using System.Windows.Input; using System.Windows.Media; -using System.Windows.Media.Imaging; using System.Windows.Shapes; -using System.Windows.Shell; - -using WinInterop = System.Windows.Interop; -using System.Runtime.InteropServices; using Microsoft.Win32; using OpenUtau.UI.Models; @@ -22,8 +12,7 @@ using OpenUtau.Core; using OpenUtau.Core.USTx; -namespace OpenUtau.UI -{ +namespace OpenUtau.UI { /// /// Interaction logic for MainWindow.xaml /// @@ -61,18 +50,6 @@ public MainWindow() trackVM.Subscribe(DocManager.Inst); CmdNewFile(); - - if (UpdateChecker.Check()) { - var menuItem = new MenuItem() { - Header = (string)FindResource("menu.updateavail"), - Foreground = ThemeManager.WhiteKeyNameBrushNormal, - }; - menuItem.Click += (sender, e) => { - System.Diagnostics.Process.Start("https://github.com/stakira/OpenUtau"); - }; - - mainMenu.Items.Add(menuItem); - } } void RenderLoop(object sender, EventArgs e) @@ -404,8 +381,6 @@ private void trackCanvas_MouseRightButtonUp(object sender, MouseButtonEventArgs private void MenuOpen_Click(object sender, RoutedEventArgs e) { CmdOpenFileDialog(); } private void MenuSave_Click(object sender, RoutedEventArgs e) { CmdSaveFile(); } private void MenuExit_Click(object sender, RoutedEventArgs e) { CmdExit(); } - private void MenuUndo_Click(object sender, RoutedEventArgs e) { DocManager.Inst.Undo(); } - private void MenuRedo_Click(object sender, RoutedEventArgs e) { DocManager.Inst.Redo(); } private void MenuImportAudio_Click(object sender, RoutedEventArgs e) { @@ -459,7 +434,7 @@ private void MenuRenderAll_Click(object sender, RoutedEventArgs e) private void MenuAbout_Click(object sender, RoutedEventArgs e) { MessageBox.Show( (string)FindResource("dialogs.about.message"), - (string)FindResource("dialogs.about.caption") + " " + UpdateChecker.GetVersion(), + (string)FindResource("dialogs.about.caption"), MessageBoxButton.OK, MessageBoxImage.None); } diff --git a/OpenUtau/UI/Strings.xaml b/OpenUtau/UI/Strings.xaml index bb68d9ab7..2a5ed7d1d 100644 --- a/OpenUtau/UI/Strings.xaml +++ b/OpenUtau/UI/Strings.xaml @@ -32,8 +32,6 @@ _Help About OpenUTAU - Update Available - Preferences General diff --git a/OpenUtau/UI/Strings.zh-CN.xaml b/OpenUtau/UI/Strings.zh-CN.xaml index 8f9fa800b..183faf1db 100644 --- a/OpenUtau/UI/Strings.zh-CN.xaml +++ b/OpenUtau/UI/Strings.zh-CN.xaml @@ -32,8 +32,6 @@ 帮助 关于 OpenUTAU - 有更新 - 使用偏好 通用 diff --git a/OpenUtau/packages.config b/OpenUtau/packages.config index e452c3975..e9181f7d1 100644 --- a/OpenUtau/packages.config +++ b/OpenUtau/packages.config @@ -2,13 +2,13 @@ - + - - + + - + - + \ No newline at end of file