Esempio n. 1
0
        /// <summary>
        /// 自動ビブラートを作成します
        /// </summary>
        /// <param name="type"></param>
        /// <param name="vibrato_clocks"></param>
        /// <returns></returns>
        public VibratoHandle createAutoVibrato(SynthesizerType type, int vibrato_clocks)
        {
            if (UseUserDefinedAutoVibratoType)
            {
                if (AutoVibratoCustom == null)
                {
                    AutoVibratoCustom = new List <VibratoHandle>();
                }

                // 下4桁からインデックスを取得
                int index = 0;
                if (this.AutoVibratoTypeCustom == null)
                {
                    index = 0;
                }
                else
                {
                    int trimlen = 4;
                    int len     = PortUtil.getStringLength(this.AutoVibratoTypeCustom);
                    if (len < 4)
                    {
                        trimlen = len;
                    }
                    if (trimlen > 0)
                    {
                        string s = this.AutoVibratoTypeCustom.Substring(len - trimlen, trimlen);
                        try {
                            index = (int)PortUtil.fromHexString(s);
                            index--;
                        } catch (Exception ex) {
                            serr.println(typeof(EditorConfig) + ".createAutoVibrato; ex=" + ex + "; AutoVibratoTypeCustom=" + AutoVibratoTypeCustom + "; s=" + s);
                            index = 0;
                        }
                    }
                }

#if DEBUG
                sout.println("EditorConfig.createAutoVibrato; AutoVibratoTypeCustom=" + AutoVibratoTypeCustom + "; index=" + index);
#endif
                VibratoHandle ret = null;
                if (0 <= index && index < this.AutoVibratoCustom.Count)
                {
                    ret = this.AutoVibratoCustom[index];
                    if (ret != null)
                    {
                        ret = (VibratoHandle)ret.clone();
                    }
                }
                if (ret == null)
                {
                    ret = new VibratoHandle();
                }
                ret.IconID = "$0404" + PortUtil.toHexString(index + 1, 4);
                ret.setLength(vibrato_clocks);
                return(ret);
            }
            else
            {
                string        iconid = type == SynthesizerType.VOCALOID1 ? AutoVibratoType1 : AutoVibratoType2;
                VibratoHandle ret    = VocaloSysUtil.getDefaultVibratoHandle(iconid,
                                                                             vibrato_clocks,
                                                                             type);
                if (ret == null)
                {
                    ret        = new VibratoHandle();
                    ret.IconID = "$04040001";
                    ret.setLength(vibrato_clocks);
                }
                return(ret);
            }
        }