public VibratoHandle() { startRate = 64; startDepth = 64; rateBP = new VibratoBPList(); depthBP = new VibratoBPList(); }
/// <summary> /// このインスタンスと,指定したVibratoBPListのインスタンスが等しいかどうかを調べます /// </summary> /// <param name="item"></param> /// <returns></returns> public bool equals(VibratoBPList item) { if (item == null) { return(false); } int size = this.m_list.Count; if (size != item.m_list.Count) { return(false); } for (int i = 0; i < size; i++) { VibratoBPPair p0 = this.m_list[i]; VibratoBPPair p1 = item.m_list[i]; if (p0.X != p1.X) { return(false); } if (p0.Y != p1.Y) { return(false); } } return(true); }
public Object clone() { VibratoBPList ret = new VibratoBPList(); for (int i = 0; i < m_list.Count; i++) { ret.m_list.Add(new VibratoBPPair(m_list[i].X, m_list[i].Y)); } return(ret); }
/// <summary> /// テキストデータからVibratoBPListを構築する /// </summary> /// <param name="strNum"></param> /// <param name="strBPX"></param> /// <param name="strBPY"></param> /// <returns></returns> private static VibratoBPList getBPListFromText(string strNum, string strBPX, string strBPY) { VibratoBPList ret = null; if (strNum == null || (strNum != null && strNum == "")) { return(ret); } int num = 0; try { num = int.Parse(strNum); } catch (Exception ex) { serr.println("org.kbinani.vsq.IconParameter.getBPListFromText; ex=" + ex); num = 0; } string[] sx = PortUtil.splitString(strBPX, ','); string[] sy = PortUtil.splitString(strBPY, ','); int actNum = Math.Min(num, Math.Min(sx.Length, sy.Length)); if (actNum > 0) { float[] x = new float[actNum]; int[] y = new int[actNum]; for (int i = 0; i < actNum; i++) { try { x[i] = (float)double.Parse(sx[i]); y[i] = int.Parse(sy[i]); } catch (Exception ex) { serr.println("org.kbinani.vsq.IconParameter.getBPListFromText; ex=" + ex); } } ret = new VibratoBPList(x, y); } return(ret); }
public bool equals(VsqEvent item) { if (this.Clock != item.Clock) { return(false); } if (this.ID.type != item.ID.type) { return(false); } if (this.ID.type == VsqIDType.Anote) { #region 音符の比較 if (this.ID.Note != item.ID.Note) { return(false); } if (this.ID.getLength() != item.ID.getLength()) { return(false); } if (this.ID.d4mean != item.ID.d4mean) { return(false); } if (this.ID.DEMaccent != item.ID.DEMaccent) { return(false); } if (this.ID.DEMdecGainRate != item.ID.DEMdecGainRate) { return(false); } if (this.ID.Dynamics != item.ID.Dynamics) { return(false); } if (this.ID.LyricHandle == null && item.ID.LyricHandle != null) { return(false); } if (this.ID.LyricHandle != null && item.ID.LyricHandle == null) { return(false); } if (this.ID.LyricHandle != null && item.ID.LyricHandle != null) { if (!this.ID.LyricHandle.L0.equalsForSynth(item.ID.LyricHandle.L0)) { return(false); } int count = this.ID.LyricHandle.Trailing.Count; if (count != item.ID.LyricHandle.Trailing.Count) { return(false); } for (int k = 0; k < count; k++) { if (!this.ID.LyricHandle.Trailing[k].equalsForSynth(item.ID.LyricHandle.Trailing[k])) { return(false); } } } if (this.ID.NoteHeadHandle == null && item.ID.NoteHeadHandle != null) { return(false); } if (this.ID.NoteHeadHandle != null && item.ID.NoteHeadHandle == null) { return(false); } if (this.ID.NoteHeadHandle != null && item.ID.NoteHeadHandle != null) { if (!this.ID.NoteHeadHandle.IconID.Equals(item.ID.NoteHeadHandle.IconID)) { return(false); } if (this.ID.NoteHeadHandle.getDepth() != item.ID.NoteHeadHandle.getDepth()) { return(false); } if (this.ID.NoteHeadHandle.getDuration() != item.ID.NoteHeadHandle.getDuration()) { return(false); } if (this.ID.NoteHeadHandle.getLength() != item.ID.NoteHeadHandle.getLength()) { return(false); } } if (this.ID.PMBendDepth != item.ID.PMBendDepth) { return(false); } if (this.ID.PMBendLength != item.ID.PMBendLength) { return(false); } if (this.ID.PMbPortamentoUse != item.ID.PMbPortamentoUse) { return(false); } if (this.ID.pMeanEndingNote != item.ID.pMeanEndingNote) { return(false); } if (this.ID.pMeanOnsetFirstNote != item.ID.pMeanOnsetFirstNote) { return(false); } VibratoHandle hVibratoThis = this.ID.VibratoHandle; VibratoHandle hVibratoItem = item.ID.VibratoHandle; if (hVibratoThis == null && hVibratoItem != null) { return(false); } if (hVibratoThis != null && hVibratoItem == null) { return(false); } if (hVibratoThis != null && hVibratoItem != null) { if (this.ID.VibratoDelay != item.ID.VibratoDelay) { return(false); } if (!hVibratoThis.IconID.Equals(hVibratoItem.IconID)) { return(false); } if (hVibratoThis.getStartDepth() != hVibratoItem.getStartDepth()) { return(false); } if (hVibratoThis.getStartRate() != hVibratoItem.getStartRate()) { return(false); } VibratoBPList vibRateThis = hVibratoThis.getRateBP(); VibratoBPList vibRateItem = hVibratoItem.getRateBP(); if (vibRateThis == null && vibRateItem != null) { return(false); } if (vibRateThis != null && vibRateItem == null) { return(false); } if (vibRateThis != null && vibRateItem != null) { int numRateCount = vibRateThis.getCount(); if (numRateCount != vibRateItem.getCount()) { return(false); } for (int k = 0; k < numRateCount; k++) { VibratoBPPair pThis = vibRateThis.getElement(k); VibratoBPPair pItem = vibRateItem.getElement(k); if (pThis.X != pItem.X) { return(false); } if (pThis.Y != pItem.Y) { return(false); } } } VibratoBPList vibDepthThis = hVibratoThis.getDepthBP(); VibratoBPList vibDepthItem = hVibratoItem.getDepthBP(); if (vibDepthThis == null && vibDepthItem != null) { return(false); } if (vibDepthThis != null && vibDepthItem == null) { return(false); } if (vibDepthThis != null && vibDepthItem != null) { int numDepthCount = vibDepthThis.getCount(); if (numDepthCount != vibDepthItem.getCount()) { return(false); } for (int k = 0; k < numDepthCount; k++) { VibratoBPPair pThis = vibDepthThis.getElement(k); VibratoBPPair pItem = vibDepthItem.getElement(k); if (pThis.X != pItem.X) { return(false); } if (pThis.Y != pItem.Y) { return(false); } } } } if (this.ID.vMeanNoteTransition != item.ID.vMeanNoteTransition) { return(false); } #endregion } else if (this.ID.type == VsqIDType.Singer) { #region シンガーイベントの比較 if (this.ID.IconHandle.Program != item.ID.IconHandle.Program) { return(false); } #endregion } else if (this.ID.type == VsqIDType.Aicon) { if (!this.ID.IconDynamicsHandle.IconID.Equals(item.ID.IconDynamicsHandle.IconID)) { return(false); } if (this.ID.IconDynamicsHandle.isDynaffType()) { // 強弱記号 } else { // クレッシェンド・デクレッシェンド if (this.ID.getLength() != item.ID.getLength()) { return(false); } } } return(true); }
protected IconParameter(string file) { if (file == null) { return; } if (file == "") { return; } StreamReader sr = null; try { sr = new StreamReader(file, Encoding.GetEncoding("Shift_JIS")); string line = ""; string strDynBPNum = ""; string strDynBPX = ""; string strDynBPY = ""; string strDepthBPNum = ""; string strDepthBPX = ""; string strDepthBPY = ""; string strRateBPNum = ""; string strRateBPX = ""; string strRateBPY = ""; while ((line = sr.ReadLine()) != null) { // コメントを除去する int indx_colon = line.IndexOf(';'); if (indx_colon >= 0) { line = line.Substring(0, indx_colon); } // セクション名の指定行 if (line.StartsWith("[")) { continue; } // イコールが含まれているかどうか string[] spl = PortUtil.splitString(line, new char[] { '=' }, 2); if (spl.Length != 2) { continue; } string name = spl[0].Trim(); // new char[]{ ' ', '\t' } ); string value = spl[1].Trim(); // new char[]{ ' ', '\t' } ); if (name == "Articulation") { if (value == "Vibrato") { articulation = ArticulationType.Vibrato; } else if (value == "Crescendo") { articulation = ArticulationType.Crescendo; } else if (value == "Dynaff") { articulation = ArticulationType.Dynaff; } else if (value == "NoteAttack") { articulation = ArticulationType.NoteAttack; } else if (value == "NoteTransition") { articulation = ArticulationType.NoteTransition; } } else if (name == "Button") { button = value; } else if (name == "Caption") { caption = value; } else if (name == "Length") { try { length = int.Parse(value); } catch (Exception ex) { serr.println("org.kbinani.vsq.IconParameter#.ctor; ex=" + ex); } } else if (name == "StartDepth") { try { startDepth = int.Parse(value); } catch (Exception ex) { serr.println("org.kbinani.vsq.IconParameter#.ctor; ex=" + ex); } } else if (name == "EndDepth") { try { endDepth = int.Parse(value); } catch (Exception ex) { serr.println("org.kbinani.vsq.IconParameter#.ctor; ex=" + ex); } } else if (name == "StartRate") { try { startRate = int.Parse(value); } catch (Exception ex) { serr.println("org.kbinani.vsq.IconParameter#.ctor; ex=" + ex); } } else if (name == "EndRate") { try { endRate = int.Parse(value); } catch (Exception ex) { serr.println("org.kbinani.vsq.IconParameter#.ctor; ex=" + ex); } } else if (name == "StartDyn") { try { startDyn = int.Parse(value); } catch (Exception ex) { serr.println("org.kbinani.vsq.IconParameter#.ctor; ex=" + ex); } } else if (name == "EndDyn") { try { endDyn = int.Parse(value); } catch (Exception ex) { serr.println("org.kbinani.vsq.IconParameter#.ctor; ex=" + ex); } } else if (name == "Duration") { try { duration = int.Parse(value); } catch (Exception ex) { serr.println("org.kbinani.vsq.IconParameter#.ctor; ex=" + ex); } } else if (name == "Depth") { try { depth = int.Parse(value); } catch (Exception ex) { serr.println("org.kbinani.vsq.IconParameter#.ctor; ex=" + ex); } } else if (name == "DynBPNum") { strDynBPNum = value; } else if (name == "DynBPX") { strDynBPX = value; } else if (name == "DynBPY") { strDynBPY = value; } else if (name == "DepthBPNum") { strDepthBPNum = value; } else if (name == "DepthBPX") { strDepthBPX = value; } else if (name == "DepthBPY") { strDepthBPY = value; } else if (name == "RateBPNum") { strRateBPNum = value; } else if (name == "RateBPX") { strRateBPX = value; } else if (name == "RateBPY") { strRateBPY = value; } } dynBP = getBPListFromText(strDynBPNum, strDynBPX, strDynBPY); rateBP = getBPListFromText(strRateBPNum, strRateBPX, strRateBPY); depthBP = getBPListFromText(strDepthBPNum, strDepthBPX, strDepthBPY); } catch (Exception ex) { serr.println("org.kbinani.vsq.IconParameter#.ctor; ex=" + ex); } finally { if (sr != null) { try { sr.Close(); } catch (Exception ex2) { } } } }
public void setDepthBP(VibratoBPList value) { depthBP = value; }
public void setRateBP(VibratoBPList value) { rateBP = value; }
/// <summary> /// FileStreamから読み込みながらコンストラクト /// </summary> /// <param name="sr">読み込み対象</param> public VsqHandle(TextStream sr, int value, ByRef <string> last_line) { this.Index = value; string[] spl; string[] spl2; // default値で梅 m_type = VsqHandleType.Vibrato; IconID = ""; IDS = "normal"; L0 = new Lyric(""); Original = 0; Caption = ""; Length = 0; StartDepth = 0; DepthBP = null; StartRate = 0; RateBP = null; Language = 0; Program = 0; Duration = 0; Depth = 64; string tmpDepthBPX = ""; string tmpDepthBPY = ""; string tmpDepthBPNum = ""; string tmpRateBPX = ""; string tmpRateBPY = ""; string tmpRateBPNum = ""; string tmpDynBPX = ""; string tmpDynBPY = ""; string tmpDynBPNum = ""; // "["にぶち当たるまで読込む last_line.value = sr.readLine().ToString(); while (!last_line.value.StartsWith("[")) { spl = PortUtil.splitString(last_line.value, new char[] { '=' }); string search = spl[0]; if (search.Equals("Language")) { m_type = VsqHandleType.Singer; Language = int.Parse(spl[1]); } else if (search.Equals("Program")) { Program = int.Parse(spl[1]); } else if (search.Equals("IconID")) { IconID = spl[1]; } else if (search.Equals("IDS")) { IDS = spl[1]; } else if (search.Equals("Original")) { Original = int.Parse(spl[1]); } else if (search.Equals("Caption")) { Caption = spl[1]; for (int i = 2; i < spl.Length; i++) { Caption += "=" + spl[i]; } } else if (search.Equals("Length")) { Length = int.Parse(spl[1]); } else if (search.Equals("StartDepth")) { StartDepth = int.Parse(spl[1]); } else if (search.Equals("DepthBPNum")) { tmpDepthBPNum = spl[1]; } else if (search.Equals("DepthBPX")) { tmpDepthBPX = spl[1]; } else if (search.Equals("DepthBPY")) { tmpDepthBPY = spl[1]; } else if (search.Equals("StartRate")) { m_type = VsqHandleType.Vibrato; StartRate = int.Parse(spl[1]); } else if (search.Equals("RateBPNum")) { tmpRateBPNum = spl[1]; } else if (search.Equals("RateBPX")) { tmpRateBPX = spl[1]; } else if (search.Equals("RateBPY")) { tmpRateBPY = spl[1]; } else if (search.Equals("Duration")) { m_type = VsqHandleType.NoteHeadHandle; Duration = int.Parse(spl[1]); } else if (search.Equals("Depth")) { Depth = int.Parse(spl[1]); } else if (search.Equals("StartDyn")) { m_type = VsqHandleType.DynamicsHandle; StartDyn = int.Parse(spl[1]); } else if (search.Equals("EndDyn")) { m_type = VsqHandleType.DynamicsHandle; EndDyn = int.Parse(spl[1]); } else if (search.Equals("DynBPNum")) { tmpDynBPNum = spl[1]; } else if (search.Equals("DynBPX")) { tmpDynBPX = spl[1]; } else if (search.Equals("DynBPY")) { tmpDynBPY = spl[1]; } else if (search.StartsWith("L") && PortUtil.getStringLength(search) >= 2) { string num = search.Substring(1); ByRef <int> vals = new ByRef <int>(0); if (PortUtil.tryParseInt(num, vals)) { Lyric lyric = new Lyric(spl[1]); m_type = VsqHandleType.Lyric; int index = vals.value; if (index == 0) { L0 = lyric; } else { if (Trailing.Count < index) { for (int i = Trailing.Count; i < index; i++) { Trailing.Add(new Lyric("a", "a")); } } Trailing[index - 1] = lyric; } } } if (!sr.ready()) { break; } last_line.value = sr.readLine().ToString(); } // RateBPX, RateBPYの設定 if (m_type == VsqHandleType.Vibrato) { if (!tmpRateBPNum.Equals("")) { RateBP = new VibratoBPList(tmpRateBPNum, tmpRateBPX, tmpRateBPY); } else { RateBP = new VibratoBPList(); } // DepthBPX, DepthBPYの設定 if (!tmpDepthBPNum.Equals("")) { DepthBP = new VibratoBPList(tmpDepthBPNum, tmpDepthBPX, tmpDepthBPY); } else { DepthBP = new VibratoBPList(); } } else { DepthBP = new VibratoBPList(); RateBP = new VibratoBPList(); } if (!tmpDynBPNum.Equals("")) { DynBP = new VibratoBPList(tmpDynBPNum, tmpDynBPX, tmpDynBPY); } else { DynBP = new VibratoBPList(); } }
/// <summary> /// クレッシェンド,デクレッシェンド,および強弱記号をダイナミクスカーブに反映させます. /// この操作によって,ダイナミクスカーブに設定されたデータは全て削除されます. /// </summary> public void reflectDynamics() { VsqBPList dyn = getCurve("dyn"); dyn.clear(); for (Iterator <VsqEvent> itr = getDynamicsEventIterator(); itr.hasNext();) { VsqEvent item = itr.next(); IconDynamicsHandle handle = item.ID.IconDynamicsHandle; if (handle == null) { continue; } int clock = item.Clock; int length = item.ID.getLength(); if (handle.isDynaffType()) { // 強弱記号 dyn.add(clock, handle.getStartDyn()); } else { // クレッシェンド,デクレッシェンド int start_dyn = dyn.getValue(clock); // 範囲内のアイテムを削除 int count = dyn.size(); for (int i = count - 1; i >= 0; i--) { int c = dyn.getKeyClock(i); if (clock <= c && c <= clock + length) { dyn.removeElementAt(i); } else if (c < clock) { break; } } VibratoBPList bplist = handle.getDynBP(); if (bplist == null || (bplist != null && bplist.getCount() <= 0)) { // カーブデータが無い場合 double a = 0.0; if (length > 0) { a = (handle.getEndDyn() - handle.getStartDyn()) / (double)length; } int last_val = start_dyn; for (int i = clock; i < clock + length; i++) { int val = start_dyn + (int)(a * (i - clock)); if (val < dyn.getMinimum()) { val = dyn.getMinimum(); } else if (dyn.getMaximum() < val) { val = dyn.getMaximum(); } if (last_val != val) { dyn.add(i, val); last_val = val; } } } else { // カーブデータがある場合 int last_val = handle.getStartDyn(); int last_clock = clock; int bpnum = bplist.getCount(); int last = start_dyn; // bplistに指定されている分のデータ点を追加 for (int i = 0; i < bpnum; i++) { VibratoBPPair point = bplist.getElement(i); int pointClock = clock + (int)(length * point.X); if (pointClock <= last_clock) { continue; } int pointValue = point.Y; double a = (pointValue - last_val) / (double)(pointClock - last_clock); for (int j = last_clock; j <= pointClock; j++) { int val = start_dyn + (int)((j - last_clock) * a); if (val < dyn.getMinimum()) { val = dyn.getMinimum(); } else if (dyn.getMaximum() < val) { val = dyn.getMaximum(); } if (val != last) { dyn.add(j, val); last = val; } } last_val = point.Y; last_clock = pointClock; } // bplistの末尾から,clock => clock + lengthまでのデータ点を追加 int last2 = last; if (last_clock < clock + length) { double a = (handle.getEndDyn() - last_val) / (double)(clock + length - last_clock); for (int j = last_clock; j < clock + length; j++) { int val = last2 + (int)((j - last_clock) * a); if (val < dyn.getMinimum()) { val = dyn.getMinimum(); } else if (dyn.getMaximum() < val) { val = dyn.getMaximum(); } if (val != last) { dyn.add(j, val); last = val; } } } } } } }
/// <summary> /// DYNカーブを表すリストを設定します。 /// </summary> /// <param name="value"></param> public void setDynBP(VibratoBPList value) { dynBP = value; }