git-svn-id: http://svn.sourceforge.jp/svnroot/lipsync@6 b1f601f4-4f45-0410-8980-aecacb008692

This commit is contained in:
kbinani
2009-06-25 14:16:22 +00:00
parent 775d25e7fa
commit 90d1578878
373 changed files with 111302 additions and 0 deletions

View File

@@ -0,0 +1,149 @@
/*
* VsqMetaText/Common.cs
* Copyright (c) 2008-2009 kbinani
*
* This file is part of Boare.Lib.Vsq.
*
* Boare.Lib.Vsq is free software; you can redistribute it and/or
* modify it under the terms of the BSD License.
*
* Boare.Lib.Vsq is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*/
using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.Drawing;
namespace Boare.Lib.Vsq {
/// <summary>
/// vsqファイルのメタテキストの[Common]セクションに記録される内容を取り扱う
/// </summary>
[Serializable]
public class VsqCommon : ICloneable {
public string Version;
public string Name;
public string Color;
public int DynamicsMode;
public int PlayMode;
public object Clone() {
string[] spl = Color.Split( ",".ToCharArray(), 3 );
int r = int.Parse( spl[0] );
int g = int.Parse( spl[1] );
int b = int.Parse( spl[2] );
System.Drawing.Color color = System.Drawing.Color.FromArgb( r, g, b );
VsqCommon res = new VsqCommon( Name, color, DynamicsMode, PlayMode );
res.Version = Version;
return res;
}
/// <summary>
/// 各パラメータを指定したコンストラクタ
/// </summary>
/// <param name="name">トラック名</param>
/// <param name="color">Color値意味は不明</param>
/// <param name="dynamics_mode">DynamicsModeデフォルトは1</param>
/// <param name="play_mode">PlayModeデフォルトは1</param>
public VsqCommon( string name, Color color, int dynamics_mode, int play_mode ) {
this.Version = "DSB301";
this.Name = name;
this.Color = color.R + "," + color.G + "," + color.B;
this.DynamicsMode = dynamics_mode;
this.PlayMode = play_mode;
}
/// <summary>
/// MetaTextのテキストファイルからのコンストラクタ
/// </summary>
/// <param name="sr">読み込むテキストファイル</param>
/// <param name="last_line">読み込んだ最後の行が返される</param>
public VsqCommon( TextMemoryStream sr, ref string last_line ) {
Version = "";
Name = "";
Color = "0,0,0";
DynamicsMode = 0;
PlayMode = 0;
last_line = sr.readLine();
string[] spl;
while ( !last_line.StartsWith( "[" ) ) {
spl = last_line.Split( new char[] { '=' } );
switch ( spl[0] ) {
case "Version":
this.Version = spl[1];
break;
case "Name":
this.Name = spl[1];
break;
case "Color":
this.Color = spl[1];
break;
case "DynamicsMode":
this.DynamicsMode = int.Parse( spl[1] );
break;
case "PlayMode":
this.PlayMode = int.Parse( spl[1] );
break;
}
if ( sr.peek() < 0 ) {
break;
}
last_line = sr.readLine();
}
}
/// <summary>
/// インスタンスの内容をテキストファイルに出力します
/// </summary>
/// <param name="sw">出力先</param>
public void write( TextMemoryStream sw ) {
sw.writeLine( "[Common]" );
sw.writeLine( "Version=" + Version );
sw.writeLine( "Name=" + Name );
sw.writeLine( "Color=" + Color );
sw.writeLine( "DynamicsMode=" + DynamicsMode );
sw.writeLine( "PlayMode=" + PlayMode );
}
/// <summary>
/// VsqCommon構造体を構築するテストを行います
/// </summary>
/// <returns>テストに成功すればtrue、そうでなければfalse</returns>
public static bool test() {
string fpath = Path.GetTempFileName();
StreamWriter sw = new StreamWriter( fpath, false, Encoding.Unicode );
sw.WriteLine( "Version=DSB301" );
sw.WriteLine( "Name=Voice1" );
sw.WriteLine( "Color=181,162,123" );
sw.WriteLine( "DynamicsMode=1" );
sw.WriteLine( "PlayMode=1" );
sw.WriteLine( "[Master]" );
sw.Close();
VsqCommon vsqCommon;
string last_line = "";
using ( TextMemoryStream sr = new TextMemoryStream( fpath, Encoding.Unicode ) ) {
vsqCommon = new VsqCommon( sr, ref last_line );
}
bool result;
if ( vsqCommon.Version == "DSB301" &&
vsqCommon.Name == "Voice1" &&
vsqCommon.Color == "181,162,123" &&
vsqCommon.DynamicsMode == 1 &&
vsqCommon.PlayMode == 1 &&
last_line == "[Master]" ) {
result = true;
} else {
result = false;
}
File.Delete( fpath );
return result;
}
}
}

View File

@@ -0,0 +1,151 @@
/*
* VsqMetaText/Common.cs
* Copyright (c) 2008 kbinani
*
* This file is part of Boare.Lib.Vsq.
*
* Boare.Lib.Vsq is free software; you can redistribute it and/or
* modify it under the terms of the BSD License.
*
* Boare.Lib.Vsq is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*/
/*using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.Drawing;*/
package com.boare.vsq;
/// <summary>
/// vsq<73>t<EFBFBD>@<40>C<EFBFBD><43><EFBFBD>̃<EFBFBD><CC83>^<5E>e<EFBFBD>L<EFBFBD>X<EFBFBD>g<EFBFBD><67>[Common]<5D>Z<EFBFBD>N<EFBFBD>V<EFBFBD><56><EFBFBD><EFBFBD><EFBFBD>ɋL<C98B>^<5E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>e<EFBFBD><65><EFBFBD><EFBFBD><EFBFBD><EFBFBD><E888B5>
/// </summary>
public class VsqCommon implements Cloneable {
public String Version;
public String Name;
public String Color;
public int DynamicsMode;
public int PlayMode;
public Object clone() {
String[] spl = Color.Split( ",".ToCharArray(), 3 );
int r = Integer.parseInt( spl[0] );
int g = Integer.parseInt( spl[1] );
int b = Integer.parseInt( spl[2] );
System.Drawing.Color color = System.Drawing.Color.FromArgb( r, g, b );
VsqCommon res = new VsqCommon( Name, color, DynamicsMode, PlayMode );
res.Version = Version;
return res;
}
/// <summary>
/// <20>e<EFBFBD>p<EFBFBD><70><EFBFBD><EFBFBD><EFBFBD>[<5B>^<5E><><EFBFBD>w<EFBFBD><EFBFBD><E882B5><EFBFBD>R<EFBFBD><52><EFBFBD>X<EFBFBD>g<EFBFBD><67><EFBFBD>N<EFBFBD>^
/// </summary>
/// <param name="name"><3E>g<EFBFBD><67><EFBFBD>b<EFBFBD>N<EFBFBD><4E></param>
/// <param name="color">Color<6F>l<EFBFBD>i<EFBFBD>Ӗ<EFBFBD><D396>͕s<CD95><73><EFBFBD>j</param>
/// <param name="dynamics_mode">DynamicsMode<64>i<EFBFBD>f<EFBFBD>t<EFBFBD>H<EFBFBD><48><EFBFBD>g<EFBFBD><67>1<EFBFBD>j</param>
/// <param name="play_mode">PlayMode<64>i<EFBFBD>f<EFBFBD>t<EFBFBD>H<EFBFBD><48><EFBFBD>g<EFBFBD><67>1<EFBFBD>j</param>
public VsqCommon( string name, Color color, int dynamics_mode, int play_mode ) {
this.Version = "DSB301";
this.Name = name;
this.Color = color.R + "," + color.G + "," + color.B;
this.DynamicsMode = dynamics_mode;
this.PlayMode = play_mode;
}
/// <summary>
/// MetaText<78>̃e<CC83>L<EFBFBD>X<EFBFBD>g<EFBFBD>t<EFBFBD>@<40>C<EFBFBD><43><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>̃R<CC83><52><EFBFBD>X<EFBFBD>g<EFBFBD><67><EFBFBD>N<EFBFBD>^
/// </summary>
/// <param name="sr"><3E>ǂݍ<C782><DD8D>ރe<DE83>L<EFBFBD>X<EFBFBD>g<EFBFBD>t<EFBFBD>@<40>C<EFBFBD><43></param>
/// <param name="last_line"><3E>ǂݍ<C782><DD8D>񂾍Ō<F182BE8D><C58C>̍s<CC8D><73><EFBFBD>Ԃ<EFBFBD><D482><EFBFBD><EFBFBD><EFBFBD></param>
public VsqCommon( TextMemoryStream sr, ref string last_line ) {
Version = "";
Name = "";
Color = "0,0,0";
DynamicsMode = 0;
PlayMode = 0;
last_line = sr.ReadLine();
string[] spl;
while ( !last_line.StartsWith( "[" ) ) {
spl = last_line.Split( new char[] { '=' } );
switch ( spl[0] ) {
case "Version":
this.Version = spl[1];
break;
case "Name":
this.Name = spl[1];
break;
case "Color":
this.Color = spl[1];
break;
case "DynamicsMode":
this.DynamicsMode = Integer.parseInt( spl[1] );
break;
case "PlayMode":
this.PlayMode = Integer.parseInt( spl[1] );
break;
}
if ( sr.Peek() < 0 ) {
break;
}
last_line = sr.ReadLine();
}
}
/// <summary>
/// <20>C<EFBFBD><43><EFBFBD>X<EFBFBD>^<5E><><EFBFBD>X<EFBFBD>̓<EFBFBD><CC93>e<EFBFBD><65><EFBFBD>e<EFBFBD>L<EFBFBD>X<EFBFBD>g<EFBFBD>t<EFBFBD>@<40>C<EFBFBD><43><EFBFBD>ɏo<C98F>͂<EFBFBD><CD82>܂<EFBFBD>
/// </summary>
/// <param name="sw"><3E>o<EFBFBD>͐<EFBFBD></param>
public void write( TextMemoryStream sw ) {
sw.WriteLine( "[Common]" );
sw.WriteLine( "Version=" + Version );
sw.WriteLine( "Name=" + Name );
sw.WriteLine( "Color=" + Color );
sw.WriteLine( "DynamicsMode=" + DynamicsMode );
sw.WriteLine( "PlayMode=" + PlayMode );
}
/// <summary>
/// VsqCommon<6F>\<5C><><EFBFBD>̂<EFBFBD><CC82>\<5C>z<EFBFBD><7A><EFBFBD><EFBFBD><EFBFBD>e<EFBFBD>X<EFBFBD>g<EFBFBD><67><EFBFBD>s<EFBFBD><73><EFBFBD>܂<EFBFBD>
/// </summary>
/// <returns><3E>e<EFBFBD>X<EFBFBD>g<EFBFBD>ɐ<EFBFBD><C990><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>true<75>A<EFBFBD><41><EFBFBD><EFBFBD><EFBFBD>łȂ<C582><C882><EFBFBD><EFBFBD><EFBFBD>false</returns>
public static bool test() {
string fpath = Path.GetTempFileName();
StreamWriter sw = new StreamWriter( fpath, false, Encoding.Unicode );
sw.WriteLine( "Version=DSB301" );
sw.WriteLine( "Name=Voice1" );
sw.WriteLine( "Color=181,162,123" );
sw.WriteLine( "DynamicsMode=1" );
sw.WriteLine( "PlayMode=1" );
sw.WriteLine( "[Master]" );
sw.Close();
VsqCommon vsqCommon;
string last_line = "";
using ( TextMemoryStream sr = new TextMemoryStream( fpath, Encoding.Unicode ) ) {
vsqCommon = new VsqCommon( sr, ref last_line );
}
bool result;
if ( vsqCommon.Version == "DSB301" &&
vsqCommon.Name == "Voice1" &&
vsqCommon.Color == "181,162,123" &&
vsqCommon.DynamicsMode == 1 &&
vsqCommon.PlayMode == 1 &&
last_line == "[Master]" ) {
result = true;
} else {
result = false;
}
File.Delete( fpath );
return result;
}
}

View File

@@ -0,0 +1,448 @@
/*
* VsqMetaText/Handle.cs
* Copyright (c) 2008-2009 kbinani
*
* This file is part of Boare.Lib.Vsq.
*
* Boare.Lib.Vsq is free software; you can redistribute it and/or
* modify it under the terms of the BSD License.
*
* Boare.Lib.Vsq is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*/
using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
namespace Boare.Lib.Vsq {
[Serializable]
public class IconHandle : ICloneable {
public string Caption;
public string IconID;
public string IDS;
public int Index;
public int Length;
public int Original;
public int Program;
public int Language;
public object Clone() {
IconHandle ret = new IconHandle();
ret.Caption = Caption;
ret.IconID = IconID;
ret.IDS = IDS;
ret.Index = Index;
ret.Language = Language;
ret.Length = Length;
ret.Original = Original;
ret.Program = Program;
return ret;
}
public VsqHandle castToVsqHandle() {
VsqHandle ret = new VsqHandle();
ret.m_type = VsqHandleType.Singer;
ret.Caption = Caption;
ret.IconID = IconID;
ret.IDS = IDS;
ret.Index = Index;
ret.Language = Language;
ret.Length = Length;
ret.Program = Program;
return ret;
}
}
[Serializable]
public class LyricHandle : ICloneable {
public Lyric L0;
public int Index;
internal LyricHandle() {
}
/// <summary>
/// type = Lyric用のhandleのコンストラクタ
/// </summary>
/// <param name="phrase">歌詞</param>
/// <param name="phonetic_symbol">発音記号</param>
public LyricHandle( string phrase, string phonetic_symbol ) {
L0 = new Lyric( phrase, phonetic_symbol );
}
public object Clone() {
LyricHandle ret = new LyricHandle();
ret.Index = Index;
ret.L0 = (Lyric)L0.Clone();
return ret;
}
public VsqHandle castToVsqHandle() {
VsqHandle ret = new VsqHandle();
ret.m_type = VsqHandleType.Lyric;
ret.L0 = (Lyric)L0.Clone();
ret.Index = Index;
return ret;
}
}
[Serializable]
public class VibratoHandle : ICloneable {
public int StartDepth;
public VibratoBPList DepthBP;
public int StartRate;
public VibratoBPList RateBP;
public int Index;
public string IconID;
public string IDS;
public int Original;
public string Caption;
public int Length;
public VibratoHandle(){
RateBP = new VibratoBPList();
DepthBP = new VibratoBPList();
}
public object Clone() {
VibratoHandle result = new VibratoHandle();
result.Index = Index;
result.IconID = IconID;
result.IDS = this.IDS;
result.Original = this.Original;
result.Caption = this.Caption;
result.Length = this.Length;
result.StartDepth = this.StartDepth;
result.DepthBP = (VibratoBPList)DepthBP.Clone();
result.StartRate = this.StartRate;
result.RateBP = (VibratoBPList)RateBP.Clone();
return result;
}
public VsqHandle castToVsqHandle() {
VsqHandle ret = new VsqHandle();
ret.m_type = VsqHandleType.Vibrato;
ret.Index = Index;
ret.IconID = IconID;
ret.IDS = IDS;
ret.Original = Original;
ret.Caption = Caption;
ret.Length = Length;
ret.StartDepth = StartDepth;
ret.StartRate = StartRate;
ret.DepthBP = (VibratoBPList)DepthBP.Clone();
ret.RateBP = (VibratoBPList)RateBP.Clone();
return ret;
}
}
/// <summary>
/// ハンドルを取り扱います。ハンドルにはLyricHandle、VibratoHandleおよびIconHandleがある
/// </summary>
[Serializable]
public class VsqHandle {
public VsqHandleType m_type;
public int Index;
public string IconID;
public string IDS;
public Lyric L0;
public int Original;
public string Caption;
public int Length;
public int StartDepth;
public VibratoBPList DepthBP;
public int StartRate;
public VibratoBPList RateBP;
public int Language;
public int Program;
public LyricHandle castToLyricHandle() {
LyricHandle ret = new LyricHandle();
ret.L0 = (Lyric)L0;
ret.Index = Index;
return ret;
}
public VibratoHandle castToVibratoHandle() {
VibratoHandle ret = new VibratoHandle();
ret.Index = Index;
ret.Caption = Caption;
ret.DepthBP = (VibratoBPList)DepthBP.Clone();
ret.IconID = IconID;
ret.IDS = IDS;
ret.Index = Index;
ret.Length = Length;
ret.Original = Original;
ret.RateBP = (VibratoBPList)RateBP.Clone();
ret.StartDepth = StartDepth;
ret.StartRate = StartRate;
return ret;
}
public IconHandle castToIconHandle() {
IconHandle ret = new IconHandle();
ret.Index = Index;
ret.Caption = Caption;
ret.IconID = IconID;
ret.IDS = IDS;
ret.Index = Index;
ret.Language = Language;
ret.Length = Length;
ret.Original = Original;
ret.Program = Program;
return ret;
}
internal VsqHandle() {
}
/// <summary>
/// インスタンスをストリームに書き込みます。
/// encode=trueの場合、2バイト文字をエンコードして出力します。
/// </summary>
/// <param name="sw">書き込み対象</param>
/// <param name="encode">2バイト文字をエンコードするか否かを指定するフラグ</param>
public void write( TextMemoryStream sw, bool encode ) {
sw.writeLine( this.ToString( encode ) );
}
/// <summary>
/// FileStreamから読み込みながらコンストラクト
/// </summary>
/// <param name="sr">読み込み対象</param>
public VsqHandle( TextMemoryStream sr, int value, ref 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;
int depth_bp_num = 0;
StartRate = 0;
RateBP = null;
int rate_bp_num = 0;
Language = 0;
Program = 0;
string tmpDepthBPX = "";
string tmpDepthBPY = "";
string tmpRateBPX = "";
string tmpRateBPY = "";
// "["にぶち当たるまで読込む
last_line = sr.readLine();
while ( !last_line.StartsWith( "[" ) ) {
spl = last_line.Split( new char[] { '=' } );
switch ( spl[0] ) {
case "Language":
Language = int.Parse( spl[1] );
break;
case "Program":
Program = int.Parse( spl[1] );
break;
case "IconID":
IconID = spl[1];
break;
case "IDS":
IDS = spl[1];
break;
case "Original":
Original = int.Parse( spl[1] );
break;
case "Caption":
Caption = spl[1];
for ( int i = 2; i < spl.Length; i++ ) {
Caption += "=" + spl[i];
}
break;
case "Length":
Length = int.Parse( spl[1] );
break;
case "StartDepth":
StartDepth = int.Parse( spl[1] );
break;
case "DepthBPNum":
depth_bp_num = int.Parse( spl[1] );
break;
case "DepthBPX":
tmpDepthBPX = spl[1];
break;
case "DepthBPY":
tmpDepthBPY = spl[1];
break;
case "StartRate":
StartRate = int.Parse( spl[1] );
break;
case "RateBPNum":
rate_bp_num = int.Parse( spl[1] );
break;
case "RateBPX":
tmpRateBPX = spl[1];
break;
case "RateBPY":
tmpRateBPY = spl[1];
break;
case "L0":
m_type = VsqHandleType.Lyric;
L0 = new Lyric( spl[1] );
break;
}
if ( sr.peek() < 0 ) {
break;
}
last_line = 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( new char[] { ',' } );
for ( int i = 0; i < rate_bp_num; i++ ) {
rate_bp_x[i] = float.Parse( spl2[i] );
}
int[] rate_bp_y = new int[rate_bp_num];
spl2 = tmpRateBPY.Split( new char[] { ',' } );
for ( int i = 0; i < rate_bp_num; i++ ) {
rate_bp_y[i] = int.Parse( 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( new char[] { ',' } );
for ( int i = 0; i < depth_bp_num; i++ ) {
depth_bp_x[i] = float.Parse( spl2[i] );
}
int[] depth_bp_y = new int[depth_bp_num];
spl2 = tmpDepthBPY.Split( new char[] { ',' } );
for ( int i = 0; i < depth_bp_num; i++ ) {
depth_bp_y[i] = int.Parse( 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();
}
}
/// <summary>
/// ハンドル指定子(例えば"h#0123"という文字列)からハンドル番号を取得します
/// </summary>
/// <param name="_string">ハンドル指定子</param>
/// <returns>ハンドル番号</returns>
public static int HandleIndexFromString( string _string ) {
string[] spl = _string.Split( new char[] { '#' } );
return int.Parse( spl[1] );
}
/// <summary>
/// インスタンスをテキストファイルに出力します
/// </summary>
/// <param name="sw">出力先</param>
public void Print( StreamWriter sw ) {
string result = this.ToString();
sw.WriteLine( result );
}
/// <summary>
/// インスタンスをコンソール画面に出力します
/// </summary>
private void Print() {
string result = this.ToString();
Console.WriteLine( result );
}
/// <summary>
/// インスタンスを文字列に変換します
/// </summary>
/// <param name="encode">2バイト文字をエンコードするか否かを指定するフラグ</param>
/// <returns>インスタンスを変換した文字列</returns>
public string ToString( bool encode ) {
string result = "";
result += "[h#" + Index.ToString( "0000" ) + "]";
switch ( m_type ) {
case VsqHandleType.Lyric:
result += Environment.NewLine + "L0=" + L0.ToString( encode );
break;
case VsqHandleType.Vibrato:
result += Environment.NewLine + "IconID=" + IconID + Environment.NewLine;
result += "IDS=" + IDS + Environment.NewLine;
result += "Original=" + Original + Environment.NewLine;
result += "Caption=" + Caption + Environment.NewLine;
result += "Length=" + Length + Environment.NewLine;
result += "StartDepth=" + StartDepth + Environment.NewLine;
result += "DepthBPNum=" + DepthBP.getCount() + Environment.NewLine;
if ( DepthBP.getCount() > 0 ) {
result += "DepthBPX=" + DepthBP.getElement( 0 ).X.ToString( "0.000000" );
for ( int i = 1; i < DepthBP.getCount(); i++ ) {
result += "," + DepthBP.getElement( i ).X.ToString( "0.000000" );
}
result += Environment.NewLine + "DepthBPY=" + DepthBP.getElement( 0 ).Y;
for ( int i = 1; i < DepthBP.getCount(); i++ ) {
result += "," + DepthBP.getElement( i ).Y;
}
result += Environment.NewLine;
}
result += "StartRate=" + StartRate + Environment.NewLine;
result += "RateBPNum=" + RateBP.getCount();
if ( RateBP.getCount() > 0 ) {
result += Environment.NewLine + "RateBPX=" + RateBP.getElement( 0 ).X.ToString( "0.000000" );
for ( int i = 1; i < RateBP.getCount(); i++ ) {
result += "," + RateBP.getElement( i ).X.ToString( "0.000000" );
}
result += Environment.NewLine + "RateBPY=" + RateBP.getElement( 0 ).Y;
for ( int i = 1; i < RateBP.getCount(); i++ ) {
result += "," + RateBP.getElement( i ).Y;
}
}
break;
case VsqHandleType.Singer:
result += Environment.NewLine + "IconID=" + IconID + Environment.NewLine;
result += "IDS=" + IDS + Environment.NewLine;
result += "Original=" + Original + Environment.NewLine;
result += "Caption=" + Caption + Environment.NewLine;
result += "Length=" + Length + Environment.NewLine;
result += "Language=" + Language + Environment.NewLine;
result += "Program=" + Program;
break;
default:
break;
}
return result;
}
}
}

View File

@@ -0,0 +1,272 @@
/*
* VsqMetaText/ID.cs
* Copyright (c) 2008-2009 kbinani
*
* This file is part of Boare.Lib.Vsq.
*
* Boare.Lib.Vsq is free software; you can redistribute it and/or
* modify it under the terms of the BSD License.
*
* Boare.Lib.Vsq is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*/
using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
namespace Boare.Lib.Vsq {
/// <summary>
/// メタテキストに埋め込まれるIDを表すクラス。
/// </summary>
[Serializable]
public class VsqID : ICloneable {
public int value;
public VsqIDType type;
public int IconHandle_index;
public IconHandle IconHandle;
public int Length;
public int Note;
public int Dynamics;
public int PMBendDepth;
public int PMBendLength;
public int PMbPortamentoUse;
public int DEMdecGainRate;
public int DEMaccent;
public int LyricHandle_index;
public LyricHandle LyricHandle;
public int VibratoHandle_index;
public VibratoHandle VibratoHandle;
public int VibratoDelay;
public static VsqID EOS = new VsqID( -1 );
/// <summary>
/// このインスタンスの簡易コピーを取得します。
/// </summary>
/// <returns>このインスタンスの簡易コピー</returns>
public object Clone() {
VsqID result = new VsqID( this.value );
result.type = this.type;
if ( this.IconHandle != null ) {
result.IconHandle = (IconHandle)this.IconHandle.Clone();
}
result.Length = this.Length;
result.Note = this.Note;
result.Dynamics = this.Dynamics;
result.PMBendDepth = this.PMBendDepth;
result.PMBendLength = this.PMBendLength;
result.PMbPortamentoUse = this.PMbPortamentoUse;
result.DEMdecGainRate = this.DEMdecGainRate;
result.DEMaccent = this.DEMaccent;
if ( this.LyricHandle != null ) {
result.LyricHandle = (LyricHandle)this.LyricHandle.Clone();
}
if ( this.VibratoHandle != null ) {
result.VibratoHandle = (VibratoHandle)this.VibratoHandle.Clone();
}
result.VibratoDelay = this.VibratoDelay;
return result;
}
/// <summary>
/// IDの番号ID#****の****)を指定したコンストラクタ。
/// </summary>
/// <param name="a_value">IDの番号</param>
public VsqID( int a_value ) {
value = a_value;
}
/// <summary>
/// テキストファイルからのコンストラクタ
/// </summary>
/// <param name="sr">読み込み対象</param>
/// <param name="value"></param>
/// <param name="last_line">読み込んだ最後の行が返されます</param>
public VsqID( TextMemoryStream sr, int value, ref string last_line ) {
string[] spl;
this.value = value;
this.type = VsqIDType.Unknown;
this.IconHandle_index = -2;
this.LyricHandle_index = -1;
this.VibratoHandle_index = -1;
this.Length = 0;
this.Note = 0;
this.Dynamics = 0;
this.PMBendDepth = 0;
this.PMBendLength = 0;
this.PMbPortamentoUse = 0;
this.DEMdecGainRate = 0;
this.DEMaccent = 0;
//this.LyricHandle_index = -2;
//this.VibratoHandle_index = -2;
this.VibratoDelay = 0;
last_line = sr.readLine();
while ( !last_line.StartsWith( "[" ) ) {
spl = last_line.Split( new char[] { '=' } );
switch ( spl[0] ) {
case "Type":
if ( spl[1] == "Anote" ) {
type = VsqIDType.Anote;
} else if ( spl[1] == "Singer" ) {
type = VsqIDType.Singer;
} else {
type = VsqIDType.Unknown;
}
break;
case "Length":
this.Length = int.Parse( spl[1] );
break;
case "Note#":
this.Note = int.Parse( spl[1] );
break;
case "Dynamics":
this.Dynamics = int.Parse( spl[1] );
break;
case "PMBendDepth":
this.PMBendDepth = int.Parse( spl[1] );
break;
case "PMBendLength":
this.PMBendLength = int.Parse( spl[1] );
break;
case "DEMdecGainRate":
this.DEMdecGainRate = int.Parse( spl[1] );
break;
case "DEMaccent":
this.DEMaccent = int.Parse( spl[1] );
break;
case "LyricHandle":
this.LyricHandle_index = VsqHandle.HandleIndexFromString( spl[1] );
break;
case "IconHandle":
this.IconHandle_index = VsqHandle.HandleIndexFromString( spl[1] );
break;
case "VibratoHandle":
this.VibratoHandle_index = VsqHandle.HandleIndexFromString( spl[1] );
break;
case "VibratoDelay":
this.VibratoDelay = int.Parse( spl[1] );
break;
case "PMbPortamentoUse":
PMbPortamentoUse = int.Parse( spl[1] );
break;
}
if ( sr.peek() < 0 ) {
break;
}
last_line = sr.readLine();
}
}
public override string ToString() {
string ret = "{Type=" + type;
switch ( type ) {
case VsqIDType.Anote:
ret += ", Length=" + Length;
ret += ", Note#=" + Note;
ret += ", Dynamics=" + Dynamics;
ret += ", PMBendDepth=" + PMBendDepth ;
ret += ", PMBendLength=" + PMBendLength ;
ret += ", PMbPortamentoUse=" + PMbPortamentoUse ;
ret += ", DEMdecGainRate=" + DEMdecGainRate ;
ret += ", DEMaccent=" + DEMaccent ;
if ( LyricHandle != null ) {
ret += ", LyricHandle=h#" + LyricHandle_index.ToString( "0000" ) ;
}
if ( VibratoHandle != null ) {
ret += ", VibratoHandle=h#" + VibratoHandle_index.ToString( "0000" );
ret += ", VibratoDelay=" + VibratoDelay ;
}
break;
case VsqIDType.Singer:
ret += ", IconHandle=h#" + IconHandle_index.ToString( "0000" );
break;
}
ret += "}";
return ret;
}
/// <summary>
/// インスタンスをテキストファイルに出力します
/// </summary>
/// <param name="sw">出力先</param>
public void write( TextMemoryStream sw ) {
sw.writeLine( "[ID#" + value.ToString( "0000" ) + "]" );
sw.writeLine( "Type=" + type );
switch( type ){
case VsqIDType.Anote:
sw.writeLine( "Length=" + Length );
sw.writeLine( "Note#=" + Note );
sw.writeLine( "Dynamics=" + Dynamics );
sw.writeLine( "PMBendDepth=" + PMBendDepth );
sw.writeLine( "PMBendLength=" + PMBendLength );
sw.writeLine( "PMbPortamentoUse=" + PMbPortamentoUse );
sw.writeLine( "DEMdecGainRate=" + DEMdecGainRate );
sw.writeLine( "DEMaccent=" + DEMaccent );
if ( LyricHandle != null ) {
sw.writeLine( "LyricHandle=h#" + LyricHandle_index.ToString( "0000" ) );
}
if ( VibratoHandle != null ) {
sw.writeLine( "VibratoHandle=h#" + VibratoHandle_index.ToString( "0000" ) );
sw.writeLine( "VibratoDelay=" + VibratoDelay );
}
break;
case VsqIDType.Singer:
sw.writeLine( "IconHandle=h#" + IconHandle_index.ToString( "0000" ) );
break;
}
}
/// <summary>
/// VsqIDを構築するテストを行います。
/// </summary>
/// <returns>テストに成功すればtrue、そうでなければfalseを返します</returns>
public static bool test() {
string fpath = Path.GetTempFileName();
using ( StreamWriter sw = new StreamWriter( fpath, false, Encoding.Unicode ) ) {
sw.WriteLine( "Type=Anote" );
sw.WriteLine( "Length=320" );
sw.WriteLine( "Note#=67" );
sw.WriteLine( "Dynamics=64" );
sw.WriteLine( "PMBendDepth=8" );
sw.WriteLine( "PMBendLength=1" );
sw.WriteLine( "PMbPortamentoUse=1" );
sw.WriteLine( "DEMdecGainRate=50" );
sw.WriteLine( "DEMaccent=50" );
sw.WriteLine( "LyricHandle=h#0111" );
sw.WriteLine( "[ID#0104]" );
}
string last_line = "";
bool result;
using ( TextMemoryStream sr = new TextMemoryStream( fpath, Encoding.Unicode ) ) {
VsqID vsqID = new VsqID( sr, 103, ref last_line );
if ( vsqID.type == VsqIDType.Anote &&
vsqID.Length == 320 &&
vsqID.Note == 67 &&
vsqID.Dynamics == 64 &&
vsqID.PMBendDepth == 8 &&
vsqID.PMBendLength == 1 &&
vsqID.PMbPortamentoUse == 1 &&
vsqID.DEMdecGainRate == 50 &&
vsqID.DEMaccent == 50 &&
vsqID.LyricHandle_index == 111 &&
last_line == "[ID#0104]" ) {
result = true;
} else {
result = false;
}
}
File.Delete( fpath );
return result;
}
}
}

View File

@@ -0,0 +1,210 @@
/*
* VsqMetaText/Lyric.cs
* Copyright (c) 2008-2009 kbinani
*
* This file is part of Boare.Lib.Vsq.
*
* Boare.Lib.Vsq is free software; you can redistribute it and/or
* modify it under the terms of the BSD License.
*
* Boare.Lib.Vsq is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*/
using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.Windows.Forms;
using bocoree;
namespace Boare.Lib.Vsq {
/// <summary>
/// VsqHandleに格納される歌詞の情報を扱うクラス。
/// </summary>
[Serializable]
public class Lyric {
/// <summary>
/// この歌詞のフレーズ
/// </summary>
public string Phrase;
private string[] m_phonetic_symbol;
public float UnknownFloat;
private int[] m_consonant_adjustment;
public bool PhoneticSymbolProtected;
public int[] getConsonantAdjustment() {
return m_consonant_adjustment;
}
/// <summary>
/// このオブジェクトの簡易コピーを取得します。
/// </summary>
/// <returns>このインスタンスの簡易コピー</returns>
public Lyric Clone() {
Lyric result = new Lyric();
result.Phrase = this.Phrase;
result.m_phonetic_symbol = (string[])this.m_phonetic_symbol.Clone();
result.UnknownFloat = this.UnknownFloat;
result.m_consonant_adjustment = (int[])this.m_consonant_adjustment.Clone();
result.PhoneticSymbolProtected = PhoneticSymbolProtected;
return result;
}
/// <summary>
/// 歌詞、発音記号を指定したコンストラクタ
/// </summary>
/// <param name="phrase">歌詞</param>
/// <param name="phonetic_symbol">発音記号</param>
public Lyric( string phrase, string phonetic_symbol ) {
Phrase = phrase;
setPhoneticSymbol( phonetic_symbol );
UnknownFloat = 0.000000f;
}
private Lyric() {
}
/// <summary>
/// この歌詞の発音記号を取得します。
/// </summary>
public string getPhoneticSymbol() {
string ret = m_phonetic_symbol[0];
for ( int i = 1; i < m_phonetic_symbol.Length; i++ ) {
ret += " " + m_phonetic_symbol[i];
}
return ret;
}
/// <summary>
/// この歌詞の発音記号を設定します。
/// </summary>
public void setPhoneticSymbol( string value ) {
string s = value.Replace( " ", " " );
m_phonetic_symbol = s.Split( " ".ToCharArray(), 16 );
for ( int i = 0; i < m_phonetic_symbol.Length; i++ ) {
m_phonetic_symbol[i] = m_phonetic_symbol[i].Replace( @"\\", @"\" );
}
m_consonant_adjustment = new int[m_phonetic_symbol.Length];
for ( int i = 0; i < m_phonetic_symbol.Length; i++ ) {
if ( VsqPhoneticSymbol.isConsonant( m_phonetic_symbol[i] ) ) {
m_consonant_adjustment[i] = 64;
} else {
m_consonant_adjustment[i] = 0;
}
}
}
public string[] getPhoneticSymbolList() {
string[] ret = new string[m_phonetic_symbol.Length];
for ( int i = 0; i < m_phonetic_symbol.Length; i++ ) {
ret[i] = m_phonetic_symbol[i];
}
return ret;
}
/// <summary>
/// 文字列からのコンストラクタ
/// </summary>
/// <param name="_line">生成元の文字列</param>
public Lyric( string _line ) {
byte[] b = new byte[_line.Length];
for ( int i = 0; i < _line.Length; i++ ) {
b[i] = (byte)_line[i];
}
string s = cp932.convert( b );
string[] spl = s.Split( new char[] { ',' } );
int c_length = spl.Length - 3;
if ( spl.Length < 4 ) {
Phrase = "a";
setPhoneticSymbol( "a" );
UnknownFloat = 0.0f;
PhoneticSymbolProtected = false;
} else {
Phrase = spl[0];
if ( Phrase.StartsWith( "\"" ) ) {
Phrase = Phrase.Substring( 1 );
}
if ( Phrase.EndsWith( "\"" ) ) {
Phrase = Phrase.Substring( 0, Phrase.Length - 1 );
}
string symbols = spl[1];
if ( symbols.StartsWith( "\"" ) ) {
symbols = symbols.Substring( 1 );
}
if ( symbols.EndsWith( "\"" ) ) {
symbols = symbols.Substring( 0, symbols.Length - 1 );
}
setPhoneticSymbol( symbols );
UnknownFloat = float.Parse( spl[2] );
PhoneticSymbolProtected = (spl[spl.Length - 1] == "0") ? false : true;
}
}
/// <summary>
/// 与えられた文字列の中の2バイト文字を\x**の形式にエンコードします。
/// </summary>
/// <param name="item">エンコード対象</param>
/// <returns>エンコードした文字列</returns>
public static char[] encode( string item ) {
//Encoding sjis = Encoding.GetEncoding( 932 );
byte[] bytea = cp932.convert( item );// sjis.GetBytes( item );
string result = "";
for ( int i = 0; i < bytea.Length; i++ ) {
if ( isprint( (char)bytea[i] ) ) {
result += (char)bytea[i];
} else {
result += "\\x" + Convert.ToString( bytea[i], 16 );
}
}
char[] res = result.ToCharArray();
return res;
}
/// <summary>
/// このインスタンスを文字列に変換します
/// </summary>
/// <param name="a_encode">2バイト文字をエンコードするか否かを指定するフラグ</param>
/// <returns>変換後の文字列</returns>
public string ToString( bool a_encode ) {
string result;
if ( a_encode ) {
string njp = new string( encode( this.Phrase ) );
result = "\"" + njp + "\",\"" + this.getPhoneticSymbol() + "\"," + UnknownFloat.ToString( "0.000000" );
} else {
result = "\"";
byte[] dat = cp932.convert( this.Phrase );
for ( int i = 0; i < dat.Length; i++ ) {
result += (char)dat[i];
}
result += "\",\"" + this.getPhoneticSymbol() + "\"," + UnknownFloat.ToString( "0.000000" );
result = result.Replace( @"\\", @"\" );
}
for ( int i = 0; i < m_consonant_adjustment.Length; i++ ) {
result += "," + m_consonant_adjustment[i];
}
if ( PhoneticSymbolProtected ) {
result += ",1";
} else {
result += ",0";
}
return result;
}
/// <summary>
/// 文字がプリント出力可能かどうかを判定します
/// </summary>
/// <param name="ch"></param>
/// <returns></returns>
private static bool isprint( char ch ) {
if ( 32 <= (int)ch && (int)ch <= 126 ) {
return true;
} else {
return false;
}
}
}
}

View File

@@ -0,0 +1,100 @@
/*
* VsqMetaText/Master.cs
* Copyright (c) 2008-2009 kbinani
*
* This file is part of Boare.Lib.Vsq.
*
* Boare.Lib.Vsq is free software; you can redistribute it and/or
* modify it under the terms of the BSD License.
*
* Boare.Lib.Vsq is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*/
using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
namespace Boare.Lib.Vsq {
/// <summary>
/// vsqファイルのメタテキストの[Master]に記録される内容を取り扱う
/// </summary>
[Serializable]
public class VsqMaster : ICloneable {
public int PreMeasure;
public object Clone() {
VsqMaster res = new VsqMaster( PreMeasure );
return res;
}
/// <summary>
/// プリメジャー値を指定したコンストラクタ
/// </summary>
/// <param name="pre_measure"></param>
public VsqMaster( int pre_measure ) {
this.PreMeasure = pre_measure;
}
/// <summary>
/// テキストファイルからのコンストラクタ
/// </summary>
/// <param name="sr">読み込み元</param>
/// <param name="last_line">最後に読み込んだ行が返されます</param>
public VsqMaster( TextMemoryStream sr, ref string last_line ) {
PreMeasure = 0;
string[] spl;
last_line = sr.readLine();
while ( !last_line.StartsWith( "[" ) ) {
spl = last_line.Split( new char[] { '=' } );
switch ( spl[0] ) {
case "PreMeasure":
this.PreMeasure = int.Parse( spl[1] );
break;
}
if ( sr.peek() < 0 ) {
break;
}
last_line = sr.readLine();
}
}
/// <summary>
/// インスタンスの内容をテキストファイルに出力します
/// </summary>
/// <param name="sw">出力先</param>
public void write( TextMemoryStream sw ) {
sw.writeLine( "[Master]" );
sw.writeLine( "PreMeasure=" + PreMeasure );
}
/// <summary>
/// VsqMasterのインスタンスを構築するテストを行います
/// </summary>
/// <returns>テストに成功すればtrue、そうでなければfalseを返します</returns>
public static bool test() {
string fpath = Path.GetTempFileName();
using ( StreamWriter sw = new StreamWriter( fpath, false, Encoding.Unicode ) ) {
sw.WriteLine( "PreMeasure=2" );
sw.WriteLine( "[Mixer]" );
}
bool result;
using ( TextMemoryStream sr = new TextMemoryStream( fpath, Encoding.Unicode ) ) {
string last_line = "";
VsqMaster vsqMaster = new VsqMaster( sr, ref last_line );
if ( vsqMaster.PreMeasure == 2 &&
last_line == "[Mixer]" ) {
result = true;
} else {
result = false;
}
}
File.Delete( fpath );
return result;
}
}
}

View File

@@ -0,0 +1,266 @@
/*
* VsqMetaText/Mixer.cs
* Copyright (c) 2008-2009 kbinani
*
* This file is part of Boare.Lib.Vsq.
*
* Boare.Lib.Vsq is free software; you can redistribute it and/or
* modify it under the terms of the BSD License.
*
* Boare.Lib.Vsq is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*/
using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
namespace Boare.Lib.Vsq {
/// <summary>
/// vsqファイルのメタテキストの[Mixer]セクションに記録される内容を取り扱う
/// </summary>
[Serializable]
public class VsqMixer : ICloneable {
public int MasterFeder;
public int MasterPanpot;
public int MasterMute;
public int OutputMode;
/// <summary>
/// vsqファイルの各トラックのfader, panpot, muteおよびoutputmode値を保持します
/// </summary>
public List<VsqMixerEntry> Slave = new List<VsqMixerEntry>();
public object Clone() {
VsqMixer res = new VsqMixer( MasterFeder, MasterPanpot, MasterMute, OutputMode );
res.Slave = new List<VsqMixerEntry>();
foreach ( VsqMixerEntry item in Slave ) {
res.Slave.Add( (VsqMixerEntry)item.Clone() );
}
return res;
}
/// <summary>
/// 各パラメータを指定したコンストラクタ
/// </summary>
/// <param name="master_fader">MasterFader値</param>
/// <param name="master_panpot">MasterPanpot値</param>
/// <param name="master_mute">MasterMute値</param>
/// <param name="output_mode">OutputMode値</param>
public VsqMixer( int master_fader, int master_panpot, int master_mute, int output_mode ) {
this.MasterFeder = master_fader;
this.MasterMute = master_mute;
this.MasterPanpot = master_panpot;
this.OutputMode = output_mode;
Slave = new List<VsqMixerEntry>();
}
/// <summary>
/// テキストファイルからのコンストラクタ
/// </summary>
/// <param name="sr">読み込み対象</param>
/// <param name="last_line">最後に読み込んだ行が返されます</param>
public VsqMixer( TextMemoryStream sr, ref string last_line ) {
MasterFeder = 0;
MasterPanpot = 0;
MasterMute = 0;
OutputMode = 0;
//Tracks = 1;
int tracks = 0;
string[] spl;
string buffer = "";
last_line = sr.readLine();
while ( !last_line.StartsWith( "[" ) ) {
spl = last_line.Split( new char[] { '=' } );
switch ( spl[0] ) {
case "MasterFeder":
MasterFeder = int.Parse( spl[1] );
break;
case "MasterPanpot":
MasterPanpot = int.Parse( spl[1] );
break;
case "MasterMute":
MasterMute = int.Parse( spl[1] );
break;
case "OutputMode":
OutputMode = int.Parse( spl[1] );
break;
case "Tracks":
tracks = int.Parse( spl[1] );
break;
default:
if ( spl[0].StartsWith( "Feder" ) ||
spl[0].StartsWith( "Panpot" ) ||
spl[0].StartsWith( "Mute" ) ||
spl[0].StartsWith( "Solo" ) ) {
buffer += spl[0] + "=" + spl[1] + Environment.NewLine;
}
break;
}
if ( sr.peek() < 0 ) {
break;
}
last_line = sr.readLine();
}
Slave = new List<VsqMixerEntry>();
for ( int i = 0; i < tracks; i++ ) {
Slave.Add( new VsqMixerEntry( 0, 0, 0, 0 ) );
}
spl = buffer.Split( new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries );
string[] spl2;
for ( int i = 0; i < spl.Length; i++ ) {
string ind = "";
int index;
spl2 = spl[i].Split( new char[] { '=' } );
if ( spl2[0].StartsWith( "Feder" ) ) {
ind = spl2[0].Replace( "Feder", "" );
index = int.Parse( ind );
Slave[index].Feder = int.Parse( spl2[1] );
} else if ( spl2[0].StartsWith( "Panpot" ) ) {
ind = spl2[0].Replace( "Panpot", "" );
index = int.Parse( ind );
Slave[index].Panpot = int.Parse( spl2[1] );
} else if ( spl2[0].StartsWith( "Mute" ) ) {
ind = spl2[0].Replace( "Mute", "" );
index = int.Parse( ind );
Slave[index].Mute = int.Parse( spl2[1] );
} else if ( spl2[0].StartsWith( "Solo" ) ) {
ind = spl2[0].Replace( "Solo", "" );
index = int.Parse( ind );
Slave[index].Solo = int.Parse( spl2[1] );
}
}
}
/// <summary>
/// このインスタンスをテキストファイルに出力します
/// </summary>
/// <param name="sw">出力対象</param>
public void write( TextMemoryStream sw ) {
sw.writeLine( "[Mixer]" );
sw.writeLine( "MasterFeder=" + MasterFeder );
sw.writeLine( "MasterPanpot=" + MasterPanpot );
sw.writeLine( "MasterMute=" + MasterMute );
sw.writeLine( "OutputMode=" + OutputMode );
sw.writeLine( "Tracks=" + Slave.Count );
for ( int i = 0; i < Slave.Count; i++ ) {
sw.writeLine( "Feder" + i + "=" + Slave[i].Feder );
sw.writeLine( "Panpot" + i + "=" + Slave[i].Panpot );
sw.writeLine( "Mute" + i + "=" + Slave[i].Mute );
sw.writeLine( "Solo" + i + "=" + Slave[i].Solo );
}
}
/// <summary>
/// VsqMixerのインスタンスを構築するテストを行います
/// </summary>
/// <returns>テストに成功すればtrue、そうでなければfalseを返します</returns>
public static bool test() {
string fpath = Path.GetTempFileName();
StreamWriter sw = new StreamWriter( fpath, false, Encoding.Unicode );
sw.WriteLine( "MasterFeder=12" );
sw.WriteLine( "MasterPanpot=13" );
sw.WriteLine( "MasterMute=14" );
sw.WriteLine( "OutputMode=15" );
sw.WriteLine( "Tracks=8" );
sw.WriteLine( "Feder0=1" );
sw.WriteLine( "Panpot0=2" );
sw.WriteLine( "Mute0=3" );
sw.WriteLine( "Solo0=4" );
sw.WriteLine( "Feder1=5" );
sw.WriteLine( "Panpot1=6" );
sw.WriteLine( "Mute1=7" );
sw.WriteLine( "Solo1=8" );
sw.WriteLine( "Feder2=9" );
sw.WriteLine( "Panpot2=10" );
sw.WriteLine( "Mute2=11" );
sw.WriteLine( "Solo2=12" );
sw.WriteLine( "Feder3=13" );
sw.WriteLine( "Panpot3=14" );
sw.WriteLine( "Mute3=15" );
sw.WriteLine( "Solo3=16" );
sw.WriteLine( "Feder4=17" );
sw.WriteLine( "Panpot4=18" );
sw.WriteLine( "Mute4=19" );
sw.WriteLine( "Solo4=20" );
sw.WriteLine( "Feder5=21" );
sw.WriteLine( "Panpot5=22" );
sw.WriteLine( "Mute5=23" );
sw.WriteLine( "Solo5=24" );
sw.WriteLine( "Feder6=25" );
sw.WriteLine( "Panpot6=26" );
sw.WriteLine( "Mute6=27" );
sw.WriteLine( "Solo6=28" );
sw.WriteLine( "Feder7=29" );
sw.WriteLine( "Panpot7=30" );
sw.WriteLine( "Mute7=31" );
sw.WriteLine( "Solo7=32" );
sw.WriteLine( "[EventList]" );
sw.Close();
TextMemoryStream sr = new TextMemoryStream( fpath, Encoding.Unicode );
string last_line = "";
VsqMixer vsqMixer = new VsqMixer( sr, ref last_line );
if( vsqMixer.MasterFeder == 12 &&
vsqMixer.MasterPanpot == 13 &&
vsqMixer.MasterMute == 14 &&
vsqMixer.OutputMode == 15 &&
vsqMixer.Slave.Count == 8 ){
for( int i = 0; i < vsqMixer.Slave.Count; i++ ){
int start = 4 * i;
if ( vsqMixer.Slave[i].Feder != start + 1 ||
vsqMixer.Slave[i].Panpot != start + 2 ||
vsqMixer.Slave[i].Mute != start + 3 ||
vsqMixer.Slave[i].Solo != start + 4 ) {
sr.close();
File.Delete( fpath );
return false;
}
}
}else{
sr.close();
File.Delete( fpath );
return false;
}
sr.close();
File.Delete( fpath );
return true;
}
}
/// <summary>
/// VsqMixerのSlave要素に格納される各エントリ
/// </summary>
[Serializable]
public class VsqMixerEntry : ICloneable {
public int Feder;
public int Panpot;
public int Mute;
public int Solo;
public object Clone() {
VsqMixerEntry res = new VsqMixerEntry( Feder, Panpot, Mute, Solo );
return res;
}
/// <summary>
/// 各パラメータを指定したコンストラクタ
/// </summary>
/// <param name="feder">Feder値</param>
/// <param name="panpot">Panpot値</param>
/// <param name="mute">Mute値</param>
/// <param name="solo">Solo値</param>
public VsqMixerEntry( int feder, int panpot, int mute, int solo ) {
this.Feder = feder;
this.Panpot = panpot;
this.Mute = mute;
this.Solo = solo;
}
}
}

View File

@@ -0,0 +1,811 @@
/*
* VsqMetaText/VsqMetaText.cs
* Copyright (c) 2008-2009 kbinani
*
* This file is part of Boare.Lib.Vsq.
*
* Boare.Lib.Vsq is free software; you can redistribute it and/or
* modify it under the terms of the BSD License.
*
* Boare.Lib.Vsq is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*/
using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.Drawing;
using System.Windows.Forms;
namespace Boare.Lib.Vsq {
/// <summary>
/// vsqのメタテキストの中身を処理するためのクラス
/// </summary>
[Serializable]
public class VsqMetaText : ICloneable {
public VsqCommon Common;
internal VsqMaster master;
internal VsqMixer mixer;
private VsqEventList m_events;
/// <summary>
/// PIT。ピッチベンド(pitchBendBPList)。default=0
/// </summary>
public VsqBPList PIT;
/// <summary>
/// PBS。ピッチベンドセンシティビティ(pitchBendSensBPList)。dfault=2
/// </summary>
public VsqBPList PBS;
/// <summary>
/// DYN。ダイナミクス(dynamicsBPList)。default=64
/// </summary>
public VsqBPList DYN;
/// <summary>
/// BRE。ブレシネス(epRResidualBPList)。default=0
/// </summary>
public VsqBPList BRE;
/// <summary>
/// BRI。ブライトネス(epRESlopeBPList)。default=64
/// </summary>
public VsqBPList BRI;
/// <summary>
/// CLE。クリアネス(epRESlopeDepthBPList)。default=0
/// </summary>
public VsqBPList CLE;
private VsqBPList reso1FreqBPList;
private VsqBPList reso2FreqBPList;
private VsqBPList reso3FreqBPList;
private VsqBPList reso4FreqBPList;
private VsqBPList reso1BWBPList;
private VsqBPList reso2BWBPList;
private VsqBPList reso3BWBPList;
private VsqBPList reso4BWBPList;
private VsqBPList reso1AmpBPList;
private VsqBPList reso2AmpBPList;
private VsqBPList reso3AmpBPList;
private VsqBPList reso4AmpBPList;
/// <summary>
/// GEN。ジェンダーファクター(genderFactorBPList)。default=64
/// </summary>
public VsqBPList GEN;
/// <summary>
/// POR。ポルタメントタイミング(portamentoTimingBPList)。default=64
/// </summary>
public VsqBPList POR;
/// <summary>
/// OPE。オープニング(openingBPList)。default=127
/// </summary>
public VsqBPList OPE;
public object Clone() {
VsqMetaText res = new VsqMetaText();
if ( Common != null ) {
res.Common = (VsqCommon)Common.Clone();
}
if ( master != null ) {
res.master = (VsqMaster)master.Clone();
}
if ( mixer != null ) {
res.mixer = (VsqMixer)mixer.Clone();
}
if ( m_events != null ) {
res.m_events = new VsqEventList();
for ( Iterator itr = m_events.iterator(); itr.hasNext(); ) {
res.m_events.add( (VsqEvent)((VsqEvent)itr.next()).Clone() );
}
}
if ( PIT != null ) {
res.PIT = (VsqBPList)PIT.Clone();
}
if ( PBS != null ) {
res.PBS = (VsqBPList)PBS.Clone();
}
if ( DYN != null ) {
res.DYN = (VsqBPList)DYN.Clone();
}
if ( BRE != null ) {
res.BRE = (VsqBPList)BRE.Clone();
}
if ( BRI != null ) {
res.BRI = (VsqBPList)BRI.Clone();
}
if ( CLE != null ) {
res.CLE = (VsqBPList)CLE.Clone();
}
if ( reso1FreqBPList != null ) {
res.reso1FreqBPList = (VsqBPList)reso1FreqBPList.Clone();
}
if ( reso2FreqBPList != null ) {
res.reso2FreqBPList = (VsqBPList)reso2FreqBPList.Clone();
}
if ( reso3FreqBPList != null ) {
res.reso3FreqBPList = (VsqBPList)reso3FreqBPList.Clone();
}
if ( reso4FreqBPList != null ) {
res.reso4FreqBPList = (VsqBPList)reso4FreqBPList.Clone();
}
if ( reso1BWBPList != null ) {
res.reso1BWBPList = (VsqBPList)reso1BWBPList.Clone();
}
if ( reso2BWBPList != null ) {
res.reso2BWBPList = (VsqBPList)reso2BWBPList.Clone();
}
if ( reso3BWBPList != null ) {
res.reso3BWBPList = (VsqBPList)reso3BWBPList.Clone();
}
if ( reso4BWBPList != null ) {
res.reso4BWBPList = (VsqBPList)reso4BWBPList.Clone();
}
if ( reso1AmpBPList != null ) {
res.reso1AmpBPList = (VsqBPList)reso1AmpBPList.Clone();
}
if ( reso2AmpBPList != null ) {
res.reso2AmpBPList = (VsqBPList)reso2AmpBPList.Clone();
}
if ( reso3AmpBPList != null ) {
res.reso3AmpBPList = (VsqBPList)reso3AmpBPList.Clone();
}
if ( reso4AmpBPList != null ) {
res.reso4AmpBPList = (VsqBPList)reso4AmpBPList.Clone();
}
if ( GEN != null ) {
res.GEN = (VsqBPList)GEN.Clone();
}
if ( POR != null ) {
res.POR = (VsqBPList)POR.Clone();
}
if ( OPE != null ) {
res.OPE = (VsqBPList)OPE.Clone();
}
return res;
}
public VsqEventList getEventList() {
return m_events;
}
internal VsqBPList getElement( string curve ) {
switch ( curve.Trim().ToLower() ) {
case "bre":
return this.BRE;
case "bri":
return this.BRI;
case "cle":
return this.CLE;
case "dyn":
return this.DYN;
case "gen":
return this.GEN;
case "ope":
return this.OPE;
case "pbs":
return this.PBS;
case "pit":
return this.PIT;
case "por":
return this.POR;
default:
return null;
}
}
internal void setElement( string curve, VsqBPList value ) {
switch ( curve.Trim().ToLower() ) {
case "bre":
this.BRE = value;
break;
case "bri":
this.BRI = value;
break;
case "cle":
this.CLE = value;
break;
case "dyn":
this.DYN = value;
break;
case "gen":
this.GEN = value;
break;
case "ope":
this.OPE = value;
break;
case "pbs":
this.PBS = value;
break;
case "pit":
this.PIT = value;
break;
case "por":
this.POR = value;
break;
}
}
/// <summary>
/// Editor画面上で上からindex番目のカーブを表すBPListを求めます
/// </summary>
/// <param name="index"></param>
/// <returns></returns>
public VsqBPList getCurve( int index ) {
switch ( index ) {
case 1:
return DYN;
case 2:
return BRE;
case 3:
return BRI;
case 4:
return CLE;
case 5:
return OPE;
case 6:
return GEN;
case 7:
return POR;
case 8:
return PIT;
case 9:
return PBS;
default:
return null;
}
}
/// <summary>
/// Editor画面上で上からindex番目のカーブの名前を調べます
/// </summary>
/// <param name="index"></param>
/// <returns></returns>
public static string getCurveName( int index ) {
switch ( index ) {
case 0:
return "VEL";
case 1:
return "DYN";
case 2:
return "BRE";
case 3:
return "BRI";
case 4:
return "CLE";
case 5:
return "OPE";
case 6:
return "GEN";
case 7:
return "POR";
case 8:
return "PIT";
case 9:
return "PBS";
default:
return "";
}
}
/// <summary>
/// Singerプロパティに指定されている
/// </summary>
public string getSinger() {
for ( Iterator itr = m_events.iterator(); itr.hasNext(); ) {
VsqEvent item = (VsqEvent)itr.next();
if ( item.ID.type == VsqIDType.Singer ) {
return item.ID.IconHandle.IDS;
}
}
return "";
}
public void setSinger( string value ) {
for ( Iterator itr = m_events.iterator(); itr.hasNext(); ) {
VsqEvent item = (VsqEvent)itr.next();
if ( item.ID.type == VsqIDType.Singer ) {
item.ID.IconHandle.IDS = value;
break;
}
}
}
/// <summary>
/// EOSイベントが記録されているクロックを取得します。
/// </summary>
/// <returns></returns>
public int getIndexOfEOS() {
int result;
if ( m_events.getCount() > 0 ) {
int ilast = m_events.getCount() - 1;
result = m_events.getElement( ilast ).Clock;
} else {
result = -1;
}
return result;
}
/// <summary>
/// このインスタンスから、IDとHandleのリストを構築します
/// </summary>
/// <param name="id"></param>
/// <param name="handle"></param>
void BuildIDHandleList( out List<VsqID> id, out List<VsqHandle> handle ) {
id = new List<VsqID>();
handle = new List<VsqHandle>();
int current_id = -1;
int current_handle = -1;
List<VsqEvent> events = new List<VsqEvent>();
for ( Iterator itr = m_events.iterator(); itr.hasNext(); ) {
events.Add( (VsqEvent)itr.next() );
}
events.Sort();
for( int i = 0; i < events.Count; i++ ){
VsqEvent item = events[i];
VsqID id_item = (VsqID)item.ID.Clone();
current_id++;
item.ID.value = current_id;
id_item.value = current_id;
// IconHandle
if ( item.ID.IconHandle != null ) {
current_handle++;
VsqHandle handle_item = item.ID.IconHandle.castToVsqHandle();
handle_item.Index = current_handle;
handle.Add( handle_item );
id_item.IconHandle_index = current_handle;
}
// LyricHandle
if ( item.ID.LyricHandle != null ) {
current_handle++;
VsqHandle handle_item = item.ID.LyricHandle.castToVsqHandle();
handle_item.Index = current_handle;
handle.Add( handle_item );
id_item.LyricHandle_index = current_handle;
}
// VibratoHandle
if ( item.ID.VibratoHandle != null ) {
current_handle++;
VsqHandle handle_item = item.ID.VibratoHandle.castToVsqHandle();
handle_item.Index = current_handle;
handle.Add( handle_item );
id_item.VibratoHandle_index = current_handle;
}
id.Add( id_item );
}
}
/// <summary>
/// このインスタンスの内容を指定されたファイルに出力します。
/// </summary>
/// <param name="sw"></param>
/// <param name="encode"></param>
public void print( TextMemoryStream sw, bool encode, int eos, int start ) {
if ( Common != null ) {
Common.write( sw );
}
if ( master != null ) {
master.write( sw );
}
if ( mixer != null ) {
mixer.write( sw );
}
List<VsqID> id;
List<VsqHandle> handle;
BuildIDHandleList( out id, out handle );
writeEventList( sw, eos );
int i;
for ( i = 0; i < id.Count; i++ ) {
id[i].write( sw );
}
for ( i = 0; i < handle.Count; i++ ) {
handle[i].write( sw, encode );
}
if ( PIT.getCount() > 0 ) {
PIT.print( sw, start, "[PitchBendBPList]" );
}
if ( PBS.getCount() > 0 ) {
PBS.print( sw, start, "[PitchBendSensBPList]" );
}
if ( DYN.getCount() > 0 ) {
DYN.print( sw, start, "[DynamicsBPList]" );
}
if ( BRE.getCount() > 0 ) {
BRE.print( sw, start, "[EpRResidualBPList]" );
}
if ( BRI.getCount() > 0 ) {
BRI.print( sw, start, "[EpRESlopeBPList]" );
}
if ( CLE.getCount() > 0 ) {
CLE.print( sw, start, "[EpRESlopeDepthBPList]" );
}
if ( reso1FreqBPList.getCount() > 0 ) {
reso1FreqBPList.print( sw, start, "[Reso1FreqBPList]" );
}
if ( reso2FreqBPList.getCount() > 0 ) {
reso2FreqBPList.print( sw, start, "[Reso2FreqBPList]" );
}
if ( reso3FreqBPList.getCount() > 0 ) {
reso3FreqBPList.print( sw, start, "[Reso3FreqBPList]" );
}
if ( reso4FreqBPList.getCount() > 0 ) {
reso4FreqBPList.print( sw, start, "[Reso4FreqBPList]" );
}
if ( reso1BWBPList.getCount() > 0 ) {
reso1BWBPList.print( sw, start, "[Reso1BWBPList]" );
}
if ( reso2BWBPList.getCount() > 0 ) {
reso2BWBPList.print( sw, start, "[Reso2BWBPList]" );
}
if ( reso3BWBPList.getCount() > 0 ) {
reso3BWBPList.print( sw, start, "[Reso3BWBPList]" );
}
if ( reso4BWBPList.getCount() > 0 ) {
reso4BWBPList.print( sw, start, "[Reso4BWBPList]" );
}
if ( reso1AmpBPList.getCount() > 0 ) {
reso1AmpBPList.print( sw, start, "[Reso1AmpBPList]" );
}
if ( reso2AmpBPList.getCount() > 0 ) {
reso2AmpBPList.print( sw, start, "[Reso2AmpBPList]" );
}
if ( reso3AmpBPList.getCount() > 0 ) {
reso3AmpBPList.print( sw, start, "[Reso3AmpBPList]" );
}
if ( reso4AmpBPList.getCount() > 0 ) {
reso4AmpBPList.print( sw, start, "[Reso4AmpBPList]" );
}
if ( GEN.getCount() > 0 ) {
GEN.print( sw, start, "[GenderFactorBPList]" );
}
if ( POR.getCount() > 0 ) {
POR.print( sw, start, "[PortamentoTimingBPList]" );
}
if ( OPE.getCount() > 0 ) {
OPE.print( sw, start, "[OpeningBPList]" );
}
}
private void writeEventList( TextMemoryStream sw, int eos ) {
sw.writeLine( "[EventList]" );
List<VsqEvent> temp = new List<VsqEvent>();
for ( Iterator itr = m_events.iterator(); itr.hasNext(); ) {
temp.Add( (VsqEvent)itr.next() );
}
temp.Sort();
int i = 0;
while ( i < temp.Count ) {
VsqEvent item = temp[i];
if ( !item.ID.Equals( VsqID.EOS ) ) {
string ids = "ID#" + i.ToString( "0000" );
int clock = temp[i].Clock;
while ( i + 1 < temp.Count && clock == temp[i + 1].Clock ) {
i++;
ids += ",ID#" + i.ToString( "0000" );
}
sw.writeLine( clock + "=" + ids );
}
i++;
}
sw.writeLine( eos + "=EOS" );
}
/// <summary>
/// 何も無いVsqMetaTextを構築する。これは、Master Track用のMetaTextとしてのみ使用されるべき
/// </summary>
public VsqMetaText() {
}
/// <summary>
/// 最初のトラック以外の一般のメタテキストを構築。(Masterが作られない)
/// </summary>
public VsqMetaText( string name, string singer )
: this( name, 0, singer, false ) {
}
/// <summary>
/// 最初のトラックのメタテキストを構築。(Masterが作られる)
/// </summary>
/// <param name="pre_measure"></param>
public VsqMetaText( string name, string singer, int pre_measure )
: this( name, pre_measure, singer, true ) {
}
private VsqMetaText( string name, int pre_measure, string singer, bool is_first_track ) {
Common = new VsqCommon( name, Color.FromArgb( 179, 181, 123 ), 1, 1 );
PIT = new VsqBPList( 0, -8192, 8192 );
PIT.add( 0, PIT.getDefault() );
PBS = new VsqBPList( 2, 0, 24 );
PBS.add( 0, PBS.getDefault() );
DYN = new VsqBPList( 64, 0, 127 );
DYN.add( 0, DYN.getDefault() );
BRE = new VsqBPList( 0, 0, 127 );
BRE.add( 0, BRE.getDefault() );
BRI = new VsqBPList( 64, 0, 127 );
BRI.add( 0, BRI.getDefault() );
CLE = new VsqBPList( 0, 0, 127 );
CLE.add( 0, CLE.getDefault() );
reso1FreqBPList = new VsqBPList( 255, 0, 255 );
reso1FreqBPList.add( 0, reso1FreqBPList.getDefault() );
reso2FreqBPList = new VsqBPList( 255, 0, 255 );
reso2FreqBPList.add( 0, reso2FreqBPList.getDefault() );
reso3FreqBPList = new VsqBPList( 255, 0, 255 );
reso3FreqBPList.add( 0, reso3FreqBPList.getDefault() );
reso4FreqBPList = new VsqBPList( 255, 0, 255 );
reso4FreqBPList.add( 0, reso4FreqBPList.getDefault() );
reso1BWBPList = new VsqBPList( 255, 0, 255 );
reso1BWBPList.add( 0, reso1BWBPList.getDefault() );
reso2BWBPList = new VsqBPList( 255, 0, 255 );
reso2BWBPList.add( 0, reso2BWBPList.getDefault() );
reso3BWBPList = new VsqBPList( 255, 0, 255 );
reso3BWBPList.add( 0, reso3BWBPList.getDefault() );
reso4BWBPList = new VsqBPList( 255, 0, 255 );
reso4BWBPList.add( 0, reso4BWBPList.getDefault() );
reso1AmpBPList = new VsqBPList( 255, 0, 255 );
reso1AmpBPList.add( 0, reso1AmpBPList.getDefault() );
reso2AmpBPList = new VsqBPList( 255, 0, 255 );
reso2AmpBPList.add( 0, reso2AmpBPList.getDefault() );
reso3AmpBPList = new VsqBPList( 255, 0, 255 );
reso3AmpBPList.add( 0, reso3AmpBPList.getDefault() );
reso4AmpBPList = new VsqBPList( 255, 0, 255 );
reso4AmpBPList.add( 0, reso4AmpBPList.getDefault() );
GEN = new VsqBPList( 64, 0, 127 );
GEN.add( 0, GEN.getDefault() );
POR = new VsqBPList( 64, 0, 127 );
POR.add( 0, POR.getDefault() );
OPE = new VsqBPList( 127, 0, 127 );
OPE.add( 0, OPE.getDefault() );
if ( is_first_track ) {
master = new VsqMaster( pre_measure );
} else {
master = null;
}
m_events = new VsqEventList();
VsqID id = new VsqID( 0 );
id.type = VsqIDType.Singer;
id.IconHandle = new IconHandle();
id.IconHandle.IconID = "$07010000";
id.IconHandle.IDS = singer;
id.IconHandle.Original = 0;
id.IconHandle.Caption = "";
id.IconHandle.Length = 1;
id.IconHandle.Language = 0;
id.IconHandle.Program = 0;
m_events.add( new VsqEvent( 0, id ) );
}
public VsqMetaText( TextMemoryStream sr ) {
List<KeyValuePair<int, int>> t_event_list = new List<KeyValuePair<int, int>>();
Dictionary<int, VsqID> __id = new Dictionary<int, VsqID>();
Dictionary<int, VsqHandle> __handle = new Dictionary<int, VsqHandle>();
PIT = new VsqBPList( 0, -8192, 8192 );
PBS = new VsqBPList( 2, 0, 24 );
DYN = new VsqBPList( 64, 0, 127 );
BRE = new VsqBPList( 0 , 0, 127);
BRI = new VsqBPList( 64, 0, 127 );
CLE = new VsqBPList( 0, 0, 127 );
reso1FreqBPList = new VsqBPList( 255, 0, 255 );
reso2FreqBPList = new VsqBPList( 255, 0, 255 );
reso3FreqBPList = new VsqBPList( 255, 0, 255 );
reso4FreqBPList = new VsqBPList( 255, 0, 255 );
reso1BWBPList = new VsqBPList( 255, 0, 255 );
reso2BWBPList = new VsqBPList( 255, 0, 255 );
reso3BWBPList = new VsqBPList( 255, 0, 255 );
reso4BWBPList = new VsqBPList( 255, 0, 255 );
reso1AmpBPList = new VsqBPList( 255, 0, 255 );
reso2AmpBPList = new VsqBPList( 255, 0, 255 );
reso3AmpBPList = new VsqBPList( 255, 0, 255 );
reso4AmpBPList = new VsqBPList( 255, 0, 255 );
GEN = new VsqBPList( 64, 0, 127 );
POR = new VsqBPList( 64, 0, 127 );
OPE = new VsqBPList( 127, 0, 127 );
string last_line = sr.readLine();
while ( true ) {
#region "TextMemoryStreamから順次読込み"
if ( last_line.Length == 0 ) {
break;
}
switch ( last_line ) {
case "[Common]":
Common = new VsqCommon( sr, ref last_line );
break;
case "[Master]":
master = new VsqMaster( sr, ref last_line );
break;
case "[Mixer]":
mixer = new VsqMixer( sr, ref last_line );
break;
case "[EventList]":
last_line = sr.readLine();
while ( !last_line.StartsWith( "[" ) ) {
string[] spl2 = last_line.Split( new char[] { '=' } );
int clock = int.Parse( spl2[0] );
int id_number = -1;
if ( spl2[1] != "EOS" ) {
string[] ids = spl2[1].Split( ",".ToCharArray() );
for ( int i = 0; i < ids.Length; i++ ) {
string[] spl3 = ids[i].Split( new char[] { '#' } );
id_number = int.Parse( spl3[1] );
t_event_list.Add( new KeyValuePair<int,int>( clock, id_number ) );
}
} else {
t_event_list.Add( new KeyValuePair<int,int>( clock, -1) );
}
if ( sr.peek() < 0 ) {
break;
} else {
last_line = sr.readLine();
}
}
break;
case "[PitchBendBPList]":
last_line = PIT.appendFromText( sr );
break;
case "[PitchBendSensBPList]":
last_line = PBS.appendFromText( sr );
break;
case "[DynamicsBPList]":
last_line = DYN.appendFromText( sr );
break;
case "[EpRResidualBPList]":
last_line = BRE.appendFromText( sr );
break;
case "[EpRESlopeBPList]":
last_line = BRI.appendFromText( sr );
break;
case "[EpRESlopeDepthBPList]":
last_line = CLE.appendFromText( sr );
break;
case "[Reso1FreqBPList]":
last_line = reso1FreqBPList.appendFromText( sr );
break;
case "[Reso2FreqBPList]":
last_line = reso2FreqBPList.appendFromText( sr );
break;
case "[Reso3FreqBPList]":
last_line = reso3FreqBPList.appendFromText( sr );
break;
case "[Reso4FreqBPList]":
last_line = reso4FreqBPList.appendFromText( sr );
break;
case "[Reso1BWBPList]":
last_line = reso1BWBPList.appendFromText( sr );
break;
case "[Reso2BWBPList]":
last_line = reso2BWBPList.appendFromText( sr );
break;
case "[Reso3BWBPList]":
last_line = reso3BWBPList.appendFromText( sr );
break;
case "[Reso4BWBPList]":
last_line = reso4BWBPList.appendFromText( sr );
break;
case "[Reso1AmpBPList]":
last_line = reso1AmpBPList.appendFromText( sr );
break;
case "[Reso2AmpBPList]":
last_line = reso2AmpBPList.appendFromText( sr );
break;
case "[Reso3AmpBPList]":
last_line = reso3AmpBPList.appendFromText( sr );
break;
case "[Reso4AmpBPList]":
last_line = reso4AmpBPList.appendFromText( sr );
break;
case "[GenderFactorBPList]":
last_line = GEN.appendFromText( sr );
break;
case "[PortamentoTimingBPList]":
last_line = POR.appendFromText( sr );
break;
case "[OpeningBPList]":
last_line = OPE.appendFromText( sr );
break;
default:
string buffer = last_line;
buffer = buffer.Replace( "[", "" );
buffer = buffer.Replace( "]", "" );
string[] spl = buffer.Split( new char[] { '#' } );
int index = int.Parse( spl[1] );
if ( last_line.StartsWith( "[ID#" ) ) {
__id.Add( index, new VsqID( sr, index, ref last_line ) );
} else if ( last_line.StartsWith( "[h#" ) ) {
__handle.Add( index, new VsqHandle( sr, index, ref last_line ) );
}
break;
#endregion
}
if ( sr.peek() < 0 ) {
break;
}
}
// まずhandleをidに埋め込み
for ( int i = 0; i < __id.Count; i++ ) {
if ( __handle.ContainsKey( __id[i].IconHandle_index ) ) {
__id[i].IconHandle = __handle[__id[i].IconHandle_index].castToIconHandle();
}
if ( __handle.ContainsKey( __id[i].LyricHandle_index ) ) {
__id[i].LyricHandle = __handle[__id[i].LyricHandle_index].castToLyricHandle();
}
if ( __handle.ContainsKey( __id[i].VibratoHandle_index ) ) {
__id[i].VibratoHandle = __handle[__id[i].VibratoHandle_index].castToVibratoHandle();
}
}
// idをeventListに埋め込み
m_events = new VsqEventList();
for ( int i = 0; i < t_event_list.Count; i++ ) {
int clock = t_event_list[i].Key;
int id_number = t_event_list[i].Value;
if ( __id.ContainsKey( id_number ) ) {
m_events.add( new VsqEvent( clock, (VsqID)__id[id_number].Clone() ) );
}
}
}
public static bool test( string fpath ) {
VsqMetaText metaText;
using ( TextMemoryStream sr = new TextMemoryStream( fpath, Encoding.Unicode ) ) {
metaText = new VsqMetaText( sr );
}
string result = "test.txt";
StreamReader honmono = new StreamReader( fpath );
TextMemoryStream copy = new TextMemoryStream( FileAccess.ReadWrite );
metaText.print( copy, true, 1000, 100 );
copy.rewind();
while ( honmono.Peek() >= 0 && copy.peek() >= 0 ) {
string hon = honmono.ReadLine();
string cop = copy.readLine();
if ( hon != cop ) {
Console.WriteLine( "honmono,copy=" + hon + "," + cop );
honmono.Close();
copy.close();
return false;
}
}
honmono.Close();
copy.close();
return true;
}
}
public enum VsqIDType {
Singer,
Anote,
Unknown
}
public enum VsqHandleType {
Lyric,
Vibrato,
Singer
}
}