public void SetAtlas(Atlas atlas) { Atlas = atlas; foreach (var note in Notes) { note.Lyric = atlas.ValidateLyric(note.Lyric); note.ParsedLyric = note.Lyric; note.IsRest = atlas.IsRest(note.Lyric); } }
public string[] GetLyrics(bool skipRest = true) { List <string> lyrics = new List <string>(); foreach (Note note in Notes) { if (note.Number == NumberManager.NEXT || note.Number == NumberManager.PREV) { continue; } if (skipRest && Atlas.IsRest(note.Lyric)) { continue; } if (note.Lyric == null) { continue; } lyrics.Add(note.ParsedLyricView); } return(lyrics.ToArray()); }
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)); } }