public void pictureDepth_Paint(Object sender, PaintEventArgs e) { // 背景を描画 int width = pictureDepth.Width; int height = pictureDepth.Height; System.Drawing.Graphics g = e.Graphics; g.FillRectangle(System.Drawing.Brushes.LightGray, 0, 0, width, height); // 選択中のハンドルを取得 VibratoHandle handle = mSelected; if (handle == null) { return; } // 描画の準備 LineGraphDrawer d = getDrawerDepth(); d.clear(); d.setGraphics(g); drawVibratoCurve( handle.getDepthBP(), handle.getStartDepth(), d, width, height); }
/// <summary> /// カスタムビブラートの選択肢の欄を更新します /// </summary> private void updateCustomVibrato() { int size = AppManager.editorConfig.AutoVibratoCustom.Count; comboAutoVibratoTypeCustom.Items.Clear(); for (int i = 0; i < size; i++) { VibratoHandle handle = AppManager.editorConfig.AutoVibratoCustom[i]; comboAutoVibratoTypeCustom.Items.Add(handle); } }
public void setAutoVibratoTypeCustom(string icon_id) { for (int i = 0; i < comboAutoVibratoTypeCustom.Items.Count; i++) { VibratoHandle handle = (VibratoHandle)comboAutoVibratoTypeCustom.Items[i]; if (handle.IconID.Equals(icon_id)) { comboAutoVibratoTypeCustom.SelectedIndex = i; return; } } }
public void buttonAdd_Click(Object sender, EventArgs e) { // 追加し, VibratoHandle handle = new VibratoHandle(); handle.setCaption("No-Name"); mHandles.Add(handle); listPresets.SelectedIndices.Clear(); // 表示反映させて updateStatus(); // 追加したのを選択状態にする listPresets.SelectedIndex = mHandles.Count - 1; }
/// <summary> /// 画面の表示状態を更新します /// </summary> private void updateStatus() { int old_select = listPresets.SelectedIndex; listPresets.SelectedIndices.Clear(); // アイテムの個数に過不足があれば数を整える int size = mHandles.Count; int delta = size - listPresets.Items.Count; #if DEBUG sout.println("FormVibratoPreset#updateStatus; delta=" + delta); #endif if (delta > 0) { for (int i = 0; i < delta; i++) { listPresets.Items.Add(""); } } else if (delta < 0) { for (int i = 0; i < -delta; i++) { listPresets.Items.RemoveAt(0); } } // アイテムを更新 for (int i = 0; i < size; i++) { VibratoHandle handle = mHandles[i]; listPresets.Items[i] = handle.getCaption(); } // 選択状態を復帰 if (size <= old_select) { old_select = size - 1; } #if DEBUG sout.println("FormVibratoPreset#updateStatus; A; old_selected=" + old_select); #endif if (old_select >= 0) { #if DEBUG sout.println("FormVibratoPreset#updateStatus; B; old_selected=" + old_select); #endif listPresets.SelectedIndex = old_select; } }
public string getAutoVibratoTypeCustom() { int count = -1; int index = comboAutoVibratoTypeCustom.SelectedIndex; if (0 <= index) { VibratoHandle vconfig = (VibratoHandle)comboAutoVibratoTypeCustom.SelectedItem; return(vconfig.IconID); } else { return("$04040001"); } }
/// <summary> /// ビブラートの選択肢の状態を更新します /// </summary> private void updateComboBoxStatus() { // 選択位置 int old = comboVibratoType.SelectedIndex; // 全部削除 comboVibratoType.Items.Clear(); // 「ビブラート無し」を表すアイテムを追加 VibratoHandle empty = new VibratoHandle(); empty.setCaption("[Non Vibrato]"); empty.IconID = "$04040000"; comboVibratoType.Items.Add(empty); // 選択元を元に,選択肢を追加する if (radioUserDefined.Checked) { // ユーザー定義のを使う場合 int size = AppManager.editorConfig.AutoVibratoCustom.Count; for (int i = 0; i < size; i++) { VibratoHandle handle = AppManager.editorConfig.AutoVibratoCustom[i]; comboVibratoType.Items.Add(handle); } } else { // VOCALOID1/VOCALOID2のシステム定義のを使う場合 SynthesizerType type = radioVocaloid1.Checked ? SynthesizerType.VOCALOID1 : SynthesizerType.VOCALOID2; foreach (var vconfig in VocaloSysUtil.vibratoConfigIterator(type)) { comboVibratoType.Items.Add(vconfig); } } // 選択位置を戻せるなら戻す int index = old; if (index >= comboVibratoType.Items.Count) { index = comboVibratoType.Items.Count - 1; } if (0 <= index) { comboVibratoType.SelectedIndex = index; } }
public void setAutoVibratoType2(string value) { for (int i = 0; i < comboAutoVibratoType2.Items.Count; i++) { VibratoHandle vconfig = (VibratoHandle)comboAutoVibratoType2.Items[i]; if (vconfig.IconID.Equals(value)) { comboAutoVibratoType2.SelectedIndex = i; return; } } if (comboAutoVibratoType2.Items.Count > 0) { comboAutoVibratoType2.SelectedIndex = 0; } }
public List <VibratoVariation> getStandardValues() { // ビブラート種類の候補値を列挙 List <VibratoVariation> list = new List <VibratoVariation>(); list.Add(new VibratoVariation(VibratoVariation.empty.description)); if (AppManager.editorConfig.UseUserDefinedAutoVibratoType) { // ユーザー定義の中から選ぶ場合 int size = AppManager.editorConfig.AutoVibratoCustom.Count; #if DEBUG sout.println("VibratoVariationConverter#GetStandardValues; size=" + size); #endif for (int i = 0; i < size; i++) { VibratoHandle handle = AppManager.editorConfig.AutoVibratoCustom[i]; #if DEBUG sout.println("VibratoVariationConverter#GetStandardValues; handle.getDisplayString()=" + handle.getDisplayString()); #endif list.Add(new VibratoVariation(handle.getDisplayString())); } } else { // VOCALOID1, VOCALOID2のシステム定義の中から選ぶ場合 SynthesizerType type = SynthesizerType.VOCALOID1; /* * VsqFileEx vsq = AppManager.getVsqFile(); * if (vsq != null) { * RendererKind kind = VsqFileEx.getTrackRendererKind(vsq.Track[AppManager.getSelected()]); * if (kind == RendererKind.VOCALOID1) { * type = SynthesizerType.VOCALOID1; * } * }*/ foreach (var vconfig in VocaloSysUtil.vibratoConfigIterator(type)) { list.Add(new VibratoVariation(vconfig.getDisplayString())); } } return(list); }
public void listPresets_SelectedIndexChanged(Object sender, EventArgs e) { // インデックスを取得 int index = listPresets.SelectedIndex; #if DEBUG sout.println("FormVibratoPreset#listPresets_SelectedIndexChanged; index=" + index); #endif // 範囲外ならbailout if ((index < 0) || (mHandles.Count <= index)) { #if DEBUG sout.println("FormVibratoPreset#listPresets_SelectedIndexChanged; bail-out, mSelected -> null; index=" + index); #endif mSelected = null; return; } // イベントハンドラを一時的に取り除く textDepth.TextChanged -= new EventHandler(textDepth_TextChanged); textRate.TextChanged -= new EventHandler(textRate_TextChanged); textName.TextChanged -= new EventHandler(textName_TextChanged); // テクストボックスに値を反映 mSelected = mHandles[index]; textDepth.Text = mSelected.getStartDepth() + ""; textRate.Text = mSelected.getStartRate() + ""; textName.Text = mSelected.getCaption(); // イベントハンドラを再登録 textDepth.TextChanged += new EventHandler(textDepth_TextChanged); textRate.TextChanged += new EventHandler(textRate_TextChanged); textName.TextChanged += new EventHandler(textName_TextChanged); // 再描画 repaintPictures(); }
public void txtVibratoLength_TextChanged(Object sender, EventArgs e) { #if DEBUG AppManager.debugWriteLine("txtVibratoLength_TextChanged"); AppManager.debugWriteLine(" (m_vibrato==null)=" + (m_vibrato == null)); #endif int percent = 0; try { percent = int.Parse(txtVibratoLength.Text); if (percent < 0) { percent = 0; } else if (100 < percent) { percent = 100; } } catch (Exception ex) { return; } if (percent == 0) { m_vibrato = null; #if DEBUG sout.println("FormVibratoConfig#txtVibratoLength_TextChanged; A; m_vibrato -> null"); #endif txtVibratoLength.Enabled = false; } else { if (m_vibrato != null) { int new_length = (int)(m_note_length * percent / 100.0f); m_vibrato.setLength(new_length); } } }
public void handleUpDownButtonClick(Object sender, EventArgs e) { // 送信元のボタンによって,選択インデックスの増分を変える int delta = 1; if (sender == buttonUp) { delta = -1; } // 移動後のインデックスは? int index = listPresets.SelectedIndex; int move_to = index + delta; // 範囲内かどうか if (index < 0) { return; } if (move_to < 0 || mHandles.Count <= move_to) { // 範囲外なら何もしない return; } // 入れ替える VibratoHandle buff = mHandles[index]; mHandles[index] = mHandles[move_to]; mHandles[move_to] = buff; // 選択状態を変える listPresets.SelectedIndices.Clear(); updateStatus(); listPresets.SelectedIndex = move_to; }
/// <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()); }
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> /// xml要素から音符イベントを生成する /// </summary> /// <param name="note">xml要素</param> /// <param name="tickOffset">指定したxml要素が所属しているmusicalPartの、オフセットtick数</param> /// <returns>生成した音符イベント</returns> private static VsqEvent createNoteEvent(XmlNode note, int tickOffset) { int posTick = int.Parse(note["posTick"].InnerText); VsqEvent item = new VsqEvent(); item.Clock = posTick + tickOffset; item.ID = new VsqID(); item.ID.type = VsqIDType.Anote; item.ID.LyricHandle = new LyricHandle(); string lyric = note["lyric"].InnerText; XmlElement phnmsElement = note["phnms"]; string symbols = phnmsElement.InnerText; bool symbolsProtected = false; if (phnmsElement.HasAttribute("lock")) { int value = int.Parse(phnmsElement.Attributes["lock"].Value); symbolsProtected = value == 1; } item.ID.LyricHandle.L0.PhoneticSymbolProtected = symbolsProtected; item.ID.LyricHandle.L0.Phrase = lyric; item.ID.LyricHandle.L0.setPhoneticSymbol(symbols); item.ID.Note = int.Parse(note["noteNum"].InnerText); item.ID.setLength(int.Parse(note["durTick"].InnerText)); item.ID.Dynamics = int.Parse(note["velocity"].InnerText); var attributes = getNoteAttributes(note); if (attributes.ContainsKey("accent")) { item.ID.DEMaccent = attributes["accent"]; } if (attributes.ContainsKey("bendDep")) { item.ID.PMBendDepth = attributes["bendDep"]; } if (attributes.ContainsKey("bendLen")) { item.ID.PMBendLength = attributes["bendLen"]; } if (attributes.ContainsKey("decay")) { item.ID.DEMdecGainRate = attributes["decay"]; } if (attributes.ContainsKey("fallPort")) { item.ID.setFallPortamento(attributes["fallPort"] == 1); } if (attributes.ContainsKey("risePort")) { item.ID.setRisePortamento(attributes["risePort"] == 1); } // vibrato if (attributes.ContainsKey("vibLen") && attributes.ContainsKey("vibType")) { int lengthPercentage = attributes["vibLen"]; int vibratoType = attributes["vibType"] - 1; if (lengthPercentage > 0) { var vibratoHandle = new VibratoHandle(); int length = item.ID.getLength(); int duration = (int)(length * (lengthPercentage / 100.0)); vibratoHandle.setLength(duration); item.ID.VibratoDelay = length - duration; vibratoHandle.IconID = "$0404" + vibratoType.ToString("X4"); double delayRatio = (double)(length - duration) / (double)length; // VibDepth vibratoHandle.setDepthBP(getVibratoCurve(note, "vibDep", delayRatio)); // VibRate vibratoHandle.setRateBP(getVibratoCurve(note, "vibRate", delayRatio)); item.ID.VibratoHandle = vibratoHandle; } } return(item); }
/// <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); } }
public void pictureResulting_Paint(Object sender, PaintEventArgs e) { // 背景を描画 int raw_width = pictureResulting.Width; int raw_height = pictureResulting.Height; System.Drawing.Graphics g = e.Graphics; g.FillRectangle(System.Drawing.Brushes.LightGray, 0, 0, raw_width, raw_height); // 選択中のハンドルを取得 VibratoHandle handle = mSelected; if (handle == null) { return; } // 描画の準備 LineGraphDrawer d = getDrawerResulting(); d.setGraphics(g); // ビブラートのピッチベンドを取得するイテレータを取得 int width = raw_width; int vib_length = 960; int tempo = 500000; double vib_seconds = tempo * 1e-6 / 480.0 * vib_length; // 480クロックは0.5秒 VsqFileEx vsq = new VsqFileEx("Miku", 1, 4, 4, tempo); VibratoBPList list_rate = handle.getRateBP(); VibratoBPList list_depth = handle.getDepthBP(); int start_rate = handle.getStartRate(); int start_depth = handle.getStartDepth(); if (list_rate == null) { list_rate = new VibratoBPList(new float[] { 0.0f }, new int[] { start_rate }); } if (list_depth == null) { list_depth = new VibratoBPList(new float[] { 0.0f }, new int[] { start_depth }); } // 解像度 float resol = (float)(vib_seconds / width); if (resol <= 0.0f) { return; } VibratoPointIteratorBySec itr = new VibratoPointIteratorBySec( vsq, list_rate, start_rate, list_depth, start_depth, 0, vib_length, resol); // 描画 int height = raw_height - MARGIN * 2; d.clear(); //g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias; int x = 0; int lastx = 0; int lasty = -10; int tx = 0, ty = 0; for (; itr.hasNext(); x++) { double pitch = itr.next().getY(); int y = height - (int)((pitch + 1.25) / 2.5 * height) + MARGIN - 1; int dx = x - lastx; // xは単調増加 int dy = Math.Abs(y - lasty); tx = x; ty = y; //if ( dx > MIN_DELTA || dy > MIN_DELTA ) { d.append(x, y); lastx = x; lasty = y; //} } d.append(tx, ty); d.flush(); }