Ejemplo n.º 1
0
        public void SetLyric(string[] lyric, bool skipRest = true)
        {
            int i = 0;

            foreach (UNote note in Notes)
            {
                if (Atlas.IsRest(note.Lyric) && skipRest)
                {
                    continue;
                }
                if (lyric.Length <= i)
                {
                    break;
                }
                note.Lyric = lyric[i];
                i++;
            }
        }
Ejemplo n.º 2
0
        public string[] GetLyrics(bool skipRest = true)
        {
            List <string> lyrics = new List <string>();

            foreach (UNote note in Notes)
            {
                if (skipRest && Atlas.IsRest(note.Lyric))
                {
                    continue;
                }
                if (note.Lyric == null)
                {
                    continue;
                }
                lyrics.Add(note.Lyric);
            }
            return(lyrics.ToArray());
        }
Ejemplo n.º 3
0
        void SeparateLyric(Ust ust)
        {
            Log("Separate Lyric", "Starting...");
            List <string> prevphonemes = new List <string>();

            Ust.MainNotes = new List <UNote>();
            foreach (UNote note in ust.Notes)
            {
                note.Children = new List <UNote>();
                note.Parent   = null;
                if (note.IsRest)
                {
                    continue;
                }
                UNote         prev     = ust.GetPrevNote(note);
                UNote         next     = ust.GetNextNote(note);
                List <string> phonemes = note.Phonemes.Split(' ').ToList();
                Ust.MainNotes.Add(note);
                phonemes.InsertRange(0, prevphonemes);
                prevphonemes = new List <string>();
                int vowel = phonemes.FindIndex(n => Atlas.IsVowel(n) || Atlas.IsRest(n));
                if (vowel == -1)
                {
                    Error(this as object, $"Can't find vowel in note {note.Lyric} [{note.Phonemes}]");
                    note.ReadLyric(phonemes[0], keepRest: true);
                    vowel = 0;
                }
                if (phonemes.Count == 0)
                {
                }
                else if (vowel < phonemes.Count - 1)
                {
                    prevphonemes = phonemes.Skip(vowel + 1).ToList();
                    phonemes     = phonemes.Take(vowel + 1).ToList();
                    note.ReadLyric(phonemes[vowel]);
                }
                else
                {
                    note.ReadLyric(phonemes[vowel]);
                }
                for (int i = vowel; i > 0; i--)
                {
                    if (phonemes.Count > 0)
                    {
                        Console.WriteLine(phonemes[i - 1]);
                        if (prev.IsRest)
                        {
                            prev.Children.Add(ust.InsertNote(prev, phonemes[i - 1], Insert.After, note));
                        }
                        else
                        {
                            prev.Children.Add(ust.InsertNote(prev, phonemes[i - 1], Insert.After, prev));
                        }
                    }
                }
                if (next == null)
                {
                    ust.InsertNote(note, "R", Insert.Append, note);
                }
                else if (next.IsRest)
                {
                    next.Children.Add(ust.InsertNote(next, "R", Insert.Before, note));
                }
                if (prevphonemes.Count == 0)
                {
                    continue;
                }
                for (int i = 0; i < prevphonemes.Count; i++)
                {
                    if (next == null)
                    {
                        note.Children.Add(ust.InsertNote(note, prevphonemes[i], Insert.After, note));
                    }
                    else if (next.IsRest)
                    {
                        note.Children.Add(ust.InsertNote(note, prevphonemes[i], Insert.After, note));
                    }
                }
                if (next == null || next.IsRest)
                {
                    prevphonemes = new List <string>();
                }
            }
            Log("Separate Lyric", "Completed.");
        }