Ejemplo n.º 1
0
        public int GetLength(Note note, AtlasSettings settings)
        {
            if (!settings.LengthByOto)
            {
                return(settings.MinLength);
            }
            var next = GetNextNote(note);

            if (next is null)
            {
                return(settings.MinLength);
            }
            if (Atlas.IsRest(next.ParsedLyric))
            {
                return(settings.MinLength);
            }
            var oto = Singer.Current.FindOto(next);

            if (oto is null)
            {
                return(settings.MinLength);
            }
            var length = MusicMath.MillisecondToTick(oto.Preutterance, Tempo) + 1;

            return(length);
        }
Ejemplo n.º 2
0
        public Oto FindOto(string lyric, int noteNum)
        {
            string notenum = MusicMath.NoteNum2String(noteNum);
            string suffix  = Pitchmap.Suffixes.ContainsKey(notenum) ? Pitchmap.Suffixes[notenum] : "";
            string prefix  = Pitchmap.Prefixes.ContainsKey(notenum) ? Pitchmap.Prefixes[notenum] : "";

            return(FindOto(lyric, suffix, prefix));
        }
Ejemplo n.º 3
0
        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));
            }
        }