/// <summary> /// FileStreamから読み込みながらコンストラクト /// </summary> /// <param name="sr">読み込み対象</param> public VsqHandle(TextMemoryStream sr, int value, StringBuilder last_line) { try { 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; int depth_bp_num = 0; startRate = 0; rateBP = null; int rate_bp_num = 0; language = 0; program = 0; duration = 0; depth = 64; String tmpDepthBPX = ""; String tmpDepthBPY = ""; String tmpRateBPX = ""; String tmpRateBPY = ""; // "["にぶち当たるまで読込む last_line.setLength(0); last_line.append(sr.readLine()); while (!last_line.toString().startsWith("[")) { spl = Misc.splitString(last_line.toString(), "="); if (spl[0].equals("Language")) { m_type = VsqHandleType.Singer; language = Integer.parseInt(spl[1]); } else if (spl[0].equals("Program")) { program = Integer.parseInt(spl[1]); } else if (spl[0].equals("IconID")) { iconID = spl[1]; } else if (spl[0].equals("IDS")) { IDS = spl[1]; } else if (spl[0].equals("Original")) { original = Integer.parseInt(spl[1]); } else if (spl[0].equals("Caption")) { caption = spl[1]; for (int i = 2; i < spl.length; i++) { caption += "=" + spl[i]; } } else if (spl[0].equals("Length")) { length = Integer.parseInt(spl[1]); } else if (spl[0].equals("StartDepth")) { startDepth = Integer.parseInt(spl[1]); } else if (spl[0].equals("DepthBPNum")) { depth_bp_num = Integer.parseInt(spl[1]); } else if (spl[0].equals("DepthBPX")) { tmpDepthBPX = spl[1]; } else if (spl[0].equals("DepthBPY")) { tmpDepthBPY = spl[1]; } else if (spl[0].equals("StartRate")) { m_type = VsqHandleType.Vibrato; startRate = Integer.parseInt(spl[1]); } else if (spl[0].equals("RateBPNum")) { rate_bp_num = Integer.parseInt(spl[1]); } else if (spl[0].equals("RateBPX")) { tmpRateBPX = spl[1]; } else if (spl[0].equals("RateBPY")) { tmpRateBPY = spl[1]; } else if (spl[0].equals("L0")) { m_type = VsqHandleType.Lyric; L0 = new Lyric(spl[1]); } else if (spl[0].equals("Duration")) { m_type = VsqHandleType.NoteHeadHandle; duration = Integer.parseInt(spl[1]); } else if (spl[0].equals("Depth")) { duration = Integer.parseInt(spl[1]); } if (sr.peek() < 0) { break; } last_line.setLength(0); last_line.append(sr.readLine()); } /*if ( IDS != "normal" ) { m_type = VsqHandleType.Singer; } else if ( IconID != "" ) { m_type = VsqHandleType.Vibrato; } else { m_type = VsqHandleType.Lyric; }*/ // RateBPX, RateBPYの設定 if (m_type == VsqHandleType.Vibrato) { if (rate_bp_num > 0) { float[] rate_bp_x = new float[rate_bp_num]; spl2 = tmpRateBPX.split(","); for (int i = 0; i < rate_bp_num; i++) { rate_bp_x[i] = Float.parseFloat(spl2[i]); } int[] rate_bp_y = new int[rate_bp_num]; spl2 = tmpRateBPY.split(","); for (int i = 0; i < rate_bp_num; i++) { rate_bp_y[i] = Integer.parseInt(spl2[i]); } rateBP = new VibratoBPList(rate_bp_x, rate_bp_y); } else { // m_rate_bp_x = null; // m_rate_bp_y = null; rateBP = new VibratoBPList(); } // DepthBPX, DepthBPYの設定 if (depth_bp_num > 0) { float[] depth_bp_x = new float[depth_bp_num]; spl2 = tmpDepthBPX.split(","); for (int i = 0; i < depth_bp_num; i++) { depth_bp_x[i] = Float.parseFloat(spl2[i]); } int[] depth_bp_y = new int[depth_bp_num]; spl2 = tmpDepthBPY.split(","); for (int i = 0; i < depth_bp_num; i++) { depth_bp_y[i] = Integer.parseInt(spl2[i]); } depthBP = new VibratoBPList(depth_bp_x, depth_bp_y); } else { depthBP = new VibratoBPList(); // m_depth_bp_x = null; // m_depth_bp_y = null; } } else { depthBP = new VibratoBPList(); rateBP = new VibratoBPList(); } } catch (Exception ex) { System.out.println("VsqHandle(TextMemoryStream,int,StringBuilder); ex=" + ex); } }
/// <summary> /// インスタンスをストリームに書き込みます。 /// encode=trueの場合、2バイト文字をエンコードして出力します。 /// </summary> /// <param name="sw">書き込み対象</param> /// <param name="encode">2バイト文字をエンコードするか否かを指定するフラグ</param> public void write(TextMemoryStream sw, boolean encode) { sw.writeLine(this.toString(encode)); }