Ejemplo n.º 1
0
        /// <summary>
        /// Consonant Adjustmentを、整数配列で取得します。
        /// </summary>
        /// <returns></returns>
        public List <int> getConsonantAdjustmentList()
        {
            if (mConsonantAdjustments != null)
            {
                return(mConsonantAdjustments);
            }
            if (mPhoneticSymbols == null)
            {
                mConsonantAdjustments = new List <int>();
                return(mConsonantAdjustments);
            }

            mConsonantAdjustments.Clear();
            for (int i = 0; i < mPhoneticSymbols.Count; i++)
            {
                int v = VsqPhoneticSymbol.isConsonant(mPhoneticSymbols[i]) ? 64 : 0;
                mConsonantAdjustments.Add(v);
            }
            return(mConsonantAdjustments);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// このインスタンスを文字列に変換します
        /// </summary>
        /// <param name="add_quatation_mark">クォーテーションマークを付けるかどうか</param>
        /// <returns>変換後の文字列</returns>
        public string toString(bool add_quatation_mark)
        {
            string quot = (add_quatation_mark ? "\"" : "");
            string result;
            string phrase = (this.Phrase == null) ? "" : this.Phrase.Replace("\"", "\"\"");

            result = quot + phrase + quot + ",";
            List <string> symbol    = getPhoneticSymbolList();
            string        strSymbol = getPhoneticSymbol();

            if (!add_quatation_mark)
            {
                if (strSymbol == null || (strSymbol != null && strSymbol == ""))
                {
                    strSymbol = "u:";
                }
            }
            result += quot + strSymbol + quot + "," + PortUtil.formatDecimal("0.000000", UnknownFloat);
            result  = result.Replace("\\" + "\\", "\\");
            if (mConsonantAdjustments == null)
            {
                mConsonantAdjustments = new List <int>();
                for (int i = 0; i < symbol.Count; i++)
                {
                    mConsonantAdjustments.Add(VsqPhoneticSymbol.isConsonant(symbol[i]) ? 64 : 0);
                }
            }
            for (int i = 0; i < mConsonantAdjustments.Count; i++)
            {
                result += "," + mConsonantAdjustments[i];
            }
            if (PhoneticSymbolProtected)
            {
                result += ",1";
            }
            else
            {
                result += ",0";
            }
            return(result);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// この歌詞の発音記号を設定します。
        /// </summary>
        public void setPhoneticSymbol(string value)
        {
            string s = value.Replace("  ", " ");

            // 古い発音記号を保持しておく
            List <string> old_symbol = null;

            if (mPhoneticSymbols != null)
            {
                int count = mPhoneticSymbols.Count;
                old_symbol = new List <string>();
                for (int i = 0; i < count; i++)
                {
                    old_symbol.Add(mPhoneticSymbols[i]);
                }
            }

            // 古いconsonant adjustmentを保持しておく
            List <int> old_adjustment = null;

            if (mConsonantAdjustments != null)
            {
                old_adjustment = new List <int>();
                int count = mConsonantAdjustments.Count;
                for (int i = 0; i < count; i++)
                {
                    old_adjustment.Add(mConsonantAdjustments[i]);
                }
            }

            string[] spl = PortUtil.splitString(s, new char[] { ' ' }, 16, true);
            if (mPhoneticSymbols == null)
            {
                mPhoneticSymbols = new List <string>();
            }
            int size = spl.Length;

            mPhoneticSymbols.Clear();
            for (int i = 0; i < size; i++)
            {
                mPhoneticSymbols.Add(spl[i]);
            }
            for (int i = 0; i < mPhoneticSymbols.Count; i++)
            {
                mPhoneticSymbols[i] = mPhoneticSymbols[i].Replace("\\" + "\\", "\\");
            }

            // consonant adjustmentを更新
            if (mConsonantAdjustments == null ||
                (mConsonantAdjustments != null && mConsonantAdjustments.Count != mPhoneticSymbols.Count))
            {
                mConsonantAdjustments = new List <int>();
                for (int i = 0; i < mPhoneticSymbols.Count; i++)
                {
                    mConsonantAdjustments.Add(0);
                }
            }

            // 古い発音記号と同じなら、古い値を使う
            if (old_symbol != null)
            {
                for (int i = 0; i < mPhoneticSymbols.Count; i++)
                {
                    if (i >= old_symbol.Count)
                    {
                        break;
                    }
                    string s0            = mPhoneticSymbols[i];
                    string s1            = old_symbol[i];
                    bool   use_old_value = (old_symbol != null && i < old_symbol.Count) &&
                                           (s0 == s1) &&
                                           (old_adjustment != null && i < old_adjustment.Count);
                    if (use_old_value)
                    {
                        mConsonantAdjustments[i] = VsqPhoneticSymbol.isConsonant(mPhoneticSymbols[i]) ? old_adjustment[i] : 0;
                    }
                    else
                    {
                        mConsonantAdjustments[i] = VsqPhoneticSymbol.isConsonant(mPhoneticSymbols[i]) ? 64 : 0;
                    }
                }
            }
        }