public void comboVibratoType_SelectedIndexChanged(Object sender, EventArgs e)
        {
            int index = comboVibratoType.SelectedIndex;

#if DEBUG
            sout.println("FormVibratoConfig#comboVibratoType_SelectedIndexChanged; index=" + index);
#endif
            if (index >= 0)
            {
                string s = ((VibratoHandle)comboVibratoType.Items[index]).IconID;
#if DEBUG
                sout.println("FormVibratoConfig#comboVibratoType_SelectedIndexChanged; index=" + index + "; iconid=" + s);
#endif
                if (s.Equals("$04040000"))
                {
#if DEBUG
                    sout.println("FormVibratoConfig#comboVibratoType_SelectedIndexChanged; B; m_vibrato -> null");
#endif
                    m_vibrato = null;
                    txtVibratoLength.Enabled = false;
                    return;
                }
                else
                {
                    txtVibratoLength.Enabled = true;
                    VibratoHandle src = null;
                    if (radioUserDefined.Checked)
                    {
                        int size = AppManager.editorConfig.AutoVibratoCustom.Count;
                        for (int i = 0; i < size; i++)
                        {
                            VibratoHandle handle = AppManager.editorConfig.AutoVibratoCustom[i];
                            if (s == handle.IconID)
                            {
                                src = handle;
                                break;
                            }
                        }
                    }
                    else
                    {
                        SynthesizerType type = radioVocaloid1.Checked ? SynthesizerType.VOCALOID1 : SynthesizerType.VOCALOID2;
                        foreach (var vconfig in VocaloSysUtil.vibratoConfigIterator(type))
                        {
                            if (s == vconfig.IconID)
                            {
                                src = vconfig;
                                break;
                            }
                        }
                    }
#if DEBUG
                    sout.println("FormVibratoConfig#comboVibratoType_SelectedIndexChanged; (src==null)=" + (src == null));
#endif
                    if (src != null)
                    {
                        int percent;
                        try {
                            percent = int.Parse(txtVibratoLength.Text);
                        } catch (Exception ex) {
                            return;
                        }
                        m_vibrato = (VibratoHandle)src.clone();
                        m_vibrato.setLength((int)(m_note_length * percent / 100.0f));
                        return;
                    }
                }
            }
        }
        /// <summary>
        /// コンストラクタ.引数vibrato_handleには,Cloneしたものを渡さなくてよい.
        /// </summary>
        /// <param name="vibrato_handle"></param>
        /// <param name="note_length"></param>
        /// <param name="default_vibrato_length"></param>
        /// <param name="type"></param>
        /// <param name="use_original"></param>
        public FormVibratoConfig(
            VibratoHandle vibrato_handle,
            int note_length,
            DefaultVibratoLengthEnum default_vibrato_length,
            SynthesizerType type,
            bool use_original)
        {
            InitializeComponent();

#if DEBUG
            AppManager.debugWriteLine("FormVibratoConfig.ctor(Vsqhandle,int,DefaultVibratoLength)");
            AppManager.debugWriteLine("    (vibrato_handle==null)=" + (vibrato_handle == null));
            sout.println("    type=" + type);
#endif
            if (use_original)
            {
                radioUserDefined.Checked = true;
            }
            else
            {
                if (type == SynthesizerType.VOCALOID1)
                {
                    radioVocaloid1.Checked = true;
                }
                else
                {
                    radioVocaloid2.Checked = true;
                }
            }
            if (vibrato_handle != null)
            {
                m_vibrato = (VibratoHandle)vibrato_handle.clone();
            }

            // 選択肢の状態を更新
            updateComboBoxStatus();
            // どれを選ぶか?
            if (vibrato_handle != null)
            {
#if DEBUG
                sout.println("FormVibratoConfig#.ctor; vibrato_handle.IconID=" + vibrato_handle.IconID);
#endif
                for (int i = 0; i < comboVibratoType.Items.Count; i++)
                {
                    VibratoHandle handle = (VibratoHandle)comboVibratoType.Items[i];
#if DEBUG
                    sout.println("FormVibratoConfig#.ctor; handle.IconID=" + handle.IconID);
#endif
                    if (vibrato_handle.IconID.Equals(handle.IconID))
                    {
                        comboVibratoType.SelectedIndex = i;
                        break;
                    }
                }
            }

            txtVibratoLength.Enabled = (vibrato_handle != null);
            if (vibrato_handle != null)
            {
                txtVibratoLength.Text = (int)((float)vibrato_handle.getLength() / (float)note_length * 100.0f) + "";
            }
            else
            {
                string s = "";
                if (default_vibrato_length == DefaultVibratoLengthEnum.L100)
                {
                    s = "100";
                }
                else if (default_vibrato_length == DefaultVibratoLengthEnum.L50)
                {
                    s = "50";
                }
                else if (default_vibrato_length == DefaultVibratoLengthEnum.L66)
                {
                    s = "66";
                }
                else if (default_vibrato_length == DefaultVibratoLengthEnum.L75)
                {
                    s = "75";
                }
                txtVibratoLength.Text = s;
            }

            m_note_length = note_length;

            registerEventHandlers();
            setResources();
            applyLanguage();

            Util.applyFontRecurse(this, AppManager.editorConfig.getBaseFont());
        }
Example #3
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);
            }
        }