コード例 #1
0
ファイル: Parser.cs プロジェクト: HeidenBZR/LyricInputHelper
        public void Split()
        {
            if (!Atlas.KeepCC && !Atlas.KeepWordsBeginnigs && !Atlas.KeepWordsEndings)
            {
                SplitFull();
                return;
            }
            var note = Ust.Notes[1];
            var next = Ust.GetNextNote(note);
            var prev = Ust.GetPrevNote(note);

            while (next != null)
            {
                if (!note.IsRest)
                {
                    if (note.Syllable is null)
                    {
                        note.Syllable = new Syllable(note.ParsedLyric.Split(' '), Atlas);
                    }
                    var syll = note.Syllable;
                    if (!syll.ContainsVowel)
                    {
                        if (Atlas.KeepCC)
                        {
                            prev = note;
                            note = next;
                            next = Ust.GetNextNote(note);
                            continue;
                        }
                        // split CC
                        note.SetParsedLyric(Atlas, syll.Phonemes.Last());
                        for (int k = 0; k < syll.Phonemes.Length - 1; k++)
                        {
                            Ust.InsertNote(note, syll.Phonemes[k], Insert.Before, note);
                        }
                    }
                    else
                    {
                        // Words beginnings
                        if (note.Word.Name != null && !Atlas.KeepWordsBeginnigs)
                        {
                            if (syll.ExtraConsonantBeginning.Length > 0)
                            {
                                if (Atlas.KeepCC)
                                {
                                    Ust.InsertNote(note, Syllable.ToString(syll.ExtraConsonantBeginning), Insert.Before, prev, prev);
                                    var ccc = Ust.GetPrevNote(note);
                                    ccc.Syllable = new Syllable(ccc.ParsedLyric.Split(' '), Atlas);
                                    if (ccc.Syllable.Phonemes.Length == 2)
                                    {
                                        ccc.SetParsedLyric(Atlas, Atlas.GetAlias("CC", ccc.Syllable.Phonemes));
                                    }
                                    if (ccc.Syllable.Phonemes.Length == 3)
                                    {
                                        ccc.SetParsedLyric(Atlas, Atlas.GetAlias("CCC", ccc.Syllable.Phonemes));
                                    }
                                    if (ccc.Syllable.Phonemes.Length == 4)
                                    {
                                        ccc.SetParsedLyric(Atlas, Atlas.GetAlias("CCCC", ccc.Syllable.Phonemes));
                                    }
                                }
                                else
                                {
                                    for (int k = 0; k < syll.ExtraConsonantBeginning.Length - 1; k++)
                                    {
                                        Ust.InsertNote(note, syll.ExtraConsonantBeginning[k], Insert.Before, prev, prev);
                                    }
                                }
                            }

                            if (!Atlas.KeepCV && syll.VowelIndex > 0)
                            {
                                Ust.InsertNote(note, syll.CV[0], Insert.Before, prev);
                            }
                        }
                        // Word endings
                        if (syll.ConsonantEnding.Length > 0)
                        {
                            if (Atlas.KeepCC)
                            {
                                //Ust.InsertNote(note, Syllable.ToString(syll.ConsonantEnding), Insert.After, note);
                                var nextNotes = syll.ConsonantEnding.Select(n => n).ToList();
                                if (!next.IsRest)
                                {
                                    nextNotes.AddRange(next.ParsedLyric.Split(' '));
                                    next.Syllable = new Syllable(nextNotes, Atlas);
                                    next.SetParsedLyric(Atlas, next.Syllable.ToString());
                                }
                                else
                                {
                                    var newSyll = new Syllable(nextNotes, Atlas);
                                    Ust.InsertNote(note, newSyll.ToString(), Insert.After, note);
                                    var newNote = Ust.GetNextNote(note);
                                    newNote.Syllable = newSyll;
                                }
                                //var ccc = Ust.GetNextNote(note);
                                //ccc.Syllable = new Syllable(ccc.ParsedLyric.Split(' '));
                                //if (ccc.Syllable.Phonemes.Length == 2)
                                //    ccc.ParsedLyric = Atlas.GetAlias("CC", ccc.Syllable.Phonemes);
                                //if (ccc.Syllable.Phonemes.Length == 3)
                                //    ccc.ParsedLyric = Atlas.GetAlias("CCC", ccc.Syllable.Phonemes);
                                //if (ccc.Syllable.Phonemes.Length == 4)
                                //    ccc.ParsedLyric = Atlas.GetAlias("CCCC", ccc.Syllable.Phonemes);
                            }
                            else
                            {
                                for (int k = syll.ConsonantEnding.Length; k > 0; k--)
                                {
                                    Ust.InsertNote(note, syll.ConsonantEnding[k - 1], Insert.Before, note);
                                }
                            }
                        }
                    }
                    if (Atlas.KeepCV)
                    {
                        note.Syllable = new Syllable(syll.Beginning, Atlas);
                    }
                    else
                    {
                        note.Syllable = new Syllable(new List <string> {
                            syll.Vowel
                        }, Atlas);
                    }
                    note.SetParsedLyric(Atlas, note.Syllable.ToString());
                    if (note.Syllable.Phonemes.Length > 1)
                    {
                        if (note.Syllable.Beginning.Length == 2)
                        {
                            note.SetParsedLyric(Atlas, Atlas.GetAlias("CV", note.Syllable.Beginning));
                        }
                        if (note.Syllable.Beginning.Length == 3)
                        {
                            note.SetParsedLyric(Atlas, Atlas.GetAlias("CCV", note.Syllable.Beginning));
                        }
                        if (note.Syllable.Beginning.Length == 4)
                        {
                            note.SetParsedLyric(Atlas, Atlas.GetAlias("CCCV", note.Syllable.Beginning));
                        }
                        if (note.Syllable.Beginning.Length == 5)
                        {
                            note.SetParsedLyric(Atlas, Atlas.GetAlias("CCCCV", note.Syllable.Beginning));
                        }
                    }
                }

                prev = note;
                note = next;
                next = Ust.GetNextNote(note);
            }
        }
コード例 #2
0
ファイル: Atlas.cs プロジェクト: HeidenBZR/LyricInputHelper
        public Syllable PhonemeReplace(Syllable syllable)
        {
            var phonemes = PhonemeReplace(syllable.ToString());

            return(new Syllable(phonemes.Split(' '), this));
        }