public Oto Substract(Oto oto) { foreach (var pitch in Pitches) { if (oto.Alias.Contains(pitch)) { oto.Pitch = pitch; oto.Alias = oto.Alias.Replace(pitch, ""); return(oto); } } return(oto); }
public static Oto CreateDefault() { var oto = new Oto() { Preutterance = 100, Overlap = 50, Cutoff = -300, Consonant = 150, Offset = 100, File = "" }; return(oto); }
public void Load() { Otos = new List <Oto> { }; foreach (string sub in Subs) { string filename = Path.Combine(Dir, sub, "oto.ini"); if (File.Exists(filename)) { string[] lines = File.ReadAllLines(filename, Encoding.GetEncoding(932)); foreach (string line in lines) { string pattern = "(.*)=(.*),(.*),(.*),(.*),(.*),(.*)"; var arr = Regex.Split(line, pattern); double temp; if (arr.Length == 1) { continue; } Oto Oto = new Oto() { File = Path.Combine(sub, arr[1]), Alias = arr[2], Offset = double.TryParse(arr[3], out temp) ? temp : 0, Consonant = double.TryParse(arr[4], out temp) ? temp : 0, Cutoff = double.TryParse(arr[5], out temp) ? temp : 0, Preutterance = double.TryParse(arr[6], out temp) ? temp : 0, Overlap = double.TryParse(arr[7], out temp) ? temp : 0, }; Oto = Pitchmap.Substract(Oto); Otos.Add(Oto); } } else { File.Create(filename); } } IsLoaded = true; LengthByOto = true; }
public void AtlasConverting(AtlasSettings settings) { //int i = Ust.Notes.First().Number == Number.PREV ? 1 : 0; int i = 1; /// Всегда нужна первая нота, но будут нюансы со вставкой //int stop = Ust.Notes.Last().Number == Number.NEXT ? 1 : 0; int stop = 0; for (; i < Ust.Notes.Length - stop; i++) { string lyric = Ust.Notes[i].ParsedLyric; string lyricPrev = Ust.Notes[i - 1].ParsedLyric; string aliasType = ""; string aliasTypePrev = ""; bool tookAliases = false; try { aliasType = Atlas.GetAliasType(lyric); aliasTypePrev = Atlas.GetAliasType(lyricPrev); tookAliases = true; } catch (KeyNotFoundException ex) { Errors.Log(ex.Message); } if (!tookAliases) { i++; continue; } if (lyricPrev == "b'e" && lyric == "po") { Console.WriteLine(); } VAtlas.Rule rule = Atlas.RuleManager.GetRule($"{aliasTypePrev},{aliasType}"); if (rule == null) { Ust.Notes[i].SetParsedLyric(Atlas, lyric); continue; } if (rule.MustConvert && Ust.Notes[i].Number != NumberManager.NEXT) { RuleResult result = Atlas.GetRuleResult(rule.FormatConvert, lyricPrev, lyric); Ust.Notes[i].SetParsedLyric(Atlas, result.Alias); if (Ust.Notes[i].Parent != null) { Oto oto = Singer.Current.FindOto(Ust.Notes[i].ParsedLyric); if (oto != null) { int ilength = MusicMath.MillisecondToTick(oto.InnerLength, Ust.Tempo); Ust.Notes[i].Length += ilength; Ust.Notes[i].Parent.Length -= ilength; } } } else { Ust.Notes[i].SetParsedLyric(Atlas, lyric); } Console.WriteLine(Ust.Notes[i].ParsedLyric); if (rule.MustInsert) { var next = Ust.GetNextNote(Ust.Notes[i]); bool isRest = Atlas.IsRest(lyric); bool prevIsRest = Atlas.IsRest(lyricPrev); RuleResult result = Atlas.GetRuleResult(rule.FormatInsert, lyricPrev, lyric); Note pitchparent = prevIsRest ? Ust.Notes[i] : Ust.Notes[i - 1]; Insert insert = isRest ? Insert.Before : Insert.After; Note parent = isRest ? Ust.Notes[i] : Ust.Notes[i - 1]; if (settings.MakeVR || result.AliasType != "V-") { if (Ust.InsertNote(parent, result.Alias, insert, pitchparent)) { Console.WriteLine(Ust.Notes[i].ParsedLyric); } } if (new[] { "-C" }.Contains(result.AliasType)) { i++; } } } foreach (var note in Ust.Notes) { note.AliasType = Atlas.GetAliasType(note.ParsedLyric); note.SetParsedLyric(Atlas, Atlas.AliasReplace(note.ParsedLyric)); } }