Esempio n. 1
0
            public bool Equals(CVVC_English_Syllable obj)
            {
                if (obj == null)
                {
                    return(false);
                }

                return(obj.Onset == this.Onset &&
                       obj.Nucleus == this.Nucleus &&
                       obj.Coda == this.Coda);
            }
Esempio n. 2
0
            /// <summary>
            /// takes a lyric and splits it into its onset/nucleus/coda parts
            /// returns a CVVC_English_Syllable of [null, null, null] if not recognized
            /// </summary>
            /// <param name="lyric"></param>
            /// <returns></returns>
            public static CVVC_English_Syllable SplitSyllable(string lyric)
            {
                var matches = Syllable_RE.Match(lyric).Groups;
                var result  = new CVVC_English_Syllable();

                if (matches.Count < 3)
                {
                    // not recognized
                    result.Onset   = null;
                    result.Nucleus = null;
                    result.Coda    = null;
                    return(new CVVC_English_Syllable((string)null, null, null));
                }

                result.Onset   = matches[1].Value;
                result.Nucleus = matches[2].Value;
                result.Coda    = matches[3].Value;

                // otherwise, return as expected
                return(result);
            }
Esempio n. 3
0
        /// <summary>
        /// Return the current note, split up as necessary to match the prev and next notes
        /// (Returns a new copy of all notes; the inputs are unchanged)
        ///
        /// </summary>
        /// <param name="prev"></param>
        /// <param name="curr"></param>
        /// <param name="next"></param>
        /// <returns></returns>
        public static List <UtauNote> GetConnectingNotes(UtauNote prev, UtauNote curr, UtauNote next)
        {
            CVVC_English_Syllable lyric_split = CVVC_English_Syllable.SplitSyllable(curr.Lyric);
            string nextlyric_start            = CVVC_English_Syllable.StartingConsonant(next.Lyric);

            List <UtauNote> toReturn = new List <UtauNote>();

            //if unrecognized, return the note untouched
            if (lyric_split.Onset == null && lyric_split.Nucleus == null)
            {
                return(new List <UtauNote> {
                    new UtauNote(curr)
                });
            }

            // add in the base note
            UtauNote CV = new UtauNote(curr);

            CV.Lyric = lyric_split.Onset + lyric_split.Nucleus;
            toReturn.Add(CV);

            // add in the VC note (first figuring out what C to add in)
            UtauNote VC = new UtauNote(curr);
            string   VC_consonant;

            if (lyric_split.Coda != "")
            {
                VC_consonant = lyric_split.Coda;
            }
            else if (nextlyric_start != "")
            {
                VC_consonant = nextlyric_start;
            }
            else
            {
                VC_consonant = null;
            }

            if (VC_consonant != null)
            {
                VC.Lyric  = lyric_split.Nucleus + VC_consonant;
                VC.Length = 120; //TODO: something more clever with lengths. For now, 120 is a 16th note
                toReturn.Add(VC);
                CV.Length = CV.Length - 120;
            }

            // adjust first sound if previous note is a rest (and this note has no starting consonant)
            if (lyric_split.Onset == "" && (prev == null || prev.IsRest))
            {
                toReturn[0].Lyric = "-" + toReturn[0].Lyric;
            }
            // adjust last sound if following note is a rest (and this note has no ending consonant)
            if (lyric_split.Coda == "" && (next == null || next.IsRest))
            {
                VC.Lyric  = lyric_split.Nucleus + "-";
                VC.Length = 120; //TODO: something more clever with lengths. For now, 120 is a 16th note
                toReturn.Add(VC);
                CV.Length = CV.Length - 120;
            }

            //TODO: vowel-vowel sounds like V

            return(toReturn);
        }