[trunk] (ry

git-svn-id: http://svn.sourceforge.jp/svnroot/lipsync@18 b1f601f4-4f45-0410-8980-aecacb008692
This commit is contained in:
kbinani 2010-03-17 03:14:08 +00:00
parent 1c5c94deac
commit 9de5d2e51e
214 changed files with 22026 additions and 17358 deletions

View File

@ -11,40 +11,49 @@
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*/
using System.Drawing;
#if JAVA
package org.kbinani.apputil;
import java.awt.*;
#else
using System;
using bocoree.java.awt;
namespace Boare.Lib.AppUtil {
#endif
public class AuthorListEntry {
string m_name;
FontStyle m_style;
String m_name;
int m_style;
public AuthorListEntry( string name, FontStyle style )
: this( name ) {
public AuthorListEntry( String name, int style ) {
m_name = name;
m_style = style;
}
public AuthorListEntry( string name ) {
m_name = name;
m_style = FontStyle.Regular;
#if JAVA
public AuthorListEntry( String name ){
this( name, Font.PLAIN );
#else
public AuthorListEntry( String name )
: this( name, Font.PLAIN ) {
#endif
}
public AuthorListEntry() {
m_name = "";
m_style = FontStyle.Regular;
m_style = Font.PLAIN;
}
public string Name {
get {
public String getName() {
return m_name;
}
}
public FontStyle Style {
get {
public int getStyle() {
return m_style;
}
}
}
#if !JAVA
}
#endif

View File

@ -1,4 +1,5 @@
/*
#if !JAVA
/*
* BHScrollBar.Designer.cs
* Copyright (c) 2009 kbinani
*
@ -12,7 +13,7 @@
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*/
namespace Boare.Lib.AppUtil {
partial class BHScrollBar {
partial class OBSOLUTE_BHScrollBar {
/// <summary>
/// 必要なデザイナ変数です。
/// </summary>
@ -64,3 +65,4 @@ namespace Boare.Lib.AppUtil {
private System.Windows.Forms.HScrollBar hScroll;
}
}
#endif

View File

@ -1,4 +1,5 @@
/*
#if !JAVA
/*
* BHScrollBar.cs
* Copyright (c) 2009 kbinani
*
@ -19,13 +20,13 @@ namespace Boare.Lib.AppUtil {
/// <summary>
/// Valueの値が正しくMinimumからMaximumの間を動くスクロールバー
/// </summary>
public partial class BHScrollBar : UserControl {
public partial class OBSOLUTE_BHScrollBar : UserControl {
int m_max = 100;
int m_min = 0;
public event EventHandler ValueChanged;
public BHScrollBar() {
public OBSOLUTE_BHScrollBar() {
InitializeComponent();
}
@ -84,3 +85,4 @@ namespace Boare.Lib.AppUtil {
}
}
#endif

View File

@ -1,4 +1,5 @@
/*
#if !JAVA
/*
* BSplitContainer.cs
* Copyright (c) 2008-2009 kbinani
*
@ -102,6 +103,14 @@ namespace Boare.Lib.AppUtil {
}
}
public bool isSplitterFixed() {
return this.IsSplitterFixed;
}
public void setSplitterFixed( bool value ) {
this.IsSplitterFixed = value;
}
/// <summary>
/// 使用中のリソースをすべてクリーンアップします。
/// </summary>
@ -277,6 +286,14 @@ namespace Boare.Lib.AppUtil {
}
}
public int getDividerSize() {
return this.SplitterWidth;
}
public void setDividerSize( int value ) {
this.SplitterWidth = value;
}
private bool UpdateLayout( int splitter_distance, int splitter_width, int panel1_min, int panel2_min, bool check_only ) {
Point mouse = this.PointToClient( Control.MousePosition );
int pad1 = (m_panel1.BorderStyle == BorderStyle.FixedSingle) ? 1 : 0;
@ -396,6 +413,14 @@ namespace Boare.Lib.AppUtil {
}
}
public int getDividerLocation() {
return this.SplitterDistance;
}
public void setDividerLocation( int value ) {
this.SplitterDistance = value;
}
public Orientation Orientation {
get {
return m_orientation;
@ -504,3 +529,4 @@ namespace Boare.Lib.AppUtil {
}
}
#endif

View File

@ -1,4 +1,5 @@
/*
#if !JAVA
/*
* BSplitterPanel.cs
* Copyright (c) 2008-2009 kbinani
*
@ -94,3 +95,4 @@ namespace Boare.Lib.AppUtil {
}
}
#endif

View File

@ -1,4 +1,5 @@
/*
#if !JAVA
/*
* BTrackBar.cs
* Copyright (c) 2009 kbinani
*
@ -287,3 +288,4 @@ namespace Boare.Lib.AppUtil {
}
}
#endif

View File

@ -12,7 +12,7 @@
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*/
namespace Boare.Lib.AppUtil {
partial class BVScrollBar {
partial class OBSOLUTE_BVScrollBar {
/// <summary>
/// 必要なデザイナ変数です。
/// </summary>

View File

@ -1,4 +1,5 @@
/*
#if !JAVA
/*
* BVScrollBar.cs
* Copyright (c) 2009 kbinani
*
@ -19,13 +20,13 @@ namespace Boare.Lib.AppUtil {
/// <summary>
/// Valueの値が正しくMinimumからMaximumの間を動くスクロールバー
/// </summary>
public partial class BVScrollBar : UserControl {
public partial class OBSOLUTE_BVScrollBar : UserControl {
int m_max = 100;
int m_min = 0;
public event EventHandler ValueChanged;
public BVScrollBar() {
public OBSOLUTE_BVScrollBar() {
InitializeComponent();
}
@ -84,3 +85,4 @@ namespace Boare.Lib.AppUtil {
}
}
#endif

View File

@ -1,4 +1,5 @@
/*
#if !JAVA
/*
* BitmapEx.cs
* Copyright (c) 2008-2009 kbinani
*
@ -157,3 +158,4 @@ namespace Boare.Lib.AppUtil {
}
}
#endif

View File

@ -3,7 +3,7 @@
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>9.0.30729</ProductVersion>
<ProductVersion>9.0.21022</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{0C58B068-272F-4390-A14F-3D72AFCF3DFB}</ProjectGuid>
<OutputType>Library</OutputType>
@ -18,37 +18,17 @@
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<DocumentationFile>Boare.Lib.AppUtil.xml</DocumentationFile>
<DefineConstants>DEBUG</DefineConstants>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<DocumentationFile>bin\x86\Debug\Boare.Lib.AppUtil.XML</DocumentationFile>
<PlatformTarget>AnyCPU</PlatformTarget>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<DocumentationFile>Boare.Lib.AppUtil.xml</DocumentationFile>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
<PlatformTarget>x86</PlatformTarget>
<OutputPath>bin\x86\Debug\</OutputPath>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<DefineConstants>DEBUG</DefineConstants>
<DocumentationFile>bin\x86\Debug\Boare.Lib.AppUtil.XML</DocumentationFile>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
<PlatformTarget>x86</PlatformTarget>
<OutputPath>bin\x86\Release\</OutputPath>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<DocumentationFile>bin\x86\Release\Boare.Lib.AppUtil.XML</DocumentationFile>
<PlatformTarget>AnyCPU</PlatformTarget>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
@ -81,14 +61,10 @@
<Compile Include="InputBox.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="InputBox.Designer.cs">
<DependentUpon>InputBox.cs</DependentUpon>
</Compile>
<Compile Include="ISO639.cs" />
<Compile Include="MessageBodyEntry.cs" />
<Compile Include="Messaging.cs" />
<Compile Include="MessageBody.cs" />
<Compile Include="Misc.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="BSplitContainer.cs">
<SubType>Component</SubType>
@ -99,6 +75,7 @@
<Compile Include="BTrackBar.cs">
<SubType>UserControl</SubType>
</Compile>
<Compile Include="Util.cs" />
<Compile Include="VersionInfo.cs">
<SubType>Form</SubType>
</Compile>
@ -111,8 +88,6 @@
<Compile Include="BVScrollBar.Designer.cs">
<DependentUpon>BVScrollBar.cs</DependentUpon>
</Compile>
<Compile Include="XmlSerializeWithDescription.cs" />
<Compile Include="XmlStaticMemberSerializer.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\bocoree\bocoree.csproj">

View File

@ -1,3 +1,4 @@
#if !JAVA
/*
* ColorBar.cs
* Copyright (c) 2008-2009 kbinani
@ -41,7 +42,7 @@ namespace Boare.Lib.AppUtil {
rflow_rainbow = 20,
}
public static partial class Misc {
public static partial class Util {
const double OPORT_OP_PI = 3.141592653589793238462643383279502884197169399;
const double OPORT_OP_PI2 = 3.141592653589793238462643383279502884197169399 * 2.0;
const double OPORT_OP_1P9 = 1.0 / 9.0;
@ -120,7 +121,7 @@ namespace Boare.Lib.AppUtil {
h = oport_colorbar_rainbow_banded_h( y );
s = oport_colorbar_rainbow_banded_s( y );
v = oport_colorbar_rainbow_banded_v( y );
HsvToRgb( h, s, v, out r, out g, out b );
Util.HsvToRgb( h, s, v, out r, out g, out b );
red = (int)(r * 255.0);
green = (int)(g * 255.0);
blue = (int)(b * 255.0);
@ -139,7 +140,7 @@ namespace Boare.Lib.AppUtil {
h = oport_colorbar_rainbow_striped_h( y );
s = oport_colorbar_rainbow_striped_s( y );
v = oport_colorbar_rainbow_striped_v( y );
HsvToRgb( h, s, v, out r, out g, out b );
Util.HsvToRgb( h, s, v, out r, out g, out b );
red = (int)(r * 255.0);
green = (int)(g * 255.0);
blue = (int)(b * 255.0);
@ -1116,3 +1117,4 @@ namespace Boare.Lib.AppUtil {
}
}
#endif

View File

@ -1,4 +1,5 @@
/*
#if !JAVA
/*
* CubicSpline.cs
* Copyright (c) 2008-2009 kbinani
*
@ -273,3 +274,4 @@ namespace Boare.Lib.AppUtil {
}
}
#endif

View File

@ -1,4 +1,5 @@
#define RGB24
#if !JAVA
#define RGB24
using System;
using System.Runtime.InteropServices;
using System.Drawing;
@ -208,3 +209,4 @@ namespace Boare.Lib.AppUtil {
}
}
#endif

View File

@ -1,4 +1,5 @@
using System;
#if !JAVA
using System;
using System.Windows.Forms;
namespace Boare.Lib.AppUtil {
@ -7,3 +8,4 @@ namespace Boare.Lib.AppUtil {
}
}
#endif

View File

@ -1,4 +1,5 @@
/*
#if !JAVA
/*
* ISO639.cs
* Copyright (c) 2008-2009 kbinani
*
@ -27,3 +28,4 @@ namespace Boare.Lib.AppUtil {
}
}
#endif

View File

@ -97,6 +97,7 @@ namespace Boare.Lib.AppUtil {
this.Name = "InputBox";
this.ShowIcon = false;
this.ShowInTaskbar = false;
this.StartPosition = System.Windows.Forms.FormStartPosition.Manual;
this.Text = "InputBox";
this.ResumeLayout( false );
this.PerformLayout();

View File

@ -11,27 +11,281 @@
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*/
#if JAVA
package org.kbinani.apputil;
import java.awt.*;
import javax.swing.*;
import org.kbinani.*;
import org.kbinani.windows.forms.*;
#else
using System;
using System.Windows.Forms;
using bocoree.windows.forms;
namespace Boare.Lib.AppUtil {
public partial class InputBox : Form {
public InputBox( string message ) {
using BEventArgs = System.EventArgs;
#endif
#if JAVA
public class InputBox extends BForm{
#else
public class InputBox : BForm {
#endif
private BLabel lblMessage;
private BButton btnCancel;
private BTextBox txtInput;
private BButton btnOk;
#if JAVA
public boolean closed = false;
private BDialogResult m_result = BDialogResult.CANCEL;
#else
/// <summary>
/// 必要なデザイナ変数です。
/// </summary>
private System.ComponentModel.IContainer components = null;
#endif
public InputBox( String message ) {
#if JAVA
initializeComponent();
#else
InitializeComponent();
lblMessage.Text = message;
#endif
lblMessage.setText( message );
}
public string Result {
get {
return txtInput.Text;
#if JAVA
public class ShowDialogRunner implements Runnable{
public void run(){
show();
while( !closed ){
try{
Thread.sleep( 100 );
}catch( Exception ex ){
break;
}
set {
txtInput.Text = value;
}
hide();
}
}
private void btnOk_Click( object sender, EventArgs e ) {
public BDialogResult showDialog(){
Thread t = new Thread( new ShowDialogRunner() );
t.run();
return m_result;
}
#endif
public String getResult(){
return txtInput.getText();
}
public void setResult( String value ){
txtInput.setText( value );
}
public void btnOk_Click( Object sender, BEventArgs e ) {
#if JAVA
closed = true;
m_result = BDialogResult.OK;
#else
DialogResult = DialogResult.OK;
#endif
}
#if JAVA
private void initializeComponent(){
txtInput = new BTextBox();
btnOk = new BButton();
lblMessage = new BLabel();
btnCancel = new BButton();
//
// txtInput
//
//
// btnOk
//
this.btnOk.setText( "OK" );
this.btnOk.clickEvent.add( new BEventHandler( this, "btnOk_Click" ) );
//
// lblMessage
//
//
// btnCancel
//
this.btnCancel.setText( "Cancel" );
this.btnCancel.setVisible( false );
//
// InputBox
//
GridBagLayout gridbag = new GridBagLayout();
GridBagConstraints c = new GridBagConstraints();
setLayout( gridbag );
// 1段目
JPanel jp1_1 = new JPanel();
gridbag.setConstraints( jp1_1, c );
add( jp1_1 );
c.gridwidth = 2;
c.fill = GridBagConstraints.HORIZONTAL;
gridbag.setConstraints( lblMessage, c );
add( lblMessage );
JPanel jp1_2 = new JPanel();
c.gridwidth = GridBagConstraints.REMAINDER;
c.fill = GridBagConstraints.NONE;
gridbag.setConstraints( jp1_2, c );
add( jp1_2 );
// 2段目
JPanel jp2_1 = new JPanel();
c.gridwidth = 1;
gridbag.setConstraints( jp2_1, c );
add( jp2_1 );
c.gridwidth = 2;
c.fill = GridBagConstraints.HORIZONTAL;
c.weightx = 1.0;
gridbag.setConstraints( txtInput, c );
add( txtInput );
JPanel jp2_2 = new JPanel();
c.gridwidth = GridBagConstraints.REMAINDER;
c.fill = GridBagConstraints.NONE;
c.weightx = 0.0;
gridbag.setConstraints( jp2_2, c );
add( jp2_2 );
// 3段目
JPanel jp3 = new JPanel();
c.gridwidth = GridBagConstraints.REMAINDER;
gridbag.setConstraints( jp3, c );
add( jp3 );
// 4段目
JPanel jp4_1 = new JPanel();
c.gridwidth = 2;
gridbag.setConstraints( jp4_1, c );
add( jp4_1 );
c.gridwidth = 1;
c.anchor = GridBagConstraints.EAST;
gridbag.setConstraints( btnOk, c );
add( btnOk );
JPanel jp4_2 = new JPanel();
c.gridwidth = GridBagConstraints.REMAINDER;
c.anchor = GridBagConstraints.CENTER;
gridbag.setConstraints( jp4_2, c );
add( jp4_2 );
// 5段目
JPanel jp5 = new JPanel();
c.gridwidth = GridBagConstraints.REMAINDER;
c.gridheight = GridBagConstraints.REMAINDER;
c.fill = GridBagConstraints.BOTH;
gridbag.setConstraints( jp5, c );
add( jp5 );
this.formClosedEvent.add( new BEventHandler( this, "InputBox_FormClosed" ) );
this.setTitle( "InputBox" );
this.setSize( 339, 110 );
}
public void InputBox_FormClosed( Object sender, BEventArgs e ){
closed = true;
}
#else
/// <summary>
/// 使用中のリソースをすべてクリーンアップします。
/// </summary>
/// <param name="disposing">マネージ リソースが破棄される場合 true、破棄されない場合は false です。</param>
protected override void Dispose( bool disposing ) {
if ( disposing && (components != null) ) {
components.Dispose();
}
base.Dispose( disposing );
}
#region Windows
/// <summary>
/// デザイナ サポートに必要なメソッドです。このメソッドの内容を
/// コード エディタで変更しないでください。
/// </summary>
private void InitializeComponent() {
this.txtInput = new BTextBox();
this.btnOk = new BButton();
this.lblMessage = new BLabel();
this.btnCancel = new BButton();
this.SuspendLayout();
//
// txtInput
//
this.txtInput.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.txtInput.Location = new System.Drawing.Point( 12, 24 );
this.txtInput.Name = "txtInput";
this.txtInput.Size = new System.Drawing.Size( 309, 19 );
this.txtInput.TabIndex = 0;
//
// btnOk
//
this.btnOk.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.btnOk.Location = new System.Drawing.Point( 246, 49 );
this.btnOk.Name = "btnOk";
this.btnOk.Size = new System.Drawing.Size( 75, 23 );
this.btnOk.TabIndex = 1;
this.btnOk.Text = "OK";
this.btnOk.UseVisualStyleBackColor = true;
this.btnOk.Click += new System.EventHandler( this.btnOk_Click );
//
// lblMessage
//
this.lblMessage.AutoSize = true;
this.lblMessage.Location = new System.Drawing.Point( 12, 9 );
this.lblMessage.Name = "lblMessage";
this.lblMessage.Size = new System.Drawing.Size( 0, 12 );
this.lblMessage.TabIndex = 2;
//
// btnCancel
//
this.btnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
this.btnCancel.Location = new System.Drawing.Point( -100, 49 );
this.btnCancel.Name = "btnCancel";
this.btnCancel.Size = new System.Drawing.Size( 75, 23 );
this.btnCancel.TabIndex = 3;
this.btnCancel.Text = "Cancel";
this.btnCancel.UseVisualStyleBackColor = true;
//
// InputBox
//
this.AcceptButton = this.btnOk;
this.AutoScaleDimensions = new System.Drawing.SizeF( 6F, 12F );
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.CancelButton = this.btnCancel;
this.ClientSize = new System.Drawing.Size( 333, 82 );
this.Controls.Add( this.btnCancel );
this.Controls.Add( this.lblMessage );
this.Controls.Add( this.btnOk );
this.Controls.Add( this.txtInput );
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "InputBox";
this.ShowIcon = false;
this.ShowInTaskbar = false;
this.StartPosition = System.Windows.Forms.FormStartPosition.Manual;
this.Text = "InputBox";
this.ResumeLayout( false );
this.PerformLayout();
}
#endregion
#endif
}
#if !JAVA
}
#endif

View File

@ -11,192 +11,235 @@
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*/
#if JAVA
package org.kbinani.apputil;
import java.util.*;
import java.io.*;
import java.awt.image.*;
import org.kbinani.*;
#else
using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using bocoree;
using bocoree.java.util;
using bocoree.java.io;
namespace Boare.Lib.AppUtil {
using boolean = System.Boolean;
#endif
public class MessageBody {
public string lang;
public string po_header = "";
public Dictionary<string, MessageBodyEntry> list = new Dictionary<string, MessageBodyEntry>();
public String lang;
public String poHeader = "";
public TreeMap<String, MessageBodyEntry> list = new TreeMap<String, MessageBodyEntry>();
public MessageBody( string lang_ ) {
public MessageBody( String lang_ ) {
lang = lang_;
}
public MessageBody( string lang, string[] ids, string[] messages ) {
public MessageBody( String lang, String[] ids, String[] messages ) {
this.lang = lang;
list = new Dictionary<string, MessageBodyEntry>();
list = new TreeMap<String, MessageBodyEntry>();
for( int i = 0; i < ids.Length; i++ ) {
list.Add( ids[i], new MessageBodyEntry( messages[i], new string[] { } ) );
list.put( ids[i], new MessageBodyEntry( messages[i], new String[] { } ) );
}
}
public MessageBody( string lang_, string file ) {
public MessageBody( String lang_, String file ) {
lang = lang_;
po_header = "";
using ( StreamReader sr = new StreamReader( file ) ) {
while ( sr.Peek() >= 0 ) {
string msgid;
string first_line = sr.ReadLine();
string[] location;
string last_line = ReadTillMessageEnd( sr, first_line, "msgid", out msgid, out location );
string msgstr;
string[] location_dumy;
last_line = ReadTillMessageEnd( sr, last_line, "msgstr", out msgstr, out location_dumy );
if ( msgid.Length > 0 ) {
if ( list.ContainsKey( msgid ) ) {
list[msgid] = new MessageBodyEntry( msgstr, location );
poHeader = "";
BufferedReader sr = null;
try {
sr = new BufferedReader( new FileReader( file ) );
String line2 = "";
while ( (line2 = sr.readLine()) != null ) {
ByRef<String> msgid = new ByRef<String>( "" );
String first_line = line2;
ByRef<String[]> location = new ByRef<String[]>();
String last_line = readTillMessageEnd( sr, first_line, "msgid", msgid, location );
ByRef<String> msgstr = new ByRef<String>( "" );
ByRef<String[]> location_dumy = new ByRef<String[]>();
last_line = readTillMessageEnd( sr, last_line, "msgstr", msgstr, location_dumy );
if ( PortUtil.getStringLength( msgid.value ) > 0 ) {
list.put( msgid.value, new MessageBodyEntry( msgstr.value, location.value ) );
} else {
list.Add( msgid, new MessageBodyEntry( msgstr, location ) );
}
} else {
po_header = msgstr;
string[] spl = po_header.Split( new char[] { (char)0x0d, (char)0x0a }, StringSplitOptions.RemoveEmptyEntries );
po_header = "";
poHeader = msgstr.value;
String[] spl = PortUtil.splitString( poHeader, new char[] { (char)0x0d, (char)0x0a }, true );
poHeader = "";
int count = 0;
foreach ( string line in spl ) {
string[] spl2 = line.Split( new char[] { ':' }, 2 );
for ( int i = 0; i < spl.Length; i++ ) {
String line = spl[i];
String[] spl2 = PortUtil.splitString( line, new char[] { ':' }, 2 );
if ( spl2.Length == 2 ) {
string name = spl2[0].Trim();
if ( name.ToLower() == "Content-Type".ToLower() ) {
po_header += (count == 0 ? "" : "\n") + "Content-Type: text/plain; charset=UTF-8";
} else if ( name.ToLower() == "Content-Transfer-Encoding".ToLower() ) {
po_header += (count == 0 ? "" : "\n") + "Content-Transfer-Encoding: 8bit";
String name = spl2[0].Trim();
String ct = "Content-Type";
String cte = "Content-Transfer-Encoding";
if ( name.ToLower().Equals( ct.ToLower() ) ) {
poHeader += (count == 0 ? "" : "\n") + "Content-Type: text/plain; charset=UTF-8";
} else if ( name.ToLower().Equals( cte.ToLower() ) ) {
poHeader += (count == 0 ? "" : "\n") + "Content-Transfer-Encoding: 8bit";
} else {
po_header += (count == 0 ? "" : "\n") + line;
poHeader += (count == 0 ? "" : "\n") + line;
}
} else {
po_header += (count == 0 ? "" : "\n") + line;
poHeader += (count == 0 ? "" : "\n") + line;
}
count++;
}
}
}
} catch ( Exception ex ) {
} finally {
if ( sr != null ) {
try {
sr.close();
} catch ( Exception ex2 ) {
}
}
}
#if DEBUG
Console.WriteLine( "MessageBody..ctor; po_header=" + po_header );
#endif
}
public string GetMessage( string id ) {
if ( list.ContainsKey( id ) ) {
string ret = list[id].Message;
if ( ret == "" ) {
public String getMessage( String id ) {
if ( list.containsKey( id ) ) {
String ret = list.get( id ).message;
if ( ret.Equals( "" ) ) {
return id;
} else {
return list[id].Message;
return list.get( id ).message;
}
}
return id;
}
public MessageBodyEntry GetMessageDetail( string id ) {
if ( list.ContainsKey( id ) ) {
string ret = list[id].Message;
if ( ret == "" ) {
return new MessageBodyEntry( id, new string[] { } );
public MessageBodyEntry getMessageDetail( String id ) {
if ( list.containsKey( id ) ) {
String ret = list.get( id ).message;
if ( ret.Equals( "" ) ) {
return new MessageBodyEntry( id, new String[] { } );
} else {
return list[id];
return list.get( id );
}
}
return new MessageBodyEntry( id, new string[] { } );
return new MessageBodyEntry( id, new String[] { } );
}
public void Write( string file ) {
using ( StreamWriter sw = new StreamWriter( file ) ) {
if ( po_header != "" ) {
sw.WriteLine( "msgid \"\"" );
sw.WriteLine( "msgstr \"\"" );
string[] spl = po_header.Split( new char[] { (char)0x0d, (char)0x0a }, StringSplitOptions.RemoveEmptyEntries );
foreach ( string line in spl ) {
sw.WriteLine( "\"" + line + "\\" + "n\"" );
public void write( String file ) {
BufferedWriter sw = null;
try {
sw = new BufferedWriter( new FileWriter( file ) );
if ( !poHeader.Equals( "" ) ) {
sw.write( "msgid \"\"" );
sw.newLine();
sw.write( "msgstr \"\"" );
sw.newLine();
String[] spl = PortUtil.splitString( poHeader, new char[] { (char)0x0d, (char)0x0a }, true );
for ( int i = 0; i < spl.Length; i++ ){
String line = spl[i];
sw.write( "\"" + line + "\\" + "n\"" );
sw.newLine();
}
sw.WriteLine();
sw.newLine();
} else {
sw.WriteLine( "msgid \"\"" );
sw.WriteLine( "msgstr \"\"" );
sw.WriteLine( "\"Content-Type: text/plain; charset=UTF-8\\" + "n\"" );
sw.WriteLine( "\"Content-Transfer-Encoding: 8bit\\" + "n\"" );
sw.WriteLine();
sw.write( "msgid \"\"" );
sw.newLine();
sw.write( "msgstr \"\"" );
sw.newLine();
sw.write( "\"Content-Type: text/plain; charset=UTF-8\\" + "n\"" );
sw.newLine();
sw.write( "\"Content-Transfer-Encoding: 8bit\\" + "n\"" );
sw.newLine();
sw.newLine();
}
foreach ( string key in list.Keys ) {
string skey = key.Replace( "\n", "\\n\"\n\"" );
string s = list[key].Message;
List<string> location = list[key].Location;
for ( int i = 0; i < location.Count; i++ ) {
sw.WriteLine( "#: " + location[i] );
for ( Iterator itr = list.keySet().iterator(); itr.hasNext(); ){
String key = (String)itr.next();
String skey = key.Replace( "\n", "\\n\"\n\"" );
MessageBodyEntry mbe = list.get( key );
String s = mbe.message;
Vector<String> location = mbe.location;
int count = location.size();
for ( int i = 0; i < count; i++ ) {
sw.write( "#: " + location.get( i ) );
sw.newLine();
}
sw.WriteLine( "msgid \"" + skey + "\"" );
sw.write( "msgid \"" + skey + "\"" );
sw.newLine();
s = s.Replace( "\n", "\\n\"\n\"" );
sw.WriteLine( "msgstr \"" + s + "\"" );
sw.WriteLine();
sw.write( "msgstr \"" + s + "\"" );
sw.newLine();
sw.newLine();
}
} catch ( Exception ex ) {
} finally {
if ( sw != null ) {
try {
sw.close();
} catch ( Exception ex2 ) {
}
}
}
}
private static void SeparateEntryAndMessage( string source, out string entry, out string message ) {
string line = source.Trim();
entry = "";
message = "";
if ( line.Length <= 0 ) {
private static void separateEntryAndMessage( String source, ByRef<String> entry, ByRef<String> message ) {
String line = source.Trim();
entry.value = "";
message.value = "";
if ( PortUtil.getStringLength( line ) <= 0 ) {
return;
}
int index_space = line.IndexOf( ' ' );
int index_dquoter = line.IndexOf( '"' );
int index = Math.Min( index_dquoter, index_space );
entry = line.Substring( 0, index );
message = line.Substring( index_dquoter + 1 );
message = message.Substring( 0, message.Length - 1 );
entry.value = line.Substring( 0, index );
message.value = line.Substring( index_dquoter + 1 );
message.value = message.value.Substring( 0, PortUtil.getStringLength( message.value ) - 1 );
}
private static string ReadTillMessageEnd( StreamReader sr, string first_line, string entry, out string msg, out string[] locations ) {
msg = "";
string line = first_line;
List<string> location = new List<string>();
bool entry_found = false;
private static String readTillMessageEnd( BufferedReader sr, String first_line, String entry, ByRef<String> msg, ByRef<String[]> locations )
#if JAVA
throws IOException
#endif
{
msg.value = "";
String line = first_line;
Vector<String> location = new Vector<String>();
boolean entry_found = false;
if ( line.StartsWith( entry ) ) {
// 1行目がすでに"entry"の行だった場合
string dum, dum2;
SeparateEntryAndMessage( line, out dum, out dum2 );
msg += dum2;
ByRef<String> dum = new ByRef<String>( "" );
ByRef<String> dum2 = new ByRef<String>( "" );
separateEntryAndMessage( line, dum, dum2 );
msg.value += dum2.value;
} else {
while ( true ) {
while ( (line = sr.readLine()) != null ) {
if ( line.StartsWith( "#:" ) ) {
line = line.Substring( 2 ).Trim();
location.Add( line );
location.add( line );
} else if ( line.StartsWith( entry ) ) {
string dum, dum2;
SeparateEntryAndMessage( line, out dum, out dum2 );
msg += dum2;
break;
}
if ( sr.Peek() >= 0 ) {
line = sr.ReadLine();
} else {
ByRef<String> dum = new ByRef<String>( "" );
ByRef<String> dum2 = new ByRef<String>( "" );
separateEntryAndMessage( line, dum, dum2 );
msg.value += dum2.value;
break;
}
}
}
locations = location.ToArray();
string ret = "";
while ( sr.Peek() >= 0 ) {
line = sr.ReadLine();
locations.value = location.toArray( new String[] { } );
String ret = "";
while ( (line = sr.readLine()) != null ) {
if ( !line.StartsWith( "\"" ) ) {
msg = msg.Replace( "\\\"", "\"" );
msg = msg.Replace( "\\n", "\n" );
msg.value = msg.value.Replace( "\\\"", "\"" );
msg.value = msg.value.Replace( "\\n", "\n" );
return line;
}
int index = line.LastIndexOf( "\"" );
msg += line.Substring( 1, index - 1 );
msg.value += line.Substring( 1, index - 1 );
}
msg = msg.Replace( "\\\"", "\"" );
msg = msg.Replace( "\\n", "\n" );
msg.value = msg.value.Replace( "\\\"", "\"" );
msg.value = msg.value.Replace( "\\n", "\n" );
return line;
}
}
#if !JAVA
}
#endif

View File

@ -11,21 +11,29 @@
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*/
#if JAVA
package org.kbinani.apputil;
import java.util.*;
#else
using System;
using System.Collections.Generic;
using bocoree.java.util;
namespace Boare.Lib.AppUtil {
#endif
public class MessageBodyEntry {
public string Message;
public List<string> Location = new List<string>();
public String message;
public Vector<String> location = new Vector<String>();
public MessageBodyEntry( string message, string[] location ) {
Message = message;
for ( int i = 0; i < location.Length; i++ ) {
Location.Add( location[i] );
public MessageBodyEntry( String message_, String[] location_ ) {
message = message_;
for ( int i = 0; i < location_.Length; i++ ) {
location.add( location_[i] );
}
}
}
#if !JAVA
}
#endif

View File

@ -11,109 +11,121 @@
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*/
#if JAVA
package org.kbinani.apputil;
import org.kbinani.*;
import java.util.*;
#else
using System;
using System.Collections.Generic;
using System.IO;
using System.Windows.Forms;
using bocoree;
using bocoree.java.util;
namespace Boare.Lib.AppUtil {
#endif
public static class Messaging {
private static string s_lang = "";
private static List<MessageBody> s_messages = new List<MessageBody>();
public class Messaging {
private static String s_lang = "";
private static Vector<MessageBody> s_messages = new Vector<MessageBody>();
public static string[] GetKeys( string lang ) {
foreach ( MessageBody dict in s_messages ) {
if ( lang == dict.lang ) {
List<string> list = new List<string>();
foreach ( string key in dict.list.Keys ) {
list.Add( key );
public static String[] getKeys( String lang ) {
for( Iterator itr = s_messages.iterator(); itr.hasNext(); ){
MessageBody dict = (MessageBody)itr.next();
if ( lang.Equals( dict.lang ) ) {
Vector<String> list = new Vector<String>();
for ( Iterator itr2 = dict.list.keySet().iterator(); itr2.hasNext(); ) {
String key = (String)itr2.next();
list.add( key );
}
return list.ToArray();
return list.toArray( new String[] { } );
}
}
return null;
}
public static string[] GetRegisteredLanguage() {
List<string> res = new List<string>();
foreach ( MessageBody dict in s_messages ) {
res.Add( dict.lang );
public static String[] getRegisteredLanguage() {
Vector<String> res = new Vector<String>();
for ( Iterator itr = s_messages.iterator(); itr.hasNext(); ) {
MessageBody dict = (MessageBody)itr.next();
res.add( dict.lang );
}
return res.ToArray();
return res.toArray( new String[] { } );
}
public static string Language {
get {
if ( s_lang != "" ) {
public static String getLanguage() {
if ( !s_lang.Equals( "" ) ) {
return s_lang;
} else {
s_lang = "en";
return s_lang;
}
}
set {
if ( value != "" ) {
public static void setLanguage( String value ) {
if ( !value.Equals( "" ) ) {
s_lang = value;
} else {
s_lang = "en";
}
}
}
/// <summary>
/// 現在の実行ディレクトリにある言語設定ファイルを全て読込み、メッセージリストに追加します
/// </summary>
public static void LoadMessages() {
LoadMessages( Application.StartupPath );
public static void loadMessages() {
loadMessages( PortUtil.getApplicationStartupPath() );
}
/// <summary>
/// 指定されたディレクトリにある言語設定ファイルを全て読込み、メッセージリストに追加します
/// </summary>
/// <param name="directory"></param>
public static void LoadMessages( string directory ) {
DirectoryInfo current = new DirectoryInfo( directory );
s_messages.Clear();
public static void loadMessages( String directory ) {
s_messages.clear();
#if DEBUG
Console.WriteLine( "Messaging+LoadMessages()" );
#endif
foreach ( FileInfo fi in current.GetFiles( "*.po" ) ) {
string fname = fi.FullName;
String[] files = PortUtil.listFiles( directory, ".po" );
for ( int i = 0; i < files.Length; i++ ){
String fname = PortUtil.combinePath( directory, files[i] );
#if DEBUG
Console.WriteLine( " fname=" + fname );
#endif
AppendFromFile( fname );
appendFromFile( fname );
}
}
public static void AppendFromFile( string file ) {
s_messages.Add( new MessageBody( Path.GetFileNameWithoutExtension( file ), file ) );
public static void appendFromFile( String file ) {
s_messages.add( new MessageBody( PortUtil.getFileNameWithoutExtension( file ), file ) );
}
public static MessageBodyEntry GetMessageDetail( string id ) {
if ( s_lang.Length <= 0 ) {
public static MessageBodyEntry getMessageDetail( String id ) {
if ( s_lang.Equals( "" ) ) {
s_lang = "en";
}
foreach ( MessageBody mb in s_messages ) {
if ( mb.lang == s_lang ) {
return mb.GetMessageDetail( id );
for ( Iterator itr = s_messages.iterator(); itr.hasNext(); ){
MessageBody mb = (MessageBody)itr.next();
if ( mb.lang.Equals( s_lang ) ) {
return mb.getMessageDetail( id );
}
}
return new MessageBodyEntry( id, new string[] { } );
return new MessageBodyEntry( id, new String[] { } );
}
public static string GetMessage( string id ) {
if ( s_lang.Length <= 0 ) {
public static String getMessage( String id ) {
if ( s_lang.Equals( "" ) ) {
s_lang = "en";
}
foreach ( MessageBody mb in s_messages ) {
if ( mb.lang == s_lang ) {
return mb.GetMessage( id );
for ( Iterator itr = s_messages.iterator(); itr.hasNext(); ){
MessageBody mb = (MessageBody)itr.next();
if ( mb.lang.Equals( s_lang ) ) {
return mb.getMessage( id );
}
}
return id;
}
}
#if !JAVA
}
#endif

View File

@ -21,7 +21,7 @@ using System.Windows.Forms;
namespace Boare.Lib.AppUtil {
public static partial class Misc {
public static partial class Util {
public static void ApplyContextMenuFontRecurse( ContextMenuStrip item, Font font ) {
item.Font = font;
foreach ( ToolStripItem tsi in item.Items ) {

View File

@ -115,10 +115,10 @@ namespace Boare.Lib.AppUtil {
public void ApplyLanguage() {
string about = string.Format( _( "About {0}" ), m_app_name );
string credit = _( "Credit" );
Size size1 = Misc.MeasureString( about, btnFlip.Font );
Size size2 = Misc.MeasureString( credit, btnFlip.Font );
m_button_width_about = Math.Max( 75, (int)(size1.Width * 1.3) );
m_button_width_credit = Math.Max( 75, (int)(size2.Width * 1.3) );
bocoree.java.awt.Dimension size1 = Util.measureString( about, new bocoree.java.awt.Font( btnFlip.Font ) );
bocoree.java.awt.Dimension size2 = Util.measureString( credit, new bocoree.java.awt.Font( btnFlip.Font ) );
m_button_width_about = Math.Max( 75, (int)(size1.width * 1.3) );
m_button_width_credit = Math.Max( 75, (int)(size2.width * 1.3) );
if( m_credit_mode ) {
btnFlip.Width = m_button_width_about;
btnFlip.Text = about;

View File

@ -1,4 +1,5 @@
/*
#if !JAVA
/*
* VersionInfo.cs
* Copyright (c) 2008-2009 kbinani
*
@ -12,13 +13,19 @@
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*/
using System;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Windows.Forms;
//using System.Drawing;
//using System.Drawing.Drawing2D;
//using System.Windows.Forms;
using bocoree;
using bocoree.java.awt;
using bocoree.java.awt.image;
namespace Boare.Lib.AppUtil {
using java = bocoree.java;
using javax = bocoree.javax;
using Graphics = bocoree.java.awt.Graphics2D;
public partial class VersionInfo : Form {
public partial class VersionInfo : System.Windows.Forms.Form {
DateTime m_scroll_started;
private AuthorListEntry[] m_credit;
const float m_speed = 35f;
@ -29,12 +36,12 @@ namespace Boare.Lib.AppUtil {
float m_shift = 0f;
int m_button_width_about = 75;
int m_button_width_credit = 75;
Bitmap m_scroll;
BufferedImage m_scroll;
const int m_height = 380;
readonly Color m_background = Color.White;
readonly Color m_background = Color.white;
private string m_app_name = "";
private Color m_app_name_color = Color.Black;
private Color m_version_color = Color.FromArgb( 105, 105, 105 );
private Color m_app_name_color = Color.black;
private Color m_version_color = new Color( 105, 105, 105 );
private bool m_shadow_enablde = true;
public VersionInfo( string app_name, string version ) {
@ -43,9 +50,9 @@ namespace Boare.Lib.AppUtil {
InitializeComponent();
ApplyLanguage();
this.SetStyle( ControlStyles.DoubleBuffer, true );
this.SetStyle( ControlStyles.UserPaint, true );
this.SetStyle( ControlStyles.AllPaintingInWmPaint, true );
this.SetStyle( System.Windows.Forms.ControlStyles.DoubleBuffer, true );
this.SetStyle( System.Windows.Forms.ControlStyles.UserPaint, true );
this.SetStyle( System.Windows.Forms.ControlStyles.AllPaintingInWmPaint, true );
m_credit = new AuthorListEntry[] { };
btnSaveAuthorList.Visible = false;
@ -63,7 +70,7 @@ namespace Boare.Lib.AppUtil {
}
public static string _( string s ) {
return Messaging.GetMessage( s );
return Messaging.getMessage( s );
}
/// <summary>
@ -90,7 +97,7 @@ namespace Boare.Lib.AppUtil {
}
}
public Bitmap Credit {
public BufferedImage Credit {
set {
m_scroll = value;
}
@ -118,55 +125,44 @@ namespace Boare.Lib.AppUtil {
const float shadow_shift = 2f;
const string font_name = "Arial";
const int font_size = 10;
Font font = new Font( font_name, font_size );
Size size = Boare.Lib.AppUtil.Misc.MeasureString( "Qjqp", font );
Font font = new Font( font_name, java.awt.Font.PLAIN, font_size );
Dimension size = Boare.Lib.AppUtil.Util.measureString( "Qjqp", font );
float width = this.Width;
float height = size.Height;
StringFormat sf = new StringFormat();
m_scroll = new Bitmap( (int)width, (int)(40f + m_credit.Length * height * 1.1f) );
using ( Graphics g = Graphics.FromImage( m_scroll ) ) {
sf.Alignment = StringAlignment.Center;
float height = size.height;
//StringFormat sf = new StringFormat();
m_scroll = new BufferedImage( (int)width, (int)(40f + m_credit.Length * height * 1.1f), BufferedImage.TYPE_INT_BGR );
Graphics2D g = m_scroll.createGraphics();
//sf.Alignment = StringAlignment.Center;
g.setFont( new Font( font_name, java.awt.Font.BOLD, (int)(font_size * 1.1f) ) );
if ( m_shadow_enablde ) {
g.DrawString( m_app_name,
new Font( font_name, (int)(font_size * 1.1f), FontStyle.Bold ),
new SolidBrush( Color.FromArgb( 40, Color.Black ) ),
new RectangleF( shadow_shift, shadow_shift, width, height ),
sf );
g.setColor( new Color( 0, 0, 0, 40 ) );
g.drawString( m_app_name, shadow_shift, shadow_shift ); //, width, height ), sf );
}
g.DrawString( m_app_name,
new Font( font_name, (int)(font_size * 1.1f), FontStyle.Bold ),
Brushes.Black,
new RectangleF( 0f, 0f, width, height ),
sf );
g.setColor( Color.black );
g.drawString( m_app_name, 0f, 0f ); //, width, height ), sf );
for ( int i = 0; i < m_credit.Length; i++ ) {
g.setFont( new Font( font_name, m_credit[i].getStyle(), font_size ) );
if ( m_shadow_enablde ) {
g.DrawString( m_credit[i].Name,
new Font( font_name, font_size, m_credit[i].Style ),
new SolidBrush( Color.FromArgb( 40, Color.Black ) ),
new RectangleF( 0f + shadow_shift, 40f + i * height * 1.1f + shadow_shift, width, height ),
sf );
}
g.DrawString( m_credit[i].Name,
new Font( font_name, font_size, m_credit[i].Style ),
Brushes.Black,
new RectangleF( 0f, 40f + i * height * 1.1f, width, height ),
sf );
g.setColor( new Color( 0, 0, 0, 40 ) );
g.drawString( m_credit[i].getName(), 0f + shadow_shift, 40f + i * height * 1.1f + shadow_shift ); //, width, height ), sf );
}
g.setColor( Color.black );
g.drawString( m_credit[i].getName(), 0f, 40f + i * height * 1.1f );// , width, height ), sf );
}
}
void btnSaveAuthorList_Click( object sender, EventArgs e ) {
#if DEBUG
using ( SaveFileDialog dlg = new SaveFileDialog() ){
if( dlg.ShowDialog() == DialogResult.OK ){
m_scroll.Save( dlg.FileName, System.Drawing.Imaging.ImageFormat.Png );
using ( System.Windows.Forms.SaveFileDialog dlg = new System.Windows.Forms.SaveFileDialog() ){
if( dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK ){
javax.imageio.ImageIO.write( m_scroll, "png", new java.io.File( dlg.FileName ) );
}
}
#endif
}
private void btnOK_Click( object sender, EventArgs e ) {
this.DialogResult = DialogResult.OK;
this.DialogResult = System.Windows.Forms.DialogResult.OK;
this.Close();
}
@ -193,50 +189,9 @@ namespace Boare.Lib.AppUtil {
this.Invalidate();
}
private void VersionInfoEx_Paint( object sender, PaintEventArgs e ) {
private void VersionInfoEx_Paint( object sender, System.Windows.Forms.PaintEventArgs e ) {
try {
Graphics g = e.Graphics;
g.Clip = new Region( new Rectangle( 0, 0, this.Width, m_height ) );
g.Clear( m_background );
if ( m_credit_mode ) {
float times = (float)(((DateTime.Now).Subtract( m_scroll_started )).TotalSeconds) - 3f;
float speed = (float)((2.0 - bocoree.math.erfcc( times * 0.8 )) / 2.0) * m_speed;
float dt = times - m_last_t;
m_shift += (speed + m_last_speed) * dt / 2f;
m_last_t = times;
m_last_speed = speed;
float dx = (this.Width - m_scroll.Width) * 0.5f;
if ( m_scroll != null ) {
g.DrawImage( m_scroll,
dx, 90f - m_shift,
m_scroll.Width, m_scroll.Height );
if ( 90f - m_shift + m_scroll.Height < 0 ) {
m_shift = -m_height * 1.5f;
}
}
int grad_height = 60;
Rectangle top = new Rectangle( 0, 0, this.Width, grad_height );
using ( LinearGradientBrush lgb = new LinearGradientBrush( top, Color.White, Color.Transparent, LinearGradientMode.Vertical ) ) {
g.FillRectangle( lgb, top );
}
Rectangle bottom = new Rectangle( 0, m_height - grad_height, this.Width, grad_height );
g.Clip = new Region( new Rectangle( 0, m_height - grad_height + 1, this.Width, grad_height - 1 ) );
using ( LinearGradientBrush lgb = new LinearGradientBrush( bottom, Color.Transparent, Color.White, LinearGradientMode.Vertical ) ) {
g.FillRectangle( lgb, bottom );
}
g.ResetClip();
} else {
g.DrawString(
m_app_name,
new Font( "Century Gorhic", 24, FontStyle.Bold ),
new SolidBrush( m_app_name_color ),
new PointF( 20, 110 ) );
g.DrawString(
"version " + m_version,
new Font( "Arial", 10 ),
new SolidBrush( m_version_color ),
new PointF( 25, 150 ) );
}
paint( new Graphics2D( e.Graphics ) );
} catch ( Exception ex ) {
#if DEBUG
Console.WriteLine( "VersionInfoEx_Paint" );
@ -245,19 +200,57 @@ namespace Boare.Lib.AppUtil {
}
}
private void VersionInfoEx_KeyDown( object sender, KeyEventArgs e ) {
if ( (e.KeyCode & Keys.Escape) == Keys.Escape ) {
this.DialogResult = DialogResult.Cancel;
public void paint( Graphics g1 ) {
Graphics2D g = (Graphics2D)g1;
g.clipRect( 0, 0, this.Width, m_height );
g.clearRect( 0, 0, this.Width, this.Height );
if ( m_credit_mode ) {
float times = (float)(((DateTime.Now).Subtract( m_scroll_started )).TotalSeconds) - 3f;
float speed = (float)((2.0 - bocoree.math.erfcc( times * 0.8 )) / 2.0) * m_speed;
float dt = times - m_last_t;
m_shift += (speed + m_last_speed) * dt / 2f;
m_last_t = times;
m_last_speed = speed;
float dx = (this.Width - m_scroll.getWidth( null )) * 0.5f;
if ( m_scroll != null ) {
g.drawImage( m_scroll, (int)dx, (int)(90f - m_shift), null );
if ( 90f - m_shift + m_scroll.getHeight( null ) < 0 ) {
m_shift = -m_height * 1.5f;
}
}
int grad_height = 60;
Rectangle top = new Rectangle( 0, 0, this.Width, grad_height );
/*using ( LinearGradientBrush lgb = new LinearGradientBrush( top, Color.White, Color.Transparent, LinearGradientMode.Vertical ) ) {
g.FillRectangle( lgb, top );
}*/
Rectangle bottom = new Rectangle( 0, m_height - grad_height, this.Width, grad_height );
g.clipRect( 0, m_height - grad_height + 1, this.Width, grad_height - 1 );
/*using ( LinearGradientBrush lgb = new LinearGradientBrush( bottom, Color.Transparent, Color.White, LinearGradientMode.Vertical ) ) {
g.FillRectangle( lgb, bottom );
}*/
g.setClip( null );
} else {
g.setFont( new Font( "Century Gorhic", java.awt.Font.BOLD, 24 ) );
g.setColor( m_app_name_color );
g.drawString( m_app_name, 20, 110 );
g.setFont( new Font( "Arial", 0, 10 ) );
g.drawString( "version " + m_version, 25, 150 );
}
}
private void VersionInfoEx_KeyDown( object sender, System.Windows.Forms.KeyEventArgs e ) {
if ( (e.KeyCode & System.Windows.Forms.Keys.Escape) == System.Windows.Forms.Keys.Escape ) {
this.DialogResult = System.Windows.Forms.DialogResult.Cancel;
this.Close();
}
}
private void VersionInfoEx_FontChanged( object sender, EventArgs e ) {
Font font = this.Font;
for ( int i = 0; i < this.Controls.Count; i++ ) {
Misc.ApplyFontRecurse( this.Controls[i], font );
Util.applyFontRecurse( this.Controls[i], new java.awt.Font( this.Font ) );
}
}
}
}
#endif

View File

@ -82,7 +82,7 @@ namespace Boare.Lib.Media {
//Open the file
int result = VFW.AVIFileOpenW(
ref aviFile, fileName,
(int)windows.OF_SHARE_DENY_WRITE, 0 );
(int)win32.OF_SHARE_DENY_WRITE, 0 );
if ( result != 0 ) {
throw new Exception( "Exception in AVIFileOpen: " + result.ToString() );

View File

@ -0,0 +1,131 @@
#if JAVA
package org.kbinani.media;
import java.io.*;
import javax.sound.sampled.*;
public class BSoundPlayer{
private static final int BUFLEN = 128000;
private AudioInputStream m_stream = null;
private boolean m_stop_required = false;
private boolean m_playing = false;
private String m_sound_location = "";
public BSoundPlayer( String sound_location ){
setSoundLocation( sound_location );
}
public BSoundPlayer(){
}
public String getSoundLocation(){
return m_sound_location;
}
public void setSoundLocation( String value ){
stop();
m_sound_location = value;
if( m_stream != null ){
try{
m_stream.close();
}catch( Exception ex0 ){
System.err.println( "BSoundPlayer#setSoundLocation; ex0=" + ex0 );
}
}
try {
File sound_file = new File( m_sound_location );
m_stream = AudioSystem.getAudioInputStream( sound_file );
}catch( Exception ex ){
System.err.println( "BSoundPlayer#.ctor; ex=" + ex );
}
}
public void play(){
try{
Thread t = new Thread( new PlaySoundRunner() );
t.start();
t.join();
}catch( Exception ex ){
System.out.println( "BSoundPlayer#play; ex=" + ex );
}
}
public void stop(){
if( m_playing ){
try{
m_stop_required = true;
while( m_playing ){
Thread.sleep( 0 );
}
m_stop_required = false;
}catch( Exception ex ){
System.err.println( "BSoundPlayer#stop; ex=" + ex );
}
}
}
public class PlaySoundRunner implements Runnable{
public void run(){
SourceDataLine line = null;
m_playing = true;
try{
AudioFormat audioFormat = m_stream.getFormat();
DataLine.Info info = new DataLine.Info( SourceDataLine.class, audioFormat );
line = (SourceDataLine)AudioSystem.getLine( info );
line.open( audioFormat );
line.start();
int len = 1;
byte[] buf = new byte[BUFLEN];
while( len > 0 && !m_stop_required ){
len = m_stream.read( buf, 0, buf.length );
if( len >= 0 ){
int nBytesWritten = line.write( buf, 0, len );
}else{
break;
}
}
} catch( Exception ex ){
System.err.println( "BSoundPlayer.PlaySoundRunner#run; ex=" + ex );
} finally {
if( line != null ){
try{
line.drain();
line.close();
}catch( Exception ex2 ){
System.err.println( "BSoundPlayer.PlaySoundRunner#run; ex2=" + ex2 );
}
}
}
m_playing = false;
}
}
}
#else
namespace Boare.Lib.Media {
public class BSoundPlayer : System.Media.SoundPlayer {
public BSoundPlayer( string sound_location )
: base( sound_location ) {
}
public BSoundPlayer()
: base() {
}
public void play() {
base.Play();
}
public string getSoundLocation() {
return base.SoundLocation;
}
public void setSoundLocation( string value ) {
base.SoundLocation = value;
}
}
}
#endif

View File

@ -2,7 +2,7 @@
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>9.0.21022</ProductVersion>
<ProductVersion>9.0.30729</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{F4F8F601-4E3D-43F5-A8A8-AA1FB7F48452}</ProjectGuid>
<OutputType>Library</OutputType>
@ -63,6 +63,9 @@
<ItemGroup>
<Compile Include="AviReader.cs" />
<Compile Include="AviWriterVcm.cs" />
<Compile Include="BSoundPlayer.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="IAviWriter.cs" />
<Compile Include="MediaPlayer.cs" />
<Compile Include="MidiInDevice.cs" />

View File

@ -229,7 +229,7 @@ namespace Boare.Lib.Media {
Close();
}
this.m_filename = filename;
m_alias = bocoree.misc.getmd5( m_filename );
m_alias = bocoree.Misc.getmd5( m_filename );
#if DEBUG
Console.WriteLine( " m_alias=" + m_alias );
#endif

View File

@ -11,15 +11,21 @@
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*/
using System;
using System.Runtime.InteropServices;
using System.Collections.Generic;
#if JAVA
package org.kbinani.media;
public class MidiInDevice{
}
#else
using System;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using bocoree;
namespace Boare.Lib.Media {
public delegate void MidiReceivedEventHandler( DateTime time, byte[] data );
public delegate void MidiReceivedEventHandler( double time, byte[] data );
public class MidiInDevice : IDisposable {
delegate void MidiInProcDelegate( uint hMidiIn, uint wMsg, int dwInstance, int dwParam1, int dwParam2 );
@ -35,13 +41,13 @@ namespace Boare.Lib.Media {
m_port_number = port_number;
m_delegate = new MidiInProcDelegate( MidiInProc );
m_delegate_pointer = Marshal.GetFunctionPointerForDelegate( m_delegate );
windows.midiInOpen( ref m_hmidiin, port_number, m_delegate_pointer, 0, windows.CALLBACK_FUNCTION );
win32.midiInOpen( ref m_hmidiin, port_number, m_delegate_pointer, 0, win32.CALLBACK_FUNCTION );
}
public void Start() {
if ( m_hmidiin > 0 ) {
try {
windows.midiInStart( m_hmidiin );
win32.midiInStart( m_hmidiin );
} catch ( Exception ex ) {
debug.push_log( "MidiInDevice.Start" );
debug.push_log( " ex=" + ex );
@ -52,7 +58,7 @@ namespace Boare.Lib.Media {
public void Stop() {
if ( m_hmidiin > 0 ) {
try {
windows.midiInReset( m_hmidiin );
win32.midiInReset( m_hmidiin );
} catch ( Exception ex ) {
debug.push_log( "MidiInDevice.Stop" );
debug.push_log( " ex=" + ex );
@ -63,7 +69,7 @@ namespace Boare.Lib.Media {
public void Close() {
if ( m_hmidiin > 0 ) {
try {
windows.midiInClose( m_hmidiin );
win32.midiInClose( m_hmidiin );
} catch ( Exception ex ) {
debug.push_log( "MidiInDevice.Close" );
debug.push_log( " ex=" + ex );
@ -78,7 +84,7 @@ namespace Boare.Lib.Media {
public static int GetNumDevs() {
try {
int i = (int)windows.midiInGetNumDevs();
int i = (int)win32.midiInGetNumDevs();
return i;
} catch ( Exception ex ) {
debug.push_log( "MidiInDevice.GetNumDevs" );
@ -91,13 +97,13 @@ namespace Boare.Lib.Media {
List<MIDIINCAPS> ret = new List<MIDIINCAPS>();
uint num = 0;
try {
num = windows.midiInGetNumDevs();
num = win32.midiInGetNumDevs();
} catch {
num = 0;
}
for ( uint i = 0; i < num; i++ ) {
MIDIINCAPS m = new MIDIINCAPS();
uint r = windows.midiInGetDevCaps( i, ref m, (uint)Marshal.SizeOf( m ) );
uint r = win32.midiInGetDevCaps( i, ref m, (uint)Marshal.SizeOf( m ) );
ret.Add( m );
}
return ret.ToArray();
@ -106,13 +112,13 @@ namespace Boare.Lib.Media {
public void MidiInProc( uint hMidiIn, uint wMsg, int dwInstance, int dwParam1, int dwParam2 ) {
try {
switch ( wMsg ) {
case windows.MM_MIM_OPEN:
case win32.MM_MIM_OPEN:
return;
case windows.MM_MIM_CLOSE:
case win32.MM_MIM_CLOSE:
return;
case windows.MM_MIM_DATA:
case win32.MM_MIM_DATA:
int receive = dwParam1;
DateTime now = DateTime.Now;
double now = PortUtil.getCurrentTime();
switch ( receive & 0xF0 ) {
case 0x80:
case 0x90:
@ -134,11 +140,11 @@ namespace Boare.Lib.Media {
break;
}
return;
case windows.MM_MIM_LONGDATA:
case win32.MM_MIM_LONGDATA:
return;
case windows.MM_MIM_ERROR:
case win32.MM_MIM_ERROR:
return;
case windows.MM_MIM_LONGERROR:
case win32.MM_MIM_LONGERROR:
return;
}
} catch ( Exception ex ) {
@ -149,3 +155,4 @@ namespace Boare.Lib.Media {
}
}
#endif

View File

@ -25,12 +25,12 @@ namespace Boare.Lib.Media {
public MidiOutDevice( uint device_id ) {
m_device_id = device_id;
windows.midiOutOpen( ref m_handle, m_device_id, null, 0, windows.CALLBACK_NULL );
win32.midiOutOpen( ref m_handle, m_device_id, null, 0, win32.CALLBACK_NULL );
}
public void Close() {
if ( !m_handle.Equals( IntPtr.Zero ) ) {
windows.midiOutClose( m_handle );
win32.midiOutClose( m_handle );
}
}
@ -55,7 +55,7 @@ namespace Boare.Lib.Media {
for ( int i = 0; i < data.Length; i++ ) {
message |= ((uint)data[i]) << (i * 8);
}
windows.midiOutShortMsg( m_handle, message );
win32.midiOutShortMsg( m_handle, message );
}
private void SendLong( byte[] data ) {
@ -66,15 +66,15 @@ namespace Boare.Lib.Media {
hdr.lpData = (byte*)dataHandle.AddrOfPinnedObject().ToPointer();
hdr.dwBufferLength = (uint)data.Length;
hdr.dwFlags = 0;
windows.midiOutPrepareHeader( m_handle, ref hdr, size );
while ( (hdr.dwFlags & windows.WHDR_PREPARED) != windows.WHDR_PREPARED ) {
win32.midiOutPrepareHeader( m_handle, ref hdr, size );
while ( (hdr.dwFlags & win32.WHDR_PREPARED) != win32.WHDR_PREPARED ) {
Application.DoEvents();
}
windows.midiOutLongMsg( m_handle, ref hdr, size );
while ( (hdr.dwFlags & windows.WHDR_DONE) != windows.WHDR_DONE ) {
win32.midiOutLongMsg( m_handle, ref hdr, size );
while ( (hdr.dwFlags & win32.WHDR_DONE) != win32.WHDR_DONE ) {
Application.DoEvents();
}
windows.midiOutUnprepareHeader( m_handle, ref hdr, size );
win32.midiOutUnprepareHeader( m_handle, ref hdr, size );
} finally {
dataHandle.Free();
}

File diff suppressed because it is too large Load Diff

View File

@ -62,7 +62,7 @@ namespace Boare.Lib.Media {
#if DEBUG
Console.WriteLine( "WavePlay.wave_callback; uMsg=" + uMsg );
#endif
if ( uMsg == windows.MM_WOM_DONE ) {
if ( uMsg == win32.MM_WOM_DONE ) {
int index_done = 0;
WAVEHDR whdr = (WAVEHDR)Marshal.PtrToStructure( new IntPtr( dwParam1 ), typeof( WAVEHDR ) );
int dwuser = whdr.dwUser.ToInt32();
@ -163,7 +163,7 @@ namespace Boare.Lib.Media {
#if DEBUG
bocoree.debug.push_log( "calling waveOutWrite...; s_hawve_out=0x" + Convert.ToString( s_hwave_out.ToInt32(), 16 ) );
#endif
uint ret = windows.waveOutWrite( s_hwave_out, ref s_wave_header[0], (uint)sizeof( WAVEHDR ) );
uint ret = win32.waveOutWrite( s_hwave_out, ref s_wave_header[0], (uint)sizeof( WAVEHDR ) );
#if DEBUG
bocoree.debug.push_log( "...done; ret=" + ret );
#endif
@ -181,7 +181,7 @@ namespace Boare.Lib.Media {
#if DEBUG
bocoree.debug.push_log( "calling waveOutWrite...; s_hawve_out=0x" + Convert.ToString( s_hwave_out.ToInt32(), 16 ) );
#endif
uint ret2 = windows.waveOutWrite( s_hwave_out, ref s_wave_header[buffer_index], (uint)sizeof( WAVEHDR ) );
uint ret2 = win32.waveOutWrite( s_hwave_out, ref s_wave_header[buffer_index], (uint)sizeof( WAVEHDR ) );
#if DEBUG
bocoree.debug.push_log( "...done; ret2=" + ret2 );
#endif
@ -192,7 +192,7 @@ namespace Boare.Lib.Media {
#if DEBUG
bocoree.debug.push_log( "calling waveOutWrite...; s_hawve_out=0x" + Convert.ToString( s_hwave_out.ToInt32(), 16 ) );
#endif
uint ret3 = windows.waveOutWrite( s_hwave_out, ref s_wave_header[s_current_buffer], (uint)sizeof( WAVEHDR ) );
uint ret3 = win32.waveOutWrite( s_hwave_out, ref s_wave_header[s_current_buffer], (uint)sizeof( WAVEHDR ) );
#if DEBUG
bocoree.debug.push_log( "...done; ret3=" + ret3 );
#endif
@ -229,7 +229,7 @@ namespace Boare.Lib.Media {
#if DEBUG
bocoree.debug.push_log( "calling waveOutWrite...; s_hawve_out=0x" + Convert.ToString( s_hwave_out.ToInt32(), 16 ) );
#endif
uint ret35 = windows.waveOutWrite( s_hwave_out, ref s_wave_header[0], (uint)sizeof( WAVEHDR ) );
uint ret35 = win32.waveOutWrite( s_hwave_out, ref s_wave_header[0], (uint)sizeof( WAVEHDR ) );
#if DEBUG
bocoree.debug.push_log( "...done; ret35=" + ret35 );
bocoree.debug.push_log( "(s_first_buffer_written_callback==null)=" + (s_first_buffer_written_callback == null) );
@ -247,7 +247,7 @@ namespace Boare.Lib.Media {
#if DEBUG
bocoree.debug.push_log( "calling waveOutWrite...; s_hawve_out=0x" + Convert.ToString( s_hwave_out.ToInt32(), 16 ) );
#endif
uint ret36 = windows.waveOutWrite( s_hwave_out, ref s_wave_header[i], (uint)sizeof( WAVEHDR ) );
uint ret36 = win32.waveOutWrite( s_hwave_out, ref s_wave_header[i], (uint)sizeof( WAVEHDR ) );
#if DEBUG
bocoree.debug.push_log( "...done; ret36=" + ret36 );
#endif
@ -276,7 +276,7 @@ namespace Boare.Lib.Media {
#if DEBUG
bocoree.debug.push_log( "calling waveOutWrite...; s_hawve_out=0x" + Convert.ToString( s_hwave_out.ToInt32(), 16 ) );
#endif
uint ret4 = windows.waveOutWrite( s_hwave_out, ref s_wave_header[s_current_buffer], (uint)sizeof( WAVEHDR ) );
uint ret4 = win32.waveOutWrite( s_hwave_out, ref s_wave_header[s_current_buffer], (uint)sizeof( WAVEHDR ) );
#if DEBUG
bocoree.debug.push_log( "...done; ret4=" + ret4 );
#endif
@ -295,10 +295,10 @@ namespace Boare.Lib.Media {
void mix( int processed_count, float amp_left, float amp_right ) {
int current_buffer = (processed_count - 1) % _NUM_BUF;
for ( int k = 0; k < s_num_wave_reader; k++ ) {
s_wave_reader[k].Read( s_block_size * (processed_count - 1) + (int)s_wave_read_offset_samples,
s_wave_reader[k].read( s_block_size * (processed_count - 1) + (int)s_wave_read_offset_samples,
s_block_size,
out s_ptr_another_wave_l[k],
out s_ptr_another_wave_r[k] );
ref s_ptr_another_wave_l[k],
ref s_ptr_another_wave_r[k] );
}
for ( int i = 0; i < s_block_size; i++ ) {
float l = s_wave_buffer_l[i] * amp_left;
@ -316,7 +316,7 @@ namespace Boare.Lib.Media {
//byte* err = (byte*)ptr_err.ToPointer();
//System.Text.StringBuilder sb = new System.Text.StringBuilder( 260 );
string ret = "";
windows.mciGetErrorStringA( msg, ret, 260 );
win32.mciGetErrorStringA( msg, ret, 260 );
/*int len = 260;
for ( int i = 1; i < 260; i++ ) {
if ( err[i] == '\0' ) {
@ -349,7 +349,7 @@ namespace Boare.Lib.Media {
Console.WriteLine( " s_wave_fomratx.cbSize=" + s_wave_formatx.cbSize );
Console.WriteLine( " sizeof( WAVEHDR )=" + sizeof( WAVEHDR ) );
#endif
s_wave_formatx.wFormatTag = windows.WAVE_FORMAT_PCM;
s_wave_formatx.wFormatTag = win32.WAVE_FORMAT_PCM;
s_wave_formatx.nChannels = 2;
s_wave_formatx.wBitsPerSample = 16;
s_wave_formatx.nBlockAlign = (ushort)(s_wave_formatx.nChannels * s_wave_formatx.wBitsPerSample / 8);
@ -359,12 +359,12 @@ namespace Boare.Lib.Media {
s_wave_callback = new delegateWaveOutProc( wave_callback );
s_hwave_out = IntPtr.Zero;
Console.WriteLine( " calling waveOutOpen..." );
uint ret = windows.waveOutOpen( ref s_hwave_out,
windows.WAVE_MAPPER,
uint ret = win32.waveOutOpen( ref s_hwave_out,
win32.WAVE_MAPPER,
ref s_wave_formatx,
s_wave_callback,
IntPtr.Zero,
(uint)windows.CALLBACK_FUNCTION );
(uint)win32.CALLBACK_FUNCTION );
Console.WriteLine( " ...done; ret=" + ret );
#if DEBUG
bocoree.debug.push_log( " s_hwave_out=0x" + Convert.ToString( s_hwave_out.ToInt32(), 16 ) );
@ -377,13 +377,13 @@ namespace Boare.Lib.Media {
s_wave_header[k] = (WAVEHDR)Marshal.PtrToStructure( s_ptr_wave_header[k], typeof( WAVEHDR ) );
s_wave_header[k].lpData = s_ptr_wave[k];
s_wave_header[k].dwBufferLength = (uint)(sizeof( uint ) * s_block_size);
s_wave_header[k].dwFlags = windows.WHDR_BEGINLOOP | windows.WHDR_ENDLOOP;
s_wave_header[k].dwFlags = win32.WHDR_BEGINLOOP | win32.WHDR_ENDLOOP;
s_wave_header[k].dwLoops = 1;
#if DEBUG
Console.WriteLine( "calling waveOutPrepareHeader..." );
#endif
uint ret2 = windows.waveOutPrepareHeader( s_hwave_out, ref s_wave_header[k], (uint)sizeof( WAVEHDR ) );
uint ret2 = win32.waveOutPrepareHeader( s_hwave_out, ref s_wave_header[k], (uint)sizeof( WAVEHDR ) );
#if DEBUG
Console.WriteLine( "...done; ret2=" + ret2 );
#endif
@ -428,18 +428,18 @@ namespace Boare.Lib.Media {
if ( s_playing ) {
MMTIME mmt = new MMTIME();
mmt.cb = (uint)sizeof( MMTIME );
mmt.wType = windows.TIME_MS;
uint ret = windows.waveOutGetPosition( s_hwave_out, ref mmt, (uint)sizeof( MMTIME ) );
mmt.wType = win32.TIME_MS;
uint ret = win32.waveOutGetPosition( s_hwave_out, ref mmt, (uint)sizeof( MMTIME ) );
#if DEBUG
bocoree.debug.push_log( " ret=" + ret );
#endif
float ms = 0.0f;
switch ( mmt.wType ) {
case windows.TIME_MS:
case win32.TIME_MS:
return mmt.ms * 0.001f;
case windows.TIME_SAMPLES:
case win32.TIME_SAMPLES:
return (float)mmt.sample / (float)s_wave_formatx.nSamplesPerSec;
case windows.TIME_BYTES:
case win32.TIME_BYTES:
return (float)mmt.cb / (float)s_wave_formatx.nAvgBytesPerSec;
default:
return -1.0f;
@ -456,7 +456,7 @@ namespace Boare.Lib.Media {
for ( int k = 0; k < _NUM_BUF; k++ ) {
s_wave_header[k].dwUser = new IntPtr( _NUM_BUF + k );
}
windows.waveOutReset( s_hwave_out );
win32.waveOutReset( s_hwave_out );
uint zero = MAKELONG( 0, 0 );
for ( int k = 0; k < _NUM_BUF; k++ ) {
for ( int i = 0; i < s_block_size; i++ ) {
@ -465,7 +465,7 @@ namespace Boare.Lib.Media {
}
}
for ( int i = 0; i < s_num_wave_reader; i++ ) {
s_wave_reader[i].Close();
s_wave_reader[i].close();
}
}
@ -500,7 +500,7 @@ namespace Boare.Lib.Media {
if ( s_wave_reader != null ) {
for ( int i = 0; i < s_num_wave_reader; i++ ) {
s_wave_reader[i].Close();
s_wave_reader[i].close();
}
//delete [] s_wave_reader;
}
@ -530,8 +530,8 @@ namespace Boare.Lib.Media {
name[k] = buf[k];
}
name[len] = '\0';*/
s_wave_reader[i].Open( files[i] );
int samples = s_wave_reader[i].TotalSamples;
s_wave_reader[i].open( files[i] );
int samples = s_wave_reader[i].getTotalSamples();
if ( samples > max_samples ) {
max_samples = samples;
}
@ -560,14 +560,14 @@ namespace Boare.Lib.Media {
public void terminate() {
if ( s_hwave_out.ToInt32() != 0 ) {
windows.waveOutReset( s_hwave_out );
win32.waveOutReset( s_hwave_out );
#if DEBUG
bocoree.debug.push_log( "waveplay::terminate; waveOutReset" );
#endif
for ( int k = 0; k < _NUM_BUF; k++ ) {
windows.waveOutUnprepareHeader( s_hwave_out, ref s_wave_header[k], (uint)sizeof( WAVEHDR ) );
win32.waveOutUnprepareHeader( s_hwave_out, ref s_wave_header[k], (uint)sizeof( WAVEHDR ) );
}
windows.waveOutClose( s_hwave_out );
win32.waveOutClose( s_hwave_out );
}
for ( int i = 0; i < _NUM_BUF; i++ ) {
if ( s_ptr_wave[i].ToInt32() != 0 ) {

View File

@ -11,125 +11,254 @@
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*/
#if JAVA
package org.kbinani.media;
import java.io.*;
import java.util.*;
import org.kbinani.*;
#else
using System;
using System.IO;
using System.Runtime.InteropServices;
using bocoree;
using bocoree.java.io;
namespace Boare.Lib.Media {
using boolean = System.Boolean;
#endif
public class WaveReader : IDisposable{
#if JAVA
public class WaveReader {
#else
public class WaveReader : IDisposable {
#endif
private int m_channel;
private int m_byte_per_sample;
private bool m_opened;
private FileStream m_stream;
private boolean m_opened;
private RandomAccessFile m_stream;
private int m_total_samples;
private double m_amplify_left = 1.0;
private double m_amplify_right = 1.0;
/// <summary>
/// ファイル先頭からdataチャンクまでのオフセット
/// </summary>
private int m_header_offset = 0x2e;
private Object m_tag = null;
private double m_offset_seconds = 0.0;
private int m_sample_per_sec;
public WaveReader() {
m_opened = false;
}
public WaveReader( string file ) {
Open( file );
public WaveReader( String file )
#if JAVA
throws IOException, FileNotFoundException
#endif
{
boolean ret = open( file );
#if DEBUG
Console.WriteLine( "WaveReader#.ctor; file=" + file + "; ret=" + ret );
#endif
}
public double getOffsetSeconds() {
return m_offset_seconds;
}
public void setOffsetSeconds( double value ) {
m_offset_seconds = value;
}
public Object getTag() {
return m_tag;
}
public void setTag( Object value ) {
m_tag = value;
}
public double getAmplifyLeft() {
return m_amplify_left;
}
public void setAmplifyLeft( double value ) {
m_amplify_left = value;
}
public double getAmplifyRight() {
return m_amplify_right;
}
public void setAmplifyRight( double value ) {
m_amplify_right = value;
}
#if !JAVA
public void Dispose() {
Close();
close();
}
#endif
public bool Open( string file ) {
public boolean open( String file )
#if JAVA
throws IOException, FileNotFoundException
#endif
{
if ( m_opened ) {
m_stream.Close();
m_stream.close();
}
m_stream = new FileStream( file, FileMode.Open, FileAccess.Read );
m_stream = new RandomAccessFile( file, "r" );
// RIFF
byte[] buf = new byte[4];
m_stream.Read( buf, 0, 4 );
m_stream.read( buf, 0, 4 );
if ( buf[0] != 'R' || buf[1] != 'I' || buf[2] != 'F' || buf[3] != 'F' ) {
m_stream.Close();
m_stream.close();
#if DEBUG
Console.WriteLine( "WaveReader#Open; header error(RIFF)" );
#endif
return false;
}
// ファイルサイズ - 8最後に記入
m_stream.Read( buf, 0, 4 );
m_stream.read( buf, 0, 4 );
// WAVE
m_stream.Read( buf, 0, 4 );
m_stream.read( buf, 0, 4 );
if ( buf[0] != 'W' || buf[1] != 'A' || buf[2] != 'V' || buf[3] != 'E' ) {
m_stream.Close();
m_stream.close();
#if DEBUG
Console.WriteLine( "WaveReader#Open; header error(WAVE)" );
#endif
return false;
}
// fmt
m_stream.Read( buf, 0, 4 );
m_stream.read( buf, 0, 4 );
if ( buf[0] != 'f' || buf[1] != 'm' || buf[2] != 't' || buf[3] != ' ' ) {
m_stream.Close();
m_stream.close();
#if DEBUG
Console.WriteLine( "WaveReader#Open; header error(fmt )" );
#endif
return false;
}
// fmt チャンクのサイズ
m_stream.Read( buf, 0, 4 );
m_stream.read( buf, 0, 4 );
int chunksize = (int)PortUtil.make_uint32_le( buf );
long fmt_chunk_end_location = m_stream.getFilePointer() + chunksize;
// format ID
m_stream.Read( buf, 0, 2 );
m_stream.read( buf, 0, 2 );
// チャンネル数
m_stream.Read( buf, 0, 2 );
m_stream.read( buf, 0, 2 );
m_channel = buf[1] << 8 | buf[0];
// サンプリングレート
m_stream.Read( buf, 0, 4 );
m_stream.read( buf, 0, 4 );
m_sample_per_sec = (int)PortUtil.make_uint32_le( buf );
// データ速度
m_stream.Read( buf, 0, 4 );
m_stream.read( buf, 0, 4 );
// ブロックサイズ
m_stream.Read( buf, 0, 2 );
m_stream.read( buf, 0, 2 );
// サンプルあたりのビット数
m_stream.Read( buf, 0, 2 );
m_stream.read( buf, 0, 2 );
int bit_per_sample = buf[1] << 8 | buf[0];
m_byte_per_sample = bit_per_sample / 8;
// 拡張部分
m_stream.Read( buf, 0, 2 );
m_stream.seek( fmt_chunk_end_location );
//m_stream.Read( buf, 0, 2 );
// data
m_stream.Read( buf, 0, 4 );
m_stream.read( buf, 0, 4 );
if ( buf[0] != 'd' || buf[1] != 'a' || buf[2] != 't' || buf[3] != 'a' ) {
m_stream.Close();
m_stream.close();
#if DEBUG
Console.WriteLine( "WaveReader#Open; header error (data)" );
#endif
return false;
}
// size of data chunk
m_stream.Read( buf, 0, 4 );
int size = BitConverter.ToInt32( buf, 0 );
m_stream.read( buf, 0, 4 );
int size = (int)PortUtil.make_uint32_le( buf );
m_total_samples = size / (m_channel * m_byte_per_sample);
m_opened = true;
m_header_offset = (int)m_stream.getFilePointer();
return true;
}
public int TotalSamples {
get {
public int getTotalSamples() {
return m_total_samples;
}
}
public void Read( long start, int length, out double[] left, out double[] right ) {
left = new double[length];
right = new double[length];
public void read( long start, int length, double[] left, double[] right )
#if JAVA
throws IOException
#endif
{
//left = new double[length];
//right = new double[length];
if ( !m_opened ) {
return;
}
long loc = 0x2e + m_byte_per_sample * m_channel * start;
m_stream.Seek( loc, SeekOrigin.Begin );
int i_start = 0;
int i_end = length - 1;
long required_sample_start = start + (long)(m_offset_seconds * m_sample_per_sec);
long required_sample_end = required_sample_start + length;
// 第required_sample_startサンプルから第required_sample_endサンプルまでの読み込みが要求された
if ( required_sample_start < 0 ) {
i_start = -(int)required_sample_start + 1;
// 0 -> i_start - 1までは0で埋める
if ( i_start >= length ) {
// 全部0で埋める必要のある場合.
for ( int i = 0; i < length; i++ ) {
left[i] = 0.0;
right[i] = 0.0;
}
return;
} else {
for ( int i = 0; i < i_start; i++ ) {
left[i] = 0.0;
right[i] = 0.0;
}
}
m_stream.seek( m_header_offset );
} else {
long loc = m_header_offset + m_byte_per_sample * m_channel * required_sample_start;
m_stream.seek( loc );
}
if ( m_total_samples < required_sample_end ) {
i_end = length - 1 - (int)required_sample_end + m_total_samples;
// i_end + 1 -> length - 1までは0で埋める
if ( i_end < 0 ) {
// 全部0で埋める必要のある場合
for ( int i = 0; i < length; i++ ) {
left[i] = 0.0;
right[i] = 0.0;
}
return;
} else {
for ( int i = i_end + 1; i < length; i++ ) {
left[i] = 0.0;
right[i] = 0.0;
}
}
}
if ( m_byte_per_sample == 2 ) {
if ( m_channel == 2 ) {
byte[] buf = new byte[4];
for ( int i = 0; i < length; i++ ) {
int ret = m_stream.Read( buf, 0, 4 );
double coeff_left = m_amplify_left / 32768.0;
double coeff_right = m_amplify_right / 32768.0;
for ( int i = i_start; i <= i_end; i++ ) {
int ret = m_stream.read( buf, 0, 4 );
if ( ret < 4 ) {
for ( int j = i; j < length; j++ ) {
left[j] = 0.0f;
@ -139,13 +268,14 @@ namespace Boare.Lib.Media {
}
short l = (short)(buf[0] | buf[1] << 8);
short r = (short)(buf[2] | buf[3] << 8);
left[i] = l / 32768.0f;
right[i] = r / 32768.0f;
left[i] = l * coeff_left;
right[i] = r * coeff_right;
}
} else {
byte[] buf = new byte[2];
for ( int i = 0; i < length; i++ ) {
int ret = m_stream.Read( buf, 0, 2 );
double coeff_left = m_amplify_left / 32768.0;
for ( int i = i_start; i <= i_end; i++ ) {
int ret = m_stream.read( buf, 0, 2 );
if ( ret < 2 ) {
for ( int j = i; j < length; j++ ) {
left[j] = 0.0f;
@ -154,15 +284,17 @@ namespace Boare.Lib.Media {
break;
}
short l = (short)(buf[0] | buf[1] << 8);
left[i] = l / 32768.0f;
left[i] = l * coeff_left;
right[i] = left[i];
}
}
} else {
if ( m_channel == 2 ) {
byte[] buf = new byte[2];
for ( int i = 0; i < length; i++ ) {
int ret = m_stream.Read( buf, 0, 2 );
double coeff_left = m_amplify_left / 64.0;
double coeff_right = m_amplify_right / 64.0;
for ( int i = i_start; i <= i_end; i++ ) {
int ret = m_stream.read( buf, 0, 2 );
if ( ret < 2 ) {
for ( int j = i; j < length; j++ ) {
left[j] = 0.0f;
@ -170,13 +302,14 @@ namespace Boare.Lib.Media {
}
break;
}
left[i] = (buf[0] - 64.0f) / 64.0f;
right[i] = (buf[1] - 64.0f) / 64.0f;
left[i] = (buf[0] - 64.0f) * coeff_left;
right[i] = (buf[1] - 64.0f) * coeff_right;
}
} else {
byte[] buf = new byte[1];
for ( int i = 0; i < length; i++ ) {
int ret = m_stream.Read( buf, 0, 1 );
double coeff_left = m_amplify_left / 64.0;
for ( int i = i_start; i <= i_end; i++ ) {
int ret = m_stream.read( buf, 0, 1 );
if ( ret < 1 ) {
for ( int j = i; j < length; j++ ) {
left[j] = 0.0f;
@ -184,104 +317,161 @@ namespace Boare.Lib.Media {
}
break;
}
left[i] = (buf[0] - 64.0f) / 64.0f;
left[i] = (buf[0] - 64.0f) * coeff_left;
right[i] = left[i];
}
}
}
}
public void Read( long start, int length, out float[] left, out float[] right ) {
left = new float[length];
right = new float[length];
public void read( long start, int length, ByRef<float[]> left, ByRef<float[]> right )
#if JAVA
throws IOException
#endif
{
left.value = new float[length];
right.value = new float[length];
if ( !m_opened ) {
return;
}
long loc = 0x2e + m_byte_per_sample * m_channel * start;
m_stream.Seek( loc, SeekOrigin.Begin );
int i_start = 0;
int i_end = length;
long required_sample_start = start + (long)(m_offset_seconds * m_sample_per_sec);
long required_sample_end = required_sample_start + length;
// 第required_sample_startサンプルから第required_sample_endサンプルまでの読み込みが要求された
if ( required_sample_start < 0 ) {
i_start = -(int)required_sample_start + 1;
// 0 -> i_start - 1までは0で埋める
for ( int i = 0; i < i_start; i++ ) {
left.value[i] = 0.0f;
right.value[i] = 0.0f;
}
m_stream.seek( m_header_offset );
} else {
long loc = m_header_offset + m_byte_per_sample * m_channel * required_sample_start;
m_stream.seek( loc );
}
if ( m_total_samples < required_sample_end ) {
i_end = length - 1 - (int)required_sample_end + m_total_samples;
// i_end + 1 -> length - 1までは0で埋める
for ( int i = i_end + 1; i < length; i++ ) {
left.value[i] = 0.0f;
right.value[i] = 0.0f;
}
}
if ( m_byte_per_sample == 2 ) {
if ( m_channel == 2 ) {
byte[] buf = new byte[4];
float coeff_left = (float)(m_amplify_left / 32768.0f);
float coeff_right = (float)(m_amplify_right / 32768.0f);
for ( int i = 0; i < length; i++ ) {
int ret = m_stream.Read( buf, 0, 4 );
int ret = m_stream.read( buf, 0, 4 );
if ( ret < 4 ) {
for ( int j = i; j < length; j++ ) {
left[j] = 0.0f;
right[j] = 0.0f;
left.value[j] = 0.0f;
right.value[j] = 0.0f;
}
break;
}
short l = (short)(buf[0] | buf[1] << 8);
short r = (short)(buf[2] | buf[3] << 8);
left[i] = l / 32768.0f;
right[i] = r / 32768.0f;
left.value[i] = l * coeff_left;
right.value[i] = r * coeff_right;
}
} else {
byte[] buf = new byte[2];
float coeff_left = (float)(m_amplify_left / 32768.0f);
for ( int i = 0; i < length; i++ ) {
int ret = m_stream.Read( buf, 0, 2 );
int ret = m_stream.read( buf, 0, 2 );
if ( ret < 2 ) {
for ( int j = i; j < length; j++ ) {
left[j] = 0.0f;
right[j] = 0.0f;
left.value[j] = 0.0f;
right.value[j] = 0.0f;
}
break;
}
short l = (short)(buf[0] | buf[1] << 8);
left[i] = l / 32768.0f;
right[i] = left[i];
left.value[i] = l * coeff_left;
right.value[i] = left.value[i];
}
}
} else {
if ( m_channel == 2 ) {
byte[] buf = new byte[2];
float coeff_left = (float)(m_amplify_left / 64.0f);
float coeff_right = (float)(m_amplify_right / 64.0f);
for ( int i = 0; i < length; i++ ) {
int ret = m_stream.Read( buf, 0, 2 );
int ret = m_stream.read( buf, 0, 2 );
if ( ret < 2 ) {
for ( int j = i; j < length; j++ ) {
left[j] = 0.0f;
right[j] = 0.0f;
left.value[j] = 0.0f;
right.value[j] = 0.0f;
}
break;
}
left[i] = (buf[0] - 64.0f) / 64.0f;
right[i] = (buf[1] - 64.0f) / 64.0f;
left.value[i] = (buf[0] - 64.0f) * coeff_left;
right.value[i] = (buf[1] - 64.0f) * coeff_right;
}
} else {
byte[] buf = new byte[1];
float coeff_left = (float)(m_amplify_left / 64.0f);
for ( int i = 0; i < length; i++ ) {
int ret = m_stream.Read( buf, 0, 1 );
int ret = m_stream.read( buf, 0, 1 );
if ( ret < 1 ) {
for ( int j = i; j < length; j++ ) {
left[j] = 0.0f;
right[j] = 0.0f;
left.value[j] = 0.0f;
right.value[j] = 0.0f;
}
break;
}
left[i] = (buf[0] - 64.0f) / 64.0f;
right[i] = left[i];
left.value[i] = (buf[0] - 64.0f) * coeff_left;
right.value[i] = left.value[i];
}
}
}
}
public unsafe void Read( long start, int length, out IntPtr ptr_left, out IntPtr ptr_right ) {
ptr_left = Marshal.AllocHGlobal( sizeof( float ) * length );
ptr_right = Marshal.AllocHGlobal( sizeof( float ) * length );
#if !JAVA
public unsafe void read( long start, int length, ref IntPtr ptr_left, ref IntPtr ptr_right ) {
float* left = (float*)ptr_left.ToPointer();
float* right = (float*)ptr_right.ToPointer();
if ( !m_opened ) {
return;
}
long loc = 0x2e + m_byte_per_sample * m_channel * start;
m_stream.Seek( loc, SeekOrigin.Begin );
int i_start = 0;
int i_end = length;
long required_sample_start = start + (long)(m_offset_seconds * m_sample_per_sec);
long required_sample_end = required_sample_start + length;
// 第required_sample_startサンプルから第required_sample_endサンプルまでの読み込みが要求された
if ( required_sample_start < 0 ) {
i_start = -(int)required_sample_start + 1;
// 0 -> i_start - 1までは0で埋める
for ( int i = 0; i < i_start; i++ ) {
left[i] = 0.0f;
right[i] = 0.0f;
}
m_stream.seek( m_header_offset );
} else {
long loc = m_header_offset + m_byte_per_sample * m_channel * required_sample_start;
m_stream.seek( loc );
}
if ( m_total_samples < required_sample_end ) {
i_end = length - 1 - (int)required_sample_end + m_total_samples;
// i_end + 1 -> length - 1までは0で埋める
for ( int i = i_end + 1; i < length; i++ ) {
left[i] = 0.0f;
right[i] = 0.0f;
}
}
if ( m_byte_per_sample == 2 ) {
if ( m_channel == 2 ) {
byte[] buf = new byte[4];
float coeff_left = (float)(m_amplify_left / 32768.0f);
float coeff_right = (float)(m_amplify_right / 32768.0f);
for ( int i = 0; i < length; i++ ) {
int ret = m_stream.Read( buf, 0, 4 );
int ret = m_stream.read( buf, 0, 4 );
if ( ret < 4 ) {
for ( int j = i; j < length; j++ ) {
left[j] = 0.0f;
@ -291,13 +481,14 @@ namespace Boare.Lib.Media {
}
short l = (short)(buf[0] | buf[1] << 8);
short r = (short)(buf[2] | buf[3] << 8);
left[i] = l / 32768.0f;
right[i] = r / 32768.0f;
left[i] = l * coeff_left;
right[i] = r * coeff_right;
}
} else {
byte[] buf = new byte[2];
float coeff_left = (float)(m_amplify_left / 32768.0f);
for ( int i = 0; i < length; i++ ) {
int ret = m_stream.Read( buf, 0, 2 );
int ret = m_stream.read( buf, 0, 2 );
if ( ret < 2 ) {
for ( int j = i; j < length; j++ ) {
left[j] = 0.0f;
@ -306,15 +497,17 @@ namespace Boare.Lib.Media {
break;
}
short l = (short)(buf[0] | buf[1] << 8);
left[i] = l / 32768.0f;
left[i] = l * coeff_left;
right[i] = left[i];
}
}
} else {
if ( m_channel == 2 ) {
byte[] buf = new byte[2];
float coeff_left = (float)(m_amplify_left / 64.0f);
float coeff_right = (float)(m_amplify_right / 64.0f);
for ( int i = 0; i < length; i++ ) {
int ret = m_stream.Read( buf, 0, 2 );
int ret = m_stream.read( buf, 0, 2 );
if ( ret < 2 ) {
for ( int j = i; j < length; j++ ) {
left[j] = 0.0f;
@ -322,13 +515,14 @@ namespace Boare.Lib.Media {
}
break;
}
left[i] = (buf[0] - 64.0f) / 64.0f;
right[i] = (buf[1] - 64.0f) / 64.0f;
left[i] = (buf[0] - 64.0f) * coeff_left;
right[i] = (buf[1] - 64.0f) * coeff_right;
}
} else {
byte[] buf = new byte[1];
float coeff_left = (float)(m_amplify_left / 64.0f);
for ( int i = 0; i < length; i++ ) {
int ret = m_stream.Read( buf, 0, 1 );
int ret = m_stream.read( buf, 0, 1 );
if ( ret < 1 ) {
for ( int j = i; j < length; j++ ) {
left[j] = 0.0f;
@ -336,24 +530,33 @@ namespace Boare.Lib.Media {
}
break;
}
left[i] = (buf[0] - 64.0f) / 64.0f;
left[i] = (buf[0] - 64.0f) * coeff_left;
right[i] = left[i];
}
}
}
}
#endif
public void Close() {
public void close()
#if JAVA
throws IOException
#endif
{
m_opened = false;
if ( m_stream != null ) {
m_stream.Close();
m_stream.close();
m_stream = null;
}
}
#if !JAVA
~WaveReader() {
Close();
close();
}
#endif
}
#if !JAVA
}
#endif

View File

@ -11,374 +11,404 @@
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*/
#if JAVA
package org.kbinani.media;
import java.io.*;
import org.kbinani.*;
#else
using System;
using System.IO;
using bocoree;
using bocoree.java.io;
namespace Boare.Lib.Media {
#endif
public class WaveWriter : IDisposable {
private WaveChannel m_channel;
private ushort m_bit_per_sample;
private uint m_sample_rate;
private uint m_total_samples = 0;
private FileStream m_stream = null;
private string m_path = "";
#if JAVA
public class WaveWriter{
#else
public class WaveWriter : IDisposable{
#endif
private int m_channel = 1;
private int m_bit_per_sample;
private int m_sample_rate;
private int m_total_samples = 0;
private RandomAccessFile m_stream = null;
private String m_path = "";
public WaveWriter( string path ) :
this ( path, WaveChannel.Stereo, 16, 44100 ) {
public WaveWriter( String path )
#if JAVA
throws IOException
{
this ( path, 2, 16, 44100 );
#else
: this( path, 2, 16, 44100 ) {
#endif
}
public WaveWriter( string path, WaveChannel channel, ushort bit_per_sample, uint sample_rate ) {
public WaveWriter( String path, int channel, int bit_per_sample, int sample_rate )
#if JAVA
throws IOException
#endif
{
m_path = path;
m_stream = new FileStream( m_path, FileMode.Create, FileAccess.Write );
m_stream = new RandomAccessFile( m_path, "rw" );
m_channel = channel;
m_bit_per_sample = bit_per_sample;
m_sample_rate = sample_rate;
m_total_samples = 0;
WriteHeader();
writeHeader();
}
#if !JAVA
public void Dispose() {
close();
}
#endif
/// <summary>
/// Writes header of WAVE file
/// </summary>
private void WriteHeader() {
private void writeHeader()
#if JAVA
throws IOException
#endif
{
// RIFF
m_stream.WriteByte( 0x52 ); // loc=0x00
m_stream.WriteByte( 0x49 );
m_stream.WriteByte( 0x46 );
m_stream.WriteByte( 0x46 );
m_stream.writeByte( 0x52 ); // loc=0x00
m_stream.writeByte( 0x49 );
m_stream.writeByte( 0x46 );
m_stream.writeByte( 0x46 );
// ファイルサイズ - 8最後に記入
m_stream.WriteByte( 0x00 ); // loc=0x04
m_stream.WriteByte( 0x00 );
m_stream.WriteByte( 0x00 );
m_stream.WriteByte( 0x00 );
m_stream.writeByte( 0x00 ); // loc=0x04
m_stream.writeByte( 0x00 );
m_stream.writeByte( 0x00 );
m_stream.writeByte( 0x00 );
// WAVE
m_stream.WriteByte( 0x57 ); // loc=0x08
m_stream.WriteByte( 0x41 );
m_stream.WriteByte( 0x56 );
m_stream.WriteByte( 0x45 );
m_stream.writeByte( 0x57 ); // loc=0x08
m_stream.writeByte( 0x41 );
m_stream.writeByte( 0x56 );
m_stream.writeByte( 0x45 );
// fmt
m_stream.WriteByte( 0x66 ); // loc=0x0c
m_stream.WriteByte( 0x6d );
m_stream.WriteByte( 0x74 );
m_stream.WriteByte( 0x20 );
m_stream.writeByte( 0x66 ); // loc=0x0c
m_stream.writeByte( 0x6d );
m_stream.writeByte( 0x74 );
m_stream.writeByte( 0x20 );
// fmt チャンクのサイズ
m_stream.WriteByte( 0x12 ); // loc=0x10
m_stream.WriteByte( 0x00 );
m_stream.WriteByte( 0x00 );
m_stream.WriteByte( 0x00 );
m_stream.writeByte( 0x12 ); // loc=0x10
m_stream.writeByte( 0x00 );
m_stream.writeByte( 0x00 );
m_stream.writeByte( 0x00 );
// format ID
m_stream.WriteByte( 0x01 ); // loc=0x14
m_stream.WriteByte( 0x00 );
m_stream.writeByte( 0x01 ); // loc=0x14
m_stream.writeByte( 0x00 );
// チャンネル数
if ( m_channel == WaveChannel.Monoral ) {
m_stream.WriteByte( 0x01 ); // loc=0x16
m_stream.WriteByte( 0x00 );
if ( m_channel == 1 ) {
m_stream.writeByte( 0x01 ); // loc=0x16
m_stream.writeByte( 0x00 );
} else {
m_stream.WriteByte( 0x02 ); //loc=0x16
m_stream.WriteByte( 0x00 );
m_stream.writeByte( 0x02 ); //loc=0x16
m_stream.writeByte( 0x00 );
}
// サンプリングレート
byte[] buf = BitConverter.GetBytes( m_sample_rate );
WriteByteArray( m_stream, buf, 4 ); // 0x18
byte[] buf = PortUtil.getbytes_uint32_le( m_sample_rate );
writeByteArray( m_stream, buf, 4 ); // 0x18
// データ速度
ushort block_size = (ushort)(m_bit_per_sample / 8 * (int)m_channel);
uint data_rate = m_sample_rate * block_size;
buf = BitConverter.GetBytes( data_rate );
WriteByteArray( m_stream, buf, 4 );//loc=0x1c
int block_size = (int)(m_bit_per_sample / 8 * (int)m_channel);
int data_rate = m_sample_rate * block_size;
buf = PortUtil.getbytes_uint32_le( data_rate );
writeByteArray( m_stream, buf, 4 );//loc=0x1c
// ブロックサイズ
buf = BitConverter.GetBytes( block_size );
WriteByteArray( m_stream, buf, 2 ); //0x20
buf = PortUtil.getbytes_uint16_le( block_size );
writeByteArray( m_stream, buf, 2 ); //0x20
// サンプルあたりのビット数
buf = BitConverter.GetBytes( m_bit_per_sample );
WriteByteArray( m_stream, buf, 2 ); //loc=0x22
buf = PortUtil.getbytes_uint16_le( m_bit_per_sample );
writeByteArray( m_stream, buf, 2 ); //loc=0x22
// 拡張部分
m_stream.WriteByte( 0x00 ); //loc=0x24
m_stream.WriteByte( 0x00 );
m_stream.writeByte( 0x00 ); //loc=0x24
m_stream.writeByte( 0x00 );
// data
m_stream.WriteByte( 0x64 ); //loc=0x26
m_stream.WriteByte( 0x61 );
m_stream.WriteByte( 0x74 );
m_stream.WriteByte( 0x61 );
m_stream.writeByte( 0x64 ); //loc=0x26
m_stream.writeByte( 0x61 );
m_stream.writeByte( 0x74 );
m_stream.writeByte( 0x61 );
// size of data chunk
uint size = block_size * m_total_samples;
buf = BitConverter.GetBytes( size );
WriteByteArray( m_stream, buf, 4 );
int size = block_size * m_total_samples;
buf = PortUtil.getbytes_uint32_le( size );
writeByteArray( m_stream, buf, 4 );
}
public void Close(){
public void close()
#if JAVA
throws IOException
#endif
{
if ( m_stream != null ) {
// 最後にWAVEチャンクのサイズ
uint position = (uint)m_stream.Position;
m_stream.Seek( 4, SeekOrigin.Begin );
byte[] buf = BitConverter.GetBytes( position - 8 );
WriteByteArray( m_stream, buf, 4 );
int position = (int)m_stream.getFilePointer();
m_stream.seek( 4 );
byte[] buf = PortUtil.getbytes_uint32_le( position - 8 );
writeByteArray( m_stream, buf, 4 );
// size of data chunk
ushort block_size = (ushort)(m_bit_per_sample / 8 * (int)m_channel);
uint size = block_size * m_total_samples;
m_stream.Seek( 42, SeekOrigin.Begin );
buf = BitConverter.GetBytes( size );
WriteByteArray( m_stream, buf, 4 );
int block_size = (int)(m_bit_per_sample / 8 * (int)m_channel);
int size = block_size * m_total_samples;
m_stream.seek( 42 );
buf = PortUtil.getbytes_uint32_le( size );
writeByteArray( m_stream, buf, 4 );
m_stream.Close();
m_stream.close();
}
}
public uint SampleRate {
get {
public int getSampleRate(){
return m_sample_rate;
}
}
public void Dispose() {
Close();
}
public void Append( float[] L ) {
public void append( float[] L )
#if JAVA
throws IOException
#endif
{
int total = L.Length;
if ( m_bit_per_sample == 8 ) {
if ( m_channel == WaveChannel.Monoral ) {
if ( m_channel == 1 ) {
for ( int i = 0; i < total; i++ ) {
m_stream.WriteByte( (byte)((L[i] + 1.0f) * 127.5f) );
m_stream.writeByte( (int)((L[i] + 1.0f) * 127.5f) );
}
} else {
for ( int i = 0; i < total; i++ ) {
byte b = (byte)((L[i] + 1.0f) * 127.5f);
m_stream.WriteByte( b );
m_stream.WriteByte( b );
int b = (int)((L[i] + 1.0f) * 127.5f);
m_stream.writeByte( b );
m_stream.writeByte( b );
}
}
} else {
byte[] buf;
if ( m_channel == WaveChannel.Monoral ) {
if ( m_channel == 1 ) {
for ( int i = 0; i < total; i++ ) {
buf = BitConverter.GetBytes( (short)(L[i] * 32768f) );
WriteByteArray( m_stream, buf, 2 );
buf = PortUtil.getbytes_int16_le( (short)(L[i] * 32768f) );
writeByteArray( m_stream, buf, 2 );
}
} else {
for ( int i = 0; i < total; i++ ) {
buf = BitConverter.GetBytes( (short)(L[i] * 32768f) );
WriteByteArray( m_stream, buf, 2 );
WriteByteArray( m_stream, buf, 2 );
buf = PortUtil.getbytes_int16_le( (short)(L[i] * 32768f) );
writeByteArray( m_stream, buf, 2 );
writeByteArray( m_stream, buf, 2 );
}
}
}
m_total_samples += (uint)total;
m_total_samples += (int)total;
}
public void Append( double[] L ) {
public void append( double[] L )
#if JAVA
throws IOException
#endif
{
int total = L.Length;
if ( m_bit_per_sample == 8 ) {
if ( m_channel == WaveChannel.Monoral ) {
if ( m_channel == 1 ) {
for ( int i = 0; i < total; i++ ) {
m_stream.WriteByte( (byte)((L[i] + 1.0) * 127.5) );
m_stream.writeByte( (int)((L[i] + 1.0) * 127.5) );
}
} else {
for ( int i = 0; i < total; i++ ) {
byte b = (byte)((L[i] + 1.0) * 127.5);
m_stream.WriteByte( b );
m_stream.WriteByte( b );
int b = (int)((L[i] + 1.0) * 127.5);
m_stream.writeByte( b );
m_stream.writeByte( b );
}
}
} else {
byte[] buf;
if ( m_channel == WaveChannel.Monoral ) {
if ( m_channel == 1 ) {
for ( int i = 0; i < total; i++ ) {
buf = BitConverter.GetBytes( (short)(L[i] * 32768.0) );
WriteByteArray( m_stream, buf, 2 );
buf = PortUtil.getbytes_int16_le( (short)(L[i] * 32768.0) );
writeByteArray( m_stream, buf, 2 );
}
} else {
for ( int i = 0; i < total; i++ ) {
buf = BitConverter.GetBytes( (short)(L[i] * 32768.0) );
WriteByteArray( m_stream, buf, 2 );
WriteByteArray( m_stream, buf, 2 );
buf = PortUtil.getbytes_int16_le( (short)(L[i] * 32768.0) );
writeByteArray( m_stream, buf, 2 );
writeByteArray( m_stream, buf, 2 );
}
}
}
m_total_samples += (uint)total;
m_total_samples += (int)total;
}
public void Append( float[] L, float[] R ) {
public void append( float[] L, float[] R )
#if JAVA
throws IOException
#endif
{
int total = Math.Min( L.Length, R.Length );
if ( m_bit_per_sample == 8 ) {
if ( m_channel == WaveChannel.Monoral ) {
if ( m_channel == 1 ) {
for ( int i = 0; i < total; i++ ) {
m_stream.WriteByte( (byte)((L[i] + R[i] + 2.0f) * 63.75f) );
m_stream.writeByte( (byte)((L[i] + R[i] + 2.0f) * 63.75f) );
}
} else {
for ( int i = 0; i < total; i++ ) {
m_stream.WriteByte( (byte)((L[i] + 1.0f) * 127.5f) );
m_stream.WriteByte( (byte)((R[i] + 1.0f) * 127.5f) );
m_stream.writeByte( (byte)((L[i] + 1.0f) * 127.5f) );
m_stream.writeByte( (byte)((R[i] + 1.0f) * 127.5f) );
}
}
} else {
byte[] buf;
if ( m_channel == WaveChannel.Monoral ) {
if ( m_channel == 1 ) {
for ( int i = 0; i < total; i++ ) {
buf = BitConverter.GetBytes( (short)((L[i] + R[i]) * 16384f) );
WriteByteArray( m_stream, buf, 2 );
buf = PortUtil.getbytes_int16_le( (short)((L[i] + R[i]) * 16384f) );
writeByteArray( m_stream, buf, 2 );
}
} else {
for ( int i = 0; i < total; i++ ) {
buf = BitConverter.GetBytes( (short)(L[i] * 32768f) );
WriteByteArray( m_stream, buf, 2 );
buf = BitConverter.GetBytes( (short)(R[i] * 32768f) );
WriteByteArray( m_stream, buf, 2 );
buf = PortUtil.getbytes_int16_le( (short)(L[i] * 32768f) );
writeByteArray( m_stream, buf, 2 );
buf = PortUtil.getbytes_int16_le( (short)(R[i] * 32768f) );
writeByteArray( m_stream, buf, 2 );
}
}
}
m_total_samples += (uint)total;
m_total_samples += (int)total;
}
public unsafe void Append( float* L, float* R, int length ) {
if ( m_bit_per_sample == 8 ) {
if ( m_channel == WaveChannel.Monoral ) {
for ( int i = 0; i < length; i++ ) {
m_stream.WriteByte( (byte)((L[i] + R[i] + 2.0f) * 63.75f) );
}
} else {
for ( int i = 0; i < length; i++ ) {
m_stream.WriteByte( (byte)((L[i] + 1.0f) * 127.5f) );
m_stream.WriteByte( (byte)((R[i] + 1.0f) * 127.5f) );
}
}
} else {
byte[] buf;
if ( m_channel == WaveChannel.Monoral ) {
for ( int i = 0; i < length; i++ ) {
buf = BitConverter.GetBytes( (short)((L[i] + R[i]) * 16384f) );
WriteByteArray( m_stream, buf, 2 );
}
} else {
for ( int i = 0; i < length; i++ ) {
buf = BitConverter.GetBytes( (short)(L[i] * 32768f) );
WriteByteArray( m_stream, buf, 2 );
buf = BitConverter.GetBytes( (short)(R[i] * 32768f) );
WriteByteArray( m_stream, buf, 2 );
}
}
}
m_total_samples += (uint)length;
}
public void Append( double[] L, double[] R ) {
public void append( double[] L, double[] R )
#if JAVA
throws IOException
#endif
{
int total = Math.Min( L.Length, R.Length );
if ( m_bit_per_sample == 8 ) {
if ( m_channel == WaveChannel.Monoral ) {
if ( m_channel == 1 ) {
for ( int i = 0; i < total; i++ ) {
m_stream.WriteByte( (byte)((L[i] + R[i] + 2.0) * 63.75) );
m_stream.writeByte( (int)((L[i] + R[i] + 2.0) * 63.75) );
}
} else {
for ( int i = 0; i < total; i++ ) {
m_stream.WriteByte( (byte)((L[i] + 1.0) * 127.5) );
m_stream.WriteByte( (byte)((R[i] + 1.0) * 127.5) );
m_stream.writeByte( (int)((L[i] + 1.0) * 127.5) );
m_stream.writeByte( (int)((R[i] + 1.0) * 127.5) );
}
}
} else {
byte[] buf;
if ( m_channel == WaveChannel.Monoral ) {
if ( m_channel == 1 ) {
for ( int i = 0; i < total; i++ ) {
buf = BitConverter.GetBytes( (short)((L[i] + R[i]) * 16384.0) );
WriteByteArray( m_stream, buf, 2 );
buf = PortUtil.getbytes_int16_le( (short)((L[i] + R[i]) * 16384.0) );
writeByteArray( m_stream, buf, 2 );
}
} else {
for ( int i = 0; i < total; i++ ) {
buf = BitConverter.GetBytes( (short)(L[i] * 32768.0) );
WriteByteArray( m_stream, buf, 2 );
buf = BitConverter.GetBytes( (short)(R[i] * 32768.0) );
WriteByteArray( m_stream, buf, 2 );
buf = PortUtil.getbytes_int16_le( (short)(L[i] * 32768.0) );
writeByteArray( m_stream, buf, 2 );
buf = PortUtil.getbytes_int16_le( (short)(R[i] * 32768.0) );
writeByteArray( m_stream, buf, 2 );
}
}
}
m_total_samples += (uint)total;
m_total_samples += (int)total;
}
public void Append( byte[] L, byte[] R ) {
public void append( byte[] L, byte[] R )
#if JAVA
throws IOException
#endif
{
int total = Math.Min( L.Length, R.Length );
if ( m_bit_per_sample == 8 ) {
if ( m_channel == WaveChannel.Monoral ) {
if ( m_channel == 1 ) {
for ( int i = 0; i < total; i++ ) {
m_stream.WriteByte( (byte)((L[i] + R[i]) / 2) );
m_stream.writeByte( 0xff & ((L[i] + R[i]) / 2) );
}
} else {
for ( int i = 0; i < total; i++ ) {
m_stream.WriteByte( L[i] );
m_stream.WriteByte( R[i] );
m_stream.writeByte( 0xff & L[i] );
m_stream.writeByte( 0xff & R[i] );
}
}
} else {
byte[] buf;
if ( m_channel == WaveChannel.Monoral ) {
if ( m_channel == 1 ) {
for ( int i = 0; i < total; i++ ) {
buf = BitConverter.GetBytes( (short)((L[i] + R[i]) * 128.5f - 32768f) );
WriteByteArray( m_stream, buf, 2 );
buf = PortUtil.getbytes_int16_le( (short)((L[i] + R[i]) * 128.5f - 32768f) );
writeByteArray( m_stream, buf, 2 );
}
} else {
for ( int i = 0; i < total; i++ ) {
buf = BitConverter.GetBytes( (short)(L[i] * 257f - 32768f) );
WriteByteArray( m_stream, buf, 2 );
buf = BitConverter.GetBytes( (short)(R[i] * 257f - 32768f) );
WriteByteArray( m_stream, buf, 2 );
buf = PortUtil.getbytes_int16_le( (short)(L[i] * 257f - 32768f) );
writeByteArray( m_stream, buf, 2 );
buf = PortUtil.getbytes_int16_le( (short)(R[i] * 257f - 32768f) );
writeByteArray( m_stream, buf, 2 );
}
}
}
m_total_samples += (uint)total;
m_total_samples += (int)total;
}
public void Append( short[] L, short[] R ) {
public void append( short[] L, short[] R )
#if JAVA
throws IOException
#endif
{
int total = Math.Min( L.Length, R.Length );
if ( m_bit_per_sample == 8 ) {
if ( m_channel == WaveChannel.Monoral ) {
if ( m_channel == 1 ) {
for ( int i = 0; i < total; i++ ) {
m_stream.WriteByte( (byte)(((L[i] + R[i]) / 2f + 32768f) / 255f) );
m_stream.writeByte( (int)(((L[i] + R[i]) / 2f + 32768f) / 255f) );
}
} else {
for ( int i = 0; i < total; i++ ) {
m_stream.WriteByte( (byte)((L[i] + 32768f) / 255f) );
m_stream.WriteByte( (byte)((R[i] + 32768f) / 255f) );
m_stream.writeByte( (int)((L[i] + 32768f) / 255f) );
m_stream.writeByte( (int)((R[i] + 32768f) / 255f) );
}
}
} else {
byte[] buf;
if ( m_channel == WaveChannel.Monoral ) {
if ( m_channel == 1 ) {
for ( int i = 0; i < total; i++ ) {
buf = BitConverter.GetBytes( (L[i] + R[i]) / 2 );
WriteByteArray( m_stream, buf, 2 );
buf = PortUtil.getbytes_int16_le( (short)((L[i] + R[i]) / 2) );
writeByteArray( m_stream, buf, 2 );
}
} else {
for ( int i = 0; i < total; i++ ) {
buf = BitConverter.GetBytes( L[i] );
WriteByteArray( m_stream, buf, 2 );
buf = BitConverter.GetBytes( R[i] );
WriteByteArray( m_stream, buf, 2 );
buf = PortUtil.getbytes_int16_le( L[i] );
writeByteArray( m_stream, buf, 2 );
buf = PortUtil.getbytes_int16_le( R[i] );
writeByteArray( m_stream, buf, 2 );
}
}
}
m_total_samples += (uint)total;
m_total_samples += (int)total;
}
private static void WriteByteArray( FileStream fs, byte[] dat, int limit ) {
fs.Write( dat, 0, (dat.Length > limit) ? limit : dat.Length );
private static void writeByteArray( RandomAccessFile fs, byte[] dat, int limit )
#if JAVA
throws IOException
#endif
{
fs.write( dat, 0, (dat.Length > limit) ? limit : dat.Length );
if ( dat.Length < limit ) {
for ( int i = 0; i < limit - dat.Length; i++ ) {
fs.WriteByte( 0x00 );
fs.writeByte( 0x00 );
}
}
}
}
#if !JAVA
}
#endif

View File

@ -12,13 +12,14 @@
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*/
#if JAVA
package com.boare.vsq;
package org.kbinani.vsq;
import java.io.*;
import org.kbinani.*;
#else
using System;
using System.IO;
using bocoree;
using bocoree.java.io;
namespace Boare.Lib.Vsq {
#endif
@ -34,12 +35,30 @@ namespace Boare.Lib.Vsq {
contents = new NoteHeadHandle();
}
#if JAVA
public String toString(){
#else
public override string ToString() {
#endif
if ( contents != null ) {
return contents.Caption;
} else {
#if JAVA
return super.toString();
#else
return base.ToString();
#endif
}
}
public void parseAic( String aic_file ) {
using ( StreamReader sr = new StreamReader( aic_file ) ) {
BufferedReader sr = null;
try {
sr = new BufferedReader( new FileReader( aic_file ) );
String line;
String current_entry = "";
String articulation = "";
while ( (line = sr.ReadLine()) != null ) {
while ( (line = sr.readLine()) != null ) {
if ( line.StartsWith( "[" ) ) {
current_entry = line;
continue;
@ -47,7 +66,7 @@ namespace Boare.Lib.Vsq {
continue;
}
String[] spl = line.Split( new char[] { '=' }, StringSplitOptions.RemoveEmptyEntries );
String[] spl = PortUtil.splitString( line, new char[] { '=' }, true );
if ( spl.Length < 2 ) {
continue;
}
@ -60,21 +79,33 @@ namespace Boare.Lib.Vsq {
} else if ( current_entry.Equals( "[Parameter]" ) ) {
if ( spl[0].Equals( "Length" ) ) {
try {
this.contents.Length = int.Parse( spl[1] );
} catch { }
this.contents.setLength( PortUtil.parseInt( spl[1] ) );
} catch ( Exception ex ) {
}
} else if ( spl[0].Equals( "Duration" ) ) {
try {
this.contents.Duration = int.Parse( spl[1] );
} catch { }
this.contents.Duration = PortUtil.parseInt( spl[1] );
} catch ( Exception ex ) {
}
} else if ( spl[0].Equals( "Depth" ) ) {
try {
this.contents.Depth = int.Parse( spl[1] );
} catch { }
this.contents.Depth = PortUtil.parseInt( spl[1] );
} catch ( Exception ex ) {
}
}
}
}
} catch ( Exception ex ) {
} finally {
if ( sr != null ) {
try {
sr.close();
} catch ( Exception ex2 ) {
}
}
}
}
}
}
#if !JAVA
}
#endif

View File

@ -12,7 +12,9 @@
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*/
#if JAVA
package com.boare.vsq;
package org.kbinani.vsq;
import java.io.*;
#else
using System;
@ -23,10 +25,10 @@ namespace Boare.Lib.Vsq {
/// Stores the paired value of "Clock" and integer. Mainly used in VsqBPList
/// </summary>
#if JAVA
class BPPair implements Comparable<BPPair> {
public class BPPair implements Comparable<BPPair>, Serializable{
#else
[Serializable]
public class BPPair : IComparable<BPPair> {
public class BPPair : IComparable<BPPair>{
#endif
public int Clock;
public int Value;
@ -46,9 +48,11 @@ namespace Boare.Lib.Vsq {
}
}
#if !JAVA
public int CompareTo( BPPair item ) {
return compareTo( item );
}
#endif
public BPPair( int clock_, int value_ ) {
Clock = clock_;
@ -56,4 +60,6 @@ namespace Boare.Lib.Vsq {
}
}
#if !JAVA
}
#endif

View File

@ -2,7 +2,7 @@
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>9.0.21022</ProductVersion>
<ProductVersion>9.0.30729</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{673347F3-6FC2-4F82-9273-BF158E0F8CB1}</ProjectGuid>
<OutputType>Library</OutputType>
@ -61,28 +61,47 @@
<ItemGroup>
<Compile Include="AttackConfig.cs" />
<Compile Include="BPPair.cs" />
<Compile Include="PortUtil.cs" />
<Compile Include="IconHandle.cs" />
<Compile Include="ITextWriter.cs" />
<Compile Include="Lyric.cs" />
<Compile Include="LyricHandle.cs" />
<Compile Include="MidiEvent.cs" />
<Compile Include="MidiFile.cs" />
<Compile Include="NoteHeadHandle.cs" />
<Compile Include="NRPN.cs" />
<Compile Include="NrpnIterator.cs" />
<Compile Include="SingerConfig.cs" />
<Compile Include="SingerConfigSys.cs" />
<Compile Include="SMF\MidiFile.cs" />
<Compile Include="SymbolTable.cs" />
<Compile Include="SynthesizerType.cs" />
<Compile Include="Timesig.cs" />
<Compile Include="TransCodeUtil.cs" />
<Compile Include="UstEnvelope.cs" />
<Compile Include="UstEvent.cs" />
<Compile Include="UstFile.cs" />
<Compile Include="UstPortamento.cs" />
<Compile Include="UstPortamentoPoint.cs" />
<Compile Include="UstPortamentoType.cs" />
<Compile Include="UstTrack.cs" />
<Compile Include="UstVibrato.cs" />
<Compile Include="VibratoBPList.cs" />
<Compile Include="VibratoBPPair.cs" />
<Compile Include="ExpressionConfigSys.cs" />
<Compile Include="VibratoConfig.cs" />
<Compile Include="VibratoType.cs" />
<Compile Include="VibratoHandle.cs" />
<Compile Include="VocaloSysUtil.cs" />
<Compile Include="VsqBPPair.cs" />
<Compile Include="VsqBPPairSearchContext.cs" />
<Compile Include="VsqCommon.cs" />
<Compile Include="VsqEventList.cs" />
<Compile Include="VsqHandle.cs" />
<Compile Include="VsqHandleType.cs" />
<Compile Include="VsqID.cs" />
<Compile Include="VsqIDType.cs" />
<Compile Include="VsqMaster.cs" />
<Compile Include="VsqMetaText.cs" />
<Compile Include="VsqMixer.cs" />
<Compile Include="VsqMixerEntry.cs" />
<Compile Include="VsqNrpn.cs" />
<Compile Include="NrpnData.cs" />
<Compile Include="VsqCommandType.cs" />
@ -95,17 +114,11 @@
<Compile Include="VsqCommand.cs" />
<Compile Include="VsqEvent.cs" />
<Compile Include="VsqFile.cs" />
<Compile Include="VsqMetaText\Common.cs" />
<Compile Include="VsqMetaText\Handle.cs" />
<Compile Include="VsqMetaText\ID.cs" />
<Compile Include="VsqMetaText\Lyric.cs" />
<Compile Include="VsqMetaText\Master.cs" />
<Compile Include="VsqMetaText\Mixer.cs" />
<Compile Include="VsqMetaText\VsqMetaText.cs" />
<Compile Include="VsqNote.cs" />
<Compile Include="VsqPhoneticSymbol.cs" />
<Compile Include="VsqTrack.cs" />
<Compile Include="VsqVoiceLanguage.cs" />
<Compile Include="WrappedStreamWriter.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\bocoree\bocoree.csproj">

View File

@ -12,64 +12,719 @@
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*/
#if JAVA
package com.boare.vsq;
package org.kbinani.vsq;
import java.util.*;
import java.io.*;
import org.kbinani.*;
#else
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
using bocoree;
using bocoree.java.util;
using bocoree.java.io;
namespace Boare.Lib.Vsq {
#endif
public class ExpressionConfigSys {
#if JAVA
private final int MAX_VIBRATO = 0x400;
#else
private const int MAX_VIBRATO = 0x400;
#endif
private Vector<VibratoConfig> m_vibrato_configs;
private Vector<AttackConfig> m_attack_configs;
private void printTo( String file ) {
BufferedWriter sw = null;
try {
sw = new BufferedWriter( new FileWriter( file ) );
int count = 0;
for ( Iterator itr = m_vibrato_configs.iterator(); itr.hasNext(); ) {
count++;
VibratoConfig vconfig = (VibratoConfig)itr.next();
String name = "v" + count;
sw.write( "VibratoConfig " + name + " = new VibratoConfig();" );
sw.newLine();
sw.write( name + ".author = \"" + vconfig.author + "\";" );
sw.newLine();
sw.write( name + ".file = \"" + vconfig.file + "\";" );
sw.newLine();
sw.write( name + ".number = " + vconfig.number + ";" );
sw.newLine();
sw.write( name + ".vendor = \"" + vconfig.vendor + "\";" );
sw.newLine();
sw.write( name + ".contents.IconID = \"" + vconfig.contents.IconID + "\";" );
sw.newLine();
sw.write( name + ".contents.IDS = \"" + vconfig.contents.IDS + "\";" );
sw.newLine();
sw.write( name + ".contents.Original = " + vconfig.contents.Original + ";" );
sw.newLine();
sw.write( name + ".contents.Caption = \"" + vconfig.contents.Caption + "\";" );
sw.newLine();
sw.write( name + ".contents.Length = " + vconfig.contents.getLength() + ";" );
sw.newLine();
sw.write( name + ".contents.StartDepth = " + vconfig.contents.StartDepth + ";" );
sw.write( name + ".contents.DepthBP = new VibratoBPList( new float[]{ " );
for ( int i = 0; i < vconfig.contents.DepthBP.getCount(); i++ ) {
sw.write( ((i > 0) ? ", " : "") + vconfig.contents.DepthBP.getElement( i ).X + "f" );
}
sw.write( " }, new int[]{ " );
for ( int i = 0; i < vconfig.contents.DepthBP.getCount(); i++ ) {
sw.write( ((i > 0) ? ", " : "") + vconfig.contents.DepthBP.getElement( i ).Y );
}
sw.write( " } );" );
sw.newLine();
sw.write( name + ".contents.StartRate = " + vconfig.contents.StartRate + ";" );
sw.newLine();
sw.write( name + ".contents.RateBP = new VibratoBPList( new float[]{ " );
for ( int i = 0; i < vconfig.contents.RateBP.getCount(); i++ ) {
sw.write( ((i > 0) ? ", " : "") + vconfig.contents.RateBP.getElement( i ).X + "f" );
}
sw.write( " }, new int[]{ " );
for ( int i = 0; i < vconfig.contents.RateBP.getCount(); i++ ) {
sw.write( ((i > 0) ? ", " : "") + vconfig.contents.RateBP.getElement( i ).Y );
}
sw.write( " } );" );
sw.newLine();
sw.write( "ret.m_vibrato_configs.add( " + name + " );" );
sw.newLine();
sw.newLine();
}
count = 0;
for ( Iterator itr = m_attack_configs.iterator(); itr.hasNext(); ) {
count++;
AttackConfig aconfig = (AttackConfig)itr.next();
String name = "a" + count;
sw.write( "AttackConfig " + name + " = new AttackConfig();" );
sw.newLine();
sw.write( name + ".author = \"" + aconfig.author + "\";" );
sw.newLine();
sw.write( name + ".file = \"" + aconfig.file + "\";" );
sw.newLine();
sw.write( name + ".number = " + aconfig.number + ";" );
sw.newLine();
sw.write( name + ".vendor = \"" + aconfig.vendor + "\";" );
sw.newLine();
sw.write( name + ".contents.IconID = \"" + aconfig.contents.IconID + "\";" );
sw.newLine();
sw.write( name + ".contents.IDS = \"" + aconfig.contents.IDS + "\";" );
sw.newLine();
sw.write( name + ".contents.Original = " + aconfig.contents.Original + ";" );
sw.newLine();
sw.write( name + ".contents.Caption = \"" + aconfig.contents.Caption + "\";" );
sw.newLine();
sw.write( name + ".contents.Length = " + aconfig.contents.getLength() + ";" );
sw.newLine();
sw.write( name + ".contents.Duration = " + aconfig.contents.Duration + ";" );
sw.newLine();
sw.write( name + ".contents.Depth = " + aconfig.contents.Depth + ";" );
sw.newLine();
sw.write( "ret.m_attack_configs.add( " + name + " );" );
sw.newLine();
sw.newLine();
}
} catch ( Exception ex ) {
} finally {
if ( sw != null ) {
try {
sw.close();
} catch ( Exception ex2 ) {
}
}
}
}
public static ExpressionConfigSys getVocaloid1Default() {
ExpressionConfigSys ret = new ExpressionConfigSys();
ret.m_vibrato_configs = new Vector<VibratoConfig>();
ret.m_attack_configs = new Vector<AttackConfig>();
VibratoConfig v1 = new VibratoConfig();
v1.author = "Taro";
v1.file = "normal.aic";
v1.number = 1;
v1.vendor = "YAMAHA";
v1.contents.IconID = "$04040001";
v1.contents.IDS = "normal";
v1.contents.Original = 0;
v1.contents.Caption = "Normal Vibrato";
v1.contents.setLength( 480 );
v1.contents.StartDepth = 64;
v1.contents.DepthBP = new VibratoBPList( new float[] { }, new int[] { } );
v1.contents.StartRate = 64;
v1.contents.RateBP = new VibratoBPList( new float[] { }, new int[] { } );
ret.m_vibrato_configs.add( v1 );
VibratoConfig v2 = new VibratoConfig();
v2.author = "Taro";
v2.file = "subtle.aic";
v2.number = 2;
v2.vendor = "YAMAHA";
v2.contents.IconID = "$04040002";
v2.contents.IDS = "normal";
v2.contents.Original = 0;
v2.contents.Caption = "Subtle Vibrato";
v2.contents.setLength( 480 );
v2.contents.StartDepth = 32;
v2.contents.DepthBP = new VibratoBPList( new float[] { }, new int[] { } );
v2.contents.StartRate = 56;
v2.contents.RateBP = new VibratoBPList( new float[] { }, new int[] { } );
ret.m_vibrato_configs.add( v2 );
VibratoConfig v3 = new VibratoConfig();
v3.author = "Taro";
v3.file = "slight.aic";
v3.number = 3;
v3.vendor = "YAMAHA";
v3.contents.IconID = "$04040003";
v3.contents.IDS = "slight";
v3.contents.Original = 0;
v3.contents.Caption = "Slight Vibrato";
v3.contents.setLength( 480 );
v3.contents.StartDepth = 32;
v3.contents.DepthBP = new VibratoBPList( new float[] { }, new int[] { } );
v3.contents.StartRate = 64;
v3.contents.RateBP = new VibratoBPList( new float[] { }, new int[] { } );
ret.m_vibrato_configs.add( v3 );
VibratoConfig v4 = new VibratoConfig();
v4.author = "Taro";
v4.file = "deep.aic";
v4.number = 4;
v4.vendor = "YAMAHA";
v4.contents.IconID = "$04040004";
v4.contents.IDS = "deep";
v4.contents.Original = 0;
v4.contents.Caption = "Deep Vibrato";
v4.contents.setLength( 480 );
v4.contents.StartDepth = 64;
v4.contents.DepthBP = new VibratoBPList( new float[] { }, new int[] { } );
v4.contents.StartRate = 64;
v4.contents.RateBP = new VibratoBPList( new float[] { }, new int[] { } );
ret.m_vibrato_configs.add( v4 );
VibratoConfig v5 = new VibratoConfig();
v5.author = "Taro";
v5.file = "verydeep.aic";
v5.number = 5;
v5.vendor = "YAMAHA";
v5.contents.IconID = "$04040005";
v5.contents.IDS = "extreme";
v5.contents.Original = 0;
v5.contents.Caption = "Very Deep Vibrato";
v5.contents.setLength( 480 );
v5.contents.StartDepth = 64;
v5.contents.DepthBP = new VibratoBPList( new float[] { }, new int[] { } );
v5.contents.StartRate = 120;
v5.contents.RateBP = new VibratoBPList( new float[] { }, new int[] { } );
ret.m_vibrato_configs.add( v5 );
VibratoConfig v6 = new VibratoConfig();
v6.author = "Taro";
v6.file = "extreme.aic";
v6.number = 6;
v6.vendor = "YAMAHA";
v6.contents.IconID = "$04040006";
v6.contents.IDS = "extreme";
v6.contents.Original = 0;
v6.contents.Caption = "Extreme Vibrato (like Japanese Enka)";
v6.contents.setLength( 480 );
v6.contents.StartDepth = 64;
v6.contents.DepthBP = new VibratoBPList( new float[] { }, new int[] { } );
v6.contents.StartRate = 64;
v6.contents.RateBP = new VibratoBPList( new float[] { }, new int[] { } );
ret.m_vibrato_configs.add( v6 );
AttackConfig a1 = new AttackConfig();
a1.author = "Taro";
a1.file = "na_tenuto.aic";
a1.number = 1;
a1.vendor = "YAMAHA";
a1.contents.IconID = "$01010001";
a1.contents.IDS = "tenuto";
a1.contents.Original = 0;
a1.contents.Caption = "Tenuto";
a1.contents.setLength( 120 );
a1.contents.Duration = 64;
a1.contents.Depth = 64;
ret.m_attack_configs.add( a1 );
AttackConfig a2 = new AttackConfig();
a2.author = "Taro";
a2.file = "na_accent.aic";
a2.number = 2;
a2.vendor = "YAMAHA";
a2.contents.IconID = "$01010002";
a2.contents.IDS = "accent";
a2.contents.Original = 0;
a2.contents.Caption = "Accent";
a2.contents.setLength( 120 );
a2.contents.Duration = 64;
a2.contents.Depth = 64;
ret.m_attack_configs.add( a2 );
AttackConfig a3 = new AttackConfig();
a3.author = "Taro";
a3.file = "na_extreme_accent.aic";
a3.number = 3;
a3.vendor = "YAMAHA";
a3.contents.IconID = "$01010003";
a3.contents.IDS = "accent_extreme";
a3.contents.Original = 0;
a3.contents.Caption = "Extreme Accent";
a3.contents.setLength( 120 );
a3.contents.Duration = 64;
a3.contents.Depth = 64;
ret.m_attack_configs.add( a3 );
AttackConfig a4 = new AttackConfig();
a4.author = "Taro";
a4.file = "na_legato.aic";
a4.number = 4;
a4.vendor = "YAMAHA";
a4.contents.IconID = "$01010004";
a4.contents.IDS = "legato";
a4.contents.Original = 0;
a4.contents.Caption = "Legato";
a4.contents.setLength( 120 );
a4.contents.Duration = 64;
a4.contents.Depth = 64;
ret.m_attack_configs.add( a4 );
AttackConfig a5 = new AttackConfig();
a5.author = "Taro";
a5.file = "na_fast_bendup.aic";
a5.number = 5;
a5.vendor = "YAMAHA";
a5.contents.IconID = "$01010005";
a5.contents.IDS = "bendup_fast";
a5.contents.Original = 0;
a5.contents.Caption = "Fast Bendu";
a5.contents.setLength( 120 );
a5.contents.Duration = 64;
a5.contents.Depth = 64;
ret.m_attack_configs.add( a5 );
AttackConfig a6 = new AttackConfig();
a6.author = "Taro";
a6.file = "na_slow_bendup.aic";
a6.number = 6;
a6.vendor = "YAMAHA";
a6.contents.IconID = "$01010006";
a6.contents.IDS = "bendup_slow";
a6.contents.Original = 0;
a6.contents.Caption = "Slow Bendup";
a6.contents.setLength( 120 );
a6.contents.Duration = 64;
a6.contents.Depth = 64;
ret.m_attack_configs.add( a6 );
AttackConfig a7 = new AttackConfig();
a7.author = "Taro";
a7.file = "na_trill_semi.aic";
a7.number = 7;
a7.vendor = "YAMAHA";
a7.contents.IconID = "$01010007";
a7.contents.IDS = "trill_semi";
a7.contents.Original = 0;
a7.contents.Caption = "Trill Semitone";
a7.contents.setLength( 120 );
a7.contents.Duration = 64;
a7.contents.Depth = 64;
ret.m_attack_configs.add( a7 );
AttackConfig a8 = new AttackConfig();
a8.author = "Taro";
a8.file = "na_trill_whole.aic";
a8.number = 8;
a8.vendor = "YAMAHA";
a8.contents.IconID = "$01010008";
a8.contents.IDS = "trill_whole";
a8.contents.Original = 0;
a8.contents.Caption = "Trill Wholetone";
a8.contents.setLength( 120 );
a8.contents.Duration = 64;
a8.contents.Depth = 64;
ret.m_attack_configs.add( a8 );
AttackConfig a9 = new AttackConfig();
a9.author = "Taro";
a9.file = "na_mordent_semi.aic";
a9.number = 9;
a9.vendor = "YAMAHA";
a9.contents.IconID = "$01010009";
a9.contents.IDS = "mordent_semi";
a9.contents.Original = 0;
a9.contents.Caption = "Mordent Semitone";
a9.contents.setLength( 120 );
a9.contents.Duration = 64;
a9.contents.Depth = 64;
ret.m_attack_configs.add( a9 );
AttackConfig a10 = new AttackConfig();
a10.author = "Taro";
a10.file = "na_mordent_whole.aic";
a10.number = 10;
a10.vendor = "YAMAHA";
a10.contents.IconID = "$0101000a";
a10.contents.IDS = "mordent_whole";
a10.contents.Original = 0;
a10.contents.Caption = "Mordent Wholetone";
a10.contents.setLength( 120 );
a10.contents.Duration = 64;
a10.contents.Depth = 64;
ret.m_attack_configs.add( a10 );
return ret;
}
public static ExpressionConfigSys getVocaloid2Default() {
ExpressionConfigSys ret = new ExpressionConfigSys();
ret.m_vibrato_configs = new Vector<VibratoConfig>();
ret.m_attack_configs = new Vector<AttackConfig>();
VibratoConfig v1 = new VibratoConfig();
v1.author = "Standard";
v1.file = "normal2_type1.aic";
v1.number = 1;
v1.vendor = "YAMAHA";
v1.contents.IconID = "$04040001";
v1.contents.IDS = "normal";
v1.contents.Original = 0;
v1.contents.Caption = "[Normal] Type 1";
v1.contents.setLength( 480 );
v1.contents.StartDepth = 64;
v1.contents.DepthBP = new VibratoBPList( new float[] { }, new int[] { } );
v1.contents.StartRate = 50;
v1.contents.RateBP = new VibratoBPList( new float[] { }, new int[] { } );
ret.m_vibrato_configs.add( v1 );
VibratoConfig v2 = new VibratoConfig();
v2.author = "Standard";
v2.file = "normal2_type2.aic";
v2.number = 2;
v2.vendor = "YAMAHA";
v2.contents.IconID = "$04040002";
v2.contents.IDS = "normal";
v2.contents.Original = 0;
v2.contents.Caption = "[Normal] Type 2";
v2.contents.setLength( 480 );
v2.contents.StartDepth = 40;
v2.contents.DepthBP = new VibratoBPList( new float[] { }, new int[] { } );
v2.contents.StartRate = 50;
v2.contents.RateBP = new VibratoBPList( new float[] { }, new int[] { } );
ret.m_vibrato_configs.add( v2 );
VibratoConfig v3 = new VibratoConfig();
v3.author = "Standard";
v3.file = "normal2_type3.aic";
v3.number = 3;
v3.vendor = "YAMAHA";
v3.contents.IconID = "$04040003";
v3.contents.IDS = "normal";
v3.contents.Original = 0;
v3.contents.Caption = "[Normal] Type 3";
v3.contents.setLength( 480 );
v3.contents.StartDepth = 127;
v3.contents.DepthBP = new VibratoBPList( new float[] { }, new int[] { } );
v3.contents.StartRate = 50;
v3.contents.RateBP = new VibratoBPList( new float[] { }, new int[] { } );
ret.m_vibrato_configs.add( v3 );
VibratoConfig v4 = new VibratoConfig();
v4.author = "Standard";
v4.file = "normal2_type4.aic";
v4.number = 4;
v4.vendor = "YAMAHA";
v4.contents.IconID = "$04040004";
v4.contents.IDS = "normal";
v4.contents.Original = 0;
v4.contents.Caption = "[Normal] Type 4";
v4.contents.setLength( 480 );
v4.contents.StartDepth = 64;
v4.contents.DepthBP = new VibratoBPList( new float[] { 0.6042f, 0.6125f, 0.6167f, 0.6208f, 0.625f, 0.6333f, 0.6375f, 0.6417f, 0.6458f, 0.6542f, 0.6583f, 0.6667f, 0.6708f, 0.675f, 0.6792f, 0.6833f, 0.6917f, 0.6958f, 0.7042f, 0.7083f, 0.7125f, 0.7167f, 0.7208f, 0.725f, 0.7292f, 0.7375f, 0.7458f, 0.75f, 0.7583f, 0.7625f, 0.7667f, 0.7708f, 0.775f, 0.7833f, 0.7917f, 0.7958f, 0.8f, 0.8042f, 0.8083f, 0.8125f, 0.8208f, 0.8292f, 0.8375f, 0.8417f, 0.8458f, 0.85f, 0.8542f, 0.8625f, 0.8667f, 0.875f, 0.8792f, 0.8833f, 0.8875f, 0.8917f, 0.8958f, 0.9f, 1f }, new int[] { 64, 63, 62, 61, 59, 58, 57, 56, 55, 54, 52, 51, 50, 49, 48, 47, 45, 44, 43, 42, 41, 40, 39, 38, 37, 35, 34, 32, 31, 30, 29, 28, 27, 25, 24, 23, 22, 21, 20, 19, 17, 15, 14, 13, 12, 11, 10, 8, 7, 6, 5, 4, 3, 2, 1, 0, 0 } );
v4.contents.StartRate = 50;
v4.contents.RateBP = new VibratoBPList( new float[] { 0.6f, 0.6125f, 0.6167f, 0.6208f, 0.6292f, 0.6333f, 0.6375f, 0.6417f, 0.6542f, 0.6583f, 0.6625f, 0.6667f, 0.675f, 0.6833f, 0.6875f, 0.6917f, 0.7f, 0.7042f, 0.7083f, 0.7125f, 0.725f, 0.7292f, 0.7333f, 0.7375f, 0.7458f, 0.75f, 0.7583f, 0.7625f, 0.7708f, 0.775f, 0.7792f, 0.7833f, 0.7958f, 0.8f, 0.8042f, 0.8083f, 0.8167f, 0.8208f, 0.8292f, 0.8333f, 0.8417f, 0.8458f, 0.85f, 0.8542f, 0.8667f, 0.8708f, 0.875f, 0.8792f, 0.8875f, 0.8917f, 0.9f, 1f }, new int[] { 50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 0 } );
ret.m_vibrato_configs.add( v4 );
VibratoConfig v5 = new VibratoConfig();
v5.author = "Standard";
v5.file = "extreme2_type1.aic";
v5.number = 5;
v5.vendor = "YAMAHA";
v5.contents.IconID = "$04040005";
v5.contents.IDS = "extreme";
v5.contents.Original = 0;
v5.contents.Caption = "[Extreme] Type 1";
v5.contents.setLength( 480 );
v5.contents.StartDepth = 64;
v5.contents.DepthBP = new VibratoBPList( new float[] { }, new int[] { } );
v5.contents.StartRate = 64;
v5.contents.RateBP = new VibratoBPList( new float[] { }, new int[] { } );
ret.m_vibrato_configs.add( v5 );
VibratoConfig v6 = new VibratoConfig();
v6.author = "Standard";
v6.file = "extreme2_type2.aic";
v6.number = 6;
v6.vendor = "YAMAHA";
v6.contents.IconID = "$04040006";
v6.contents.IDS = "extreme";
v6.contents.Original = 0;
v6.contents.Caption = "[Extreme] Type 2";
v6.contents.setLength( 480 );
v6.contents.StartDepth = 32;
v6.contents.DepthBP = new VibratoBPList( new float[] { }, new int[] { } );
v6.contents.StartRate = 32;
v6.contents.RateBP = new VibratoBPList( new float[] { }, new int[] { } );
ret.m_vibrato_configs.add( v6 );
VibratoConfig v7 = new VibratoConfig();
v7.author = "Standard";
v7.file = "extreme2_type3.aic";
v7.number = 7;
v7.vendor = "YAMAHA";
v7.contents.IconID = "$04040007";
v7.contents.IDS = "extreme";
v7.contents.Original = 0;
v7.contents.Caption = "[Extreme] Type 3";
v7.contents.setLength( 480 );
v7.contents.StartDepth = 100;
v7.contents.DepthBP = new VibratoBPList( new float[] { }, new int[] { } );
v7.contents.StartRate = 50;
v7.contents.RateBP = new VibratoBPList( new float[] { }, new int[] { } );
ret.m_vibrato_configs.add( v7 );
VibratoConfig v8 = new VibratoConfig();
v8.author = "Standard";
v8.file = "extreme2_type4.aic";
v8.number = 8;
v8.vendor = "YAMAHA";
v8.contents.IconID = "$04040008";
v8.contents.IDS = "extreme";
v8.contents.Original = 0;
v8.contents.Caption = "[Extreme] Type 4";
v8.contents.setLength( 480 );
v8.contents.StartDepth = 64;
v8.contents.DepthBP = new VibratoBPList( new float[] { 0.6042f, 0.6125f, 0.6167f, 0.6208f, 0.625f, 0.6333f, 0.6375f, 0.6417f, 0.6458f, 0.6542f, 0.6583f, 0.6667f, 0.6708f, 0.675f, 0.6792f, 0.6833f, 0.6917f, 0.6958f, 0.7042f, 0.7083f, 0.7125f, 0.7167f, 0.7208f, 0.725f, 0.7292f, 0.7375f, 0.7458f, 0.75f, 0.7583f, 0.7625f, 0.7667f, 0.7708f, 0.775f, 0.7833f, 0.7917f, 0.7958f, 0.8f, 0.8042f, 0.8083f, 0.8125f, 0.8208f, 0.8292f, 0.8375f, 0.8417f, 0.8458f, 0.85f, 0.8542f, 0.8625f, 0.8667f, 0.875f, 0.8792f, 0.8833f, 0.8875f, 0.8917f, 0.8958f, 0.9f, 1f }, new int[] { 64, 63, 62, 61, 59, 58, 57, 56, 55, 54, 52, 51, 50, 49, 48, 47, 45, 44, 43, 42, 41, 40, 39, 38, 37, 35, 34, 32, 31, 30, 29, 28, 27, 25, 24, 23, 22, 21, 20, 19, 17, 15, 14, 13, 12, 11, 10, 8, 7, 6, 5, 4, 3, 2, 1, 0, 0 } );
v8.contents.StartRate = 64;
v8.contents.RateBP = new VibratoBPList( new float[] { 0.6042f, 0.6125f, 0.6167f, 0.6208f, 0.625f, 0.6333f, 0.6375f, 0.6417f, 0.6458f, 0.6542f, 0.6583f, 0.6667f, 0.6708f, 0.675f, 0.6792f, 0.6833f, 0.6917f, 0.6958f, 0.7042f, 0.7083f, 0.7125f, 0.7167f, 0.7208f, 0.725f, 0.7292f, 0.7375f, 0.7458f, 0.75f, 0.7583f, 0.7625f, 0.7667f, 0.7708f, 0.775f, 0.7833f, 0.7917f, 0.7958f, 0.8f, 0.8042f, 0.8083f, 0.8125f, 0.8208f, 0.8292f, 0.8375f, 0.8417f, 0.8458f, 0.85f, 0.8542f, 0.8625f, 0.8667f, 0.875f, 0.8792f, 0.8833f, 0.8875f, 0.8917f, 0.8958f, 0.9f, 1f }, new int[] { 64, 63, 62, 61, 59, 58, 57, 56, 55, 54, 52, 51, 50, 49, 48, 47, 45, 44, 43, 42, 41, 40, 39, 38, 37, 35, 34, 32, 31, 30, 29, 28, 27, 25, 24, 23, 22, 21, 20, 19, 17, 15, 14, 13, 12, 11, 10, 8, 7, 6, 5, 4, 3, 2, 1, 0, 0 } );
ret.m_vibrato_configs.add( v8 );
VibratoConfig v9 = new VibratoConfig();
v9.author = "Standard";
v9.file = "fast2_type1.aic";
v9.number = 9;
v9.vendor = "YAMAHA";
v9.contents.IconID = "$04040009";
v9.contents.IDS = "fast";
v9.contents.Original = 0;
v9.contents.Caption = "[Fast] Type 1";
v9.contents.setLength( 480 );
v9.contents.StartDepth = 64;
v9.contents.DepthBP = new VibratoBPList( new float[] { }, new int[] { } );
v9.contents.StartRate = 64;
v9.contents.RateBP = new VibratoBPList( new float[] { }, new int[] { } );
ret.m_vibrato_configs.add( v9 );
VibratoConfig v10 = new VibratoConfig();
v10.author = "Standard";
v10.file = "fast2_type2.aic";
v10.number = 10;
v10.vendor = "YAMAHA";
v10.contents.IconID = "$0404000a";
v10.contents.IDS = "fast";
v10.contents.Original = 0;
v10.contents.Caption = "[Fast] Type 2";
v10.contents.setLength( 480 );
v10.contents.StartDepth = 40;
v10.contents.DepthBP = new VibratoBPList( new float[] { }, new int[] { } );
v10.contents.StartRate = 50;
v10.contents.RateBP = new VibratoBPList( new float[] { }, new int[] { } );
ret.m_vibrato_configs.add( v10 );
VibratoConfig v11 = new VibratoConfig();
v11.author = "Standard";
v11.file = "fast2_type3.aic";
v11.number = 11;
v11.vendor = "YAMAHA";
v11.contents.IconID = "$0404000b";
v11.contents.IDS = "fast";
v11.contents.Original = 0;
v11.contents.Caption = "[Fast] Type 3";
v11.contents.setLength( 480 );
v11.contents.StartDepth = 80;
v11.contents.DepthBP = new VibratoBPList( new float[] { }, new int[] { } );
v11.contents.StartRate = 70;
v11.contents.RateBP = new VibratoBPList( new float[] { }, new int[] { } );
ret.m_vibrato_configs.add( v11 );
VibratoConfig v12 = new VibratoConfig();
v12.author = "Standard";
v12.file = "fast2_type4.aic";
v12.number = 12;
v12.vendor = "YAMAHA";
v12.contents.IconID = "$0404000c";
v12.contents.IDS = "fast";
v12.contents.Original = 0;
v12.contents.Caption = "[Fast] Type 4";
v12.contents.setLength( 480 );
v12.contents.StartDepth = 64;
v12.contents.DepthBP = new VibratoBPList( new float[] { 0.6042f, 0.6125f, 0.6167f, 0.6208f, 0.625f, 0.6333f, 0.6375f, 0.6417f, 0.6458f, 0.6542f, 0.6583f, 0.6667f, 0.6708f, 0.675f, 0.6792f, 0.6833f, 0.6917f, 0.6958f, 0.7042f, 0.7083f, 0.7125f, 0.7167f, 0.7208f, 0.725f, 0.7292f, 0.7375f, 0.7458f, 0.75f, 0.7583f, 0.7625f, 0.7667f, 0.7708f, 0.775f, 0.7833f, 0.7917f, 0.7958f, 0.8f, 0.8042f, 0.8083f, 0.8125f, 0.8208f, 0.8292f, 0.8375f, 0.8417f, 0.8458f, 0.85f, 0.8542f, 0.8625f, 0.8667f, 0.875f, 0.8792f, 0.8833f, 0.8875f, 0.8917f, 0.8958f, 0.9f, 1f }, new int[] { 64, 63, 62, 61, 59, 58, 57, 56, 55, 54, 52, 51, 50, 49, 48, 47, 45, 44, 43, 42, 41, 40, 39, 38, 37, 35, 34, 32, 31, 30, 29, 28, 27, 25, 24, 23, 22, 21, 20, 19, 17, 15, 14, 13, 12, 11, 10, 8, 7, 6, 5, 4, 3, 2, 1, 0, 0 } );
v12.contents.StartRate = 64;
v12.contents.RateBP = new VibratoBPList( new float[] { 0.6042f, 0.6125f, 0.6167f, 0.6208f, 0.625f, 0.6333f, 0.6375f, 0.6417f, 0.6458f, 0.6542f, 0.6583f, 0.6667f, 0.6708f, 0.675f, 0.6792f, 0.6833f, 0.6917f, 0.6958f, 0.7042f, 0.7083f, 0.7125f, 0.7167f, 0.7208f, 0.725f, 0.7292f, 0.7375f, 0.7458f, 0.75f, 0.7583f, 0.7625f, 0.7667f, 0.7708f, 0.775f, 0.7833f, 0.7917f, 0.7958f, 0.8f, 0.8042f, 0.8083f, 0.8125f, 0.8208f, 0.8292f, 0.8375f, 0.8417f, 0.8458f, 0.85f, 0.8542f, 0.8625f, 0.8667f, 0.875f, 0.8792f, 0.8833f, 0.8875f, 0.8917f, 0.8958f, 0.9f, 1f }, new int[] { 64, 63, 62, 61, 59, 58, 57, 56, 55, 54, 52, 51, 50, 49, 48, 47, 45, 44, 43, 42, 41, 40, 39, 38, 37, 35, 34, 32, 31, 30, 29, 28, 27, 25, 24, 23, 22, 21, 20, 19, 17, 15, 14, 13, 12, 11, 10, 8, 7, 6, 5, 4, 3, 2, 1, 0, 0 } );
ret.m_vibrato_configs.add( v12 );
VibratoConfig v13 = new VibratoConfig();
v13.author = "Standard";
v13.file = "slight2_type1.aic";
v13.number = 13;
v13.vendor = "YAMAHA";
v13.contents.IconID = "$0404000d";
v13.contents.IDS = "slight";
v13.contents.Original = 0;
v13.contents.Caption = "[Slight] Type 1";
v13.contents.setLength( 480 );
v13.contents.StartDepth = 64;
v13.contents.DepthBP = new VibratoBPList( new float[] { }, new int[] { } );
v13.contents.StartRate = 64;
v13.contents.RateBP = new VibratoBPList( new float[] { }, new int[] { } );
ret.m_vibrato_configs.add( v13 );
VibratoConfig v14 = new VibratoConfig();
v14.author = "Standard";
v14.file = "slight2_type2.aic";
v14.number = 14;
v14.vendor = "YAMAHA";
v14.contents.IconID = "$0404000e";
v14.contents.IDS = "slight";
v14.contents.Original = 0;
v14.contents.Caption = "[Slight] Type 2";
v14.contents.setLength( 480 );
v14.contents.StartDepth = 40;
v14.contents.DepthBP = new VibratoBPList( new float[] { }, new int[] { } );
v14.contents.StartRate = 64;
v14.contents.RateBP = new VibratoBPList( new float[] { }, new int[] { } );
ret.m_vibrato_configs.add( v14 );
VibratoConfig v15 = new VibratoConfig();
v15.author = "Standard";
v15.file = "slight2_type3.aic";
v15.number = 15;
v15.vendor = "YAMAHA";
v15.contents.IconID = "$0404000f";
v15.contents.IDS = "slight";
v15.contents.Original = 0;
v15.contents.Caption = "[Slight] Type 3";
v15.contents.setLength( 480 );
v15.contents.StartDepth = 72;
v15.contents.DepthBP = new VibratoBPList( new float[] { }, new int[] { } );
v15.contents.StartRate = 64;
v15.contents.RateBP = new VibratoBPList( new float[] { }, new int[] { } );
ret.m_vibrato_configs.add( v15 );
VibratoConfig v16 = new VibratoConfig();
v16.author = "Standard";
v16.file = "slight2_type4.aic";
v16.number = 16;
v16.vendor = "YAMAHA";
v16.contents.IconID = "$04040010";
v16.contents.IDS = "slight";
v16.contents.Original = 0;
v16.contents.Caption = "[Slight] Type 4";
v16.contents.setLength( 480 );
v16.contents.StartDepth = 64;
v16.contents.DepthBP = new VibratoBPList( new float[] { 0.6042f, 0.6125f, 0.6167f, 0.6208f, 0.625f, 0.6333f, 0.6375f, 0.6417f, 0.6458f, 0.6542f, 0.6583f, 0.6667f, 0.6708f, 0.675f, 0.6792f, 0.6833f, 0.6917f, 0.6958f, 0.7042f, 0.7083f, 0.7125f, 0.7167f, 0.7208f, 0.725f, 0.7292f, 0.7375f, 0.7458f, 0.75f, 0.7583f, 0.7625f, 0.7667f, 0.7708f, 0.775f, 0.7833f, 0.7917f, 0.7958f, 0.8f, 0.8042f, 0.8083f, 0.8125f, 0.8208f, 0.8292f, 0.8375f, 0.8417f, 0.8458f, 0.85f, 0.8542f, 0.8625f, 0.8667f, 0.875f, 0.8792f, 0.8833f, 0.8875f, 0.8917f, 0.8958f, 0.9f, 1f }, new int[] { 64, 63, 62, 61, 59, 58, 57, 56, 55, 54, 52, 51, 50, 49, 48, 47, 45, 44, 43, 42, 41, 40, 39, 38, 37, 35, 34, 32, 31, 30, 29, 28, 27, 25, 24, 23, 22, 21, 20, 19, 17, 15, 14, 13, 12, 11, 10, 8, 7, 6, 5, 4, 3, 2, 1, 0, 0 } );
v16.contents.StartRate = 64;
v16.contents.RateBP = new VibratoBPList( new float[] { 0.6042f, 0.6125f, 0.6167f, 0.6208f, 0.625f, 0.6333f, 0.6375f, 0.6417f, 0.6458f, 0.6542f, 0.6583f, 0.6667f, 0.6708f, 0.675f, 0.6792f, 0.6833f, 0.6917f, 0.6958f, 0.7042f, 0.7083f, 0.7125f, 0.7167f, 0.7208f, 0.725f, 0.7292f, 0.7375f, 0.7458f, 0.75f, 0.7583f, 0.7625f, 0.7667f, 0.7708f, 0.775f, 0.7833f, 0.7917f, 0.7958f, 0.8f, 0.8042f, 0.8083f, 0.8125f, 0.8208f, 0.8292f, 0.8375f, 0.8417f, 0.8458f, 0.85f, 0.8542f, 0.8625f, 0.8667f, 0.875f, 0.8792f, 0.8833f, 0.8875f, 0.8917f, 0.8958f, 0.9f, 1f }, new int[] { 64, 63, 62, 61, 59, 58, 57, 56, 55, 54, 52, 51, 50, 49, 48, 47, 45, 44, 43, 42, 41, 40, 39, 38, 37, 35, 34, 32, 31, 30, 29, 28, 27, 25, 24, 23, 22, 21, 20, 19, 17, 15, 14, 13, 12, 11, 10, 8, 7, 6, 5, 4, 3, 2, 1, 0, 0 } );
ret.m_vibrato_configs.add( v16 );
return ret;
}
public int getVibratoConfigCount() {
return m_vibrato_configs.size();
}
public int getAttackConfigCount() {
return m_attack_configs.size();
}
public Iterator vibratoConfigIterator() {
#if JAVA
return m_vibrato_configs.iterator();
#else
return new ListIterator<VibratoConfig>( m_vibrato_configs );
#endif
}
public Iterator attackConfigIterator() {
#if JAVA
return m_attack_configs.iterator();
#else
return new ListIterator<AttackConfig>( m_attack_configs );
#endif
}
private ExpressionConfigSys() {
}
public ExpressionConfigSys( String path_expdb ) {
m_vibrato_configs = new Vector<VibratoConfig>();
m_attack_configs = new Vector<AttackConfig>();
String expression = Path.Combine( path_expdb, "expression.map" );
if ( !File.Exists( expression ) ) {
String expression = PortUtil.combinePath( path_expdb, "expression.map" );
if ( !PortUtil.isFileExists( expression ) ) {
#if DEBUG
PortUtil.println( "ExpressionConfigSys#.ctor; expression.map does not exist" );
#endif
return;
}
FileStream fs = null;
RandomAccessFile fs = null;
try {
new FileStream( expression, FileMode.Open, FileAccess.Read );
fs = new RandomAccessFile( expression, "r" );
byte[] dat = new byte[8];
fs.Seek( 0x20, SeekOrigin.Begin );
fs.seek( 0x20 );
for ( int i = 0; i < MAX_VIBRATO; i++ ) {
fs.Read( dat, 0, 8 );
ulong value = VocaloSysUtil.makelong_le( dat );
fs.read( dat, 0, 8 );
long value = VocaloSysUtil.makelong_le( dat );
if ( value <= 0 ) {
continue;
}
String ved = Path.Combine( path_expdb, "vexp" + value + ".ved" );
if ( !File.Exists( ved ) ) {
String ved = PortUtil.combinePath( path_expdb, "vexp" + value + ".ved" );
if ( !PortUtil.isFileExists( ved ) ) {
continue;
}
String vexp_dir = Path.Combine( path_expdb, "vexp" + value );
if ( !Directory.Exists( vexp_dir ) ) {
String vexp_dir = PortUtil.combinePath( path_expdb, "vexp" + value );
if ( !PortUtil.isFileExists( vexp_dir ) ) {
continue;
}
#if DEBUG
PortUtil.println( "ExpresionConfigSys#.ctor; ved=" + ved + "; vexp_dir=" + vexp_dir );
#endif
String NL = (char)0x0D + "" + (char)0x0A;
FileStream fs_ved = null;
RandomAccessFile fs_ved = null;
try {
fs_ved = new FileStream( ved, FileMode.Open, FileAccess.Read );
byte[] byte_ved = new byte[fs_ved.Length];
fs_ved.Read( byte_ved, 0, byte_ved.Length );
TransCodeUtil.decodeBytes( ref byte_ved );
String str = new String( Encoding.ASCII.GetChars( byte_ved ) );
String[] spl = str.Split( new String[] { NL }, StringSplitOptions.RemoveEmptyEntries );
fs_ved = new RandomAccessFile( ved, "r" );
byte[] byte_ved = new byte[(int)fs_ved.length()];
fs_ved.read( byte_ved, 0, byte_ved.Length );
TransCodeUtil.decodeBytes( byte_ved );
String str = PortUtil.getDecodedString( "ASCII", byte_ved );
#if DEBUG
String txt_file = PortUtil.combinePath( path_expdb, "vexp" + value + ".txt" );
using ( System.IO.StreamWriter sw = new System.IO.StreamWriter( txt_file ) ) {
sw.Write( str );
}
#endif
String[] spl = PortUtil.splitString( str, new String[] { NL }, true );
String current_entry = "";
for ( int j = 0; j < spl.Length; j++ ) {
#if DEBUG
//PortUtil.println( "ExpressionConfigSys#.ctor; line=" + spl[j] );
#endif
if ( spl[j].StartsWith( "[" ) ) {
current_entry = spl[j];
continue;
@ -77,63 +732,82 @@ namespace Boare.Lib.Vsq {
continue;
}
if ( current_entry.Equals( "[VIBRATO]" ) ) {
String[] spl2 = spl[j].Split( ',' );
String[] spl2 = PortUtil.splitString( spl[j], ',' );
if ( spl2.Length < 6 ) {
continue;
}
// ex: 1,1,"normal","normal2_type1.aic","[Normal]:Type:1","Standard","YAMAHA",0
VibratoConfig item = new VibratoConfig();
item.number = int.Parse( spl2[0] );
item.number = PortUtil.parseInt( spl2[0] );
item.contents.IDS = spl2[2].Replace( "\"", "" );
item.file = spl2[3].Replace( "\"", "" );
item.contents.Caption = spl2[4].Replace( ":", " " ).Replace( "\"", "" );
item.author = spl2[5].Replace( "\"", "" );
item.vendor = spl2[6].Replace( "\"", "" );
String aic_file = Path.Combine( vexp_dir, item.file );
if ( !File.Exists( aic_file ) ) {
item.contents.IconID = "$0404" + PortUtil.toHexString( item.number, 4 );
String aic_file = PortUtil.combinePath( vexp_dir, item.file );
if ( !PortUtil.isFileExists( aic_file ) ) {
continue;
}
item.parseAic( aic_file );
m_vibrato_configs.add( item );
} if ( current_entry.Equals( "[NOTEATTACK]" ) ) {
String[] spl2 = spl[j].Split( ',' );
String[] spl2 = PortUtil.splitString( spl[j], ',' );
if ( spl2.Length < 6 ) {
continue;
}
// ex: 1,1,"normal","normal2_type1.aic","[Normal]:Type:1","Standard","YAMAHA",0
AttackConfig item = new AttackConfig();
item.number = int.Parse( spl2[0] );
item.number = PortUtil.parseInt( spl2[0] );
item.contents.IDS = spl2[2].Replace( "\"", "" );
item.file = spl2[3].Replace( "\"", "" );
item.contents.Caption = spl2[4].Replace( ":", " " ).Replace( "\"", "" );
item.author = spl2[5].Replace( "\"", "" );
item.vendor = spl2[6].Replace( "\"", "" );
String aic_file = Path.Combine( vexp_dir, item.file );
if ( !File.Exists( aic_file ) ) {
item.contents.IconID = "$0101" + PortUtil.toHexString( item.number, 4 );
String aic_file = PortUtil.combinePath( vexp_dir, item.file );
if ( !PortUtil.isFileExists( aic_file ) ) {
continue;
}
item.parseAic( aic_file );
m_attack_configs.add( item );
}
}
} catch ( Exception ex ) {
#if DEBUG
PortUtil.println( "ExpressionConfigSys#.ctor; ex=" + ex );
#endif
} finally {
if ( fs_ved != null ) {
try {
fs_ved.Close();
fs_ved.close();
} catch ( Exception ex2 ) {
#if DEBUG
PortUtil.println( "ExpressionConfigSys#.ctor; ex2=" + ex2 );
#endif
}
}
}
}
} catch ( Exception ex ) {
#if DEBUG
PortUtil.println( "ExpressionConfigSys#.ctor; ex=" + ex );
#endif
} finally {
if ( fs != null ) {
try {
fs.Close();
fs.close();
} catch ( Exception ex2 ) {
}
#if DEBUG
PortUtil.println( "ExpressionConfigSys#.ctor; ex2=" + ex2 );
#endif
}
}
}
}
}
#if !JAVA
}
#endif

View File

@ -0,0 +1,38 @@
/*
* ITextWriter.cs
* Copyright (c) 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.
*/
#if JAVA
package org.kbinani.vsq;
import java.io.*;
#else
using System;
namespace Boare.Lib.Vsq {
#endif
public interface ITextWriter {
#if JAVA
void write( String value ) throws IOException;
void writeLine( String value ) throws IOException;
void close() throws IOException;
#else
void write( String value );
void writeLine( String value );
void close();
#endif
}
#if !JAVA
}
#endif

View File

@ -0,0 +1,94 @@
/*
* IconHandle.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.
*/
#if JAVA
package org.kbinani.vsq;
import java.io.*;
#else
using System;
namespace Boare.Lib.Vsq {
using boolean = System.Boolean;
#endif
#if JAVA
public class IconHandle implements Cloneable, Serializable{
#else
[Serializable]
public class IconHandle : ICloneable{
#endif
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 IconHandle() {
}
public int getLength() {
return Length;
}
public void setLength( int value ) {
Length = value;
}
public boolean equals( IconHandle item ) {
if ( item == null ) {
return false;
} else {
return IconID.Equals( item.IconID );
}
}
public Object clone() {
IconHandle ret = new IconHandle();
ret.Caption = Caption;
ret.IconID = IconID;
ret.IDS = IDS;
ret.Index = Index;
ret.Language = Language;
ret.setLength( Length );
ret.Original = Original;
ret.Program = Program;
return ret;
}
#if !JAVA
public object Clone() {
return clone();
}
#endif
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.setLength( Length );
ret.Program = Program;
return ret;
}
}
#if !JAVA
}
#endif

View File

@ -1,5 +1,5 @@
/*
* VsqMetaText/Lyric.cs
* Lyric.cs
* Copyright (c) 2008-2009 kbinani
*
* This file is part of Boare.Lib.Vsq.
@ -11,23 +11,28 @@
* 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;
#if JAVA
package org.kbinani.vsq;
import java.io.*;
import org.kbinani.*;
#else
using System;
using bocoree;
namespace Boare.Lib.Vsq {
using boolean = System.Boolean;
#endif
/// <summary>
/// VsqHandleに格納される歌詞の情報を扱うクラス。
/// </summary>
#if JAVA
public class Lyric implements Serializable{
#else
[Serializable]
public class Lyric {
#endif
/// <summary>
/// この歌詞のフレーズ
/// </summary>
@ -45,16 +50,28 @@ namespace Boare.Lib.Vsq {
/// このオブジェクトの簡易コピーを取得します。
/// </summary>
/// <returns>このインスタンスの簡易コピー</returns>
public Lyric Clone() {
public Object clone() {
Lyric result = new Lyric();
result.Phrase = this.Phrase;
result.m_phonetic_symbol = (String[])this.m_phonetic_symbol.Clone();
result.m_phonetic_symbol = new String[m_phonetic_symbol.Length];
for ( int i = 0; i < m_phonetic_symbol.Length; i++ ) {
result.m_phonetic_symbol[i] = m_phonetic_symbol[i];
}
result.UnknownFloat = this.UnknownFloat;
result.m_consonant_adjustment = (int[])this.m_consonant_adjustment.Clone();
result.m_consonant_adjustment = new int[m_consonant_adjustment.Length];
for ( int i = 0; i < m_consonant_adjustment.Length; i++ ) {
result.m_consonant_adjustment[i] = m_consonant_adjustment[i];
}
result.PhoneticSymbolProtected = PhoneticSymbolProtected;
return result;
}
#if !JAVA
public Object Clone() {
return clone();
}
#endif
/// <summary>
/// 歌詞、発音記号を指定したコンストラクタ
/// </summary>
@ -85,9 +102,9 @@ namespace Boare.Lib.Vsq {
/// </summary>
public void setPhoneticSymbol( String value ) {
String s = value.Replace( " ", " " );
m_phonetic_symbol = s.Split( " ".ToCharArray(), 16 );
m_phonetic_symbol = PortUtil.splitString( s, new char[] { ' ' }, 16 );
for ( int i = 0; i < m_phonetic_symbol.Length; i++ ) {
m_phonetic_symbol[i] = m_phonetic_symbol[i].Replace( @"\\", @"\" );
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++ ) {
@ -99,6 +116,7 @@ namespace Boare.Lib.Vsq {
}
}
#if !JAVA
/// <summary>
/// XMLシリアライズ用
/// </summary>
@ -110,6 +128,7 @@ namespace Boare.Lib.Vsq {
setPhoneticSymbol( value );
}
}
#endif
public String[] getPhoneticSymbolList() {
String[] ret = new String[m_phonetic_symbol.Length];
@ -124,12 +143,7 @@ namespace Boare.Lib.Vsq {
/// </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[] { ',' } );
String[] spl = PortUtil.splitString( _line, ',' );
int c_length = spl.Length - 3;
if ( spl.Length < 4 ) {
Phrase = "a";
@ -142,57 +156,32 @@ namespace Boare.Lib.Vsq {
Phrase = Phrase.Substring( 1 );
}
if ( Phrase.EndsWith( "\"" ) ) {
Phrase = Phrase.Substring( 0, Phrase.Length - 1 );
Phrase = Phrase.Substring( 0, PortUtil.getStringLength( Phrase ) - 1 );
}
String symbols = spl[1];
if ( symbols.StartsWith( "\"" ) ) {
symbols = symbols.Substring( 1 );
}
if ( symbols.EndsWith( "\"" ) ) {
symbols = symbols.Substring( 0, symbols.Length - 1 );
symbols = symbols.Substring( 0, PortUtil.getStringLength( symbols ) - 1 );
}
setPhoneticSymbol( symbols );
UnknownFloat = float.Parse( spl[2] );
UnknownFloat = PortUtil.parseFloat( spl[2] );
PhoneticSymbolProtected = (spl[spl.Length - 1].Equals( "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( boolean a_encode ) {
public String toString() {
String result;
if ( a_encode ) {
String njp = new String( encode( this.Phrase ) );
result = "\"" + njp + "\",\"" + this.getPhoneticSymbol() + "\"," + UnknownFloat.ToString( "0.000000" );
} else {
result = "\"";
result += this.Phrase;
result += "\",\"" + this.getPhoneticSymbol() + "\"," + UnknownFloat.ToString( "0.000000" );
result = result.Replace( @"\\", @"\" );
}
result += "\",\"" + this.getPhoneticSymbol() + "\"," + PortUtil.formatDecimal( "0.000000", UnknownFloat );
result = result.Replace( "\\" + "\\", "\\" );
for ( int i = 0; i < m_consonant_adjustment.Length; i++ ) {
result += "," + m_consonant_adjustment[i];
}
@ -204,18 +193,13 @@ namespace Boare.Lib.Vsq {
return result;
}
/// <summary>
/// 文字がプリント出力可能かどうかを判定します
/// </summary>
/// <param name="ch"></param>
/// <returns></returns>
private static boolean isprint( char ch ) {
if ( 32 <= (int)ch && (int)ch <= 126 ) {
return true;
} else {
return false;
}
#if !JAVA
public override string ToString() {
return toString();
}
#endif
}
#if !JAVA
}
#endif

View File

@ -0,0 +1,99 @@
/*
* LyricHandle.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.
*/
#if JAVA
package org.kbinani.vsq;
import java.io.*;
import java.util.*;
#else
using System;
using bocoree.java.util;
namespace Boare.Lib.Vsq {
#endif
#if JAVA
public class LyricHandle implements Cloneable, Serializable{
#else
[Serializable]
public class LyricHandle : ICloneable {
#endif
public Lyric L0;
public int Index;
public Vector<Lyric> Trailing = new Vector<Lyric>();
public LyricHandle() {
L0 = new Lyric();
}
public Lyric getLyricAt( int index ){
if( index == 0 ){
return L0;
}else{
return Trailing.get( index - 1 );
}
}
public void setLyricAt( int index, Lyric value ){
if( index == 0 ){
L0 = value;
}else{
Trailing.set( index - 1, value );
}
}
public int getCount(){
return Trailing.size() + 1;
}
/// <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();
int c = Trailing.size();
for( int i = 0; i < c; i++ ){
Lyric buf = (Lyric)Trailing.get( i ).clone();
ret.Trailing.add( buf );
}
return ret;
}
#if !JAVA
public object Clone() {
return clone();
}
#endif
public VsqHandle castToVsqHandle() {
VsqHandle ret = new VsqHandle();
ret.m_type = VsqHandleType.Lyric;
ret.L0 = (Lyric)L0.clone();
ret.Trailing = Trailing;
ret.Index = Index;
return ret;
}
}
#if !JAVA
}
#endif

View File

@ -0,0 +1,282 @@
/*
* MidiEvent.cs
* Copyright (c) 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.
*/
#if JAVA
package org.kbinani.vsq;
import java.io.*;
import org.kbinani.*;
#else
using System;
using bocoree;
using bocoree.java.io;
namespace Boare.Lib.Vsq {
using boolean = System.Boolean;
using Long = System.Int64;
#endif
/// <summary>
/// midiイベント。メタイベントは、メタイベントのデータ長をData[1]に格納せず、生のデータをDataに格納するので、注意が必要
/// </summary>
#if JAVA
public class MidiEvent implements Comparable<MidiEvent> {
#else
public struct MidiEvent : IComparable<MidiEvent> {
#endif
public long clock;
public byte firstByte;
public byte[] data;
private static void writeDeltaClock( RandomAccessFile stream, long number )
#if JAVA
throws IOException
#endif
{
boolean[] bits = new boolean[64];
long val = 0x1;
bits[0] = (number & val) == val;
for ( int i = 1; i < 64; i++ ) {
val = val << 1;
bits[i] = (number & val) == val;
}
int first = 0;
for ( int i = 63; i >= 0; i-- ) {
if ( bits[i] ) {
first = i;
break;
}
}
// 何バイト必要か?
int bytes = first / 7 + 1;
for ( int i = 1; i <= bytes; i++ ) {
long num = 0;
long count = 0x80;
for ( int j = (bytes - i + 1) * 7 - 1; j >= (bytes - i + 1) * 7 - 6 - 1; j-- ) {
count = count >> 1;
if ( bits[j] ) {
num += count;
}
}
if ( i != bytes ) {
num += 0x80;
}
stream.write( (byte)num );
}
}
private static long readDeltaClock( RandomAccessFile stream )
#if JAVA
throws IOException
#endif
{
long ret = 0;
while ( true ) {
int i = stream.read();
if ( i < 0 ) {
break;
}
byte d = (byte)i;
ret = (ret << 7) | ((long)d & 0x7f);
if ( (d & 0x80) == 0x00 ) {
break;
}
}
return ret;
}
public static MidiEvent read( RandomAccessFile stream, ByRef<Long> last_clock, ByRef<Byte> last_status_byte )
#if JAVA
throws IOException, Exception
#endif
{
long delta_clock = readDeltaClock( stream );
last_clock.value += delta_clock;
byte first_byte = (byte)stream.read();
if ( first_byte < 0x80 ) {
// ランニングステータスが適用される
long pos = stream.getFilePointer();
stream.seek( pos - 1 );
first_byte = last_status_byte.value;
} else {
last_status_byte.value = first_byte;
}
byte ctrl = (byte)(first_byte & (byte)0xf0);
if ( ctrl == 0x80 || ctrl == 0x90 || ctrl == 0xA0 || ctrl == 0xB0 || ctrl == 0xE0 || first_byte == 0xF2 ) {
// 3byte使用するチャンネルメッセージ
// 0x8*: ノートオフ
// 0x9*: ノートオン
// 0xA*: ポリフォニック・キープレッシャ
// 0xB*: コントロールチェンジ
// 0xE*: ピッチベンドチェンジ
// 3byte使用するシステムメッセージ
// 0xF2: ソングポジション・ポインタ
MidiEvent me = new MidiEvent();
me.clock = last_clock.value;
me.firstByte = first_byte;
me.data = new byte[2];
stream.read( me.data, 0, 2 );
return me;
} else if ( ctrl == 0xC0 || ctrl == 0xD0 || first_byte == 0xF1 || first_byte == 0xF2 ) {
// 2byte使用するチャンネルメッセージ
// 0xC*: プログラムチェンジ
// 0xD*: チャンネルプレッシャ
// 2byte使用するシステムメッセージ
// 0xF1: クォータフレーム
// 0xF3: ソングセレクト
MidiEvent me = new MidiEvent();
me.clock = last_clock.value;
me.firstByte = first_byte;
me.data = new byte[1];
stream.read( me.data, 0, 1 );
return me;
} else if ( first_byte == 0xF6 ) {
// 1byte使用するシステムメッセージ
// 0xF6: チューンリクエスト
// 0xF7: エンドオブエクスクルーシブこのクラスではF0ステータスのSysExの一部として取り扱う
// 0xF8: タイミングクロック
// 0xFA: スタート
// 0xFB: コンティニュー
// 0xFC: ストップ
// 0xFE: アクティブセンシング
// 0xFF: システムリセット
MidiEvent me = new MidiEvent();
me.clock = last_clock.value;
me.firstByte = first_byte;
me.data = new byte[0];
return me;
} else if ( first_byte == 0xff ) {
// メタイベント
byte meta_event_type = (byte)stream.read();
long meta_event_length = readDeltaClock( stream );
MidiEvent me = new MidiEvent();
me.clock = last_clock.value;
me.firstByte = first_byte;
me.data = new byte[(int)meta_event_length + 1];
me.data[0] = meta_event_type;
stream.read( me.data, 1, (int)meta_event_length );
return me;
} else if ( first_byte == 0xf0 ) {
// f0ステータスのSysEx
MidiEvent me = new MidiEvent();
me.clock = last_clock.value;
me.firstByte = first_byte;
long sysex_length = readDeltaClock( stream );
me.data = new byte[(int)sysex_length + 1];
stream.read( me.data, 0, (int)(sysex_length + 1) );
return me;
} else if ( first_byte == 0xf7 ) {
// f7ステータスのSysEx
MidiEvent me = new MidiEvent();
me.clock = last_clock.value;
me.firstByte = first_byte;
long sysex_length = readDeltaClock( stream );
me.data = new byte[(int)sysex_length];
stream.read( me.data, 0, (int)sysex_length );
return me;
} else {
throw new Exception( "don't know how to process first_byte: 0x" + PortUtil.toHexString( first_byte ) );
}
}
public void writeData( RandomAccessFile stream )
#if JAVA
throws IOException
#endif
{
stream.write( firstByte );
if ( firstByte == 0xff ) {
stream.write( data[0] );
writeDeltaClock( stream, data.Length - 1 );
//stream.WriteByte( (byte)(Data.Length - 1) );
stream.write( data, 1, data.Length - 1 );
} else {
stream.write( data, 0, data.Length );
}
}
public int compareTo( MidiEvent item ) {
if ( clock != item.clock ) {
return (int)(clock - item.clock);
} else {
int first_this = firstByte & 0xf0;
int first_item = item.firstByte & 0xf0;
if ( (first_this == 0x80 || first_this == 0x90) && (first_item == 0x80 || first_item == 0x90) ) {
if ( data != null && data.Length >= 2 && item.data != null && item.data.Length >= 2 ) {
if ( first_item == 0x90 && item.data[1] == 0 ) {
first_item = 0x80;
}
if ( first_this == 0x90 && data[1] == 0 ) {
first_this = 0x80;
}
if ( data[0] == item.data[0] ) {
if ( first_this == 0x90 ) {
if ( first_item == 0x80 ) {
// ON -> OFF
return 1;
} else {
// ON -> ON
return 0;
}
} else {
if ( first_item == 0x80 ) {
// OFF -> OFF
return 0;
} else {
// OFF -> ON
return -1;
}
}
}
}
}
return (int)(clock - item.clock);
}
}
#if !JAVA
public int CompareTo( MidiEvent item ) {
return compareTo( item );
}
#endif
public static MidiEvent generateTimeSigEvent( int clock, int numerator, int denominator ) {
MidiEvent ret = new MidiEvent();
ret.clock = clock;
ret.firstByte = (byte)0xff;
byte b_numer = (byte)(Math.Log( denominator ) / Math.Log( 2 ) + 0.1);
#if DEBUG
PortUtil.println( "VsqEvent.generateTimeSigEvent; b_number=" + b_numer + "; denominator=" + denominator );
#endif
ret.data = new byte[] { 0x58, (byte)numerator, b_numer, 0x18, 0x08 };
return ret;
}
public static MidiEvent generateTempoChangeEvent( int clock, int tempo ) {
MidiEvent ret = new MidiEvent();
ret.clock = clock;
ret.firstByte = (byte)0xff;
byte b1 = (byte)(tempo & 0xff);
tempo = tempo >> 8;
byte b2 = (byte)(tempo & 0xff);
tempo = tempo >> 8;
byte b3 = (byte)(tempo & 0xff);
ret.data = new byte[] { (byte)0x51, b3, b2, b1 };
return ret;
}
}
#if !JAVA
}
#endif

View File

@ -0,0 +1,203 @@
/*
* MidiFile.cs
* Copyright (c) 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.
*/
#if JAVA
package org.kbinani.vsq;
import java.io.*;
import java.util.*;
import org.kbinani.*;
#else
using System;
using bocoree;
using bocoree.java.util;
using bocoree.java.io;
namespace Boare.Lib.Vsq {
using boolean = System.Boolean;
using Long = System.Int64;
#endif
public class MidiFile {
private Vector<Vector<MidiEvent>> m_events;
private int m_format;
private int m_time_format;
public MidiFile( String path )
#if JAVA
throws FileNotFoundException
#endif
{
RandomAccessFile stream = new RandomAccessFile( path, "r" );
try {
// ヘッダ
byte[] byte4 = new byte[4];
stream.read( byte4, 0, 4 );
if ( PortUtil.make_uint32_be( byte4 ) != 0x4d546864 ) {
throw new Exception( "header error: MThd" );
}
// データ長
stream.read( byte4, 0, 4 );
long length = PortUtil.make_uint32_be( byte4 );
// フォーマット
stream.read( byte4, 0, 2 );
m_format = PortUtil.make_uint16_be( byte4 );
// トラック数
int tracks = 0;
stream.read( byte4, 0, 2 );
tracks = (int)PortUtil.make_uint16_be( byte4 );
// 時間分解能
stream.read( byte4, 0, 2 );
m_time_format = PortUtil.make_uint16_be( byte4 );
// 各トラックを読込み
m_events = new Vector<Vector<MidiEvent>>();
for ( int track = 0; track < tracks; track++ ) {
Vector<MidiEvent> track_events = new Vector<MidiEvent>();
// ヘッダー
stream.read( byte4, 0, 4 );
if ( PortUtil.make_uint32_be( byte4 ) != 0x4d54726b ) {
throw new Exception( "header error; MTrk" );
}
// チャンクサイズ
stream.read( byte4, 0, 4 );
long size = (long)PortUtil.make_uint32_be( byte4 );
long startpos = stream.getFilePointer();
// チャンクの終わりまで読込み
ByRef<Long> clock = new ByRef<Long>( (long)0 );
ByRef<Byte> last_status_byte = new ByRef<Byte>( (byte)0x00 );
while ( stream.getFilePointer() < startpos + size ) {
MidiEvent mi = MidiEvent.read( stream, clock, last_status_byte );
track_events.add( mi );
}
if ( m_time_format != 480 ) {
int count = track_events.size();
for ( int i = 0; i < count; i++ ) {
MidiEvent mi = track_events.get( i );
mi.clock = mi.clock * 480 / m_time_format;
track_events.set( i, mi );
}
}
m_events.add( track_events );
}
m_time_format = 480;
#if DEBUG && MIDI_PRINT_TO_FILE
String dbg = PortUtil.combinePath( PortUtil.getDirectoryName( path ), PortUtil.getFileNameWithoutExtension( path ) + ".txt" );
BufferedWriter sw = null;
try {
sw = new BufferedWriter( new FileWriter( dbg ) );
const String format = " {0,8} 0x{1:X4} {2,-35} 0x{3:X2} 0x{4:X2}";
const String format0 = " {0,8} 0x{1:X4} {2,-35} 0x{3:X2}";
for ( int track = 1; track < m_events.size(); track++ ) {
sw.write( "MidiFile..ctor; track=" + track );
sw.newLine();
byte msb, lsb, data_msb, data_lsb;
msb = lsb = data_msb = data_lsb = 0x0;
for ( int i = 0; i < m_events.get( track ).size(); i++ ) {
if ( m_events.get( track ).get( i ).firstByte == 0xb0 ) {
switch ( m_events.get( track ).get( i ).data[0] ) {
case 0x63:
msb = m_events.get( track ).get( i ).data[1];
lsb = 0x0;
break;
case 0x62:
lsb = m_events.get( track ).get( i ).data[1];
break;
case 0x06:
data_msb = m_events.get( track ).get( i ).data[1];
ushort nrpn = (ushort)(msb << 8 | lsb);
String name = NRPN.getName( nrpn );
if ( name.Equals( "" ) ) {
name = "* * UNKNOWN * *";
sw.write( String.Format( format0, m_events.get( track ).get( i ).clock, nrpn, name, data_msb ) );
sw.newLine();
} else {
//if ( !NRPN.is_require_data_lsb( nrpn ) ) {
sw.write( String.Format( format0, m_events.get( track ).get( i ).clock, nrpn, name, data_msb ) );
sw.newLine();
//}
}
break;
case 0x26:
data_lsb = m_events.get( track ).get( i ).data[1];
ushort nrpn2 = (ushort)(msb << 8 | lsb);
String name2 = NRPN.getName( nrpn2 );
if ( name2.Equals( "" ) ) {
name2 = "* * UNKNOWN * *";
}
sw.write( String.Format( format, m_events.get( track ).get( i ).clock, nrpn2, name2, data_msb, data_lsb ) );
sw.newLine();
break;
}
}
}
}
} catch ( Exception ex ) {
} finally {
if ( sw != null ) {
try {
sw.close();
} catch ( Exception ex2 ) {
}
}
}
#endif
} catch ( Exception ex ) {
} finally {
if ( stream != null ) {
try {
stream.close();
} catch ( Exception ex2 ) {
}
}
}
}
public Vector<MidiEvent> getMidiEventList( int track ) {
if ( m_events == null ) {
return new Vector<MidiEvent>();
} else if ( 0 <= track && track < m_events.size() ) {
return m_events.get( track );
} else {
return new Vector<MidiEvent>();
}
}
public int getTrackCount() {
if ( m_events == null ) {
return 0;
} else {
return m_events.size();
}
}
public void close() {
if ( m_events != null ) {
int c = m_events.size();
for ( int i = 0; i < c; i++ ) {
m_events.get( i ).clear();
}
m_events.clear();
}
}
}
#if !JAVA
}
#endif

View File

@ -11,595 +11,573 @@
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*/
#if JAVA
package org.kbinani.vsq;
import java.util.*;
import java.lang.reflect.*;
import org.kbinani.*;
#else
using System;
using System.Reflection;
using System.Collections.Generic;
using bocoree;
using bocoree.java.util;
namespace Boare.Lib.Vsq {
using boolean = System.Boolean;
using Integer = System.Int32;
#endif
public static class NRPN {
public class NRPN {
/// <summary>
/// (0x5000) Version number(MSB) &amp;, Device number(LSB)
/// </summary>
public const ushort CVM_NM_VERSION_AND_DEVICE = 0x5000;
public const int CVM_NM_VERSION_AND_DEVICE = 0x5000;
/// <summary>
/// (0x5001) Delay in millisec(MSB, LSB)
/// </summary>
public const ushort CVM_NM_DELAY = 0x5001;
public const int CVM_NM_DELAY = 0x5001;
/// <summary>
/// (0x5002) Note number(MSB)
/// </summary>
public const ushort CVM_NM_NOTE_NUMBER = 0x5002;
public const int CVM_NM_NOTE_NUMBER = 0x5002;
/// <summary>
/// (0x5003) Velocity(MSB)
/// </summary>
public const ushort CVM_NM_VELOCITY = 0x5003;
public const int CVM_NM_VELOCITY = 0x5003;
/// <summary>
/// (0x5004) Note Duration in millisec(MSB, LSB)
/// </summary>
public const ushort CVM_NM_NOTE_DURATION = 0x5004;
public const int CVM_NM_NOTE_DURATION = 0x5004;
/// <summary>
/// (0x5005) Note Location(MSB)
/// </summary>
public const ushort CVM_NM_NOTE_LOCATION = 0x5005;
public const int CVM_NM_NOTE_LOCATION = 0x5005;
/// <summary>
/// (0x5006) Attack Type(MSB, LSB)
/// </summary>
public const ushort CVM_NM_ATTACK_TYPE = 0x5006;
public const int CVM_NM_ATTACK_TYPE = 0x5006;
/// <summary>
/// (0x5007) Attack Duration in millisec(MSB, LSB)
/// </summary>
public const ushort CVM_NM_ATTACK_DURATION = 0x5007;
public const int CVM_NM_ATTACK_DURATION = 0x5007;
/// <summary>
/// (0x5008) Attack Depth(MSB)
/// </summary>
public const ushort CVM_NM_ATTACK_DEPTH = 0x5008;
public const int CVM_NM_ATTACK_DEPTH = 0x5008;
/// <summary>
/// (0x500c) Index of Vibrato DB(MSB: ID_H00, LSB:ID_L00)
/// </summary>
public const ushort CVM_NM_INDEX_OF_VIBRATO_DB = 0x500c;
public const int CVM_NM_INDEX_OF_VIBRATO_DB = 0x500c;
/// <summary>
/// (0x500d) Vibrato configuration(MSB: Index of Vibrato Type, LSB: Duration &amp;, Configuration parameter of vibrato)
/// </summary>
public const ushort CVM_NM_VIBRATO_CONFIG = 0x500d;
public const int CVM_NM_VIBRATO_CONFIG = 0x500d;
/// <summary>
/// (0x500e) Vibrato Delay(MSB)
/// </summary>
public const ushort CVM_NM_VIBRATO_DELAY = 0x500e;
/*/// <summary>
/// (0x5011) Unknonw(MSB), only used in VOCALOID1
/// </summary>
public const ushort CVM_NM_UNKNOWN1 = 0x5011;*/
public const int CVM_NM_VIBRATO_DELAY = 0x500e;
// // <summary>
// // (0x5011) Unknonw(MSB), only used in VOCALOID1
// // </summary>
// public const int CVM_NM_UNKNOWN1 = 0x5011;
/// <summary>
/// (0x5012) Number of phonetic symbols in bytes(MSB)
/// </summary>
public const ushort CVM_NM_PHONETIC_SYMBOL_BYTES = 0x5012;
public const int CVM_NM_PHONETIC_SYMBOL_BYTES = 0x5012;
/// <summary>
/// (0x5013) Phonetic symbol 1(MSB:Phonetic symbol 1, LSB: Consonant adjustment 1)
/// </summary>
public const ushort CVM_NM_PHONETIC_SYMBOL1 = 0x5013;
public const int CVM_NM_PHONETIC_SYMBOL1 = 0x5013;
/// <summary>
/// (0x5014) Phonetic symbol 2(MSB:Phonetic symbol 2, LSB: Consonant adjustment 2)
/// </summary>
public const ushort CVM_NM_PHONETIC_SYMBOL2 = 0x5014;
public const int CVM_NM_PHONETIC_SYMBOL2 = 0x5014;
/// <summary>
/// (0x5015) Phonetic symbol 3(MSB:Phonetic symbol 3, LSB: Consonant adjustment 3)
/// </summary>
public const ushort CVM_NM_PHONETIC_SYMBOL3 = 0x5015;
public const int CVM_NM_PHONETIC_SYMBOL3 = 0x5015;
/// <summary>
/// (0x5016) Phonetic symbol 4(MSB:Phonetic symbol 4, LSB: Consonant adjustment 4)
/// </summary>
public const ushort CVM_NM_PHONETIC_SYMBOL4 = 0x5016;
public const int CVM_NM_PHONETIC_SYMBOL4 = 0x5016;
/// <summary>
/// (0x5017) Phonetic symbol 5(MSB:Phonetic symbol 5, LSB: Consonant adjustment 5)
/// </summary>
public const ushort CVM_NM_PHONETIC_SYMBOL5 = 0x5017;
public const int CVM_NM_PHONETIC_SYMBOL5 = 0x5017;
/// <summary>
/// (0x5018) Phonetic symbol 6(MSB:Phonetic symbol 6, LSB: Consonant adjustment 6)
/// </summary>
public const ushort CVM_NM_PHONETIC_SYMBOL6 = 0x5018;
public const int CVM_NM_PHONETIC_SYMBOL6 = 0x5018;
/// <summary>
/// (0x5019) Phonetic symbol 7(MSB:Phonetic symbol 7, LSB: Consonant adjustment 7)
/// </summary>
public const ushort CVM_NM_PHONETIC_SYMBOL7 = 0x5019;
public const int CVM_NM_PHONETIC_SYMBOL7 = 0x5019;
/// <summary>
/// (0x501a) Phonetic symbol 8(MSB:Phonetic symbol 8, LSB: Consonant adjustment 8)
/// </summary>
public const ushort CVM_NM_PHONETIC_SYMBOL8 = 0x501a;
public const int CVM_NM_PHONETIC_SYMBOL8 = 0x501a;
/// <summary>
/// (0x501b) Phonetic symbol 9(MSB:Phonetic symbol 9, LSB: Consonant adjustment 9)
/// </summary>
public const ushort CVM_NM_PHONETIC_SYMBOL9 = 0x501b;
public const int CVM_NM_PHONETIC_SYMBOL9 = 0x501b;
/// <summary>
/// (0x501c) Phonetic symbol 10(MSB:Phonetic symbol 10, LSB: Consonant adjustment 10)
/// </summary>
public const ushort CVM_NM_PHONETIC_SYMBOL10 = 0x501c;
public const int CVM_NM_PHONETIC_SYMBOL10 = 0x501c;
/// <summary>
/// (0x501d) Phonetic symbol 11(MSB:Phonetic symbol 11, LSB: Consonant adjustment 11)
/// </summary>
public const ushort CVM_NM_PHONETIC_SYMBOL11 = 0x501d;
public const int CVM_NM_PHONETIC_SYMBOL11 = 0x501d;
/// <summary>
/// (0x501e) Phonetic symbol 12(MSB:Phonetic symbol 12, LSB: Consonant adjustment 12)
/// </summary>
public const ushort CVM_NM_PHONETIC_SYMBOL12 = 0x501e;
public const int CVM_NM_PHONETIC_SYMBOL12 = 0x501e;
/// <summary>
/// (0x501f) Phonetic symbol 13(MSB:Phonetic symbol 13, LSB: Consonant adjustment 13)
/// </summary>
public const ushort CVM_NM_PHONETIC_SYMBOL13 = 0x501f;
public const int CVM_NM_PHONETIC_SYMBOL13 = 0x501f;
/// <summary>
/// (0x5020) Phonetic symbol 14(MSB:Phonetic symbol 14, LSB: Consonant adjustment 14)
/// </summary>
public const ushort CVM_NM_PHONETIC_SYMBOL14 = 0x5020;
public const int CVM_NM_PHONETIC_SYMBOL14 = 0x5020;
/// <summary>
/// (0x5021) Phonetic symbol 15(MSB:Phonetic symbol 15, LSB: Consonant adjustment 15)
/// </summary>
public const ushort CVM_NM_PHONETIC_SYMBOL15 = 0x5021;
public const int CVM_NM_PHONETIC_SYMBOL15 = 0x5021;
/// <summary>
/// (0x5022) Phonetic symbol 16(MSB:Phonetic symbol 16, LSB: Consonant adjustment 16)
/// </summary>
public const ushort CVM_NM_PHONETIC_SYMBOL16 = 0x5022;
public const int CVM_NM_PHONETIC_SYMBOL16 = 0x5022;
/// <summary>
/// (0x5023) Phonetic symbol 17(MSB:Phonetic symbol 17, LSB: Consonant adjustment 17)
/// </summary>
public const ushort CVM_NM_PHONETIC_SYMBOL17 = 0x5023;
public const int CVM_NM_PHONETIC_SYMBOL17 = 0x5023;
/// <summary>
/// (0x5024) Phonetic symbol 18(MSB:Phonetic symbol 18, LSB: Consonant adjustment 18)
/// </summary>
public const ushort CVM_NM_PHONETIC_SYMBOL18 = 0x5024;
public const int CVM_NM_PHONETIC_SYMBOL18 = 0x5024;
/// <summary>
/// (0x5025) Phonetic symbol 19(MSB:Phonetic symbol 19, LSB: Consonant adjustment 19)
/// </summary>
public const ushort CVM_NM_PHONETIC_SYMBOL19 = 0x5025;
public const int CVM_NM_PHONETIC_SYMBOL19 = 0x5025;
/// <summary>
/// (0x5026) Phonetic symbol 20(MSB:Phonetic symbol 20, LSB: Consonant adjustment 20)
/// </summary>
public const ushort CVM_NM_PHONETIC_SYMBOL20 = 0x5026;
public const int CVM_NM_PHONETIC_SYMBOL20 = 0x5026;
/// <summary>
/// (0x5027) Phonetic symbol 21(MSB:Phonetic symbol 21, LSB: Consonant adjustment 21)
/// </summary>
public const ushort CVM_NM_PHONETIC_SYMBOL21 = 0x5027;
public const int CVM_NM_PHONETIC_SYMBOL21 = 0x5027;
/// <summary>
/// (0x5028) Phonetic symbol 22(MSB:Phonetic symbol 22, LSB: Consonant adjustment 22)
/// </summary>
public const ushort CVM_NM_PHONETIC_SYMBOL22 = 0x5028;
public const int CVM_NM_PHONETIC_SYMBOL22 = 0x5028;
/// <summary>
/// (0x5029) Phonetic symbol 23(MSB:Phonetic symbol 23, LSB: Consonant adjustment 23)
/// </summary>
public const ushort CVM_NM_PHONETIC_SYMBOL23 = 0x5029;
public const int CVM_NM_PHONETIC_SYMBOL23 = 0x5029;
/// <summary>
/// (0x502a) Phonetic symbol 24(MSB:Phonetic symbol 24, LSB: Consonant adjustment 24)
/// </summary>
public const ushort CVM_NM_PHONETIC_SYMBOL24 = 0x502a;
public const int CVM_NM_PHONETIC_SYMBOL24 = 0x502a;
/// <summary>
/// (0x502b) Phonetic symbol 25(MSB:Phonetic symbol 25, LSB: Consonant adjustment 25)
/// </summary>
public const ushort CVM_NM_PHONETIC_SYMBOL25 = 0x502b;
public const int CVM_NM_PHONETIC_SYMBOL25 = 0x502b;
/// <summary>
/// (0x502c) Phonetic symbol 26(MSB:Phonetic symbol 26, LSB: Consonant adjustment 26)
/// </summary>
public const ushort CVM_NM_PHONETIC_SYMBOL26 = 0x502c;
public const int CVM_NM_PHONETIC_SYMBOL26 = 0x502c;
/// <summary>
/// (0x502d) Phonetic symbol 27(MSB:Phonetic symbol 27, LSB: Consonant adjustment 27)
/// </summary>
public const ushort CVM_NM_PHONETIC_SYMBOL27 = 0x502d;
public const int CVM_NM_PHONETIC_SYMBOL27 = 0x502d;
/// <summary>
/// (0x502e) Phonetic symbol 28(MSB:Phonetic symbol 28, LSB: Consonant adjustment 28)
/// </summary>
public const ushort CVM_NM_PHONETIC_SYMBOL28 = 0x502e;
public const int CVM_NM_PHONETIC_SYMBOL28 = 0x502e;
/// <summary>
/// (0x502f) Phonetic symbol 29(MSB:Phonetic symbol 29, LSB: Consonant adjustment 29)
/// </summary>
public const ushort CVM_NM_PHONETIC_SYMBOL29 = 0x502f;
public const int CVM_NM_PHONETIC_SYMBOL29 = 0x502f;
/// <summary>
/// (0x5030) Phonetic symbol 30(MSB:Phonetic symbol 30, LSB: Consonant adjustment 30)
/// </summary>
public const ushort CVM_NM_PHONETIC_SYMBOL30 = 0x5030;
public const int CVM_NM_PHONETIC_SYMBOL30 = 0x5030;
/// <summary>
/// (0x5031) Phonetic symbol 31(MSB:Phonetic symbol 31, LSB: Consonant adjustment 31)
/// </summary>
public const ushort CVM_NM_PHONETIC_SYMBOL31 = 0x5031;
public const int CVM_NM_PHONETIC_SYMBOL31 = 0x5031;
/// <summary>
/// (0x5032) Phonetic symbol 32(MSB:Phonetic symbol 32, LSB: Consonant adjustment 32)
/// </summary>
public const ushort CVM_NM_PHONETIC_SYMBOL32 = 0x5032;
public const int CVM_NM_PHONETIC_SYMBOL32 = 0x5032;
/// <summary>
/// (0x5033) Phonetic symbol 33(MSB:Phonetic symbol 33, LSB: Consonant adjustment 33)
/// </summary>
public const ushort CVM_NM_PHONETIC_SYMBOL33 = 0x5033;
public const int CVM_NM_PHONETIC_SYMBOL33 = 0x5033;
/// <summary>
/// (0x5034) Phonetic symbol 34(MSB:Phonetic symbol 34, LSB: Consonant adjustment 34)
/// </summary>
public const ushort CVM_NM_PHONETIC_SYMBOL34 = 0x5034;
public const int CVM_NM_PHONETIC_SYMBOL34 = 0x5034;
/// <summary>
/// (0x5035) Phonetic symbol 35(MSB:Phonetic symbol 35, LSB: Consonant adjustment 35)
/// </summary>
public const ushort CVM_NM_PHONETIC_SYMBOL35 = 0x5035;
public const int CVM_NM_PHONETIC_SYMBOL35 = 0x5035;
/// <summary>
/// (0x5036) Phonetic symbol 36(MSB:Phonetic symbol 36, LSB: Consonant adjustment 36)
/// </summary>
public const ushort CVM_NM_PHONETIC_SYMBOL36 = 0x5036;
public const int CVM_NM_PHONETIC_SYMBOL36 = 0x5036;
/// <summary>
/// (0x5037) Phonetic symbol 37(MSB:Phonetic symbol 37, LSB: Consonant adjustment 37)
/// </summary>
public const ushort CVM_NM_PHONETIC_SYMBOL37 = 0x5037;
public const int CVM_NM_PHONETIC_SYMBOL37 = 0x5037;
/// <summary>
/// (0x5038) Phonetic symbol 38(MSB:Phonetic symbol 38, LSB: Consonant adjustment 38)
/// </summary>
public const ushort CVM_NM_PHONETIC_SYMBOL38 = 0x5038;
public const int CVM_NM_PHONETIC_SYMBOL38 = 0x5038;
/// <summary>
/// (0x5039) Phonetic symbol 39(MSB:Phonetic symbol 39, LSB: Consonant adjustment 39)
/// </summary>
public const ushort CVM_NM_PHONETIC_SYMBOL39 = 0x5039;
public const int CVM_NM_PHONETIC_SYMBOL39 = 0x5039;
/// <summary>
/// (0x503a) Phonetic symbol 40(MSB:Phonetic symbol 40, LSB: Consonant adjustment 40)
/// </summary>
public const ushort CVM_NM_PHONETIC_SYMBOL40 = 0x503a;
public const int CVM_NM_PHONETIC_SYMBOL40 = 0x503a;
/// <summary>
/// (0x503b) Phonetic symbol 41(MSB:Phonetic symbol 41, LSB: Consonant adjustment 41)
/// </summary>
public const ushort CVM_NM_PHONETIC_SYMBOL41 = 0x503b;
public const int CVM_NM_PHONETIC_SYMBOL41 = 0x503b;
/// <summary>
/// (0x503c) Phonetic symbol 42(MSB:Phonetic symbol 42, LSB: Consonant adjustment 42)
/// </summary>
public const ushort CVM_NM_PHONETIC_SYMBOL42 = 0x503c;
public const int CVM_NM_PHONETIC_SYMBOL42 = 0x503c;
/// <summary>
/// (0x503d) Phonetic symbol 43(MSB:Phonetic symbol 43, LSB: Consonant adjustment 43)
/// </summary>
public const ushort CVM_NM_PHONETIC_SYMBOL43 = 0x503d;
public const int CVM_NM_PHONETIC_SYMBOL43 = 0x503d;
/// <summary>
/// (0x503e) Phonetic symbol 44(MSB:Phonetic symbol 44, LSB: Consonant adjustment 44)
/// </summary>
public const ushort CVM_NM_PHONETIC_SYMBOL44 = 0x503e;
public const int CVM_NM_PHONETIC_SYMBOL44 = 0x503e;
/// <summary>
/// (0x503f) Phonetic symbol 45(MSB:Phonetic symbol 45, LSB: Consonant adjustment 45)
/// </summary>
public const ushort CVM_NM_PHONETIC_SYMBOL45 = 0x503f;
public const int CVM_NM_PHONETIC_SYMBOL45 = 0x503f;
/// <summary>
/// (0x5040) Phonetic symbol 46(MSB:Phonetic symbol 46, LSB: Consonant adjustment 46)
/// </summary>
public const ushort CVM_NM_PHONETIC_SYMBOL46 = 0x5040;
public const int CVM_NM_PHONETIC_SYMBOL46 = 0x5040;
/// <summary>
/// (0x5041) Phonetic symbol 47(MSB:Phonetic symbol 47, LSB: Consonant adjustment 47)
/// </summary>
public const ushort CVM_NM_PHONETIC_SYMBOL47 = 0x5041;
public const int CVM_NM_PHONETIC_SYMBOL47 = 0x5041;
/// <summary>
/// (0x5042) Phonetic symbol 48(MSB:Phonetic symbol 48, LSB: Consonant adjustment 48)
/// </summary>
public const ushort CVM_NM_PHONETIC_SYMBOL48 = 0x5042;
public const int CVM_NM_PHONETIC_SYMBOL48 = 0x5042;
/// <summary>
/// (0x5043) Phonetic symbol 49(MSB:Phonetic symbol 49, LSB: Consonant adjustment 49)
/// </summary>
public const ushort CVM_NM_PHONETIC_SYMBOL49 = 0x5043;
public const int CVM_NM_PHONETIC_SYMBOL49 = 0x5043;
/// <summary>
/// (0x5044) Phonetic symbol 50(MSB:Phonetic symbol 50, LSB: Consonant adjustment 50)
/// </summary>
public const ushort CVM_NM_PHONETIC_SYMBOL50 = 0x5044;
public const int CVM_NM_PHONETIC_SYMBOL50 = 0x5044;
/// <summary>
/// (0x5045) Phonetic symbol 51(MSB:Phonetic symbol 51, LSB: Consonant adjustment 51)
/// </summary>
public const ushort CVM_NM_PHONETIC_SYMBOL51 = 0x5045;
public const int CVM_NM_PHONETIC_SYMBOL51 = 0x5045;
/// <summary>
/// (0x5046) Phonetic symbol 52(MSB:Phonetic symbol 52, LSB: Consonant adjustment 52)
/// </summary>
public const ushort CVM_NM_PHONETIC_SYMBOL52 = 0x5046;
public const int CVM_NM_PHONETIC_SYMBOL52 = 0x5046;
/// <summary>
/// (0x5047) Phonetic symbol 53(MSB:Phonetic symbol 53, LSB: Consonant adjustment 53)
/// </summary>
public const ushort CVM_NM_PHONETIC_SYMBOL53 = 0x5047;
public const int CVM_NM_PHONETIC_SYMBOL53 = 0x5047;
/// <summary>
/// (0x5048) Phonetic symbol 54(MSB:Phonetic symbol 54, LSB: Consonant adjustment 54)
/// </summary>
public const ushort CVM_NM_PHONETIC_SYMBOL54 = 0x5048;
public const int CVM_NM_PHONETIC_SYMBOL54 = 0x5048;
/// <summary>
/// (0x5049) Phonetic symbol 55(MSB:Phonetic symbol 55, LSB: Consonant adjustment 55)
/// </summary>
public const ushort CVM_NM_PHONETIC_SYMBOL55 = 0x5049;
public const int CVM_NM_PHONETIC_SYMBOL55 = 0x5049;
/// <summary>
/// (0x504a) Phonetic symbol 56(MSB:Phonetic symbol 56, LSB: Consonant adjustment 56)
/// </summary>
public const ushort CVM_NM_PHONETIC_SYMBOL56 = 0x504a;
public const int CVM_NM_PHONETIC_SYMBOL56 = 0x504a;
/// <summary>
/// (0x504b) Phonetic symbol 57(MSB:Phonetic symbol 57, LSB: Consonant adjustment 57)
/// </summary>
public const ushort CVM_NM_PHONETIC_SYMBOL57 = 0x504b;
public const int CVM_NM_PHONETIC_SYMBOL57 = 0x504b;
/// <summary>
/// (0x504c) Phonetic symbol 58(MSB:Phonetic symbol 58, LSB: Consonant adjustment 58)
/// </summary>
public const ushort CVM_NM_PHONETIC_SYMBOL58 = 0x504c;
public const int CVM_NM_PHONETIC_SYMBOL58 = 0x504c;
/// <summary>
/// (0x504d) Phonetic symbol 59(MSB:Phonetic symbol 59, LSB: Consonant adjustment 59)
/// </summary>
public const ushort CVM_NM_PHONETIC_SYMBOL59 = 0x504d;
public const int CVM_NM_PHONETIC_SYMBOL59 = 0x504d;
/// <summary>
/// (0x504e) Phonetic symbol 60(MSB:Phonetic symbol 60, LSB: Consonant adjustment 60)
/// </summary>
public const ushort CVM_NM_PHONETIC_SYMBOL60 = 0x504e;
public const int CVM_NM_PHONETIC_SYMBOL60 = 0x504e;
/// <summary>
/// (0x504f) Phonetic symbol continuation(MSB, 0x7f=end, 0x00=continue)
/// </summary>
public const ushort CVM_NM_PHONETIC_SYMBOL_CONTINUATION = 0x504f;
public const int CVM_NM_PHONETIC_SYMBOL_CONTINUATION = 0x504f;
/// <summary>
/// (0x5050) v1mean in Cent/5(MSB)
/// </summary>
public const ushort CVM_NM_V1MEAN = 0x5050;
public const int CVM_NM_V1MEAN = 0x5050;
/// <summary>
/// (0x5051) d1mean in millisec/5(MSB)
/// </summary>
public const ushort CVM_NM_D1MEAN = 0x5051;
public const int CVM_NM_D1MEAN = 0x5051;
/// <summary>
/// (0x5052) d1meanFirstNote in millisec/5(MSB)
/// </summary>
public const ushort CVM_NM_D1MEAN_FIRST_NOTE = 0x5052;
public const int CVM_NM_D1MEAN_FIRST_NOTE = 0x5052;
/// <summary>
/// (0x5053) d2mean in millisec/5(MSB)
/// </summary>
public const ushort CVM_NM_D2MEAN = 0x5053;
public const int CVM_NM_D2MEAN = 0x5053;
/// <summary>
/// (0x5054) d4mean in millisec/5(MSB)
/// </summary>
public const ushort CVM_NM_D4MEAN = 0x5054;
public const int CVM_NM_D4MEAN = 0x5054;
/// <summary>
/// (0x5055) pMeanOnsetFirstNote in Cent/5(MSB)
/// </summary>
public const ushort CVM_NM_PMEAN_ONSET_FIRST_NOTE = 0x5055;
public const int CVM_NM_PMEAN_ONSET_FIRST_NOTE = 0x5055;
/// <summary>
/// (0x5056) vMeanNoteTransition in Cent/5(MSB)
/// </summary>
public const ushort CVM_NM_VMEAN_NOTE_TRNSITION = 0x5056;
public const int CVM_NM_VMEAN_NOTE_TRNSITION = 0x5056;
/// <summary>
/// (0x5057) pMeanEndingNote in Cent/5(MSB)
/// </summary>
public const ushort CVM_NM_PMEAN_ENDING_NOTE = 0x5057;
public const int CVM_NM_PMEAN_ENDING_NOTE = 0x5057;
/// <summary>
/// (0x5058) AddScooptoUpIntervals &amp;, AddPortamentoToDownIntervals(MSB)
/// </summary>
public const ushort CVM_NM_ADD_PORTAMENTO = 0x5058;
public const int CVM_NM_ADD_PORTAMENTO = 0x5058;
/// <summary>
/// (0x5059) changAfterPeak(MSB)
/// </summary>
public const ushort CVM_NM_CHANGE_AFTER_PEAK = 0x5059;
public const int CVM_NM_CHANGE_AFTER_PEAK = 0x5059;
/// <summary>
/// (0x505a) Accent(MSB)
/// </summary>
public const ushort CVM_NM_ACCENT = 0x505a;
public const int CVM_NM_ACCENT = 0x505a;
/// <summary>
/// (0x507f) Note message continuation(MSB)
/// </summary>
public const ushort CVM_NM_NOTE_MESSAGE_CONTINUATION = 0x507f;
public const int CVM_NM_NOTE_MESSAGE_CONTINUATION = 0x507f;
/// <summary>
/// (0x5075) Extended Note message; Voice Overlap(MSB, LSB)(VoiceOverlap = ((MSB &amp; 0x7f) &lt;&lt; 7) | (LSB &amp; 0x7f) - 8192)
/// </summary>
public const ushort CVM_EXNM_VOICE_OVERLAP = 0x5075;
public const int CVM_EXNM_VOICE_OVERLAP = 0x5075;
/// <summary>
/// (0x5076) Extended Note message; Flags length in bytes(MSB, LSB)
/// </summary>
public const ushort CVM_EXNM_FLAGS_BYTES = 0x5076;
public const int CVM_EXNM_FLAGS_BYTES = 0x5076;
/// <summary>
/// (0x5077) Extended Note message; Flag(MSB)
/// </summary>
public const ushort CVM_EXNM_FLAGS = 0x5077;
public const int CVM_EXNM_FLAGS = 0x5077;
/// <summary>
/// (0x5078) Extended Note message; Flag continuation(MSB)(MSB, 0x7f=end, 0x00=continue)
/// </summary>
public const ushort CVM_EXNM_FLAGS_CONINUATION = 0x5078;
public const int CVM_EXNM_FLAGS_CONINUATION = 0x5078;
/// <summary>
/// (0x5079) Extended Note message; Moduration(MSB, LSB)(Moduration = ((MSB &amp; 0x7f) &lt;&lt; 7) | (LSB &amp; 0x7f) - 100)
/// </summary>
public const ushort CVM_EXNM_MODURATION = 0x5079;
public const int CVM_EXNM_MODURATION = 0x5079;
/// <summary>
/// (0x507a) Extended Note message; PreUtterance(MSB, LSB)(PreUtterance = ((MSB &amp; 0x7f) &lt;&lt; 7) | (LSB &amp; 0x7f) - 8192)
/// </summary>
public const ushort CVM_EXNM_PRE_UTTERANCE = 0x507a;
public const int CVM_EXNM_PRE_UTTERANCE = 0x507a;
/// <summary>
/// (0x507e) Extended Note message; Envelope: value1(MSB, LSB) actual value = (value3.msb &amp; 0xf) &lt;&lt; 28 | (value2.msb &amp; 0x7f) &lt;&lt; 21 | (value2.lsb &amp; 0x7f) &lt;&lt; 14 | (value1.msb &amp; 0x7f) &lt;&lt; 7 | (value1.lsb &amp; 0x7f)
/// </summary>
public const ushort CVM_EXNM_ENV_DATA1 = 0x507e;
public const int CVM_EXNM_ENV_DATA1 = 0x507e;
/// <summary>
/// (0x507d) Extended Note message; Envelope: value2(MSB, LSB)
/// </summary>
public const ushort CVM_EXNM_ENV_DATA2 = 0x507d;
public const int CVM_EXNM_ENV_DATA2 = 0x507d;
/// <summary>
/// (0x507c) Extended Note message; Envelope: value3(MSB)
/// </summary>
public const ushort CVM_EXNM_ENV_DATA3 = 0x507c;
public const int CVM_EXNM_ENV_DATA3 = 0x507c;
/// <summary>
/// (0x507b) Extended Note message; Envelope: data point continuation(MSB)(MSB, 0x7f=end, 0x00=continue)
/// </summary>
public const ushort CVM_EXNM_ENV_DATA_CONTINUATION = 0x507b;
public const int CVM_EXNM_ENV_DATA_CONTINUATION = 0x507b;
/// <summary>
/// (0x6000) Version number &amp;, Device number(MSB, LSB)
/// </summary>
public const ushort CC_BS_VERSION_AND_DEVICE = 0x6000;
public const int CC_BS_VERSION_AND_DEVICE = 0x6000;
/// <summary>
/// (0x6001) Delay in millisec(MSB, LSB)
/// </summary>
public const ushort CC_BS_DELAY = 0x6001;
public const int CC_BS_DELAY = 0x6001;
/// <summary>
/// (0x6002) Laugnage type(MSB, optional LSB)
/// </summary>
public const ushort CC_BS_LANGUAGE_TYPE = 0x6002;
public const int CC_BS_LANGUAGE_TYPE = 0x6002;
/// <summary>
/// (0x6100) Version number &amp;, device number(MSB, LSB)
/// </summary>
public const ushort CC_CV_VERSION_AND_DEVICE = 0x6100;
public const int CC_CV_VERSION_AND_DEVICE = 0x6100;
/// <summary>
/// (0x6101) Delay in millisec(MSB, LSB)
/// </summary>
public const ushort CC_CV_DELAY = 0x6101;
public const int CC_CV_DELAY = 0x6101;
/// <summary>
/// (0x6102) Volume value(MSB)
/// </summary>
public const ushort CC_CV_VOLUME = 0x6102;
public const int CC_CV_VOLUME = 0x6102;
/// <summary>
/// (0x6200) Version number &amp;, device number(MSB, LSB)
/// </summary>
public const ushort CC_P_VERSION_AND_DEVICE = 0x6200;
public const int CC_P_VERSION_AND_DEVICE = 0x6200;
/// <summary>
/// (0x6201) Delay in millisec(MSB, LSB)
/// </summary>
public const ushort CC_P_DELAY = 0x6201;
public const int CC_P_DELAY = 0x6201;
/// <summary>
/// (0x6202) Pan value(MSB)
/// </summary>
public const ushort CC_PAN = 0x6202;
public const int CC_PAN = 0x6202;
/// <summary>
/// (0x6300) Version number &amp;, device number(MSB, LSB)
/// </summary>
public const ushort CC_E_VESION_AND_DEVICE = 0x6300;
public const int CC_E_VESION_AND_DEVICE = 0x6300;
/// <summary>
/// (0x6301) Delay in millisec(MSB, LSB)
/// </summary>
public const ushort CC_E_DELAY = 0x6301;
public const int CC_E_DELAY = 0x6301;
/// <summary>
/// (0x6302) Expression vlaue(MSB)
/// </summary>
public const ushort CC_E_EXPRESSION = 0x6302;
public const int CC_E_EXPRESSION = 0x6302;
/// <summary>
/// (0x6400) Version number &amp;, device number(MSB, LSB)
/// </summary>
public const ushort CC_VR_VERSION_AND_DEVICE = 0x6400;
public const int CC_VR_VERSION_AND_DEVICE = 0x6400;
/// <summary>
/// (0x6401) Delay in millisec(MSB, LSB)
/// </summary>
public const ushort CC_VR_DELAY = 0x6401;
public const int CC_VR_DELAY = 0x6401;
/// <summary>
/// (0x6402) Vibrato Rate value(MSB)
/// </summary>
public const ushort CC_VR_VIBRATO_RATE = 0x6402;
public const int CC_VR_VIBRATO_RATE = 0x6402;
/// <summary>
/// (0x6500) Version number &amp;, device number(MSB, LSB)
/// </summary>
public const ushort CC_VD_VERSION_AND_DEVICE = 0x6500;
public const int CC_VD_VERSION_AND_DEVICE = 0x6500;
/// <summary>
/// (0x6501) Delay in millisec(MSB, LSB)
/// </summary>
public const ushort CC_VD_DELAY = 0x6501;
public const int CC_VD_DELAY = 0x6501;
/// <summary>
/// (0x6502) Vibrato Depth value(MSB)
/// </summary>
public const ushort CC_VD_VIBRATO_DEPTH = 0x6502;
public const int CC_VD_VIBRATO_DEPTH = 0x6502;
/// <summary>
/// (0x6600) Version number &amp;, device number(MSB, LSB)
/// </summary>
public const ushort CC_FX2_VERSION_AND_DEVICE = 0x6600;
public const int CC_FX2_VERSION_AND_DEVICE = 0x6600;
/// <summary>
/// (0x6601) Delay in millisec(MSB, LSB)
/// </summary>
public const ushort CC_FX2_DELAY = 0x6601;
public const int CC_FX2_DELAY = 0x6601;
/// <summary>
/// (0x6602) Effect2 Depth(MSB)
/// </summary>
public const ushort CC_FX2_EFFECT2_DEPTH = 0x6602;
public const int CC_FX2_EFFECT2_DEPTH = 0x6602;
/// <summary>
/// (0x6700) Version number &amp;, device number(MSB, LSB)
/// </summary>
public const ushort CC_PBS_VERSION_AND_DEVICE = 0x6700;
public const int CC_PBS_VERSION_AND_DEVICE = 0x6700;
/// <summary>
/// (0x6701) Delay in millisec(MSB, LSB)
/// </summary>
public const ushort CC_PBS_DELAY = 0x6701;
public const int CC_PBS_DELAY = 0x6701;
/// <summary>
/// (0x6702) Pitch Bend Sensitivity(MSB, LSB)
/// </summary>
public const ushort CC_PBS_PITCH_BEND_SENSITIVITY = 0x6702;
public const int CC_PBS_PITCH_BEND_SENSITIVITY = 0x6702;
/// <summary>
/// (0x5300) Version number &amp;, device number(MSB, LSB)
/// </summary>
public const ushort PC_VERSION_AND_DEVICE = 0x5300;
public const int PC_VERSION_AND_DEVICE = 0x5300;
/// <summary>
/// (0x5301) Delay in millisec(MSB, LSB)
/// </summary>
public const ushort PC_DELAY = 0x5301;
public const int PC_DELAY = 0x5301;
/// <summary>
/// (0x5302) Voice Type(MSB)
/// </summary>
public const ushort PC_VOICE_TYPE = 0x5302;
public const int PC_VOICE_TYPE = 0x5302;
/// <summary>
/// (0x5400) Version number &amp;, device number(MSB, LSB)
/// </summary>
public const ushort PB_VERSION_AND_DEVICE = 0x5400;
public const int PB_VERSION_AND_DEVICE = 0x5400;
/// <summary>
/// (0x5401) Delay in millisec(MSB, LSB)
/// </summary>
public const ushort PB_DELAY = 0x5401;
public const int PB_DELAY = 0x5401;
/// <summary>
/// (0x5402) Pitch Bend value(MSB, LSB)
/// </summary>
public const ushort PB_PITCH_BEND = 0x5402;
public const int PB_PITCH_BEND = 0x5402;
/// <summary>
/// (0x5500) Version number &amp;, device number(MSB, LSB)
/// </summary>
public const ushort VCP_VERSION_AND_DEVICE = 0x5500;
public const int VCP_VERSION_AND_DEVICE = 0x5500;
/// <summary>
/// (0x5501) Delay in millisec(MSB, LSB)
/// </summary>
public const ushort VCP_DELAY = 0x5501;
public const int VCP_DELAY = 0x5501;
/// <summary>
/// (0x5502) Voice Change Parameter ID(MSB)
/// </summary>
public const ushort VCP_VOICE_CHANGE_PARAMETER_ID = 0x5502;
public const int VCP_VOICE_CHANGE_PARAMETER_ID = 0x5502;
/// <summary>
/// (0x5503) Voice Change Parameter value(MSB)
/// </summary>
public const ushort VCP_VOICE_CHANGE_PARAMETER = 0x5503;
public const int VCP_VOICE_CHANGE_PARAMETER = 0x5503;
private class NrpnIterator : Iterator {
private Vector<ushort> nrpns = new Vector<ushort>();
private int m_pos = -1;
public NrpnIterator() {
Type t = typeof( NRPN );
foreach ( FieldInfo fi in t.GetFields() ) {
if ( fi.FieldType.Equals( typeof( ushort ) ) ) {
nrpns.add( (ushort)fi.GetValue( t ) );
}
}
}
public boolean hasNext() {
if ( 0 <= m_pos + 1 && m_pos + 1 < nrpns.size() ) {
return true;
} else {
return false;
}
}
public Object next() {
m_pos++;
return nrpns.get( m_pos );
}
public void remove() {
}
private NRPN() {
}
public static Iterator iterator() {
return new NrpnIterator();
}
public static String getName( ushort nrpn ) {
foreach ( FieldInfo fi in typeof( NRPN ).GetFields() ) {
if ( fi.FieldType.Equals( typeof( ushort ) ) ) {
ushort v = (ushort)fi.GetValue( typeof( NRPN ) );
if ( v == nrpn ) {
return fi.Name;
}
public static String getName( int nrpn ) {
for ( Iterator itr = iterator(); itr.hasNext(); ) {
ValuePair<String, Integer> v = (ValuePair<String, Integer>)itr.next();
if ( v.getValue() == nrpn ) {
return v.getKey();
}
}
return "";
@ -612,69 +590,50 @@ namespace Boare.Lib.Vsq {
/// <returns></returns>
public static byte getVoiceChangeParameterID( String curve_name ) {
byte lsb = 0x31;
switch ( curve_name.ToLower() ) {
case "harmonics":
curve_name = curve_name.ToLower();
if ( curve_name.Equals( "harmonics" ) ) {
lsb = 0x30;
break;
case "bre":
} else if ( curve_name.Equals( "bre" ) ) {
lsb = 0x31;
break;
case "bri":
} else if ( curve_name.Equals( "bri" ) ) {
lsb = 0x32;
break;
case "cle":
} else if ( curve_name.Equals( "cle" ) ) {
lsb = 0x33;
break;
case "por":
} else if ( curve_name.Equals( "por" ) ) {
lsb = 0x34;
break;
case "ope":
} else if ( curve_name.Equals( "ope" ) ) {
lsb = 0x35;
break;
case "reso1freq":
} else if ( curve_name.Equals( "reso1freq" ) ) {
lsb = 0x40;
break;
case "reso2freq":
} else if ( curve_name.Equals( "reso2freq" ) ) {
lsb = 0x41;
break;
case "reso3freq":
} else if ( curve_name.Equals( "reso3freq" ) ) {
lsb = 0x42;
break;
case "reso4freq":
} else if ( curve_name.Equals( "reso4freq" ) ) {
lsb = 0x43;
break;
case "reso1bw":
} else if ( curve_name.Equals( "reso1bw" ) ) {
lsb = 0x50;
break;
case "reso2bw":
} else if ( curve_name.Equals( "reso2bw" ) ) {
lsb = 0x51;
break;
case "reso3bw":
} else if ( curve_name.Equals( "reso3bw" ) ) {
lsb = 0x52;
break;
case "reso4bw":
} else if ( curve_name.Equals( "reso4bw" ) ) {
lsb = 0x53;
break;
case "reso1amp":
} else if ( curve_name.Equals( "reso1amp" ) ) {
lsb = 0x60;
break;
case "reso2amp":
} else if ( curve_name.Equals( "reso2amp" ) ) {
lsb = 0x61;
break;
case "reso3amp":
} else if ( curve_name.Equals( "reso3amp" ) ) {
lsb = 0x62;
break;
case "reso4amp":
} else if ( curve_name.Equals( "reso4amp" ) ) {
lsb = 0x63;
break;
case "gen":
} else if ( curve_name.Equals( "gen" ) ) {
lsb = 0x70;
break;
}
return lsb;
}
public static boolean is_require_data_lsb( ushort nrpn ) {
public static boolean is_require_data_lsb( int nrpn ) {
switch ( nrpn ) {
case CVM_NM_VERSION_AND_DEVICE:
case CVM_NM_DELAY:
@ -747,4 +706,6 @@ namespace Boare.Lib.Vsq {
}
#if !JAVA
}
#endif

View File

@ -0,0 +1,94 @@
/*
* NoteHeadHandle.cs
* Copyright (c) 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.
*/
#if JAVA
package org.kbinani.vsq;
import java.io.*;
#else
using System;
namespace Boare.Lib.Vsq {
#endif
#if JAVA
public class NoteHeadHandle implements Cloneable, Serializable {
#else
[Serializable]
public class NoteHeadHandle : ICloneable {
#endif
public int Index;
public String IconID = "";
public String IDS = "";
public int Original;
public String Caption = "";
public int Length;
public int Duration;
public int Depth;
public NoteHeadHandle() {
}
public int getLength() {
return Length;
}
public void setLength( int value ) {
Length = value;
}
public String getDisplayString() {
String s = IDS;
if ( !Caption.Equals( "" ) ) {
s += " (" + Caption + ")";
}
return s;
}
#if !JAVA
public object Clone() {
return clone();
}
#endif
public Object clone() {
NoteHeadHandle result = new NoteHeadHandle();
result.Index = Index;
result.IconID = IconID;
result.IDS = IDS;
result.Original = Original;
result.Caption = Caption;
result.setLength( Length );
result.Duration = Duration;
result.Depth = Depth;
return result;
}
public VsqHandle castToVsqHandle() {
VsqHandle ret = new VsqHandle();
ret.m_type = VsqHandleType.NoteHeadHandle;
ret.Index = Index;
ret.IconID = IconID;
ret.IDS = IDS;
ret.Original = Original;
ret.Caption = Caption;
ret.setLength( Length );
ret.Duration = Duration;
ret.Depth = Depth;
return ret;
}
}
#if !JAVA
}
#endif

View File

@ -11,7 +11,11 @@
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*/
#if JAVA
package org.kbinani.vsq;
#else
namespace Boare.Lib.Vsq {
#endif
public class NrpnData {
int m_clock;
@ -24,13 +28,15 @@ namespace Boare.Lib.Vsq {
Value = value;
}
public int getClock(){
public int getClock() {
return m_clock;
}
public byte getParameter(){
public byte getParameter() {
return m_parameter;
}
}
#if !JAVA
}
#endif

View File

@ -0,0 +1,83 @@
/*
* NrpnIterator.cs
* Copyright (c) 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.
*/
#if JAVA
package org.kbinani.vsq;
import java.lang.reflect.*;
import java.util.*;
import org.kbinani.*;
#else
using System;
using System.Reflection;
using bocoree;
using bocoree.java.util;
namespace Boare.Lib.Vsq {
using boolean = System.Boolean;
using Integer = System.Int32;
#endif
#if JAVA
public class NrpnIterator implements Iterator {
#else
public class NrpnIterator : Iterator {
#endif
private Vector<ValuePair<String, Integer>> nrpns = new Vector<ValuePair<String, Integer>>();
private int m_pos = -1;
public NrpnIterator() {
#if JAVA
try{
Field[] fields = NRPN.class.getFields();
for( int i = 0; i < 0; i++ ){
Class type = fields[i].getType();
if( type == Integer.class || type == Integer.TYPE ){
Integer value = (Integer)fields[i].get( null );
String name = fields[i].getName();
nrpns.add( new ValuePair<String, Integer>( name, value ) );
}
}
}catch( Exception ex ){
System.out.println( "com.boare.vsq.NrpnIterator#.ctor; ex=" + ex );
}
#else
Type t = typeof( NRPN );
foreach ( FieldInfo fi in t.GetFields() ) {
if ( fi.FieldType.Equals( typeof( int ) ) ) {
nrpns.add( new ValuePair<String, Integer>( fi.Name, (int)fi.GetValue( t ) ) );
}
}
#endif
}
public boolean hasNext() {
if ( 0 <= m_pos + 1 && m_pos + 1 < nrpns.size() ) {
return true;
} else {
return false;
}
}
public Object next() {
m_pos++;
return nrpns.get( m_pos ).getValue();
}
public void remove() {
}
}
#if !JAVA
}
#endif

View File

@ -1,444 +0,0 @@
/*
* MidiFile.cs
* Copyright (c) 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.IO;
using System.Collections.Generic;
using bocoree;
namespace Boare.Lib.Vsq {
using boolean = System.Boolean;
/// <summary>
/// midiイベント。メタイベントは、メタイベントのデータ長をData[1]に格納せず、生のデータをDataに格納するので、注意が必要
/// </summary>
public struct MidiEvent : IComparable<MidiEvent> {
public long clock;
public byte firstByte;
public byte[] data;
public long Clock {
get {
return clock;
}
set {
clock = value;
}
}
public byte FirstByte {
get {
return firstByte;
}
set {
firstByte = value;
}
}
public byte[] Data {
get {
return data;
}
set {
data = value;
}
}
private static void writeDeltaClock( Stream stream, long number ) {
boolean[] bits = new boolean[64];
long val = 0x1;
bits[0] = (number & val) == val;
for ( int i = 1; i < 64; i++ ) {
val = val << 1;
bits[i] = (number & val) == val;
}
int first = 0;
for ( int i = 63; i >= 0; i-- ) {
if ( bits[i] ) {
first = i;
break;
}
}
// 何バイト必要か?
int bytes = first / 7 + 1;
for ( int i = 1; i <= bytes; i++ ) {
uint num = 0;
uint count = 0x80;
for ( int j = (bytes - i + 1) * 7 - 1; j >= (bytes - i + 1) * 7 - 6 - 1; j-- ) {
count = count >> 1;
if ( bits[j] ) {
num += count;
}
}
if ( i != bytes ) {
num += 0x80;
}
stream.WriteByte( (byte)num );
}
}
private static long readDeltaClock( Stream stream ) {
long ret = 0;
while ( true ) {
int i = stream.ReadByte();
if ( i < 0 ) {
break;
}
byte d = (byte)i;
ret = (ret << 7) | ((long)d & 0x7f);
if ( (d & 0x80) == 0x00 ) {
break;
}
}
return ret;
}
public static MidiEvent read( Stream stream, ref long last_clock, ref byte last_status_byte ) {
long delta_clock = readDeltaClock( stream );
last_clock += delta_clock;
byte first_byte = (byte)stream.ReadByte();
if ( first_byte < 0x80 ) {
// ランニングステータスが適用される
stream.Seek( -1, SeekOrigin.Current );
first_byte = last_status_byte;
} else {
last_status_byte = first_byte;
}
byte ctrl = (byte)(first_byte & (byte)0xf0);
if ( ctrl == 0x80 || ctrl == 0x90 || ctrl == 0xA0 || ctrl == 0xB0 || ctrl == 0xE0 || first_byte == 0xF2 ) {
// 3byte使用するチャンネルメッセージ
// 0x8*: ノートオフ
// 0x9*: ノートオン
// 0xA*: ポリフォニック・キープレッシャ
// 0xB*: コントロールチェンジ
// 0xE*: ピッチベンドチェンジ
// 3byte使用するシステムメッセージ
// 0xF2: ソングポジション・ポインタ
MidiEvent me = new MidiEvent();
me.clock = last_clock;
me.firstByte = first_byte;
me.data = new byte[2];
stream.Read( me.data, 0, 2 );
return me;
} else if ( ctrl == 0xC0 || ctrl == 0xD0 || first_byte == 0xF1 || first_byte == 0xF2 ) {
// 2byte使用するチャンネルメッセージ
// 0xC*: プログラムチェンジ
// 0xD*: チャンネルプレッシャ
// 2byte使用するシステムメッセージ
// 0xF1: クォータフレーム
// 0xF3: ソングセレクト
MidiEvent me = new MidiEvent();
me.clock = last_clock;
me.firstByte = first_byte;
me.data = new byte[1];
stream.Read( me.data, 0, 1 );
return me;
} else if ( first_byte == 0xF6 ) {
// 1byte使用するシステムメッセージ
// 0xF6: チューンリクエスト
// 0xF7: エンドオブエクスクルーシブこのクラスではF0ステータスのSysExの一部として取り扱う
// 0xF8: タイミングクロック
// 0xFA: スタート
// 0xFB: コンティニュー
// 0xFC: ストップ
// 0xFE: アクティブセンシング
// 0xFF: システムリセット
MidiEvent me = new MidiEvent();
me.clock = last_clock;
me.firstByte = first_byte;
me.data = new byte[0];
return me;
} else if ( first_byte == 0xff ) {
// メタイベント
byte meta_event_type = (byte)stream.ReadByte();
long meta_event_length = readDeltaClock( stream );
MidiEvent me = new MidiEvent();
me.clock = last_clock;
me.firstByte = first_byte;
me.data = new byte[meta_event_length + 1];
me.data[0] = meta_event_type;
stream.Read( me.data, 1, (int)meta_event_length );
return me;
} else if ( first_byte == 0xf0 ) {
// f0ステータスのSysEx
MidiEvent me = new MidiEvent();
me.clock = last_clock;
me.firstByte = first_byte;
long sysex_length = readDeltaClock( stream );
me.data = new byte[sysex_length + 1];
stream.Read( me.data, 0, (int)(sysex_length + 1) );
return me;
} else if ( first_byte == 0xf7 ) {
// f7ステータスのSysEx
MidiEvent me = new MidiEvent();
me.clock = last_clock;
me.firstByte = first_byte;
long sysex_length = readDeltaClock( stream );
me.data = new byte[sysex_length];
stream.Read( me.data, 0, (int)sysex_length );
return me;
} else {
throw new ApplicationException( "don't know how to process first_byte: 0x" + Convert.ToString( first_byte, 16 ) );
}
}
public void writeData( Stream stream ) {
stream.WriteByte( firstByte );
if ( firstByte == 0xff ) {
stream.WriteByte( data[0] );
writeDeltaClock( stream, data.Length - 1 );
//stream.WriteByte( (byte)(Data.Length - 1) );
stream.Write( data, 1, data.Length - 1 );
} else {
stream.Write( data, 0, data.Length );
}
}
public int CompareTo( MidiEvent item ) {
if ( clock != item.clock ) {
return (int)(clock - item.clock);
} else {
int first_this = firstByte & 0xf0;
int first_item = item.firstByte & 0xf0;
if ( (first_this == 0x80 || first_this == 0x90) && (first_item == 0x80 || first_item == 0x90) ) {
if ( data != null && data.Length >= 2 && item.data != null && item.data.Length >= 2 ) {
if ( first_item == 0x90 && item.data[1] == 0 ) {
first_item = 0x80;
}
if ( first_this == 0x90 && data[1] == 0 ) {
first_this = 0x80;
}
if ( data[0] == item.data[0] ) {
if ( first_this == 0x90 ) {
if ( first_item == 0x80 ) {
// ON -> OFF
return 1;
} else {
// ON -> ON
return 0;
}
} else {
if ( first_item == 0x80 ) {
// OFF -> OFF
return 0;
} else {
// OFF -> ON
return -1;
}
}
}
}
}
return (int)(clock - item.clock);
}
}
public static MidiEvent generateTimeSigEvent( int clock, int numerator, int denominator ) {
MidiEvent ret = new MidiEvent();
ret.clock = clock;
ret.firstByte = 0xff;
byte b_numer = (byte)(Math.Log( denominator, 2 ) + 0.1);
#if DEBUG
Console.WriteLine( "VsqEvent.generateTimeSigEvent; b_number=" + b_numer + "; denominator=" + denominator );
#endif
ret.data = new byte[5] { 0x58, (byte)numerator, b_numer, 0x18, 0x08 };
return ret;
}
public static MidiEvent generateTempoChangeEvent( int clock, int tempo ) {
MidiEvent ret = new MidiEvent();
ret.clock = clock;
ret.firstByte = 0xff;
byte b1 = (byte)(tempo & 0xff);
tempo = tempo >> 8;
byte b2 = (byte)(tempo & 0xff);
tempo = tempo >> 8;
byte b3 = (byte)(tempo & 0xff);
ret.data = new byte[4] { 0x51, b3, b2, b1 };
return ret;
}
}
public class MidiFile : IDisposable {
private Vector<Vector<MidiEvent>> m_events;
private ushort m_format;
private ushort m_time_format;
public MidiFile( String path ){
Stream stream = new FileStream( path, FileMode.Open, FileAccess.Read );
// ヘッダ
byte[] byte4 = new byte[4];
stream.Read( byte4, 0, 4 );
if ( makeUInt32( byte4 ) != 0x4d546864 ) {
throw new ApplicationException( "header error: MThd" );
}
// データ長
stream.Read( byte4, 0, 4 );
uint length = makeUInt32( byte4 );
// フォーマット
stream.Read( byte4, 0, 2 );
m_format = makeUint16( byte4 );
// トラック数
int tracks = 0;
stream.Read( byte4, 0, 2 );
tracks = (int)makeUint16( byte4 );
// 時間分解能
stream.Read( byte4, 0, 2 );
m_time_format = makeUint16( byte4 );
// 各トラックを読込み
m_events = new Vector<Vector<MidiEvent>>();
for ( int track = 0; track < tracks; track++ ) {
// ヘッダー
stream.Read( byte4, 0, 4 );
if ( makeUInt32( byte4 ) != 0x4d54726b ) {
throw new ApplicationException( "header error; MTrk" );
}
m_events.add( new Vector<MidiEvent>() );
// チャンクサイズ
stream.Read( byte4, 0, 4 );
long size = (long)makeUInt32( byte4 );
long startpos = stream.Position;
// チャンクの終わりまで読込み
long clock = 0;
byte last_status_byte = 0x00;
while ( stream.Position < startpos + size ) {
MidiEvent mi = MidiEvent.read( stream, ref clock, ref last_status_byte );
m_events.get( track ).add( mi );
}
if ( m_time_format != 480 ) {
int count = m_events.get( track ).size();
for ( int i = 0; i < count; i++ ) {
MidiEvent mi = m_events.get( track ).get( i );
mi.clock = mi.clock * 480 / m_time_format;
m_events.get( track ).set( i, mi );
}
}
}
m_time_format = 480;
#if DEBUG
String dbg = Path.Combine( Path.GetDirectoryName( path ), Path.GetFileNameWithoutExtension( path ) + ".txt" );
using ( StreamWriter sw = new StreamWriter( dbg ) ) {
const String format = " {0,8} 0x{1:X4} {2,-35} 0x{3:X2} 0x{4:X2}";
const String format0 = " {0,8} 0x{1:X4} {2,-35} 0x{3:X2}";
for ( int track = 1; track < m_events.size(); track++ ) {
sw.WriteLine( "MidiFile..ctor; track=" + track );
byte msb, lsb, data_msb, data_lsb;
msb = lsb = data_msb = data_lsb = 0x0;
for ( int i = 0; i < m_events.get( track ).size(); i++ ) {
if ( m_events.get( track ).get( i ).firstByte == 0xb0 ) {
switch ( m_events.get( track ).get( i ).data[0] ) {
case 0x63:
msb = m_events.get( track ).get( i ).data[1];
lsb = 0x0;
break;
case 0x62:
lsb = m_events.get( track ).get( i ).data[1];
break;
case 0x06:
data_msb = m_events.get( track ).get( i ).data[1];
ushort nrpn = (ushort)(msb << 8 | lsb);
String name = NRPN.getName( nrpn );
if ( name.Equals( "" ) ) {
name = "* * UNKNOWN * *";
sw.WriteLine( String.Format( format0, m_events.get( track ).get( i ).clock, nrpn, name, data_msb ) );
} else {
//if ( !NRPN.is_require_data_lsb( nrpn ) ) {
sw.WriteLine( String.Format( format0, m_events.get( track ).get( i ).clock, nrpn, name, data_msb ) );
//}
}
break;
case 0x26:
data_lsb = m_events.get( track ).get( i ).data[1];
ushort nrpn2 = (ushort)(msb << 8 | lsb);
String name2 = NRPN.getName( nrpn2 );
if ( name2.Equals( "" ) ) {
name2 = "* * UNKNOWN * *";
}
sw.WriteLine( String.Format( format, m_events.get( track ).get( i ).clock, nrpn2, name2, data_msb, data_lsb ) );
break;
}
}
}
}
}
#endif
stream.Close();
}
/*public void Write( String path ) {
}*/
public Vector<MidiEvent> getMidiEventList( int track ) {
if ( m_events == null ) {
return new Vector<MidiEvent>();
} else if ( 0 <= track && track < m_events.size() ) {
return m_events.get( track );
} else {
return new Vector<MidiEvent>();
}
}
public int getTrackCount() {
if ( m_events == null ) {
return 0;
} else {
return m_events.size();
}
}
public void Dispose() {
Close();
}
public void Close() {
if ( m_events != null ) {
for ( int i = 0; i < m_events.size(); i++ ) {
m_events.get( i ).clear();
}
m_events.clear();
}
}
private static UInt32 makeUInt32( byte[] value ) {
return (uint)((uint)((uint)((uint)(value[0] << 8) | value[1]) << 8 | value[2]) << 8 | value[3]);
}
private static UInt16 makeUint16( byte[] value ) {
return (ushort)((ushort)(value[0] << 8) | value[1]);
}
private static long readDeltaClock( Stream stream ) {
byte[] b;
long ret = 0;
while ( true ) {
byte d = (byte)stream.ReadByte();
ret = (ret << 7) | ((long)d & 0x7f);
if ( (d & 0x80) == 0x00 ) {
break;
}
}
return ret;
}
}
}

View File

@ -11,15 +11,26 @@
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*/
using System;
using System.IO;
using System.Collections.Generic;
#if JAVA
package org.kbinani.vsq;
import java.io.*;
import java.util.*;
import org.kbinani.*;
#else
using System;
using bocoree;
using bocoree.java.util;
using bocoree.java.io;
namespace Boare.Lib.Vsq {
#endif
#if JAVA
public class SingerConfig implements Cloneable {
#else
public class SingerConfig : ICloneable {
#endif
public String ID = "";
public String FORMAT = "";
public String VOICEIDSTR = "";
@ -48,7 +59,7 @@ namespace Boare.Lib.Vsq {
public SingerConfig() {
}
public object Clone() {
public Object clone() {
SingerConfig ret = new SingerConfig();
ret.ID = ID;
ret.FORMAT = FORMAT;
@ -77,6 +88,12 @@ namespace Boare.Lib.Vsq {
return ret;
}
#if !JAVA
public object Clone() {
return clone();
}
#endif
public static SingerConfig fromVvd( String file, int original ) {
SingerConfig sc = new SingerConfig();
//original = original;
@ -90,21 +107,23 @@ namespace Boare.Lib.Vsq {
sc.Opening = 0;
sc.GenderFactor = 0;
sc.Original = original; //original = 0;
FileStream fs = null;
RandomAccessFile fs = null;
try {
fs = new FileStream( file, FileMode.Open, FileAccess.Read );
int length = (int)fs.Length;
fs = new RandomAccessFile( file, "r" );
int length = (int)fs.length();
byte[] dat = new byte[length];
fs.Read( dat, 0, length );
TransCodeUtil.decodeBytes( ref dat );
String str = bocoree.cp932.convert( dat );
fs.read( dat, 0, length );
TransCodeUtil.decodeBytes( dat );
String str = PortUtil.getDecodedString( "Shift_JIS", dat );
#if DEBUG
Console.WriteLine( "SingerConfig.readSingerConfig; str=" + str );
PortUtil.println( "SingerConfig.readSingerConfig; str=" + str );
#endif
String crlf = ((char)0x0d).ToString() + ((char)0x0a).ToString();
String[] spl = str.Split( new String[] { crlf }, StringSplitOptions.RemoveEmptyEntries );
String crlf = "" + (char)0x0d + "" + (char)0x0a;
String[] spl = PortUtil.splitString( str, new String[] { crlf }, true );
foreach ( String s in spl ) {
int count = spl.Length;
for ( int i = 0; i < spl.Length; i++ ) {
String s = spl[i];
int first = s.IndexOf( '"' );
int first_end = get_quated_string( s, first );
int second = s.IndexOf( '"', first_end + 1 );
@ -112,11 +131,14 @@ namespace Boare.Lib.Vsq {
char[] chs = s.ToCharArray();
String id = new String( chs, first, first_end - first + 1 );
String value = new String( chs, second, second_end - second + 1 );
id = id.Substring( 1, id.Length - 2 );
value = value.Substring( 1, value.Length - 2 );
value = value.Replace( "\\\"", "\"" );
id = id.Substring( 1, PortUtil.getStringLength( id ) - 2 );
value = value.Substring( 1, PortUtil.getStringLength( value ) - 2 );
value = value.Replace( "\\" + "\"", "\"" );
int parsed_int = 64;
int.TryParse( value, out parsed_int );
try {
parsed_int = PortUtil.parseInt( value );
} catch ( Exception ex ) {
}
if ( id.Equals( "ID" ) ) {
sc.ID = value;
} else if ( id.Equals( "FORMAT" ) ) {
@ -163,11 +185,14 @@ namespace Boare.Lib.Vsq {
sc.Harmonics = parsed_int;
}
}
} catch {
} catch ( Exception ex ) {
} finally {
if ( fs != null ) {
fs.Close();
try {
fs.close();
} catch ( Exception ex2 ) {
}
}
}
return sc;
@ -211,17 +236,27 @@ namespace Boare.Lib.Vsq {
ret.add( "\"Clearness\":=:\"" + Clearness + "\"" );
ret.add( "\"Opening\":=:\"" + Opening + "\"" );
ret.add( "\"Gender:Factor\":=:\"" + GenderFactor + "\"" );
return ret.toArray( new String[]{} );
return ret.toArray( new String[] { } );
}
public override String ToString() {
#if !JAVA
public override string ToString() {
return toString();
}
#endif
public String toString() {
String[] r = ToStringArray();
String ret = "";
foreach ( String s in r ) {
int count = r.Length;
for ( int i = 0; i < count; i++ ) {
String s = r[i];
ret += s + "\n";
}
return ret;
}
}
#if !JAVA
}
#endif

View File

@ -11,13 +11,20 @@
* 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.IO;
#if JAVA
package org.kbinani.vsq;
import java.io.*;
import java.util.*;
import org.kbinani.*;
#else
using System;
using bocoree;
using bocoree.java.util;
using bocoree.java.io;
namespace Boare.Lib.Vsq {
#endif
public class SingerConfigSys {
private const int MAX_SINGERS = 0x4000;
@ -33,23 +40,25 @@ namespace Boare.Lib.Vsq {
public SingerConfigSys( String path_voicedb, String[] path_installed_singers ) {
m_installed_singers = new Vector<SingerConfig>();
m_singer_configs = new Vector<SingerConfig>();
String map = Path.Combine( path_voicedb, "voice.map" );
if ( !File.Exists( map ) ) {
String map = PortUtil.combinePath( path_voicedb, "voice.map" );
if ( !PortUtil.isFileExists( map ) ) {
return;
}
using ( FileStream fs = new FileStream( map, FileMode.Open, FileAccess.Read ) ) {
RandomAccessFile fs = null;
try {
fs = new RandomAccessFile( map, "r" );
byte[] dat = new byte[8];
fs.Seek( 0x20, SeekOrigin.Begin );
fs.seek( 0x20 );
for ( int i = 0; i < MAX_SINGERS; i++ ) {
fs.Read( dat, 0, 8 );
ulong value = VocaloSysUtil.makelong_le( dat );
fs.read( dat, 0, 8 );
long value = VocaloSysUtil.makelong_le( dat );
if ( value >= 1 ) {
String vvd = Path.Combine( path_voicedb, "vvoice" + value + ".vvd" );
String vvd = PortUtil.combinePath( path_voicedb, "vvoice" + value + ".vvd" );
SingerConfig item = SingerConfig.fromVvd( vvd, 0 );
item.Program = i;
int original = -1;
for ( Iterator itr = m_installed_singers.iterator(); itr.hasNext(); ){
for ( Iterator itr = m_installed_singers.iterator(); itr.hasNext(); ) {
SingerConfig sc = (SingerConfig)itr.next();
if ( sc.VOICEIDSTR.Equals( item.VOICEIDSTR ) ) {
original = sc.Program;
@ -57,10 +66,20 @@ namespace Boare.Lib.Vsq {
}
}
if ( original < 0 ) {
foreach ( String ipath in path_installed_singers ) {
#if JAVA
int count = path_installed_singers.length;
#else
int count = path_installed_singers.Length;
#endif
for ( int j = 0; j < count; j++ ) {
String ipath = path_installed_singers[j];
if ( ipath.EndsWith( item.VOICEIDSTR ) ) {
String[] vvds = Directory.GetFiles( ipath, "*.vvd" );
String[] vvds = PortUtil.listFiles( ipath, "*.vvd" );
#if JAVA
if ( vvds.length > 0 ) {
#else
if ( vvds.Length > 0 ) {
#endif
original = m_installed_singers.size();
SingerConfig installed = SingerConfig.fromVvd( vvds[0], original );
installed.Program = original;
@ -75,11 +94,19 @@ namespace Boare.Lib.Vsq {
m_singer_configs.add( item );
}
}
} catch ( Exception ex ) {
} finally {
if ( fs != null ) {
try {
fs.close();
} catch ( Exception ex2 ) {
}
}
}
}
public SingerConfig[] getInstalledSingers() {
return m_installed_singers.toArray( new SingerConfig[]{} );
return m_installed_singers.toArray( new SingerConfig[] { } );
}
/// <summary>
@ -101,19 +128,24 @@ namespace Boare.Lib.Vsq {
sc = new SingerConfig();
}
int lang = 0;
for( Iterator itr = m_installed_singers.iterator(); itr.hasNext(); ){
for ( Iterator itr = m_installed_singers.iterator(); itr.hasNext(); ) {
SingerConfig sc2 = (SingerConfig)itr.next();
if ( sc.VOICEIDSTR.Equals( sc2.VOICEIDSTR ) ) {
lang = (int)VocaloSysUtil.getLanguageFromName( sc.VOICENAME );
VsqVoiceLanguage lang_enum = VocaloSysUtil.getLanguageFromName( sc.VOICENAME );
#if JAVA
lang = lang_enum.ordinal();
#else
lang = (int)lang_enum;
#endif
break;
}
}
ret.IconHandle = new IconHandle();
ret.IconHandle.IconID = "$0701" + sc.Program.ToString( "0000" );
ret.IconHandle.IconID = "$0701" + PortUtil.toHexString( sc.Program, 4 );
ret.IconHandle.IDS = sc.VOICENAME;
ret.IconHandle.Index = 0;
ret.IconHandle.Language = lang;
ret.IconHandle.Length = 1;
ret.IconHandle.setLength( 1 );
ret.IconHandle.Original = sc.Original;
ret.IconHandle.Program = sc.Program;
ret.IconHandle.Caption = "";
@ -126,7 +158,7 @@ namespace Boare.Lib.Vsq {
/// <param name="program_change"></param>
/// <returns></returns>
public SingerConfig getSingerInfo( String singer ) {
for ( Iterator itr = m_installed_singers.iterator(); itr.hasNext(); ){
for ( Iterator itr = m_installed_singers.iterator(); itr.hasNext(); ) {
SingerConfig item = (SingerConfig)itr.next();
if ( item.VOICENAME.Equals( singer ) ) {
return item;
@ -140,8 +172,10 @@ namespace Boare.Lib.Vsq {
/// </summary>
/// <returns></returns>
public SingerConfig[] getSingerConfigs() {
return m_singer_configs.toArray( new SingerConfig[]{} );
return m_singer_configs.toArray( new SingerConfig[] { } );
}
}
#if !JAVA
}
#endif

View File

@ -11,28 +11,43 @@
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*/
using System;
using System.IO;
using System.Text;
using System.Collections.Generic;
using System.Windows.Forms;
#if JAVA
package org.kbinani.vsq;
import java.util.*;
import java.io.*;
import org.kbinani.*;
#else
using System;
using System.Text;
using System.Windows.Forms;
using bocoree;
using bocoree.java.util;
using bocoree.java.io;
namespace Boare.Lib.Vsq {
using boolean = System.Boolean;
using Integer = System.Int32;
#endif
#if JAVA
public class SymbolTable implements Cloneable {
#else
public class SymbolTable : ICloneable {
#endif
private TreeMap<String, String> m_dict;
private String m_name;
private boolean m_enabled;
#region Static Field
private static SortedList<int, SymbolTable> s_table = new SortedList<int, SymbolTable>();
private static TreeMap<Integer, SymbolTable> s_table = new TreeMap<Integer, SymbolTable>();
private static SymbolTable s_default_jp = null;
private static boolean s_initialized = false;
#if JAVA
public static final String[][] _KEY_JP = {
#else
public static readonly String[,] _KEY_JP = {
#endif
{"あ", "a"},
{"い", "i"},
{"う", "M"},
@ -60,7 +75,7 @@ namespace Boare.Lib.Vsq {
{"の", "n o"},
{"は", "h a"},
{"ひ", "C i"},
{"ふ", @"p\ M"},
{"ふ", "p\\ M"},
{"へ", "h e"},
{"ほ", "h o"},
{"ま", "m a"},
@ -134,10 +149,10 @@ namespace Boare.Lib.Vsq {
{"ひゅ", "C M"},
{"ひぇ", "C e"},
{"ひょ", "C o"},
{"ふゃ", @"p\' a"},
{"ふぃ", @"p\' i"},
{"ふゅ", @"p\' M"},
{"ふぇ", @"p\ e"},
{"ふゃ", "p\\' a"},
{"ふぃ", "p\\' i"},
{"ふゅ", "p\\' M"},
{"ふぇ", "p\\ e"},
{"みゃ", "m' a"},
{"みゅ", "m' M"},
{"みぇ", "m' e"},
@ -162,8 +177,8 @@ namespace Boare.Lib.Vsq {
{"ぴゅ", "p' M"},
{"ぴぇ", "p' e"},
{"ぴょ", "p' o"},
{"ふぁ", @"p\ a"},
{"ふぉ", @"p\ o"},
{"ふぁ", "p\\ a"},
{"ふぉ", "p\\ o"},
{"てゃ", "t' a"},
{"てぃ", "t' i"},
{"てゅ", "t' M"},
@ -209,7 +224,7 @@ namespace Boare.Lib.Vsq {
{"", "n o"},
{"ハ", "h a"},
{"ヒ", "C i"},
{"フ", @"p\ M"},
{"フ", "p\\ M"},
{"ヘ", "h e"},
{"ホ", "h o"},
{"マ", "m a"},
@ -283,10 +298,10 @@ namespace Boare.Lib.Vsq {
{"ヒュ", "C M"},
{"ヒェ", "C e"},
{"ヒョ", "C o"},
{"フャ", @"p\' a"},
{"フィ", @"p\' i"},
{"フュ", @"p\' M"},
{"フェ", @"p\ e"},
{"フャ", "p\\' a"},
{"フィ", "p\\' i"},
{"フュ", "p\\' M"},
{"フェ", "p\\ e"},
{"ミャ", "m' a"},
{"ミュ", "m' M"},
{"ミェ", "m' e"},
@ -311,8 +326,8 @@ namespace Boare.Lib.Vsq {
{"ピュ", "p' M"},
{"ピェ", "p' e"},
{"ピョ", "p' o"},
{"ファ", @"p\ a"},
{"フォ", @"p\ o"},
{"ファ", "p\\ a"},
{"フォ", "p\\ o"},
{"テャ", "t' a"},
{"ティ", "t' i"},
{"テュ", "t' M"},
@ -452,7 +467,7 @@ namespace Boare.Lib.Vsq {
{"chi", "tS i"},
{"chu", "tS M"},
{"cho", "tS o"},
{"fu", @"p\ M"},
{"fu", "p\\ M"},
{"ja", "dZ a"},
{"ji", "dZ i"},
{"ju", "dZ M"},
@ -465,8 +480,8 @@ namespace Boare.Lib.Vsq {
if ( !s_initialized ) {
loadDictionary();
}
if ( 0 <= index && index < s_table.Count ) {
return s_table[index];
if ( 0 <= index && index < s_table.size() ) {
return s_table.get( index );
} else {
return null;
}
@ -474,64 +489,65 @@ namespace Boare.Lib.Vsq {
public static void loadDictionary() {
#if DEBUG
Console.WriteLine( "SymbolTable.LoadDictionary()" );
PortUtil.println( "SymbolTable.LoadDictionary()" );
#endif
s_default_jp = new SymbolTable( "DEFAULT_JP", _KEY_JP, true );
s_table.Clear();
s_table.Add( 0, s_default_jp );
s_table.clear();
s_table.put( 0, s_default_jp );
int count = 0;
// 辞書フォルダからの読込み
String editor_path = VocaloSysUtil.getEditorPath2();
String editor_path = VocaloSysUtil.getEditorPath( SynthesizerType.VOCALOID2 );
if ( editor_path != "" ) {
String path = Path.Combine( Path.GetDirectoryName( editor_path ), "UDIC" );
if ( !Directory.Exists( path ) ) {
String path = PortUtil.combinePath( PortUtil.getDirectoryName( editor_path ), "UDIC" );
if ( !PortUtil.isDirectoryExists( path ) ) {
return;
}
String[] files = Directory.GetFiles( path, "*.udc" );
String[] files = PortUtil.listFiles( path, "*.udc" );
for ( int i = 0; i < files.Length; i++ ) {
files[i] = Path.GetFileName( files[i] );
files[i] = PortUtil.getFileName( files[i] );
#if DEBUG
Console.WriteLine( " files[i]=" + files[i] );
PortUtil.println( " files[i]=" + files[i] );
#endif
count++;
String dict = Path.Combine( path, files[i] );
s_table.Add( count, new SymbolTable( dict, true, false ) );
String dict = PortUtil.combinePath( path, files[i] );
s_table.put( count, new SymbolTable( dict, true, false ) );
}
}
// 起動ディレクトリ
String path2 = Path.Combine( Application.StartupPath, "udic" );
if ( Directory.Exists( path2 ) ) {
String[] files2 = Directory.GetFiles( path2, "*.eudc" );
String path2 = PortUtil.combinePath( PortUtil.getApplicationStartupPath(), "udic" );
if ( PortUtil.isDirectoryExists( path2 ) ) {
String[] files2 = PortUtil.listFiles( path2, "*.eudc" );
for ( int i = 0; i < files2.Length; i++ ) {
files2[i] = Path.GetFileName( files2[i] );
files2[i] = PortUtil.getFileName( files2[i] );
#if DEBUG
Console.WriteLine( " files2[i]=" + files2[i] );
PortUtil.println( " files2[i]=" + files2[i] );
#endif
count++;
String dict = Path.Combine( path2, files2[i] );
s_table.Add( count, new SymbolTable( dict, false, false ) );
String dict = PortUtil.combinePath( path2, files2[i] );
s_table.put( count, new SymbolTable( dict, false, false ) );
}
}
s_initialized = true;
}
public static boolean attatch( String phrase, out String result ) {
public static boolean attatch( String phrase, ByRef<String> result ) {
#if DEBUG
Console.WriteLine( "SymbolTable.Attatch" );
Console.WriteLine( " phrase=" + phrase );
PortUtil.println( "SymbolTable.Attatch" );
PortUtil.println( " phrase=" + phrase );
#endif
for ( int i = 0; i < s_table.Keys.Count; i++ ) {
int key = s_table.Keys[i];
if ( s_table[key].isEnabled() ) {
if ( s_table[key].attatchImp( phrase, out result ) ) {
for ( Iterator itr = s_table.keySet().iterator(); itr.hasNext(); ) {
int key = (Integer)itr.next();
SymbolTable table = s_table.get( key );
if ( table.isEnabled() ) {
if ( table.attatchImp( phrase, result ) ) {
return true;
}
}
}
result = "a";
result.value = "a";
return false;
}
@ -539,27 +555,31 @@ namespace Boare.Lib.Vsq {
if ( !s_initialized ) {
loadDictionary();
}
return s_table.Count;
return s_table.size();
}
public static void changeOrder( KeyValuePair<String, boolean>[] list ) {
public static void changeOrder( Vector<ValuePair<String, Boolean>> list ) {
#if DEBUG
Console.WriteLine( "SymbolTable.Sort()" );
PortUtil.println( "SymbolTable.Sort()" );
#endif
SortedList<int, SymbolTable> buff = new SortedList<int, SymbolTable>();
foreach ( int key in s_table.Keys ) {
buff.Add( key, (SymbolTable)s_table[key].Clone() );
TreeMap<Integer, SymbolTable> buff = new TreeMap<Integer, SymbolTable>();
for ( Iterator itr = s_table.keySet().iterator(); itr.hasNext(); ) {
int key = (Integer)itr.next();
buff.put( key, (SymbolTable)s_table.get( key ).clone() );
}
s_table.Clear();
for ( int i = 0; i < list.Length; i++ ) {
s_table.clear();
int count = list.size();
for ( int i = 0; i < count; i++ ) {
ValuePair<String, Boolean> itemi = list.get( i );
#if DEBUG
Console.WriteLine( " list[i]=" + list[i].Key + "," + list[i].Value );
PortUtil.println( " list[i]=" + itemi.getKey() + "," + itemi.getValue() );
#endif
for ( int j = 0; j < buff.Keys.Count; j++ ) {
int key = buff.Keys[j];
if ( buff[key].getName().Equals( list[i].Key ) ) {
buff[key].setEnabled( list[i].Value );
s_table.Add( i, buff[key] );
for ( Iterator itr = buff.keySet().iterator(); itr.hasNext(); ) {
int key = (Integer)itr.next();
SymbolTable table = buff.get( key );
if ( table.getName().Equals( itemi.getKey() ) ) {
table.setEnabled( itemi.getValue() );
s_table.put( i, table );
break;
}
}
@ -567,10 +587,16 @@ namespace Boare.Lib.Vsq {
}
#endregion
#if !JAVA
public object Clone() {
return clone();
}
#endif
public Object clone() {
SymbolTable ret = new SymbolTable();
ret.m_dict = new TreeMap<String, String>();
for ( Iterator itr = m_dict.keySet().iterator(); itr.hasNext(); ){
for ( Iterator itr = m_dict.keySet().iterator(); itr.hasNext(); ) {
String key = (String)itr.next();
ret.m_dict.put( key, m_dict.get( key ) );
}
@ -590,90 +616,95 @@ namespace Boare.Lib.Vsq {
return m_enabled;
}
public void setEnabled( boolean value ){
public void setEnabled( boolean value ) {
m_enabled = value;
}
public SymbolTable( String path, boolean is_udc_mode, boolean enabled ) {
m_dict = new TreeMap<String, String>();
m_enabled = enabled;
if ( !File.Exists( path ) ) {
if ( !PortUtil.isFileExists( path ) ) {
return;
}
m_name = Path.GetFileName( path );
cp932reader sr1 = null;
StreamReader sr2 = null;
m_name = PortUtil.getFileName( path );
BufferedReader sr = null;
try {
if ( is_udc_mode ) {
sr1 = new cp932reader( path );
if ( sr1 == null ) {
sr = new BufferedReader( new InputStreamReader( new FileInputStream( path ), "Shift_JIS" ) );
if ( sr == null ) {
return;
}
} else {
sr2 = new StreamReader( path, Encoding.UTF8 );
if ( sr2 == null ) {
sr = new BufferedReader( new InputStreamReader( new FileInputStream( path ), "UTF8" ) );
if ( sr == null ) {
return;
}
}
String line;
int peek = (is_udc_mode) ? sr1.Peek() : sr2.Peek();
while ( peek >= 0 ) {
line = (is_udc_mode) ? sr1.ReadLine() : sr2.ReadLine();
while ( sr.ready() ) {
line = sr.readLine();
if ( !line.StartsWith( "//" ) ) {
String[] spl = line.Split( "\t".ToCharArray(), 2, StringSplitOptions.RemoveEmptyEntries );
String[] spl = PortUtil.splitString( line, new String[] { "\t" }, 2, true );
if ( spl.Length >= 2 ) {
if ( m_dict.containsKey( spl[0] ) ) {
bocoree.debug.push_log( "SymbolTable..ctor" );
bocoree.debug.push_log( " dictionary already contains key: " + spl[0] );
PortUtil.println( "SymbolTable..ctor" );
PortUtil.println( " dictionary already contains key: " + spl[0] );
} else {
m_dict.put( spl[0], spl[1] );
}
}
}
peek = (is_udc_mode) ? sr1.Peek() : sr2.Peek();
}
} catch ( Exception ex ) {
bocoree.debug.push_log( "SymbolTable..ctor" );
bocoree.debug.push_log( " " + ex );
PortUtil.println( "SymbolTable..ctor" );
PortUtil.println( " " + ex );
} finally {
if ( sr1 != null ) {
sr1.Close();
if ( sr != null ) {
try {
sr.close();
} catch ( Exception ex2 ) {
}
if ( sr2 != null ) {
sr2.Close();
}
}
}
private boolean attatchImp( String phrase, out String result ) {
private boolean attatchImp( String phrase, ByRef<String> result ) {
String s = phrase.ToLower();
if ( m_dict.containsKey( s ) ) {
result = m_dict.get( s );
result.value = m_dict.get( s );
return true;
} else {
result = "a";
result.value = "a";
return false;
}
}
#if JAVA
private SymbolTable( String name, String[][] key, boolean enabled ){
#else
private SymbolTable( String name, String[,] key, boolean enabled ) {
#if DEBUG
Console.WriteLine( "SymolTable.ctor(String,String[,])" );
Console.WriteLine( " key.GetLength(0)=" + key.GetLength( 0 ) );
#endif
m_enabled = enabled;
m_name = name;
m_dict = new TreeMap<String, String>();
#if JAVA
for( int i = 0; i < key.length; i++ ){
if( m_dict.containsKey( key[i][0] ) ){
}else{
m_dict.put( key[i][0], key[i][1] );
}
}
#else
for ( int i = 0; i < key.GetLength( 0 ); i++ ) {
if ( m_dict.containsKey( key[i, 0] ) ) {
#if DEBUG
throw new ApplicationException( "dictionary already contains key: " + key[i, 0] );
#endif
} else {
m_dict.put( key[i, 0], key[i, 1] );
}
}
#endif
}
}
#if !JAVA
}
#endif

View File

@ -0,0 +1,27 @@
/*
* SynthesizerType.cs
* Copyright (c) 2009 kbinani
*
* This file is part of Boare.Cadencii.
*
* Boare.Cadencii is free software; you can redistribute it and/or
* modify it under the terms of the GPLv3 License.
*
* Boare.Cadencii 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.
*/
#if JAVA
package org.kbinani.vsq;
#else
namespace Boare.Lib.Vsq {
#endif
public enum SynthesizerType {
VOCALOID1,
VOCALOID2,
}
#if !JAVA
}
#endif

View File

@ -11,152 +11,37 @@
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*/
using System;
using System.Collections.Generic;
#if JAVA
package org.kbinani.vsq;
using bocoree;
import java.io.*;
#else
using System;
namespace Boare.Lib.Vsq {
using boolean = System.Boolean;
#endif
public class TempoTable : ICloneable {
private struct TempoTableEntry : IComparable<TempoTableEntry> {
public int Clock;
public int Tempo;
public double Time;
public TempoTableEntry( int clock, int tempo, double time ) {
Clock = clock;
Tempo = tempo;
Time = time;
}
public int CompareTo( TempoTableEntry item ) {
return Clock - item.Clock;
}
}
private Vector<TempoTableEntry> m_tempo_table;
private int m_base_tempo;
private int m_tpq;
private TempoTable() {
}
public TempoTable( int base_tempo, int clock_per_quoter ) {
m_base_tempo = base_tempo;
m_tpq = clock_per_quoter;
m_tempo_table = new Vector<TempoTableEntry>();
m_tempo_table.add( new TempoTableEntry( 0, base_tempo, 0.0 ) );
}
public object Clone() {
TempoTable ret = new TempoTable();
ret.m_base_tempo = m_base_tempo;
ret.m_tpq = m_tpq;
ret.m_tempo_table = new Vector<TempoTableEntry>();
for ( int i = 0; i < m_tempo_table.size(); i++ ) {
ret.m_tempo_table.add( m_tempo_table.get( i ) );
}
ret.update();
return ret;
}
public void add( int clock, int tempo ) {
boolean found = false;
for ( int i = 0; i < m_tempo_table.size(); i++ ) {
if ( m_tempo_table.get( i ).Clock == clock ) {
found = true;
m_tempo_table.set( i, new TempoTableEntry( clock, tempo, 0.0 ) );
break;
}
}
if ( !found ) {
m_tempo_table.add( new TempoTableEntry( clock, tempo, 0.0 ) );
}
Collections.sort( m_tempo_table );
update();
}
public void clear( int base_tempo ) {
m_tempo_table.clear();
m_tempo_table.add( new TempoTableEntry( 0, base_tempo, 0.0 ) );
}
private void update() {
for ( int i = 0; i < m_tempo_table.size(); i++ ) {
long sum = 0;
for ( int k = 0; k < i; k++ ) {
sum += (m_tempo_table.get( k ).Tempo * (m_tempo_table.get( k + 1 ).Clock - m_tempo_table.get( k ).Clock));
}
double time = sum / (m_tpq * 1e6);
m_tempo_table.set( i, new TempoTableEntry( m_tempo_table.get( i ).Clock, m_tempo_table.get( i ).Tempo, time ) );
}
}
/// <summary>
/// 指定した時刻における、クロックを取得します
/// </summary>
/// <param name="time"></param>
/// <returns></returns>
public double getClockFromSec( double time ) {
// timeにおけるテンポを取得
int tempo = m_base_tempo;
double base_clock = 0;
double base_time = 0f;
if ( m_tempo_table.size() == 0 ) {
tempo = m_base_tempo;
base_clock = 0;
base_time = 0f;
} else if ( m_tempo_table.size() == 1 ) {
tempo = m_tempo_table.get( 0 ).Tempo;
base_clock = m_tempo_table.get( 0 ).Clock;
base_time = m_tempo_table.get( 0 ).Time;
} else {
for ( int i = m_tempo_table.size() - 1; i >= 0; i-- ) {
if ( m_tempo_table.get( i ).Time < time ) {
return m_tempo_table.get( i ).Clock + (time - m_tempo_table.get( i ).Time) * m_tpq * 1000000.0 / m_tempo_table.get( i ).Tempo;
}
}
}
double dt = time - base_time;
return base_clock + dt * m_tpq * 1000000.0 / (double)tempo;
}
/// <summary>
/// 指定したクロックにおける、clock=0からの演奏経過時間(sec)を取得します
/// </summary>
/// <param name="clock"></param>
/// <returns></returns>
public double getSecFromClock( int clock ) {
for ( int i = m_tempo_table.size() - 1; i >= 0; i-- ) {
if ( m_tempo_table.get( i ).Clock < clock ) {
double init = m_tempo_table.get( i ).Time;
int dclock = clock - m_tempo_table.get( i ).Clock;
double sec_per_clock1 = m_tempo_table.get( i ).Tempo * 1e-6 / 480.0;
return init + dclock * sec_per_clock1;
}
}
double sec_per_clock = m_base_tempo * 1e-6 / 480.0;
return clock * sec_per_clock;
}
public int getBaseTempo() {
return m_base_tempo;
}
}
#if JAVA
public class TempoTableEntry implements Comparable<TempoTableEntry>, Cloneable, Serializable {
#else
[Serializable]
public class TempoTableEntry : IComparable<TempoTableEntry>, ICloneable {
#endif
public int Clock;
public int Tempo;
public double Time;
public object Clone() {
public Object clone() {
return new TempoTableEntry( Clock, Tempo, Time );
}
#if !JAVA
public object Clone() {
return clone();
}
#endif
public TempoTableEntry( int clock, int _tempo, double _time ) {
this.Clock = clock;
this.Tempo = _tempo;
@ -166,10 +51,16 @@ namespace Boare.Lib.Vsq {
public TempoTableEntry() {
}
public int CompareTo( TempoTableEntry entry ) {
public int compareTo( TempoTableEntry entry ) {
return this.Clock - entry.Clock;
}
#if !JAVA
public int CompareTo( TempoTableEntry entry ) {
return compareTo( entry );
}
#endif
public boolean Equals( TempoTableEntry entry ) {
if ( this.Clock == entry.Clock ) {
return true;
@ -179,4 +70,6 @@ namespace Boare.Lib.Vsq {
}
}
#if !JAVA
}
#endif

View File

@ -11,16 +11,26 @@
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*/
using System;
using System.IO;
using System.Text;
using System.Collections.Generic;
#if JAVA
package org.kbinani.vsq;
import java.util.*;
import java.io.*;
import org.kbinani.*;
#else
using System;
using bocoree;
using bocoree.java.util;
using bocoree.java.io;
namespace Boare.Lib.Vsq {
#endif
public class TextMemoryStream : IDisposable {
#if JAVA
public class TextMemoryStream implements ITextWriter {
#else
public class TextMemoryStream : IDisposable, ITextWriter {
#endif
private static readonly String NL = (char)0x0d + "" + (char)0x0a;
private Vector<String> m_lines;
@ -32,16 +42,26 @@ namespace Boare.Lib.Vsq {
m_index = 0;
}
public TextMemoryStream( String path, Encoding encoding ) {
public TextMemoryStream( String path, String encoding ) {
m_lines = new Vector<String>();
m_index = 0;
if ( File.Exists( path ) ) {
using ( StreamReader sr = new StreamReader( path, encoding ) ) {
while ( sr.Peek() >= 0 ) {
String line = sr.ReadLine();
if ( PortUtil.isFileExists( path ) ) {
BufferedReader sr = null;
try {
sr = new BufferedReader( new InputStreamReader( new FileInputStream( path ), encoding ) );
while ( sr.ready() ) {
String line = sr.readLine();
m_lines.add( line );
m_index++;
}
} catch ( Exception ex ) {
} finally {
if ( sr != null ) {
try {
sr.close();
} catch ( Exception ex2 ) {
}
}
}
}
}
@ -54,15 +74,23 @@ namespace Boare.Lib.Vsq {
appendString( value + NL );
}
private static Vector<String> splitLine( String line ) {
Vector<String> ret = new Vector<String>();
String[] spl_0x0d_0x0a = PortUtil.splitString( line, new String[] { NL }, false );
for ( int i = 0; i < spl_0x0d_0x0a.Length; i++ ) {
String[] spl_0x0d = PortUtil.splitString( spl_0x0d_0x0a[i], (char)0x0d );
for ( int j = 0; j < spl_0x0d.Length; j++ ) {
String[] spl_0x0a = PortUtil.splitString( spl_0x0d[j], (char)0x0a );
for ( int k = 0; k < spl_0x0a.Length; k++ ) {
ret.add( spl_0x0a[k] );
}
}
}
return ret;
}
private void appendString( String value ) {
String[] lines = value.Split( new String[] { NL }, StringSplitOptions.None );
Vector<String> lines2 = new Vector<String>();
for ( int i = 0; i < lines.Length; i++ ) {
String[] spl = lines[i].Split( (char)0x0d, (char)0x0a );
for ( int j = 0; j < spl.Length; j++ ) {
lines2.add( spl[j] );
}
}
Vector<String> lines2 = splitLine( value );
int count = lines2.size();
if ( count > 0 ) {
m_lines.set( m_index, m_lines.get( m_index ) + lines2.get( 0 ) );
@ -87,7 +115,11 @@ namespace Boare.Lib.Vsq {
if ( m_lines.get( m_index ).Equals( "" ) ) {
return -1;
} else {
#if JAVA
return (int)m_lines.get( m_index ).charAt( 0 );
#else
return (int)m_lines.get( m_index )[0];
#endif
}
} else {
return -1;
@ -103,4 +135,6 @@ namespace Boare.Lib.Vsq {
}
}
#if !JAVA
}
#endif

View File

@ -11,14 +11,23 @@
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*/
using System;
#if JAVA
package org.kbinani.vsq;
import java.io.*;
#else
using System;
using bocoree;
namespace Boare.Lib.Vsq{
namespace Boare.Lib.Vsq {
#endif
#if JAVA
public class TimeSigTableEntry implements Comparable<TimeSigTableEntry>, Cloneable, Serializable {
#else
[Serializable]
public class TimeSigTableEntry : IComparable<TimeSigTableEntry>, ICloneable {
#endif
/// <summary>
/// クロック数
/// </summary>
@ -54,13 +63,27 @@ namespace Boare.Lib.Vsq{
return "{Clock=" + Clock + ", Numerator=" + Numerator + ", Denominator=" + Denominator + ", BarCount=" + BarCount + "}";
}
public object Clone() {
public Object clone() {
return new TimeSigTableEntry( Clock, Numerator, Denominator, BarCount );
}
public int CompareTo( TimeSigTableEntry item ) {
#if !JAVA
public object Clone() {
return clone();
}
#endif
public int compareTo( TimeSigTableEntry item ) {
return this.BarCount - item.BarCount;
}
#if !JAVA
public int CompareTo( TimeSigTableEntry item ) {
return compareTo( item );
}
#endif
}
#if !JAVA
}
#endif

View File

@ -0,0 +1,27 @@
/*
* Timesig.cs
* Copyright (c) 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.
*/
#if JAVA
package org.kbinani.vsq;
#else
namespace Boare.Lib.Vsq {
#endif
public struct Timesig {
public int numerator;
public int denominator;
}
#if !JAVA
}
#endif

View File

@ -1,10 +1,27 @@
namespace Boare.Lib.Vsq {
/*
* TransCodeUtil.cs
* Copyright (c) 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.
*/
#if JAVA
package org.kbinani.vsq;
#else
namespace Boare.Lib.Vsq {
#endif
public static class TransCodeUtil {
public class TransCodeUtil {
private static readonly byte[] MAP_L = new byte[] { 0xA, 0xB, 0x8, 0x9, 0xE, 0xF, 0xC, 0xD, 0x2, 0x3, 0x0, 0x1, 0x6, 0x7, 0x4, 0x5 };
private static readonly byte[] MAP_R = new byte[] { 0x1, 0x0, 0x3, 0x2, 0x5, 0x4, 0x7, 0x6, 0x9, 0x8, 0xB, 0xA, 0xD, 0xC, 0xF, 0xE };
public static void decodeBytes( ref byte[] dat ) {
public static void decodeBytes( byte[] dat ) {
for ( int i = 0; i < dat.Length; i++ ) {
byte M = (byte)(dat[i] >> 4);
byte L = (byte)(dat[i] - (M << 4));
@ -29,4 +46,6 @@
}
}
#if !JAVA
}
#endif

View File

@ -11,14 +11,24 @@
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*/
using System;
#if JAVA
package org.kbinani.vsq;
import java.io.*;
import org.kbinani.*;
#else
using System;
using bocoree;
namespace Boare.Lib.Vsq {
#endif
#if JAVA
public class UstEnvelope implements Cloneable, Serializable {
#else
[Serializable]
public class UstEnvelope : ICloneable {
#endif
public int p1 = 0;
public int p2 = 5;
public int p3 = 35;
@ -36,33 +46,45 @@ namespace Boare.Lib.Vsq {
public UstEnvelope( String line ) {
if ( line.ToLower().StartsWith( "envelope=" ) ) {
String[] spl = line.Split( '=' );
spl = spl[1].Split( ',' );
String[] spl = PortUtil.splitString( line, '=' );
spl = PortUtil.splitString( spl[1], ',' );
if ( spl.Length < 7 ) {
return;
}
//Separator = "";
p1 = int.Parse( spl[0] );
p2 = int.Parse( spl[1] );
p3 = int.Parse( spl[2] );
v1 = int.Parse( spl[3] );
v2 = int.Parse( spl[4] );
v3 = int.Parse( spl[5] );
v4 = int.Parse( spl[6] );
p1 = PortUtil.parseInt( spl[0] );
p2 = PortUtil.parseInt( spl[1] );
p3 = PortUtil.parseInt( spl[2] );
v1 = PortUtil.parseInt( spl[3] );
v2 = PortUtil.parseInt( spl[4] );
v3 = PortUtil.parseInt( spl[5] );
v4 = PortUtil.parseInt( spl[6] );
if ( spl.Length == 11 ) {
//Separator = "%";
p4 = int.Parse( spl[8] );
p5 = int.Parse( spl[9] );
v5 = int.Parse( spl[10] );
p4 = PortUtil.parseInt( spl[8] );
p5 = PortUtil.parseInt( spl[9] );
v5 = PortUtil.parseInt( spl[10] );
}
}
}
public Object clone() {
return new UstEnvelope( toString() );
}
#if !JAVA
public object Clone() {
return new UstEnvelope( ToString() );
return clone();
}
#endif
public override String ToString() {
#if !JAVA
public override string ToString() {
return toString();
}
#endif
public String toString() {
String ret = "Envelope=" + p1 + "," + p2 + "," + p3 + "," + v1 + "," + v2 + "," + v3 + "," + v4;
ret += ",%," + p4 + "," + p5 + "," + v5;
return ret;
@ -77,4 +99,6 @@ namespace Boare.Lib.Vsq {
}
}
#if !JAVA
}
#endif

View File

@ -11,17 +11,25 @@
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*/
using System;
using System.IO;
using System.Collections.Generic;
using System.Text;
#if JAVA
package org.kbinani.vsq;
import java.io.*;
import org.kbinani.*;
#else
using System;
using bocoree;
using bocoree.java.io;
namespace Boare.Lib.Vsq {
#endif
#if JAVA
public class UstEvent implements Cloneable, Serializable {
#else
[Serializable]
public class UstEvent : ICloneable {
#endif
public String Tag;
public int Length = 0;
public String Lyric = "";
@ -39,12 +47,20 @@ namespace Boare.Lib.Vsq {
public int Moduration = 100;
public int Index;
public UstEvent(){
public UstEvent() {
}
public object Clone() {
public int getLength() {
return Length;
}
public void setLength( int value ) {
Length = value;
}
public Object clone() {
UstEvent ret = new UstEvent();
ret.Length = Length;
ret.setLength( Length );
ret.Lyric = Lyric;
ret.Note = Note;
ret.Intensity = Intensity;
@ -57,13 +73,13 @@ namespace Boare.Lib.Vsq {
}
ret.Tempo = Tempo;
if ( Vibrato != null ) {
ret.Vibrato = (UstVibrato)Vibrato.Clone();
ret.Vibrato = (UstVibrato)Vibrato.clone();
}
if ( Portamento != null ) {
ret.Portamento = (UstPortamento)Portamento.Clone();
ret.Portamento = (UstPortamento)Portamento.clone();
}
if ( Envelope != null ) {
ret.Envelope = (UstEnvelope)Envelope.Clone();
ret.Envelope = (UstEnvelope)Envelope.clone();
}
ret.PreUtterance = PreUtterance;
ret.VoiceOverlap = VoiceOverlap;
@ -73,57 +89,99 @@ namespace Boare.Lib.Vsq {
return ret;
}
public void print( StreamWriter sw ) {
if ( this.Index == int.MinValue ) {
sw.WriteLine( "[#PREV]" );
} else if ( this.Index == int.MaxValue ) {
sw.WriteLine( "[#NEXT]" );
} else {
sw.WriteLine( String.Format( "[#{0:d4}]", Index ) );
#if !JAVA
public object Clone() {
return clone();
}
sw.WriteLine( "Length=" + Length );
sw.WriteLine( "Lyric=" + Lyric );
sw.WriteLine( "NoteNum=" + Note );
#endif
public void print( BufferedWriter sw )
#if JAVA
throws IOException
#endif
{
if ( this.Index == int.MinValue ) {
sw.write( "[#PREV]" );
sw.newLine();
} else if ( this.Index == int.MaxValue ) {
sw.write( "[#NEXT]" );
sw.newLine();
} else {
sw.write( "[#" + PortUtil.formatDecimal( "0000", Index ) + "]" );
sw.newLine();
}
sw.write( "Length=" + Length );
sw.newLine();
sw.write( "Lyric=" + Lyric );
sw.newLine();
sw.write( "NoteNum=" + Note );
sw.newLine();
if ( Intensity >= 0 ) {
sw.WriteLine( "Intensity=" + Intensity );
sw.write( "Intensity=" + Intensity );
sw.newLine();
}
if ( PBType >= 0 && Pitches != null ) {
sw.WriteLine( "PBType=" + PBType );
sw.Write( "Piches=" );
sw.write( "PBType=" + PBType );
sw.newLine();
sw.write( "Piches=" );
for ( int i = 0; i < Pitches.Length; i++ ) {
if ( i == 0 ) {
sw.Write( Pitches[i] );
sw.write( Pitches[i] + "" );
} else {
sw.Write( "," + Pitches[i] );
sw.write( "," + Pitches[i] );
}
}
sw.WriteLine();
sw.newLine();
}
if ( Tempo > 0 ) {
sw.WriteLine( "Tempo=" + Tempo );
sw.write( "Tempo=" + Tempo );
sw.newLine();
}
if ( Vibrato != null ) {
sw.WriteLine( Vibrato.ToString() );
sw.write( Vibrato.ToString() );
sw.newLine();
}
if ( Portamento != null ) {
Portamento.print( sw );
}
if ( Envelope != null ) {
if ( PreUtterance >= 0 ) {
sw.WriteLine( "PreUtterance=" + PreUtterance );
sw.write( "PreUtterance=" + PreUtterance );
sw.newLine();
}
if ( VoiceOverlap != 0 ) {
sw.WriteLine( "VoiceOverlap=" + VoiceOverlap );
sw.write( "VoiceOverlap=" + VoiceOverlap );
sw.newLine();
}
sw.WriteLine( Envelope.ToString() );
sw.write( Envelope.ToString() );
sw.newLine();
}
if ( Flags != "" ) {
sw.WriteLine( "Flags=" + Flags );
sw.write( "Flags=" + Flags );
sw.newLine();
}
if ( Moduration >= 0 ) {
sw.WriteLine( "Moduration=" + Moduration );
}
sw.write( "Moduration=" + Moduration );
sw.newLine();
}
}
/*public VsqEvent convertToVsqEvent( int clock, int internal_id ) {
VsqEvent ret = new VsqEvent();
ret.Clock = clock;
ret.InternalID = internal_id;
ret.UstEvent = (UstEvent)this.clone();
ret.ID.setLength( Length );
ByRef<string> phonetic_symbol = new ByRef<string>( "" );
SymbolTable.attatch( Lyric, phonetic_symbol );
ret.ID.LyricHandle = new LyricHandle( Lyric, phonetic_symbol.value );
ret.ID.Note = Note;
ret.ID.Dynamics = Intensity;
ret.ID.type = VsqIDType.Anote;
return ret;
}*/
}
#if !JAVA
}
#endif

View File

@ -1,4 +1,4 @@
/*
/*
* UstFile.cs
* Copyright (c) 2009 kbinani, PEX
*
@ -11,17 +11,38 @@
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*/
#if JAVA
package org.kbinani.vsq;
import java.util.*;
import java.io.*;
import org.kbinani.*;
#else
using System;
using System.IO;
using System.Collections.Generic;
using System.Text;
using bocoree;
using bocoree.java.util;
using bocoree.java.io;
namespace Boare.Lib.Vsq{
namespace Boare.Lib.Vsq {
using Float = System.Single;
using boolean = System.Boolean;
#endif
#if JAVA
public class UstFile implements Cloneable {
#else
public class UstFile : ICloneable {
public object Tag;
#endif
/// <summary>
/// [#PREV]が指定されているUstEventのIndex
/// </summary>
public const int PREV_INDEX = int.MinValue;
/// <summary>
/// [#NEXT]が指定されているUstEventのIndex
/// </summary>
public const int NEXT_INDEX = int.MaxValue;
public Object Tag;
private float m_tempo = 120.00f;
private String m_project_name = "";
private String m_voice_dir = "";
@ -32,22 +53,23 @@ namespace Boare.Lib.Vsq{
private Vector<UstTrack> m_tracks = new Vector<UstTrack>();
private Vector<TempoTableEntry> m_tempo_table;
public UstFile( String path ){
public UstFile( String path ) {
BufferedReader sr = null;
try {
cp932reader sr = new cp932reader( path );
sr = new BufferedReader( new InputStreamReader( new FileInputStream( path ), "Shift_JIS" ) );
#if DEBUG
bocoree.debug.push_log( "path=" + path );
bocoree.debug.push_log( "(sr==null)=" + (sr == null) );
#endif
String line = sr.ReadLine();
if ( line != "[#SETTING]" ) {
String line = sr.readLine();
if ( !line.Equals( "[#SETTING]" ) ) {
throw new Exception( "invalid ust file" );
}
UstTrack track = new UstTrack();
int type = 0; //0 => reading "SETTING" section
while ( true ) {
#if DEBUG
bocoree.debug.push_log( "line=" + line );
PortUtil.println( "line=" + line );
#endif
UstEvent ue = null;
if ( type == 1 ) {
@ -57,32 +79,40 @@ namespace Boare.Lib.Vsq{
if ( line.Equals( "[#TRACKEND]" ) ) {
break;
} else if ( line.ToUpper().Equals( "[#NEXT]" ) ) {
index = int.MaxValue;
index = NEXT_INDEX;
} else if ( line.ToUpper().Equals( "[#PREV]" ) ) {
index = int.MinValue;
index = PREV_INDEX;
} else {
String s = line.Replace( "[#", "" ).Replace( "#", "" ).Trim();
int.TryParse( s, out index );
String s = line.Replace( "[#", "" ).Replace( "]", "" ).Trim();
try {
index = PortUtil.parseInt( s );
} catch ( Exception ex ) {
#if DEBUG
PortUtil.println( "UstFile#.ctor; ex=" + ex );
#endif
}
}
#if DEBUG
bocoree.debug.push_log( "index=" + index );
#endif
line = sr.ReadLine(); // "[#" 直下の行
line = sr.readLine(); // "[#" 直下の行
if ( line == null ) {
break;
}
while ( !line.StartsWith( "[#" ) ) {
#if DEBUG
Console.WriteLine( "line=" + line );
PortUtil.println( "line=" + line );
#endif
String[] spl = line.Split( "=".ToCharArray(), 2 );
String[] spl = PortUtil.splitString( line, new char[] { '=' }, 2 );
if ( type == 0 ) {
// reading "SETTING" section
if ( spl[0].Equals( "Tempo" ) ) {
m_tempo = 125f;
float v = 125f;
if ( float.TryParse( spl[1], out v ) ) {
try {
v = PortUtil.parseFloat( spl[1] );
m_tempo = v;
} catch ( Exception ex ) {
}
} else if ( spl[0].Equals( "ProjectName" ) ) {
m_project_name = spl[1];
@ -100,45 +130,58 @@ namespace Boare.Lib.Vsq{
} else if ( type == 1 ) {
// readin event section
if ( spl[0].Equals( "Length" ) ) {
ue.Length = 0;
ue.setLength( 0 );
int v = 0;
if ( int.TryParse( spl[1], out v ) ) {
ue.Length = v;
try {
v = PortUtil.parseInt( spl[1] );
ue.setLength( v );
} catch ( Exception ex ) {
}
} else if ( spl[0].Equals( "Lyric" ) ) {
ue.Lyric = spl[1];
} else if ( spl[0].Equals( "NoteNum" ) ) {
ue.Note = 0;
int v = 0;
if ( int.TryParse( spl[1], out v ) ) {
try {
v = PortUtil.parseInt( spl[1] );
ue.Note = v;
} catch ( Exception ex ) {
}
} else if ( spl[0].Equals( "Intensity" ) ) {
ue.Intensity = 64;
int v = 64;
if ( int.TryParse( spl[1], out v ) ) {
try {
v = PortUtil.parseInt( spl[1] );
ue.Intensity = v;
} catch ( Exception ex ) {
}
} else if ( spl[0].Equals( "PBType" ) ) {
ue.PBType = 5;
int v = 5;
if ( int.TryParse( spl[1], out v ) ) {
try {
v = PortUtil.parseInt( spl[1] );
ue.PBType = v;
} catch ( Exception ex ) {
}
} else if ( spl[0].Equals( "Piches" ) ) {
String[] spl2 = spl[1].Split( ",".ToCharArray() );
String[] spl2 = PortUtil.splitString( spl[1], ',' );
float[] t = new float[spl2.Length];
for ( int i = 0; i < spl2.Length; i++ ) {
float v = 0;
float.TryParse( spl2[i], out v );
try {
v = PortUtil.parseFloat( spl2[i] );
t[i] = v;
} catch ( Exception ex ) {
}
}
ue.Pitches = t;
} else if ( spl[0].Equals( "Tempo" ) ) {
ue.Tempo = 125f;
float v;
if ( float.TryParse( spl[1], out v ) ) {
try {
v = PortUtil.parseFloat( spl[1] );
ue.Tempo = v;
} catch ( Exception ex ) {
}
} else if ( spl[0].Equals( "VBR" ) ) {
ue.Vibrato = new UstVibrato( line );
@ -159,20 +202,24 @@ namespace Boare.Lib.Vsq{
//VoiceOverlap=6
} else if ( spl[0].Equals( "VoiceOverlap" ) ) {
if ( spl[1] != "" ) {
ue.VoiceOverlap = int.Parse( spl[1] );
ue.VoiceOverlap = PortUtil.parseInt( spl[1] );
}
} else if ( spl[0].Equals( "PreUtterance" ) ) {
if ( spl[1] != "" ) {
ue.PreUtterance = int.Parse( spl[1] );
ue.PreUtterance = PortUtil.parseInt( spl[1] );
}
} else if ( spl[0].Equals( "Flags" ) ) {
ue.Flags = line.Substring( 6 );
} else {
#if DEBUG
PortUtil.println( "UstFile#.ctor; info: don't know how to process this line; line=" + line );
#endif
}
}
if ( sr.Peek() < 0 ) {
if ( !sr.ready() ) {
break;
}
line = sr.ReadLine();
line = sr.readLine();
}
#if DEBUG
bocoree.debug.push_log( "(ue==null)=" + (ue == null) );
@ -185,16 +232,109 @@ namespace Boare.Lib.Vsq{
}
}
m_tracks.add( track );
sr.Close();
updateTempoInfo();
} catch ( Exception ex ) {
#if DEBUG
bocoree.debug.push_log( "ex=" + ex );
#endif
} finally {
if ( sr != null ) {
try {
sr.close();
} catch ( Exception ex2 ) {
}
}
}
}
private UstFile(){
/// <summary>
/// vsqの指定したトラックを元にトラックを1つだけ持つustを構築します
/// </summary>
/// <param name="vsq"></param>
/// <param name="track_index"></param>
public UstFile( VsqFile vsq, int track_index ) {
VsqTrack track = vsq.Track.get( track_index );
// デフォルトのテンポ
if( vsq.TempoTable.size() <= 0 ){
m_tempo = 120.0f;
}else{
m_tempo = (float)(60e6 / (double)vsq.TempoTable.get( 0 ).Tempo);
}
updateTempoInfo();
// R用音符のテンプレート
int PBTYPE = 5;
UstEvent template = new UstEvent();
template.Lyric = "R";
template.Note = 60;
template.PreUtterance = 0;
template.VoiceOverlap = 0;
template.Intensity = 100;
template.Moduration = 0;
// 再生秒時をとりあえず無視して,ゲートタイム基準で音符を追加
UstTrack track_add = new UstTrack();
int last_clock = 0;
int index = 0;
for( Iterator itr = track.getNoteEventIterator(); itr.hasNext(); ){
VsqEvent item = (VsqEvent)itr.next();
if( last_clock < item.Clock ){
// ゲートタイム差ありRを追加
UstEvent itemust = (UstEvent)template.clone();
itemust.setLength( item.Clock - last_clock );
itemust.Index = index;
index++;
track_add.addEvent( itemust );
}
UstEvent item_add = new UstEvent();
item_add.setLength( item.ID.getLength() );
item_add.Lyric = item.ID.LyricHandle.L0.Phrase;
item_add.Note = item.ID.Note;
item_add.Index = index;
item_add.Intensity = item.ID.Dynamics;
item_add.Moduration = item.UstEvent.Moduration;
item_add.PreUtterance = item.UstEvent.PreUtterance;
item_add.VoiceOverlap = item.UstEvent.VoiceOverlap;
index++;
track_add.addEvent( item_add );
last_clock = item.Clock + item.ID.getLength();
}
// 再生秒時を無視して,ピッチベンドを追加
//VsqBPList pbs = track.getCurve( "pbs" );
//VsqBPList pit = track.getCurve( "pit" );
int clock = 0;
for ( Iterator itr = track_add.getNoteEventIterator(); itr.hasNext(); ) {
UstEvent item = (UstEvent)itr.next();
int clock_begin = clock;
int clock_end = clock + item.getLength();
Vector<Float> pitch = new Vector<Float>();
boolean allzero = true;
for ( int cl = clock_begin; cl <= clock_end; cl += PBTYPE ) {
float pit = (float)track.getPitchAt( cl );
if ( pit != 0.0 ) {
allzero = false;
}
pitch.add( pit );
}
if ( !allzero ) {
item.Pitches = PortUtil.convertFloatArray( pitch.toArray( new Float[] { } ) );
item.PBType = PBTYPE;
} else {
item.PBType = -1;
}
clock += item.getLength();
}
// 再生秒時を考慮して,適時テンポを追加
//TODO: このへん
// throw new NotImplementedException();
m_tracks.add( track_add );
}
private UstFile() {
}
public String getProjectName() {
@ -210,7 +350,7 @@ namespace Boare.Lib.Vsq{
for ( int track = 0; track < m_tracks.size(); track++ ) {
int count = 0;
for ( int i = 0; i < m_tracks.get( track ).getEventCount(); i++ ) {
count += (int)m_tracks.get( track ).getEvent( i ).Length;
count += (int)m_tracks.get( track ).getEvent( i ).getLength();
}
max = Math.Max( max, count );
}
@ -230,7 +370,7 @@ namespace Boare.Lib.Vsq{
}
/// <summary>
/// TempoTableの[*].Timeの部分を更新します
/// TempoTableの[*].Timeの部分を更新します
/// </summary>
/// <returns></returns>
public void updateTempoInfo() {
@ -240,8 +380,8 @@ namespace Boare.Lib.Vsq{
}
int clock = 0;
double time = 0.0;
int last_tempo_clock = 0; //最後にTempo値が代入されていたイベントのクロック
float last_tempo = m_tempo; //最後に代入されていたテンポの値
int last_tempo_clock = 0; //最後にTempo値が代入されていたイベントのクロック
float last_tempo = m_tempo; //最後に代入されていたテンポの値
for ( int i = 0; i < m_tracks.get( 0 ).getEventCount(); i++ ) {
if ( m_tracks.get( 0 ).getEvent( i ).Tempo > 0f ) {
time += (clock - last_tempo_clock) / (8.0 * last_tempo);
@ -252,29 +392,23 @@ namespace Boare.Lib.Vsq{
last_tempo = m_tracks.get( 0 ).getEvent( i ).Tempo;
last_tempo_clock = clock;
}
clock += (int)m_tracks.get( 0 ).getEvent( i ).Length;
clock += (int)m_tracks.get( 0 ).getEvent( i ).getLength();
}
#if DEBUG
using ( StreamWriter sw = new StreamWriter( Path.Combine( System.Windows.Forms.Application.StartupPath, "ust_tempo_info.txt" ) ) ) {
sw.WriteLine( "Clock\tTime\tTempo" );
for ( int i = 0; i < m_tempo_table.size(); i++ ) {
sw.WriteLine( m_tempo_table.get( i ).Clock + "\t" + m_tempo_table.get( i ).Time + "\t" + m_tempo_table.get( i ).Tempo );
}
}
#endif
}
/// <summary>
/// 指定したクロックにおける、clock=0からの演奏経過時間(sec)
/// 指定したクロックにおける、clock=0からの演奏経過時間(sec)
/// </summary>
/// <param name="clock"></param>
/// <returns></returns>
public double getSecFromClock( int clock ) {
for ( int i = m_tempo_table.size() - 1; i >= 0; i-- ) {
if ( m_tempo_table.get( i ).Clock < clock ) {
double init = m_tempo_table.get( i ).Time;
int dclock = clock - m_tempo_table.get( i ).Clock;
double sec_per_clock1 = m_tempo_table.get( i ).Tempo * 1e-6 / 480.0;
int c = m_tempo_table.size();
for ( int i = c - 1; i >= 0; i-- ) {
TempoTableEntry item = m_tempo_table.get( i );
if ( item.Clock < clock ) {
double init = item.Time;
int dclock = clock - item.Clock;
double sec_per_clock1 = item.Tempo * 1e-6 / 480.0;
return init + dclock * sec_per_clock1;
}
}
@ -283,24 +417,46 @@ namespace Boare.Lib.Vsq{
}
public void write( String file ) {
StreamWriter sw = new StreamWriter( file, false, Encoding.GetEncoding( "Shift_JIS" ) );
sw.WriteLine( "[#SETTING]" );
sw.WriteLine( "Tempo=" + m_tempo );
sw.WriteLine( "Tracks=1" );
sw.WriteLine( "ProjectName=" + m_project_name );
sw.WriteLine( "VoiceDir=" + m_voice_dir );
sw.WriteLine( "OutFile=" + m_out_file );
sw.WriteLine( "CacheDir=" + m_cache_dir );
sw.WriteLine( "Tool1=" + m_tool1 );
sw.WriteLine( "Tool2=" + m_tool2 );
for ( int i = 0; i < m_tracks.get( 0 ).getEventCount(); i++ ) {
m_tracks.get( 0 ).getEvent( i ).print( sw );
BufferedWriter sw = null;
try {
sw = new BufferedWriter( new OutputStreamWriter( new FileOutputStream( file ), "Shift_JIS" ) );
sw.write( "[#SETTING]" );
sw.newLine();
sw.write( "Tempo=" + m_tempo );
sw.newLine();
sw.write( "Tracks=1" );
sw.newLine();
sw.write( "ProjectName=" + m_project_name );
sw.newLine();
sw.write( "VoiceDir=" + m_voice_dir );
sw.newLine();
sw.write( "OutFile=" + m_out_file );
sw.newLine();
sw.write( "CacheDir=" + m_cache_dir );
sw.newLine();
sw.write( "Tool1=" + m_tool1 );
sw.newLine();
sw.write( "Tool2=" + m_tool2 );
sw.newLine();
UstTrack target = m_tracks.get( 0 );
int count = target.getEventCount();
for ( int i = 0; i < count; i++ ) {
target.getEvent( i ).print( sw );
}
sw.write( "[#TRACKEND]" );
sw.newLine();
} catch ( Exception ex ) {
} finally {
if ( sw != null ) {
try {
sw.close();
} catch ( Exception ex2 ) {
}
}
}
sw.WriteLine( "[#TRACKEND]" );
sw.Close();
}
public object Clone(){
public Object clone() {
UstFile ret = new UstFile();
ret.m_tempo = m_tempo;
ret.m_project_name = m_project_name;
@ -310,14 +466,22 @@ namespace Boare.Lib.Vsq{
ret.m_tool1 = m_tool1;
ret.m_tool2 = m_tool2;
for ( int i = 0; i < m_tracks.size(); i++ ) {
ret.m_tracks.set( i, (UstTrack)m_tracks.get( i ).Clone() );
ret.m_tracks.set( i, (UstTrack)m_tracks.get( i ).clone() );
}
ret.m_tempo_table = new Vector<TempoTableEntry>();
for ( int i = 0; i < m_tempo_table.size(); i++ ) {
ret.m_tempo_table.add( (TempoTableEntry)m_tempo_table.get( i ).Clone() );
ret.m_tempo_table.add( (TempoTableEntry)m_tempo_table.get( i ).clone() );
}
return ret;
}
#if !JAVA
public object Clone() {
return clone();
}
#endif
}
#if !JAVA
}
#endif

View File

@ -11,59 +11,82 @@
* 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.IO;
#if JAVA
package org.kbinani.vsq;
import java.util.*;
import java.io.*;
import org.kbinani.*;
#else
using System;
using bocoree;
using bocoree.java.util;
using bocoree.java.io;
namespace Boare.Lib.Vsq {
#endif
#if JAVA
public class UstPortamento implements Cloneable, Serializable {
#else
[Serializable]
public class UstPortamento : ICloneable {
#endif
public Vector<UstPortamentoPoint> Points = new Vector<UstPortamentoPoint>();
public int Start;
public void print( StreamWriter sw ) {
public void print( BufferedWriter sw )
#if JAVA
throws IOException
#endif
{
String pbw = "";
String pby = "";
String pbm = "";
for ( int i = 0; i < Points.size(); i++ ) {
int count = Points.size();
for ( int i = 0; i < count; i++ ) {
String comma = (i == 0 ? "" : ",");
pbw += comma + Points.get( i ).Step;
pby += comma + Points.get( i ).Value;
String type = "";
switch ( Points.get( i ).Type ) {
case UstPortamentoType.S:
UstPortamentoType ut = Points.get( i ).Type;
if ( ut == UstPortamentoType.S ) {
type = "";
break;
case UstPortamentoType.Linear:
} else if ( ut == UstPortamentoType.Linear ) {
type = "s";
break;
case UstPortamentoType.R:
} else if ( ut == UstPortamentoType.R ) {
type = "r";
break;
case UstPortamentoType.J:
} else if ( ut == UstPortamentoType.J ) {
type = "j";
break;
}
pbm += comma + type;
}
sw.WriteLine( "PBW=" + pbw );
sw.WriteLine( "PBS=" + Start );
sw.WriteLine( "PBY=" + pby );
sw.WriteLine( "PBM=" + pbm );
sw.write( "PBW=" + pbw );
sw.newLine();
sw.write( "PBS=" + Start );
sw.newLine();
sw.write( "PBY=" + pby );
sw.newLine();
sw.write( "PBM=" + pbm );
sw.newLine();
}
public object Clone() {
public Object clone() {
UstPortamento ret = new UstPortamento();
for ( int i = 0; i < Points.size(); i++ ) {
int count = Points.size();
for ( int i = 0; i < count; i++ ) {
ret.Points.add( Points.get( i ) );
}
ret.Start = Start;
return ret;
}
#if !JAVA
public object Clone() {
return clone();
}
#endif
/*
PBW=50,50,46,48,56,50,50,50,50
PBS=-87
@ -72,20 +95,20 @@ namespace Boare.Lib.Vsq {
*/
public void ParseLine( String line ) {
line = line.ToLower();
String[] spl = line.Split( '=' );
String[] spl = PortUtil.splitString( line, '=' );
if ( spl.Length == 0 ) {
return;
}
String[] values = spl[1].Split( ',' );
String[] values = PortUtil.splitString( spl[1], ',' );
if ( line.StartsWith( "pbs=" ) ) {
Start = int.Parse( values[0] );
Start = PortUtil.parseInt( values[0] );
} else if ( line.StartsWith( "pbw=" ) ) {
for ( int i = 0; i < values.Length; i++ ) {
if ( i >= Points.size() ) {
Points.add( new UstPortamentoPoint() );
}
UstPortamentoPoint up = Points.get( i );
up.Step = int.Parse( values[i] );
up.Step = PortUtil.parseInt( values[i] );
Points.set( i, up );
}
} else if ( line.StartsWith( "pby=" ) ) {
@ -94,7 +117,7 @@ namespace Boare.Lib.Vsq {
Points.add( new UstPortamentoPoint() );
}
UstPortamentoPoint up = Points.get( i );
up.Value = float.Parse( values[i] );
up.Value = PortUtil.parseFloat( values[i] );
Points.set( i, up );
}
} else if ( line.StartsWith( "pbm=" ) ) {
@ -103,19 +126,15 @@ namespace Boare.Lib.Vsq {
Points.add( new UstPortamentoPoint() );
}
UstPortamentoPoint up = Points.get( i );
switch ( values[i].ToLower() ) {
case "s":
String search = values[i].ToLower();
if ( search.Equals( "s" ) ) {
up.Type = UstPortamentoType.Linear;
break;
case "r":
} else if ( search.Equals( "r" ) ) {
up.Type = UstPortamentoType.R;
break;
case "j":
} else if ( search.Equals( "j" ) ) {
up.Type = UstPortamentoType.J;
break;
default:
} else {
up.Type = UstPortamentoType.S;
break;
}
Points.set( i, up );
}
@ -125,29 +144,6 @@ namespace Boare.Lib.Vsq {
}
}
public struct UstPortamentoPoint {
public int Step;
public float Value;
public UstPortamentoType Type;
}
public enum UstPortamentoType{
/// <summary>
/// S型表記は''(空文字)
/// </summary>
S,
/// <summary>
/// 直線型.表記は's'
/// </summary>
Linear,
/// <summary>
/// R型表記は'r'
/// </summary>
R,
/// <summary>
/// J型表記は'j'
/// </summary>
J,
}
#if !JAVA
}
#endif

View File

@ -0,0 +1,28 @@
/*
* UstPortamentoPoint.cs
* Copyright (c) 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.
*/
#if JAVA
package org.kbinani.vsq;
#else
namespace Boare.Lib.Vsq {
#endif
public struct UstPortamentoPoint {
public int Step;
public float Value;
public UstPortamentoType Type;
}
#if !JAVA
}
#endif

View File

@ -0,0 +1,41 @@
/*
* UstPortamentoType.cs
* Copyright (c) 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.
*/
#if JAVA
package org.kbinani.vsq;
#else
namespace Boare.Lib.Vsq {
#endif
public enum UstPortamentoType {
/// <summary>
/// S型表記は''(空文字)
/// </summary>
S,
/// <summary>
/// 直線型.表記は's'
/// </summary>
Linear,
/// <summary>
/// R型表記は'r'
/// </summary>
R,
/// <summary>
/// J型表記は'j'
/// </summary>
J,
}
#if !JAVA
}
#endif

View File

@ -11,18 +11,27 @@
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*/
#if JAVA
package org.kbinani.vsq;
import java.util.*;
#else
using System;
using System.Collections.Generic;
using bocoree;
using bocoree.java.util;
namespace Boare.Lib.Vsq{
namespace Boare.Lib.Vsq {
#endif
#if JAVA
public class UstTrack implements Cloneable {
#else
public class UstTrack : ICloneable {
public object Tag;
#endif
public Object Tag;
private Vector<UstEvent> m_events;
public UstTrack(){
public UstTrack() {
m_events = new Vector<UstEvent>();
}
@ -38,7 +47,7 @@ namespace Boare.Lib.Vsq{
m_events.add( item );
}
public void removeEvent( int index ) {
public void removeEventAt( int index ) {
m_events.removeElementAt( index );
}
@ -47,16 +56,29 @@ namespace Boare.Lib.Vsq{
}
public Iterator getNoteEventIterator() {
#if JAVA
return m_events.iterator();
#else
return new ListIterator<UstEvent>( m_events );
#endif
}
public object Clone() {
public Object clone() {
UstTrack ret = new UstTrack();
for ( int i = 0; i < m_events.size(); i++ ) {
ret.m_events.set( i, (UstEvent)m_events.get( i ).Clone() );
int c = m_events.size();
for ( int i = 0; i < c; i++ ) {
ret.m_events.set( i, (UstEvent)m_events.get( i ).clone() );
}
return ret;
}
#if !JAVA
public object Clone() {
return clone();
}
#endif
}
#if !JAVA
}
#endif

View File

@ -11,14 +11,24 @@
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*/
using System;
#if JAVA
package org.kbinani.vsq;
import java.io.*;
import org.kbinani.*;
#else
using System;
using bocoree;
namespace Boare.Lib.Vsq {
#endif
#if JAVA
public class UstVibrato implements Cloneable, Serializable {
#else
[Serializable]
public class UstVibrato : ICloneable {
#endif
/// <summary>
/// 音符の長さに対する、パーセントで表したビブラートの長さ。
/// </summary>
@ -51,18 +61,18 @@ namespace Boare.Lib.Vsq {
public UstVibrato( String line ) {
if ( line.ToLower().StartsWith( "vbr=" ) ) {
String[] spl = line.Split( '=' );
spl = spl[1].Split( ',' );
String[] spl = PortUtil.splitString( line, '=' );
spl = PortUtil.splitString( spl[1], ',' );
//VBR=65,180,70,20.0,17.6,82.8,49.8,100
if ( spl.Length >= 8 ) {
Length = float.Parse( spl[0] );
Period = float.Parse( spl[1] );
Depth = float.Parse( spl[2] );
In = float.Parse( spl[3] );
Out = float.Parse( spl[4] );
Phase = float.Parse( spl[5] );
Shift = float.Parse( spl[6] );
Unknown = float.Parse( spl[7] );
Length = PortUtil.parseFloat( spl[0] );
Period = PortUtil.parseFloat( spl[1] );
Depth = PortUtil.parseFloat( spl[2] );
In = PortUtil.parseFloat( spl[3] );
Out = PortUtil.parseFloat( spl[4] );
Phase = PortUtil.parseFloat( spl[5] );
Shift = PortUtil.parseFloat( spl[6] );
Unknown = PortUtil.parseFloat( spl[7] );
}
}
}
@ -70,13 +80,27 @@ namespace Boare.Lib.Vsq {
public UstVibrato() {
}
public override String ToString() {
public float getLength() {
return Length;
}
public void setLength( float value ) {
Length = value;
}
#if !JAVA
public override string ToString() {
return toString();
}
#endif
public String toString() {
return "VBR=" + Length + "," + Period + "," + Depth + "," + In + "," + Out + "," + Phase + "," + Shift + "," + Unknown;
}
public object Clone() {
public Object clone() {
UstVibrato ret = new UstVibrato();
ret.Length = Length;
ret.setLength( Length );
ret.Period = Period;
ret.Depth = Depth;
ret.In = In;
@ -86,6 +110,14 @@ namespace Boare.Lib.Vsq {
ret.Unknown = Unknown;
return ret;
}
#if !JAVA
public object Clone() {
return clone();
}
#endif
}
#if !JAVA
}
#endif

View File

@ -11,27 +11,50 @@
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*/
using System;
using System.Collections.Generic;
#if JAVA
package org.kbinani.vsq;
import java.util.*;
import java.io.*;
import org.kbinani.*;
#else
using System;
using bocoree;
using bocoree.java.util;
namespace Boare.Lib.Vsq {
#endif
#if JAVA
public class VibratoBPList implements Cloneable, Serializable {
#else
[Serializable]
public class VibratoBPList : ICloneable {
#endif
private Vector<VibratoBPPair> m_list;
public VibratoBPList() {
m_list = new Vector<VibratoBPPair>();
}
public VibratoBPList( float[] x, int[] y ){
if ( x == null ){
public VibratoBPList( float[] x, int[] y )
#if JAVA
throws NullPointerException
#endif
{
if ( x == null ) {
#if JAVA
throw new NullPointerException( "x" );
#else
throw new ArgumentNullException( "x" );
#endif
}
if ( y == null ){
if ( y == null ) {
#if JAVA
throw new NullPointerException( "y" );
#else
throw new ArgumentNullException( "y" );
#endif
}
int len = Math.Min( x.Length, y.Length );
m_list = new Vector<VibratoBPPair>( len );
@ -46,7 +69,8 @@ namespace Boare.Lib.Vsq {
return default_value;
}
int index = -1;
for ( int i = 0; i < m_list.size(); i++ ) {
int size = m_list.size();
for ( int i = 0; i < size; i++ ) {
if ( x < m_list.get( i ).X ) {
break;
}
@ -59,7 +83,7 @@ namespace Boare.Lib.Vsq {
}
}
public object Clone() {
public Object clone() {
VibratoBPList ret = new VibratoBPList();
for ( int i = 0; i < m_list.size(); i++ ) {
ret.m_list.add( new VibratoBPPair( m_list.get( i ).X, m_list.get( i ).Y ) );
@ -67,6 +91,12 @@ namespace Boare.Lib.Vsq {
return ret;
}
#if !JAVA
public object Clone() {
return clone();
}
#endif
public int getCount() {
return m_list.size();
}
@ -79,29 +109,41 @@ namespace Boare.Lib.Vsq {
m_list.set( index, value );
}
#if !JAVA
/// <summary>
/// XMLシリアライズ用
/// </summary>
public String Data {
get {
return getData();
}
set {
setData( value );
}
}
#endif
public String getData() {
String ret = "";
for ( int i = 0; i < m_list.size(); i++ ) {
ret += (i == 0 ? "" : ",") + m_list.get( i ).X + "=" + m_list.get( i ).Y;
}
return ret;
}
set {
public void setData( String value ) {
m_list.clear();
String[] spl = value.Split( ',' );
String[] spl = PortUtil.splitString( value, ',' );
for ( int i = 0; i < spl.Length; i++ ) {
String[] spl2 = spl[i].Split( '=' );
String[] spl2 = PortUtil.splitString( spl[i], '=' );
if ( spl2.Length < 2 ) {
continue;
}
m_list.add( new VibratoBPPair( float.Parse( spl2[0] ), int.Parse( spl2[1] ) ) );
}
m_list.add( new VibratoBPPair( PortUtil.parseFloat( spl2[0] ), PortUtil.parseInt( spl2[1] ) ) );
}
}
}
#if !JAVA
}
#endif

View File

@ -11,12 +11,22 @@
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*/
#if JAVA
package org.kbinani.vsq;
import java.io.*;
#else
using System;
namespace Boare.Lib.Vsq {
#endif
#if JAVA
public class VibratoBPPair implements Comparable<VibratoBPPair>, Serializable {
#else
[Serializable]
public class VibratoBPPair : IComparable<VibratoBPPair> {
#endif
public float X;
public int Y;
@ -28,7 +38,7 @@ namespace Boare.Lib.Vsq {
Y = y;
}
public int CompareTo( VibratoBPPair item ) {
public int compareTo( VibratoBPPair item ) {
float v = X - item.X;
if ( v > 0.0f ) {
return 1;
@ -37,6 +47,14 @@ namespace Boare.Lib.Vsq {
}
return 0;
}
#if !JAVA
public int CompareTo( VibratoBPPair item ) {
return compareTo( item );
}
#endif
}
#if !JAVA
}
#endif

View File

@ -11,12 +11,18 @@
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*/
using System;
using System.IO;
#if JAVA
package org.kbinani.vsq;
import java.io.*;
import org.kbinani.*;
#else
using System;
using bocoree;
using bocoree.java.io;
namespace Boare.Lib.Vsq {
#endif
public class VibratoConfig {
public int number;
@ -25,12 +31,22 @@ namespace Boare.Lib.Vsq {
public String vendor;
public VibratoHandle contents;
public override String ToString() {
if ( contents == null ) {
return base.ToString();
} else {
return contents.Caption;
}
}
public VibratoConfig() {
contents = new VibratoHandle();
}
public void parseAic( String aic_file ) {
using ( StreamReader sr = new StreamReader( aic_file ) ) {
BufferedReader sr = null;
try {
sr = new BufferedReader( new FileReader( aic_file ) );
String line;
String current_entry = "";
String articulation = "";
@ -40,7 +56,7 @@ namespace Boare.Lib.Vsq {
String rate_bpy = "";
int depth_bpnum = 0;
int rate_bpnum = 0;
while ( (line = sr.ReadLine()) != null ) {
while ( (line = sr.readLine()) != null ) {
if ( line.StartsWith( "[" ) ) {
current_entry = line;
continue;
@ -48,7 +64,7 @@ namespace Boare.Lib.Vsq {
continue;
}
String[] spl = line.Split( new char[] { '=' }, StringSplitOptions.RemoveEmptyEntries );
String[] spl = PortUtil.splitString( line, new char[] { '=' }, true );
if ( spl.Length < 2 ) {
continue;
}
@ -61,28 +77,33 @@ namespace Boare.Lib.Vsq {
} else if ( current_entry.Equals( "[Parameter]" ) ) {
if ( spl[0].Equals( "Length" ) ) {
try {
this.contents.Length = int.Parse( spl[1] );
} catch { }
this.contents.setLength( PortUtil.parseInt( spl[1] ) );
} catch ( Exception ex0 ) {
}
} else if ( spl[0].Equals( "StartDepth" ) ) {
try {
this.contents.StartDepth = int.Parse( spl[1] );
} catch { }
this.contents.StartDepth = PortUtil.parseInt( spl[1] );
} catch ( Exception ex0 ) {
}
} else if ( spl[0].Equals( "DepthBPNum" ) ) {
try {
depth_bpnum = int.Parse( spl[1] );
} catch { }
depth_bpnum = PortUtil.parseInt( spl[1] );
} catch ( Exception ex0 ) {
}
} else if ( spl[0].Equals( "DepthBPX" ) ) {
depth_bpx = spl[1];
} else if ( spl[0].Equals( "DepthBPY" ) ) {
depth_bpy = spl[1];
} else if ( spl[0].Equals( "StartRate" ) ) {
try {
this.contents.StartRate = int.Parse( spl[1] );
} catch { }
this.contents.StartRate = PortUtil.parseInt( spl[1] );
} catch ( Exception ex0 ) {
}
} else if ( spl[0].Equals( "RateBPNum" ) ) {
try {
rate_bpnum = int.Parse( spl[1] );
} catch { }
rate_bpnum = PortUtil.parseInt( spl[1] );
} catch ( Exception ex0 ) {
}
} else if ( spl[0].Equals( "RateBPX" ) ) {
rate_bpx = spl[1];
} else if ( spl[0].Equals( "RateBPY" ) ) {
@ -90,45 +111,57 @@ namespace Boare.Lib.Vsq {
}
}
}
if ( articulation != "Vibrato" ) {
if ( !articulation.Equals( "Vibrato" ) ) {
return;
}
// depth bp
if ( depth_bpnum > 0 && depth_bpx != "" && depth_bpy != "" ) {
String[] bpx = depth_bpx.Split( ',' );
String[] bpy = depth_bpy.Split( ',' );
if ( depth_bpnum > 0 && !depth_bpx.Equals( "" ) && !depth_bpy.Equals( "" ) ) {
String[] bpx = PortUtil.splitString( depth_bpx, ',' );
String[] bpy = PortUtil.splitString( depth_bpy, ',' );
if ( depth_bpnum == bpx.Length && depth_bpnum == bpy.Length ) {
float[] x = new float[depth_bpnum];
int[] y = new int[depth_bpnum];
try {
for ( int i = 0; i < depth_bpnum; i++ ) {
x[i] = float.Parse( bpx[i] );
y[i] = int.Parse( bpy[i] );
x[i] = PortUtil.parseFloat( bpx[i] );
y[i] = PortUtil.parseInt( bpy[i] );
}
this.contents.DepthBP = new VibratoBPList( x, y );
} catch { }
} catch ( Exception ex0 ) {
}
}
}
// rate bp
if ( rate_bpnum > 0 && rate_bpx != "" && rate_bpy != "" ) {
String[] bpx = rate_bpx.Split( ',' );
String[] bpy = rate_bpy.Split( ',' );
if ( rate_bpnum > 0 && !rate_bpx.Equals( "" ) && !rate_bpy.Equals( "" ) ) {
String[] bpx = PortUtil.splitString( rate_bpx, ',' );
String[] bpy = PortUtil.splitString( rate_bpy, ',' );
if ( rate_bpnum == bpx.Length && rate_bpnum == bpy.Length ) {
float[] x = new float[rate_bpnum];
int[] y = new int[rate_bpnum];
try {
for ( int i = 0; i < rate_bpnum; i++ ) {
x[i] = float.Parse( bpx[i] );
y[i] = int.Parse( bpy[i] );
x[i] = PortUtil.parseFloat( bpx[i] );
y[i] = PortUtil.parseInt( bpy[i] );
}
this.contents.RateBP = new VibratoBPList( x, y );
} catch { }
} catch ( Exception ex0 ) {
}
}
}
} catch ( Exception ex ) {
} finally {
if ( sr != null ) {
try {
sr.close();
} catch ( Exception ex2 ) {
}
}
}
}
}
#if !JAVA
}
#endif

View File

@ -0,0 +1,104 @@
/*
* VibratoHandle.cs
* Copyright (c) 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.
*/
#if JAVA
package org.kbinani.vsq;
import java.io.*;
#else
using System;
namespace Boare.Lib.Vsq {
#endif
#if JAVA
public class VibratoHandle implements Cloneable, Serializable {
#else
[Serializable]
public class VibratoHandle : ICloneable {
#endif
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() {
StartRate = 64;
StartDepth = 64;
RateBP = new VibratoBPList();
DepthBP = new VibratoBPList();
}
public int getLength() {
return Length;
}
public void setLength( int value ) {
Length = value;
}
public String getDisplayString() {
String s = IDS;
if ( !Caption.Equals( "" ) ) {
s += " (" + Caption + ")";
}
return s;
}
#if !JAVA
public object Clone() {
return clone();
}
#endif
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.setLength( 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.setLength( Length );
ret.StartDepth = StartDepth;
ret.StartRate = StartRate;
ret.DepthBP = (VibratoBPList)DepthBP.clone();
ret.RateBP = (VibratoBPList)RateBP.clone();
return ret;
}
}
#if !JAVA
}
#endif

File diff suppressed because it is too large Load Diff

View File

@ -11,65 +11,89 @@
* 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;
#if JAVA
package org.kbinani.vsq;
import java.util.*;
import java.io.*;
import org.kbinani.*;
#else
using System;
using bocoree;
using bocoree.java.io;
using bocoree.java.util;
namespace Boare.Lib.Vsq {
using boolean = System.Boolean;
using Integer = System.Int32;
#endif
/// <summary>
/// BPListのデータ部分を取り扱うためのクラス。
/// </summary>
#if JAVA
public class VsqBPList implements Cloneable, Serializable{
#else
[Serializable]
public class VsqBPList : ICloneable {
private SortedList<int, VsqBPPair> m_list = new SortedList<int, VsqBPPair>();
#endif
private Vector<Integer> m_clock = new Vector<Integer>();
private Vector<VsqBPPair> m_items = new Vector<VsqBPPair>();
private int m_default = 0;
private int m_maximum = 127;
private int m_minimum = 0;
/// <summary>
/// このリストに設定されたidの最大値次にデータ点が追加されたときは個の値+1がidとして利用される削除された場合でも減らない
/// </summary>
private int m_max_id = 0;
private long m_max_id = 0;
private class KeyClockIterator : Iterator {
private SortedList<int, VsqBPPair> m_list;
class KeyClockIterator : Iterator {
private VsqBPList m_list;
private int m_pos;
public KeyClockIterator( SortedList<int, VsqBPPair> list ) {
public KeyClockIterator( VsqBPList list ) {
m_list = list;
m_pos = -1;
}
public boolean hasNext() {
if ( m_pos + 1 < m_list.Keys.Count ) {
if ( m_pos + 1 < m_list.m_clock.size() ) {
return true;
} else {
return false;
}
}
public object next() {
public Object next() {
m_pos++;
return m_list.Keys[m_pos];
return m_list.m_clock.get( m_pos );
}
public void remove() {
if ( 0 <= m_pos && m_pos < m_list.Keys.Count ) {
int key = m_list.Keys[m_pos];
m_list.Remove( key );
if ( 0 <= m_pos && m_pos < m_list.m_clock.size() ) {
int key = m_list.m_clock.get( m_pos );
m_list.m_clock.removeElementAt( m_pos );
m_list.m_items.removeElementAt( m_pos );
}
}
}
/// <summary>
/// コンストラクタ。デフォルト値はココで指定する。
/// </summary>
/// <param name="default_value"></param>
public VsqBPList( int default_value, int minimum, int maximum ) {
m_default = default_value;
m_maximum = maximum;
m_minimum = minimum;
m_max_id = 0;
}
#if JAVA
public VsqBPList(){
this( 0, 0, 64 );
#else
public VsqBPList()
: this( 0, 0, 64 ) {
#endif
}
#if !JAVA
public int Default {
get {
return getDefault();
@ -78,6 +102,11 @@ namespace Boare.Lib.Vsq {
setDefault( value );
}
}
#endif
public long getMaxID() {
return m_max_id;
}
/// <summary>
/// このBPListのデフォルト値を取得します
@ -96,76 +125,90 @@ namespace Boare.Lib.Vsq {
/// </summary>
public void renumberIDs() {
m_max_id = 0;
for ( Iterator itr = keyClockIterator(); itr.hasNext(); ) {
VsqBPPair item = (VsqBPPair)itr.next();
int count = m_items.size();
for ( int i = 0; i < count; i++ ) {
m_max_id++;
item.id = m_max_id;
VsqBPPair v = m_items.get( i );
v.id = m_max_id;
m_items.set( i, v );
}
}
#if !JAVA
/// <summary>
/// XMLシリアライズ用
/// </summary>
public String Data {
get {
return getData();
}
set {
setData( value );
}
}
#endif
public String getData() {
String ret = "";
int count = -1;
foreach ( int key in m_list.Keys ) {
int size = m_clock.size();
for ( int i = 0; i < size; i++ ) {
count++;
ret += (count == 0 ? "" : "," ) + key + "=" + m_list[key].value;
ret += (count == 0 ? "" : ",") + m_clock.get( i ) + "=" + m_items.get( i ).value;
}
return ret;
}
set {
m_list.Clear();
public void setData( String value ) {
m_clock.clear();
m_items.clear();
m_max_id = 0;
String[] spl = value.Split( ',' );
String[] spl = PortUtil.splitString( value, ',' );
for ( int i = 0; i < spl.Length; i++ ) {
String[] spl2 = spl[i].Split( '=' );
String[] spl2 = PortUtil.splitString( spl[i], '=' );
if ( spl2.Length < 2 ) {
continue;
}
try {
m_list.Add( int.Parse( spl2[0] ), new VsqBPPair( int.Parse( spl2[1] ), m_max_id + 1 ) );
int clock = PortUtil.parseInt( spl2[0] );
m_clock.add( clock );
m_items.add( new VsqBPPair( PortUtil.parseInt( spl2[1] ), m_max_id + 1 ) );
m_max_id++;
} catch ( Exception ex ) {
#if DEBUG
Console.WriteLine( " ex=" + ex );
Console.WriteLine( " i=" + i + "; spl2[0]=" + spl2[0] + "; spl2[1]=" + spl2[1] );
PortUtil.println( " ex=" + ex );
PortUtil.println( " i=" + i + "; spl2[0]=" + spl2[0] + "; spl2[1]=" + spl2[1] );
#endif
}
}
}
}
/// <summary>
/// このVsqBPListの同一コピーを作成します
/// </summary>
/// <returns></returns>
public Object clone() {
VsqBPList res = new VsqBPList( getDefault(), getMinimum(), getMaximum() );
foreach ( int key in m_list.Keys ) {
res.m_list.Add( key, m_list[key] );
VsqBPList res = new VsqBPList( m_default, m_minimum, m_maximum );
int count = m_clock.size();
for ( int i = 0; i < count; i++ ) {
res.m_clock.add( m_clock.get( i ) );
#if JAVA
res.m_items.add( (VsqBPPair)m_items.get( i ).clone() );
#else
res.m_items.add( m_items.get( i ) );
#endif
}
res.m_max_id = m_max_id;
return res;
}
#if !JAVA
public object Clone() {
return clone();
}
#endif
/// <summary>
/// コンストラクタ。デフォルト値はココで指定する。
/// </summary>
/// <param name="default_value"></param>
public VsqBPList( int default_value, int minimum, int maximum ) {
m_default = default_value;
m_maximum = maximum;
m_minimum = minimum;
m_max_id = 0;
}
#if !JAVA
public int Maximum {
get {
return getMaximum();
@ -174,6 +217,7 @@ namespace Boare.Lib.Vsq {
setMaximum( value );
}
}
#endif
/// <summary>
/// このリストに設定された最大値を取得します。
@ -182,10 +226,11 @@ namespace Boare.Lib.Vsq {
return m_maximum;
}
public void setMaximum( int value ){
public void setMaximum( int value ) {
m_maximum = value;
}
#if !JAVA
public int Minimum {
get {
return getMinimum();
@ -194,6 +239,7 @@ namespace Boare.Lib.Vsq {
setMinimum( value );
}
}
#endif
/// <summary>
/// このリストに設定された最小値を取得します
@ -206,31 +252,29 @@ namespace Boare.Lib.Vsq {
m_minimum = value;
}
public Iterator keyClockIterator() {
return new KeyClockIterator( m_list );
public void remove( int clock ) {
int index = m_clock.indexOf( clock );
removeElementAt( index );
}
public void remove( int clock ) {
if ( m_list.ContainsKey( clock ) ) {
m_list.Remove( clock );
public void removeElementAt( int index ) {
if ( index >= 0 ) {
m_clock.removeElementAt( index );
m_items.removeElementAt( index );
}
}
public boolean isContainsKey( int clock ) {
return m_list.ContainsKey( clock );
return m_clock.contains( clock );
}
public int size() {
return m_list.Count;
}
public int[] getKeys() {
Vector<int> t = new Vector<int>();
/* public int[] getKeys() {
Vector<Integer> t = new Vector<Integer>();
foreach( int key in m_list.Keys ){
t.add( key );
}
return t.toArray( new Int32[]{} );
}
return t.toArray( new Integer[]{} );
}*/
/// <summary>
/// 時刻clockのデータを時刻new_clockに移動します。
@ -240,46 +284,30 @@ namespace Boare.Lib.Vsq {
/// <param name="clock"></param>
/// <param name="new_clock"></param>
public void move( int clock, int new_clock, int new_value ) {
if ( !m_list.ContainsKey( clock ) ) {
int index = m_clock.indexOf( clock );
if ( index < 0 ) {
return;
}
VsqBPPair item = m_list[clock];
m_list.Remove( clock );
if ( m_list.ContainsKey( new_clock ) ) {
m_list.Remove( new_clock );
}
VsqBPPair item = m_items.get( index );
m_clock.removeElementAt( index );
m_items.removeElementAt( index );
int index_new = m_clock.indexOf( new_clock );
if ( index_new >= 0 ) {
item.value = new_value;
m_list.Add( new_clock, item );
m_items.set( index_new, item );
return;
} else {
m_clock.add( new_clock );
Collections.sort( m_clock );
index_new = m_clock.indexOf( new_clock );
item.value = new_value;
m_items.insertElementAt( item, index_new );
}
}
public void clear() {
m_list.Clear();
}
/// <summary>
/// 新しいデータ点を追加します。
/// 戻り値に、新しいデータ点のIDを返します
/// </summary>
/// <param name="clock"></param>
/// <param name="value"></param>
/// <returns></returns>
public long add( int clock, int value ) {
lock ( m_list ) {
if ( m_list.ContainsKey( clock ) ) {
VsqBPPair v = m_list[clock];
v.value = value;
m_list[clock] = v;
return v.id;
} else {
VsqBPPair v = new VsqBPPair( value, m_max_id + 1 );
m_max_id++;
#if DEBUG
//Console.WriteLine( "VsqBPList#add; m_max_id=" + m_max_id );
#endif
m_list.Add( clock, v );
return m_max_id;
}
}
m_clock.clear();
m_items.clear();
}
public int getElement( int index ) {
@ -287,22 +315,23 @@ namespace Boare.Lib.Vsq {
}
public int getElementA( int index ) {
return m_list[m_list.Keys[index]].value;
return m_items.get( index ).value;
}
public VsqBPPair getElementB( int index ) {
return m_list[m_list.Keys[index]];
return m_items.get( index );
}
public int getKeyClock( int index ) {
return m_list.Keys[index];
return m_clock.get( index );
}
public int findValueFromID( long id ) {
int c = m_list.Keys.Count;
foreach ( int key in m_list.Keys ) {
if ( m_list[key].id == id ) {
return m_list[key].value;
int c = m_items.size();
for ( int i = 0; i < c; i++ ) {
VsqBPPair item = m_items.get( i );
if ( item.id == id ) {
return item.value;
}
}
return m_default;
@ -315,12 +344,11 @@ namespace Boare.Lib.Vsq {
/// <returns></returns>
public VsqBPPairSearchContext findElement( long id ) {
VsqBPPairSearchContext context = new VsqBPPairSearchContext();
int c = m_list.Keys.Count;
int c = m_items.size();
for ( int i = 0; i < c; i++ ) {
int clock = m_list.Keys[i];
VsqBPPair item = m_list[clock];
VsqBPPair item = m_items.get( i );
if ( item.id == id ) {
context.clock = clock;
context.clock = m_clock.get( i );
context.index = i;
context.point = item;
return context;
@ -333,94 +361,82 @@ namespace Boare.Lib.Vsq {
}
public void setValueForID( long id, int value ) {
int c = m_list.Keys.Count;
foreach ( int key in m_list.Keys ) {
if ( m_list[key].id == id ) {
VsqBPPair v = m_list[key];
v.value = value;
m_list[key] = v;
int c = m_items.size();
for ( int i = 0; i < c; i++ ) {
VsqBPPair item = m_items.get( i );
if ( item.id == id ) {
item.value = value;
m_items.set( i, item );
break;
}
}
}
public int getValue( int clock, ref int index ) {
if ( m_list.Count == 0 ) {
public int getValue( int clock, ByRef<Integer> index ) {
int count = m_clock.size();
if ( count == 0 ) {
return m_default;
} else {
if ( index < 0 ) {
index = 0;
if ( index.value < 0 ) {
index.value = 0;
}
for ( int i = index ; i < m_list.Keys.Count; i++ ) {
int keyclock = m_list.Keys[i];
for ( int i = index.value; i < count; i++ ) {
int keyclock = m_clock.get( i );
if ( clock < keyclock ) {
if ( i > 0 ) {
index = i;
return m_list[m_list.Keys[i - 1]].value;
index.value = i;
return m_items.get( i - 1 ).value;
} else {
index = i;
index.value = i;
return m_default;
}
}
}
index = m_list.Keys.Count - 1;
return m_list[m_list.Keys[m_list.Keys.Count - 1]].value;
index.value = count - 1;
return m_items.get( count - 1 ).value;
}
}
public int getValue( int clock ) {
if ( m_list.Count == 0 ) {
return m_default;
} else {
for ( int i = 0; i < m_list.Keys.Count; i++ ) {
int keyclock = m_list.Keys[i];
if ( clock < keyclock ) {
if ( i > 0 ) {
return m_list[m_list.Keys[i - 1]].value;
} else {
return m_default;
}
}
}
return m_list[m_list.Keys[m_list.Keys.Count - 1]].value;
}
}
/// <summary>
/// このBPListの内容をテキストファイルに書き出します
/// </summary>
/// <param name="writer"></param>
public void print( StreamWriter writer ) {
boolean first = true;
foreach ( int key in m_list.Keys ) {
int val = m_list[key].value;
if ( first ) {
writer.WriteLine( key + "=" + val );
first = false;
} else {
writer.WriteLine( key + "=" + val );
}
}
}
/// <summary>
/// このBPListの内容をテキストファイルに書き出します
/// </summary>
/// <param name="writer"></param>
public void print( TextMemoryStream writer, int start, String header ) {
boolean first = true;
foreach ( int key in m_list.Keys ) {
if ( start <= key ) {
if ( first ) {
private void printCor( ITextWriter writer, int start_clock, String header )
#if JAVA
throws IOException
#endif
{
writer.writeLine( header );
first = false;
}
int val = m_list[key].value;
int c = m_clock.size();
for ( int i = 0; i < c; i++ ) {
int key = m_clock.get( i );
if ( start_clock <= key ) {
int val = m_items.get( i ).value;
writer.writeLine( key + "=" + val );
}
}
}
/// <summary>
/// このBPListの内容をテキストファイルに書き出します
/// </summary>
/// <param name="writer"></param>
public void print( BufferedWriter writer, int start, String header )
#if JAVA
throws IOException
#endif
{
printCor( new WrappedStreamWriter( writer ), start, header );
}
/// <summary>
/// このBPListの内容をテキストファイルに書き出します
/// </summary>
/// <param name="writer"></param>
public void print( TextMemoryStream writer, int start, String header )
#if JAVA
throws IOException
#endif
{
printCor( writer, start, header );
}
/// <summary>
/// テキストファイルからデータ点を読込み、現在のリストに追加します
/// </summary>
@ -429,12 +445,10 @@ namespace Boare.Lib.Vsq {
public String appendFromText( TextMemoryStream reader ) {
String last_line = reader.readLine();
while ( !last_line.StartsWith( "[" ) ) {
String[] spl = last_line.Split( new char[] { '=' } );
int i1 = int.Parse( spl[0] );
int i2 = int.Parse( spl[1] );
VsqBPPair v = new VsqBPPair( i2, m_max_id + 1 );
m_max_id++;
m_list.Add( i1, v );
String[] spl = PortUtil.splitString( last_line, new char[] { '=' } );
int clock = PortUtil.parseInt( spl[0] );
int value = PortUtil.parseInt( spl[1] );
this.add( clock, value );
if ( reader.peek() < 0 ) {
break;
} else {
@ -443,6 +457,86 @@ namespace Boare.Lib.Vsq {
}
return last_line;
}
public int size() {
return m_clock.size();
}
public Iterator keyClockIterator() {
return new KeyClockIterator( this );
}
public long add( int clock, int value ) {
int index = m_clock.indexOf( clock );
if ( index >= 0 ) {
VsqBPPair v = m_items.get( index );
v.value = value;
m_items.set( index, v );
return v.id;
} else {
m_clock.add( clock );
Collections.sort( m_clock );
index = m_clock.indexOf( clock );
m_max_id++;
m_items.insertElementAt( new VsqBPPair( value, m_max_id ), index );
return m_max_id;
}
}
public void addWithID( int clock, int value, long id ) {
int index = m_clock.indexOf( clock );
if ( index >= 0 ) {
VsqBPPair v = m_items.get( index );
v.value = value;
v.id = id;
m_items.set( index, v );
} else {
m_clock.add( clock );
Collections.sort( m_clock );
index = m_clock.indexOf( clock );
m_items.insertElementAt( new VsqBPPair( value, id ), index );
m_max_id = Math.Max( m_max_id, id );
}
}
public void removeWithID( long id ) {
int c = m_items.size();
for ( int i = 0; i < c; i++ ) {
if ( m_items.get( i ).id == id ) {
m_items.removeElementAt( i );
m_clock.removeElementAt( i );
break;
}
}
}
public int getValue( int clock ) {
int index = m_clock.indexOf( clock );
if ( index >= 0 ) {
return m_items.get( index ).value;
} else {
int count = m_clock.size();
if ( count <= 0 ) {
return m_default;
} else {
int draft = -1;
for ( int i = 0; i < count; i++ ) {
int c = m_clock.get( i );
if ( clock < c ) {
break;
}
draft = i;
}
if ( draft < 0 ) {
return m_default;
} else {
return m_items.get( draft ).value;
}
}
}
}
}
#if !JAVA
}
#endif

View File

@ -11,12 +11,22 @@
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*/
#if JAVA
package org.kbinani.vsq;
import java.io.*;
#else
using System;
namespace Boare.Lib.Vsq {
#endif
#if JAVA
public class VsqBPPair implements Cloneable, Serializable {
#else
[Serializable]
public struct VsqBPPair {
#endif
public int value;
public long id;
@ -24,6 +34,14 @@ namespace Boare.Lib.Vsq {
value = value_;
id = id_;
}
#if JAVA
public Object clone(){
return new VsqBPPair( value, id );
}
#endif
}
#if !JAVA
}
#endif

View File

@ -1,4 +1,21 @@
namespace Boare.Lib.Vsq {
/*
* VsqBPPairSearchContext.cs
* Copyright (c) 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.
*/
#if JAVA
package org.kbinani.vsq;
#else
namespace Boare.Lib.Vsq {
#endif
public class VsqBPPairSearchContext {
public int clock;
@ -6,4 +23,6 @@
public VsqBPPair point;
}
#if !JAVA
}
#endif

View File

@ -11,11 +11,14 @@
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*/
#if JAVA
package org.kbinani.vsq;
#else
using System;
namespace Boare.Lib.Vsq {
using boolean = System.Boolean;
#endif
public struct VsqBarLineType {
private int m_clock;
@ -53,4 +56,6 @@ namespace Boare.Lib.Vsq {
}
}
#if !JAVA
}
#endif

View File

@ -11,27 +11,38 @@
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*/
#if JAVA
package org.kbinani.vsq;
import java.io.*;
import java.util.*;
import org.kbinani.*;
#else
using System;
using System.Collections.Generic;
using bocoree;
using bocoree.java.util;
namespace Boare.Lib.Vsq {
using boolean = System.Boolean;
using Integer = System.Int32;
using Long = System.Int64;
#endif
/// <summary>
///
/// </summary>
#if JAVA
public class VsqCommand implements Serializable {
#else
[Serializable]
public class VsqCommand {
#endif
public VsqCommandType Type;
/// <summary>
/// コマンドの処理内容を保持します。Args具体的な内容は、処理するクラスごとに異なります
/// </summary>
public object[] Args;
public Object[] Args;
/// <summary>
/// 後続するコマンド
/// </summary>
@ -56,25 +67,25 @@ namespace Boare.Lib.Vsq {
public static VsqCommand generateCommandReplace( VsqFile vsq ) {
VsqCommand command = new VsqCommand();
command.Args = new object[1];
command.Args = new Object[1];
command.Type = VsqCommandType.REPLACE;
command.Args[0] = (VsqFile)vsq.Clone();
command.Args[0] = (VsqFile)vsq.clone();
return command;
}
public static VsqCommand generateCommandTrackReplace( int track, VsqTrack item ) {
VsqCommand command = new VsqCommand();
command.Type = VsqCommandType.TRACK_REPLACE;
command.Args = new object[2];
command.Args = new Object[2];
command.Args[0] = track;
command.Args[1] = (VsqTrack)item.Clone();
command.Args[1] = (VsqTrack)item.clone();
return command;
}
public static VsqCommand generateCommandUpdateTimesig( int bar_count, int new_barcount, int numerator, int denominator ) {
VsqCommand command = new VsqCommand();
command.Type = VsqCommandType.UPDATE_TIMESIG;
command.Args = new object[4];
command.Args = new Object[4];
command.Args[0] = bar_count;
command.Args[1] = numerator;
command.Args[2] = denominator;
@ -85,28 +96,28 @@ namespace Boare.Lib.Vsq {
public static VsqCommand generateCommandUpdateTimesigRange( int[] bar_counts, int[] new_barcounts, int[] numerators, int[] denominators ) {
VsqCommand command = new VsqCommand();
command.Type = VsqCommandType.UPDATE_TIMESIG_RANGE;
command.Args = new object[4];
command.Args[0] = (int[])bar_counts.Clone();
command.Args[1] = (int[])numerators.Clone();
command.Args[2] = (int[])denominators.Clone();
command.Args[3] = (int[])new_barcounts.Clone();
command.Args = new Object[4];
command.Args[0] = copyIntArray( bar_counts );
command.Args[1] = copyIntArray( numerators );
command.Args[2] = copyIntArray( denominators );
command.Args[3] = copyIntArray( new_barcounts );
return command;
}
public static VsqCommand generateCommandUpdateTempoRange( int[] clocks, int[] new_clocks, int[] tempos ) {
VsqCommand command = new VsqCommand();
command.Type = VsqCommandType.UPDATE_TEMPO_RANGE;
command.Args = new object[3];
command.Args[0] = (int[])clocks.Clone();
command.Args[1] = (int[])tempos.Clone();
command.Args[2] = (int[])new_clocks.Clone();
command.Args = new Object[3];
command.Args[0] = copyIntArray( clocks );
command.Args[1] = copyIntArray( tempos );
command.Args[2] = copyIntArray( new_clocks );
return command;
}
public static VsqCommand generateCommandUpdateTempo( int clock, int new_clock, int tempo ) {
VsqCommand command = new VsqCommand();
command.Type = VsqCommandType.UPDATE_TEMPO;
command.Args = new object[3];
command.Args = new Object[3];
command.Args[0] = clock;
command.Args[1] = tempo;
command.Args[2] = new_clock;
@ -116,7 +127,7 @@ namespace Boare.Lib.Vsq {
public static VsqCommand generateCommandChangePreMeasure( int pre_measure ) {
VsqCommand command = new VsqCommand();
command.Type = VsqCommandType.CHANGE_PRE_MEASURE;
command.Args = new object[1];
command.Args = new Object[1];
command.Args[0] = pre_measure;
return command;
}
@ -124,7 +135,7 @@ namespace Boare.Lib.Vsq {
public static VsqCommand generateCommandDeleteTrack( int track ) {
VsqCommand command = new VsqCommand();
command.Type = VsqCommandType.TRACK_DELETE;
command.Args = new object[1];
command.Args = new Object[1];
command.Args[0] = track;
return command;
}
@ -137,7 +148,7 @@ namespace Boare.Lib.Vsq {
public static VsqCommand generateCommandAddTrack( VsqTrack track, VsqMixerEntry mixer, int position ) {
VsqCommand command = new VsqCommand();
command.Type = VsqCommandType.TRACK_ADD;
command.Args = new object[5];
command.Args = new Object[3];
command.Args[0] = track;
command.Args[1] = mixer;
command.Args[2] = position;
@ -153,7 +164,7 @@ namespace Boare.Lib.Vsq {
public static VsqCommand generateCommandTrackChangeName( int track, String new_name ) {
VsqCommand command = new VsqCommand();
command.Type = VsqCommandType.TRACK_CHANGE_NAME;
command.Args = new object[2];
command.Args = new Object[2];
command.Args[0] = track;
command.Args[1] = new_name;
return command;
@ -162,7 +173,7 @@ namespace Boare.Lib.Vsq {
public static VsqCommand generateCommandTrackChangePlayMode( int track, int play_mode ) {
VsqCommand command = new VsqCommand();
command.Type = VsqCommandType.TRACK_CHANGE_PLAY_MODE;
command.Args = new object[2];
command.Args = new Object[2];
command.Args[0] = track;
command.Args[1] = play_mode;
return command;
@ -180,11 +191,15 @@ namespace Boare.Lib.Vsq {
VsqCommand command = new VsqCommand();
command.Type = VsqCommandType.EVENT_CHANGE_CLOCK_AND_ID_CONTAINTS_RANGE;
int count = internal_ids.Length;
command.Args = new object[4];
command.Args = new Object[4];
command.Args[0] = track;
command.Args[1] = (int[])internal_ids.Clone();
command.Args[2] = (int[])clocks.Clone();
command.Args[3] = (VsqID[])values.Clone();
command.Args[1] = copyIntArray( internal_ids );
command.Args[2] = copyIntArray( clocks );
VsqID[] cp_values = new VsqID[values.Length];
for ( int i = 0; i < values.Length; i++ ) {
cp_values[i] = (VsqID)values[i].clone();
}
command.Args[3] = cp_values;
return command;
}
@ -199,7 +214,7 @@ namespace Boare.Lib.Vsq {
public static VsqCommand generateCommandEventChangeClockAndIDContaints( int track, int internal_id, int clock, VsqID value ) {
VsqCommand command = new VsqCommand();
command.Type = VsqCommandType.EVENT_CHANGE_CLOCK_AND_ID_CONTAINTS;
command.Args = new object[4];
command.Args = new Object[4];
command.Args[0] = track;
command.Args[1] = internal_id;
command.Args[2] = clock;
@ -217,9 +232,9 @@ namespace Boare.Lib.Vsq {
public static VsqCommand generateCommandEventChangeIDContaintsRange( int track, int[] internal_ids, VsqID[] values ) {
VsqCommand command = new VsqCommand();
command.Type = VsqCommandType.EVENT_CHANGE_ID_CONTAINTS_RANGE;
command.Args = new object[3];
command.Args = new Object[3];
command.Args[0] = track;
command.Args[1] = (int[])internal_ids.Clone();
command.Args[1] = copyIntArray( internal_ids );
VsqID[] list = new VsqID[values.Length];
for ( int i = 0; i < values.Length; i++ ) {
list[i] = (VsqID)values[i].clone();
@ -238,7 +253,7 @@ namespace Boare.Lib.Vsq {
public static VsqCommand generateCommandEventChangeIDContaints( int track, int internal_id, VsqID value ) {
VsqCommand command = new VsqCommand();
command.Type = VsqCommandType.EVENT_CHANGE_ID_CONTAINTS;
command.Args = new object[3];
command.Args = new Object[3];
command.Args[0] = track;
command.Args[1] = internal_id;
command.Args[2] = (VsqID)value.clone();
@ -256,7 +271,7 @@ namespace Boare.Lib.Vsq {
public static VsqCommand generateCommandEventChangeClockAndLength( int track, int internal_id, int new_clock, int new_length ) {
VsqCommand command = new VsqCommand();
command.Type = VsqCommandType.EVENT_CHANGE_CLOCK_AND_LENGTH;
command.Args = new object[4];
command.Args = new Object[4];
command.Args[0] = track;
command.Args[1] = internal_id;
command.Args[2] = new_clock;
@ -274,7 +289,7 @@ namespace Boare.Lib.Vsq {
public static VsqCommand generateCommandEventChangeLength( int track, int internal_id, int new_length ) {
VsqCommand command = new VsqCommand();
command.Type = VsqCommandType.EVENT_CHANGE_LENGTH;
command.Args = new object[3];
command.Args = new Object[3];
command.Args[0] = track;
command.Args[1] = internal_id;
command.Args[2] = new_length;
@ -288,15 +303,15 @@ namespace Boare.Lib.Vsq {
/// <param name="track"></param>
/// <param name="velocity"></param>
/// <returns></returns>
public static VsqCommand generateCommandEventChangeVelocity( int track, Vector<KeyValuePair<Integer, Integer>> velocity ) {
public static VsqCommand generateCommandEventChangeVelocity( int track, Vector<ValuePair<Integer, Integer>> velocity ) {
VsqCommand command = new VsqCommand();
command.Type = VsqCommandType.EVENT_CHANGE_VELOCITY;
command.Args = new object[2];
command.Args = new Object[2];
command.Args[0] = track;
Vector<KeyValuePair<Integer, Integer>> list = new Vector<KeyValuePair<Integer, Integer>>();
for( Iterator itr = velocity.iterator(); itr.hasNext(); ){
KeyValuePair<Int32, Int32> item = (KeyValuePair<Int32, Int32>)itr.next();
list.add( new KeyValuePair<Integer, Integer>( item.Key, item.Value ) );
Vector<ValuePair<Integer, Integer>> list = new Vector<ValuePair<Integer, Integer>>();
for ( Iterator itr = velocity.iterator(); itr.hasNext(); ) {
ValuePair<Integer, Integer> item = (ValuePair<Integer, Integer>)itr.next();
list.add( new ValuePair<Integer, Integer>( item.getKey(), item.getValue() ) );
}
command.Args[1] = list;
return command;
@ -305,7 +320,7 @@ namespace Boare.Lib.Vsq {
public static VsqCommand generateCommandEventReplace( int track, VsqEvent item ) {
VsqCommand command = new VsqCommand();
command.Type = VsqCommandType.EVENT_REPLACE;
command.Args = new object[2];
command.Args = new Object[2];
command.Args[0] = track;
command.Args[1] = item.clone();
return command;
@ -314,10 +329,10 @@ namespace Boare.Lib.Vsq {
public static VsqCommand generateCommandEventReplaceRange( int track, VsqEvent[] items ) {
VsqCommand command = new VsqCommand();
command.Type = VsqCommandType.EVENT_REPLACE_RANGE;
command.Args = new object[2];
command.Args = new Object[2];
command.Args[0] = track;
VsqEvent[] objs = new VsqEvent[items.Length];
for( int i = 0; i < items.Length; i++ ){
for ( int i = 0; i < items.Length; i++ ) {
objs[i] = (VsqEvent)items[i].clone();
}
command.Args[1] = objs;
@ -331,15 +346,15 @@ namespace Boare.Lib.Vsq {
/// <param name="track"></param>
/// <param name="accent_list"></param>
/// <returns></returns>
public static VsqCommand generateCommandEventChangeAccent( int track, Vector<KeyValuePair<Integer, Integer>> accent_list ) {
public static VsqCommand generateCommandEventChangeAccent( int track, Vector<ValuePair<Integer, Integer>> accent_list ) {
VsqCommand command = new VsqCommand();
command.Type = VsqCommandType.EVENT_CHANGE_ACCENT;
command.Args = new object[2];
command.Args = new Object[2];
command.Args[0] = track;
Vector<KeyValuePair<Integer, Integer>> list = new Vector<KeyValuePair<Integer, Integer>>();
for ( Iterator itr = accent_list.iterator(); itr.hasNext(); ){
KeyValuePair<Int32, Int32> item = (KeyValuePair<Int32, Int32>)itr.next();
list.add( new KeyValuePair<Integer, Integer>( item.Key, item.Value ) );
Vector<ValuePair<Integer, Integer>> list = new Vector<ValuePair<Integer, Integer>>();
for ( Iterator itr = accent_list.iterator(); itr.hasNext(); ) {
ValuePair<Integer, Integer> item = (ValuePair<Integer, Integer>)itr.next();
list.add( new ValuePair<Integer, Integer>( item.getKey(), item.getValue() ) );
}
command.Args[1] = list;
return command;
@ -352,15 +367,15 @@ namespace Boare.Lib.Vsq {
/// <param name="track"></param>
/// <param name="decay_list"></param>
/// <returns></returns>
public static VsqCommand generateCommandEventChangeDecay( int track, Vector<KeyValuePair<Integer, Integer>> decay_list ) {
public static VsqCommand generateCommandEventChangeDecay( int track, Vector<ValuePair<Integer, Integer>> decay_list ) {
VsqCommand command = new VsqCommand();
command.Type = VsqCommandType.EVENT_CHANGE_DECAY;
command.Args = new object[2];
command.Args = new Object[2];
command.Args[0] = track;
Vector<KeyValuePair<Integer, Integer>> list = new Vector<KeyValuePair<Integer, Integer>>();
for ( Iterator itr = decay_list.iterator(); itr.hasNext(); ){
KeyValuePair<Integer, Integer> item = (KeyValuePair<Integer, Integer>)itr.next();
list.add( new KeyValuePair<Integer, Integer>( item.Key, item.Value ) );
Vector<ValuePair<Integer, Integer>> list = new Vector<ValuePair<Integer, Integer>>();
for ( Iterator itr = decay_list.iterator(); itr.hasNext(); ) {
ValuePair<Integer, Integer> item = (ValuePair<Integer, Integer>)itr.next();
list.add( new ValuePair<Integer, Integer>( item.getKey(), item.getValue() ) );
}
command.Args[1] = list;
return command;
@ -369,7 +384,7 @@ namespace Boare.Lib.Vsq {
public static VsqCommand generateCommandTrackCurveReplaceRange( int track, String[] target_curve, VsqBPList[] bplist ) {
VsqCommand command = new VsqCommand();
command.Type = VsqCommandType.TRACK_CURVE_REPLACE_RANGE;
command.Args = new object[3];
command.Args = new Object[3];
command.Args[0] = track;
String[] arr = new String[target_curve.Length];
for ( int i = 0; i < target_curve.Length; i++ ) {
@ -387,7 +402,7 @@ namespace Boare.Lib.Vsq {
public static VsqCommand generateCommandTrackCurveReplace( int track, String target_curve, VsqBPList bplist ) {
VsqCommand command = new VsqCommand();
command.Type = VsqCommandType.TRACK_CURVE_REPLACE;
command.Args = new object[3];
command.Args = new Object[3];
command.Args[0] = track;
command.Args[1] = target_curve;
command.Args[2] = bplist.clone();
@ -397,7 +412,7 @@ namespace Boare.Lib.Vsq {
/*public static VsqCommand generateCommandTrackRemovePoints( int track, String target, Vector<Long> ids ) {
VsqCommand command = new VsqCommand();
command.Type = VsqCommandType.TRACK_CURVE_REMOVE_POINTS;
command.Args = new object[3];
command.Args = new Object[3];
command.Args[0] = track;
command.Args[1] = target;
Vector<Long> cpy = new Vector<Long>();
@ -421,11 +436,11 @@ namespace Boare.Lib.Vsq {
public static VsqCommand generateCommandTrackCurveEdit( int track, String target, Vector<BPPair> edit ) {
VsqCommand command = new VsqCommand();
command.Type = VsqCommandType.TRACK_CURVE_EDIT;
command.Args = new object[5];
command.Args = new Object[3];
command.Args[0] = track;
command.Args[1] = target;
Vector<BPPair> copied = new Vector<BPPair>();
for ( Iterator itr = edit.iterator(); itr.hasNext(); ){
for ( Iterator itr = edit.iterator(); itr.hasNext(); ) {
BPPair item = (BPPair)itr.next();
copied.add( item );
}
@ -433,22 +448,107 @@ namespace Boare.Lib.Vsq {
return command;
}
public static VsqCommand generateCommandTrackCurveEditRange( int track, String[] targets, Vector<BPPair>[] edits ) {
/// <summary>
/// コントロールカーブを編集するコマンドを発行します.
/// </summary>
/// <param name="track">編集対象のコントロールカーブが含まれるトラックの番号</param>
/// <param name="target">編集対象のコントロールカーブ名</param>
/// <param name="delete">削除を行うデータ点のリスト</param>
/// <param name="add_or_move">追加または移動を行うデータ点のリスト</param>
/// <returns></returns>
public static VsqCommand generateCommandTrackCurveEdit2( int track, String target, Vector<Long> delete, TreeMap<Integer, VsqBPPair> add ) {
VsqCommand command = new VsqCommand();
command.Type = VsqCommandType.TRACK_CURVE_EDIT2;
command.Args = new Object[4];
command.Args[0] = track;
command.Args[1] = target;
Vector<Long> cp_delete = new Vector<Long>();
for ( Iterator itr = delete.iterator(); itr.hasNext(); ) {
long id = (Long)itr.next();
cp_delete.add( id );
}
command.Args[2] = cp_delete;
TreeMap<Integer, VsqBPPair> cp_add = new TreeMap<Integer, VsqBPPair>();
for ( Iterator itr = add.keySet().iterator(); itr.hasNext(); ) {
int clock = (Integer)itr.next();
VsqBPPair item = add.get( clock );
cp_add.put( clock, item );
}
command.Args[3] = cp_add;
return command;
}
public static VsqCommand generateCommandTrackCurveEditRange( int track, Vector<String> targets, Vector<Vector<BPPair>> edits ) {
VsqCommand command = new VsqCommand();
command.Type = VsqCommandType.TRACK_CURVE_EDIT_RANGE;
command.Args = new object[3];
command.Args = new Object[3];
command.Args[0] = track;
command.Args[1] = (String[])targets.Clone();
Vector<BPPair>[] cpy = new Vector<BPPair>[targets.Length];
for ( int i = 0; i < edits.Length; i++ ) {
Vector<String> cp_targets = new Vector<String>();
int count = targets.size();
for ( int i = 0; i < count; i++ ) {
cp_targets.add( targets.get( i ) );
}
command.Args[1] = cp_targets;
Vector<Vector<BPPair>> cp_edits = new Vector<Vector<BPPair>>();
count = edits.size();
for ( int i = 0; i < count; i++ ) {
Vector<BPPair> copied = new Vector<BPPair>();
for ( Iterator itr = edits[i].iterator(); itr.hasNext(); ){
for ( Iterator itr = edits.get( i ).iterator(); itr.hasNext(); ) {
BPPair item = (BPPair)itr.next();
copied.add( new BPPair( item.Clock, item.Value ) );
}
cpy[i] = copied;
cp_edits.add( copied );
}
command.Args[2] = cpy;
command.Args[2] = cp_edits;
return command;
}
/// <summary>
/// コントロールカーブを編集するコマンドを発行します.
/// </summary>
/// <param name="track">編集対象のコントロールカーブが含まれるトラックの番号</param>
/// <param name="target">編集対象のコントロールカーブ名</param>
/// <param name="delete">削除を行うデータ点のリスト</param>
/// <param name="add_or_move">追加または移動を行うデータ点のリスト</param>
/// <returns></returns>
public static VsqCommand generateCommandTrackCurveEdit2All( int track, Vector<String> target, Vector<Vector<Long>> delete, Vector<TreeMap<Integer, VsqBPPair>> add ) {
VsqCommand command = new VsqCommand();
command.Type = VsqCommandType.TRACK_CURVE_EDIT2_ALL;
command.Args = new Object[4];
command.Args[0] = track;
Vector<String> cp_target = new Vector<String>();
int c = target.size();
for ( int i = 0; i < c; i++ ) {
cp_target.add( target.get( i ) );
}
command.Args[1] = cp_target;
Vector<Vector<Long>> cp_vec_delete = new Vector<Vector<Long>>();
c = delete.size();
for ( int i = 0; i < c; i++ ) {
Vector<Long> cp_delete = new Vector<Long>();
for ( Iterator itr = delete.get( i ).iterator(); itr.hasNext(); ) {
long id = (Long)itr.next();
cp_delete.add( id );
}
cp_vec_delete.add( cp_delete );
}
command.Args[2] = cp_vec_delete;
Vector<TreeMap<Integer, VsqBPPair>> cp_vec_add = new Vector<TreeMap<Integer, VsqBPPair>>();
c = add.size();
for ( int i = 0; i < c; i++ ) {
TreeMap<Integer, VsqBPPair> cp_add = new TreeMap<Integer, VsqBPPair>();
TreeMap<Integer, VsqBPPair> tmp = add.get( i );
for ( Iterator itr = tmp.keySet().iterator(); itr.hasNext(); ) {
int clock = (Integer)itr.next();
VsqBPPair item = tmp.get( clock );
cp_add.put( clock, item );
}
cp_vec_add.add( cp_add );
}
command.Args[3] = cp_vec_add;
return command;
}
@ -463,7 +563,7 @@ namespace Boare.Lib.Vsq {
public static VsqCommand generateCommandEventChangeLyric( int track, int internal_id, String phrase, String phonetic_symbol, boolean protect_symbol ) {
VsqCommand command = new VsqCommand();
command.Type = VsqCommandType.EVENT_CHANGE_LYRIC;
command.Args = new object[5];
command.Args = new Object[5];
command.Args[0] = track;
command.Args[1] = internal_id;
command.Args[2] = phrase;
@ -482,19 +582,19 @@ namespace Boare.Lib.Vsq {
public static VsqCommand generateCommandEventChangeClock( int track, int internal_id, int value ) {
VsqCommand command = new VsqCommand();
command.Type = VsqCommandType.EVENT_CHANGE_CLOCK;
command.Args = new object[3];
command.Args = new Object[3];
command.Args[0] = track;
command.Args[1] = internal_id;
command.Args[2] = value;
return command;
}
public static VsqCommand generateCommandEventDeleteRange( int track, int[] internal_ids ) {
public static VsqCommand generateCommandEventDeleteRange( int track, Vector<Integer> internal_ids ) {
VsqCommand command = new VsqCommand();
command.Type = VsqCommandType.EVENT_DELETE_RANGE;
command.Args = new object[2];
command.Args[0] = (int[])internal_ids.Clone();
command.Args[1] = track;
command.Args = new Object[2];
command.Args[0] = track;
command.Args[1] = copyIntVector( internal_ids );
return command;
}
@ -506,18 +606,22 @@ namespace Boare.Lib.Vsq {
public static VsqCommand generateCommandEventDelete( int track, int internal_id ) {
VsqCommand command = new VsqCommand();
command.Type = VsqCommandType.EVENT_DELETE;
command.Args = new object[2];
command.Args[1] = track;
command.Args[0] = internal_id;
command.Args = new Object[2];
command.Args[0] = track;
command.Args[1] = internal_id;
return command;
}
public static VsqCommand generateCommandEventAddRange( int track, VsqEvent[] items ) {
VsqCommand command = new VsqCommand();
command.Type = VsqCommandType.EVENT_ADD_RANGE;
command.Args = new object[2];
command.Args = new Object[2];
command.Args[0] = track;
command.Args[1] = (VsqEvent[])items.Clone();
VsqEvent[] cp_items = new VsqEvent[items.Length];
for ( int i = 0; i < items.Length; i++ ) {
cp_items[i] = (VsqEvent)items[i].clone();
}
command.Args[1] = cp_items;
return command;
}
@ -530,7 +634,7 @@ namespace Boare.Lib.Vsq {
public static VsqCommand generateCommandEventAdd( int track, VsqEvent item ) {
VsqCommand command = new VsqCommand();
command.Type = VsqCommandType.EVENT_ADD;
command.Args = new object[2];
command.Args = new Object[2];
command.Args[0] = track;
command.Args[1] = (VsqEvent)item.clone();
return command;
@ -546,7 +650,7 @@ namespace Boare.Lib.Vsq {
public static VsqCommand generateCommandEventChangeNote( int track, int internal_id, int note ) {
VsqCommand command = new VsqCommand();
command.Type = VsqCommandType.EVENT_CHANGE_NOTE;
command.Args = new object[3];
command.Args = new Object[3];
command.Args[0] = track;
command.Args[1] = internal_id;
command.Args[2] = note;
@ -563,13 +667,32 @@ namespace Boare.Lib.Vsq {
public static VsqCommand generateCommandEventChangeClockAndNote( int track, int internal_id, int clock, int note ) {
VsqCommand command = new VsqCommand();
command.Type = VsqCommandType.EVENT_CHANGE_CLOCK_AND_NOTE;
command.Args = new object[4];
command.Args = new Object[4];
command.Args[0] = track;
command.Args[1] = internal_id;
command.Args[2] = clock;
command.Args[3] = note;
return command;
}
private static int[] copyIntArray( int[] value ) {
int[] ret = new int[value.Length];
for ( int i = 0; i < value.Length; i++ ) {
ret[i] = value[i];
}
return ret;
}
private static Vector<Integer> copyIntVector( Vector<Integer> value ) {
Vector<Integer> ret = new Vector<Integer>();
int count = value.size();
for ( int i = 0; i < count; i++ ) {
ret.add( value.get( i ) );
}
return ret;
}
}
#if !JAVA
}
#endif

View File

@ -11,7 +11,11 @@
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*/
#if JAVA
package org.kbinani.vsq;
#else
namespace Boare.Lib.Vsq {
#endif
public enum VsqCommandType {
ROOT,
@ -24,6 +28,8 @@ namespace Boare.Lib.Vsq {
EVENT_CHANGE_CLOCK_AND_NOTE,
TRACK_CURVE_EDIT,
TRACK_CURVE_EDIT_RANGE,
TRACK_CURVE_EDIT2,
TRACK_CURVE_EDIT2_ALL,
//TRACK_CURVE_REMOVE_POINTS,
TRACK_CURVE_REPLACE,
TRACK_CURVE_REPLACE_RANGE,
@ -52,4 +58,6 @@ namespace Boare.Lib.Vsq {
EVENT_REPLACE_RANGE,
}
#if !JAVA
}
#endif

View File

@ -0,0 +1,194 @@
/*
* VsqCommon.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.
*/
#if JAVA
package org.kbinani.vsq;
import java.io.*;
import org.kbinani.*;
#else
using System;
using bocoree;
using bocoree.java.io;
namespace Boare.Lib.Vsq {
using boolean = System.Boolean;
#endif
/// <summary>
/// vsqファイルのメタテキストの[Common]セクションに記録される内容を取り扱う
/// </summary>
#if JAVA
public class VsqCommon implements Cloneable, Serializable {
#else
[Serializable]
public class VsqCommon : ICloneable {
#endif
public String Version;
public String Name;
public String Color;
public int DynamicsMode;
public int PlayMode = 1;
#if !JAVA
public object Clone() {
return clone();
}
#endif
public Object clone() {
String[] spl = PortUtil.splitString( Color, new char[] { ',' }, 3 );
int r = PortUtil.parseInt( spl[0] );
int g = PortUtil.parseInt( spl[1] );
int b = PortUtil.parseInt( spl[2] );
VsqCommon res = new VsqCommon( Name, r, g, b, 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, int red, int green, int blue, int dynamics_mode, int play_mode ) {
this.Version = "DSB301";
this.Name = name;
this.Color = red + "," + green + "," + blue;
this.DynamicsMode = dynamics_mode;
this.PlayMode = play_mode;
}
#if JAVA
public VsqCommon(){
this( "Miku", 179, 181, 123, 1, 1 );
#else
public VsqCommon()
: this( "Miku", 179, 181, 123, 1, 1 ) {
#endif
}
/// <summary>
/// MetaTextのテキストファイルからのコンストラクタ
/// </summary>
/// <param name="sr">読み込むテキストファイル</param>
/// <param name="last_line">読み込んだ最後の行が返される</param>
public VsqCommon( TextMemoryStream sr, ByRef<String> last_line ) {
Version = "";
Name = "";
Color = "0,0,0";
DynamicsMode = 0;
PlayMode = 1;
last_line.value = sr.readLine();
String[] spl;
while ( !last_line.value.StartsWith( "[" ) ) {
spl = PortUtil.splitString( last_line.value, new char[] { '=' } );
String search = spl[0];
if ( search.Equals( "Version" ) ) {
this.Version = spl[1];
} else if ( search.Equals( "Name" ) ) {
this.Name = spl[1];
} else if ( search.Equals( "Color" ) ) {
this.Color = spl[1];
} else if ( search.Equals( "DynamicsMode" ) ) {
this.DynamicsMode = PortUtil.parseInt( spl[1] );
} else if ( search.Equals( "PlayMode" ) ) {
this.PlayMode = PortUtil.parseInt( spl[1] );
}
if ( sr.peek() < 0 ) {
break;
}
last_line.value = 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 boolean test()
#if JAVA
throws IOException
#endif
{
String fpath = PortUtil.createTempFile();
BufferedWriter sw = new BufferedWriter( new FileWriter( fpath ) );
sw.write( "Version=DSB301" );
sw.newLine();
sw.write( "Name=Voice1" );
sw.newLine();
sw.write( "Color=181,162,123" );
sw.newLine();
sw.write( "DynamicsMode=1" );
sw.newLine();
sw.write( "PlayMode=1" );
sw.newLine();
sw.write( "[Master]" );
sw.newLine();
sw.close();
VsqCommon vsqCommon = null;
ByRef<String> last_line = new ByRef<String>( "" );
TextMemoryStream sr = null;
try {
sr = new TextMemoryStream( fpath, "UTF8" );
vsqCommon = new VsqCommon( sr, last_line );
} catch ( Exception ex ) {
} finally {
if ( sr != null ) {
try {
sr.close();
} catch ( Exception ex2 ) {
}
}
}
if ( vsqCommon == null ) {
vsqCommon = new VsqCommon();
}
boolean result;
if ( vsqCommon.Version.Equals( "DSB301" ) &&
vsqCommon.Name.Equals( "Voice1" ) &&
vsqCommon.Color.Equals( "181,162,123" ) &&
vsqCommon.DynamicsMode == 1 &&
vsqCommon.PlayMode == 1 &&
last_line.value.Equals( "[Master]" ) ) {
result = true;
} else {
result = false;
}
PortUtil.deleteFile( fpath );
return result;
}
}
#if !JAVA
}
#endif

View File

@ -11,17 +11,30 @@
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*/
using System;
#if JAVA
package org.kbinani.vsq;
import java.io.*;
import java.util.*;
import org.kbinani.*;
#else
using System;
using bocoree;
using bocoree.java.util;
using bocoree.java.io;
namespace Boare.Lib.Vsq {
#endif
/// <summary>
/// vsqファイルのメタテキスト内に記述されるイベント。
/// </summary>
#if JAVA
public class VsqEvent implements Comparable<VsqEvent>, Cloneable, Serializable {
#else
[Serializable]
public class VsqEvent : IComparable<VsqEvent>, ICloneable {
#endif
public String Tag;
/// <summary>
/// 内部で使用するインスタンス固有のID
@ -31,6 +44,75 @@ namespace Boare.Lib.Vsq {
public VsqID ID;
public UstEvent UstEvent = new UstEvent();
/// <summary>
/// インスタンスをテキストファイルに出力します
/// </summary>
/// <param name="sw">出力先</param>
public void write( TextMemoryStream sw )
#if JAVA
throws IOException
#endif
{
Vector<String> def = new Vector<String>( Arrays.asList( new String[]{ "Length",
"Note#",
"Dynamics",
"PMBendDepth",
"PMBendLength",
"PMbPortamentoUse",
"DEMdecGainRate",
"DEMaccent" } ) );
write( sw, def );
}
public void write( TextMemoryStream writer, Vector<String> print_targets )
#if JAVA
throws IOException
#endif
{
writeCor( writer, print_targets );
}
public void write( BufferedWriter writer, Vector<String> print_targets )
#if JAVA
throws IOException
#endif
{
writeCor( new WrappedStreamWriter( writer ), print_targets );
}
private void writeCor( ITextWriter writer, Vector<String> print_targets )
#if JAVA
throws IOException
#endif
{
writer.writeLine( "[ID#" + PortUtil.formatDecimal( "0000", ID.value ) + "]" );
writer.writeLine( "Type=" + ID.type );
if ( ID.type == VsqIDType.Anote ) {
if ( print_targets.contains( "Length" ) ) writer.writeLine( "Length=" + ID.getLength() );
if ( print_targets.contains( "Note#" ) ) writer.writeLine( "Note#=" + ID.Note );
if ( print_targets.contains( "Dynamics" ) ) writer.writeLine( "Dynamics=" + ID.Dynamics );
if ( print_targets.contains( "PMBendDepth" ) ) writer.writeLine( "PMBendDepth=" + ID.PMBendDepth );
if ( print_targets.contains( "PMBendLength" ) ) writer.writeLine( "PMBendLength=" + ID.PMBendLength );
if ( print_targets.contains( "PMbPortamentoUse" ) ) writer.writeLine( "PMbPortamentoUse=" + ID.PMbPortamentoUse );
if ( print_targets.contains( "DEMdecGainRate" ) ) writer.writeLine( "DEMdecGainRate=" + ID.DEMdecGainRate );
if ( print_targets.contains( "DEMaccent" ) ) writer.writeLine( "DEMaccent=" + ID.DEMaccent );
if ( print_targets.contains( "PreUtterance" ) ) writer.writeLine( "PreUtterance=" + UstEvent.PreUtterance );
if ( print_targets.contains( "VoiceOverlap" ) ) writer.writeLine( "VoiceOverlap=" + UstEvent.VoiceOverlap );
if ( ID.LyricHandle != null ) {
writer.writeLine( "LyricHandle=h#" + PortUtil.formatDecimal( "0000", ID.LyricHandle_index ) );
}
if ( ID.VibratoHandle != null ) {
writer.writeLine( "VibratoHandle=h#" + PortUtil.formatDecimal( "0000", ID.VibratoHandle_index ) );
writer.writeLine( "VibratoDelay=" + ID.VibratoDelay );
}
if ( ID.NoteHeadHandle != null ) {
writer.writeLine( "NoteHeadHandle=h#" + PortUtil.formatDecimal( "0000", ID.NoteHeadHandle_index ) );
}
} else if ( ID.type == VsqIDType.Singer ) {
writer.writeLine( "IconHandle=h#" + PortUtil.formatDecimal( "0000", ID.IconHandle_index ) );
}
}
/// <summary>
/// このオブジェクトのコピーを作成します
/// </summary>
@ -39,21 +121,33 @@ namespace Boare.Lib.Vsq {
VsqEvent ret = new VsqEvent( Clock, (VsqID)ID.clone() );
ret.InternalID = InternalID;
if ( UstEvent != null ) {
ret.UstEvent = (UstEvent)UstEvent.Clone();
ret.UstEvent = (UstEvent)UstEvent.clone();
}
ret.Tag = Tag;
return ret;
}
#if !JAVA
public object Clone() {
return clone();
}
#endif
#if !JAVA
public int CompareTo( VsqEvent item ) {
return compareTo( item );
}
#endif
public int compareTo( VsqEvent item ) {
int ret = this.Clock - item.Clock;
if ( ret == 0 ) {
if ( this.ID != null && item.ID != null ) {
#if JAVA
return this.ID.type.ordinal() - item.ID.type.ordinal();
#else
return (int)this.ID.type - (int)item.ID.type;
#endif
} else {
return ret;
}
@ -63,15 +157,20 @@ namespace Boare.Lib.Vsq {
}
public VsqEvent( String line ) {
String[] spl = line.Split( new char[] { '=' } );
Clock = int.Parse( spl[0] );
String[] spl = PortUtil.splitString( line, new char[] { '=' } );
Clock = PortUtil.parseInt( spl[0] );
if ( spl[1].Equals( "EOS" ) ) {
ID = VsqID.EOS;
}
}
#if JAVA
public VsqEvent(){
this( 0, new VsqID() );
#else
public VsqEvent()
: this( 0, new VsqID() ) {
#endif
}
public VsqEvent( int clock, VsqID id /*, int internal_id*/ ) {
@ -82,4 +181,6 @@ namespace Boare.Lib.Vsq {
}
}
#if !JAVA
}
#endif

View File

@ -11,31 +11,42 @@
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*/
using System;
using System.Collections.Generic;
#if JAVA
package org.kbinani.vsq;
import java.io.*;
import java.util.*;
#else
using System;
using bocoree;
using bocoree.java.util;
namespace Boare.Lib.Vsq {
using Integer = System.Int32;
#endif
/// <summary>
/// 固有ID付きのVsqEventのリストを取り扱う
/// </summary>
#if JAVA
public class VsqEventList implements Serializable {
#else
[Serializable]
public class VsqEventList {
#endif
public Vector<VsqEvent> Events;
private Vector<int> m_ids;
private Vector<Integer> m_ids;
/// <summary>
/// コンストラクタ
/// </summary>
public VsqEventList() {
Events = new Vector<VsqEvent>();
m_ids = new Vector<int>();
m_ids = new Vector<Integer>();
}
public VsqEvent findFromID( int internal_id ) {
for ( Iterator itr = Events.iterator(); itr.hasNext(); ){
for ( Iterator itr = Events.iterator(); itr.hasNext(); ) {
VsqEvent item = (VsqEvent)itr.next();
if ( item.InternalID == internal_id ) {
return item;
@ -68,17 +79,21 @@ namespace Boare.Lib.Vsq {
public Iterator iterator() {
updateIDList();
return new ListIterator<VsqEvent>( Events );
return Events.iterator();
}
public void add( VsqEvent item ) {
add( item, getNextId( 0 ) );
}
public void add( VsqEvent item, int internal_id ) {
updateIDList();
int new_id = getNextId( 0 );
item.InternalID = new_id;
item.InternalID = internal_id;
Events.add( item );
m_ids.add( new_id );
m_ids.add( internal_id );
Collections.sort( Events );
for ( int i = 0; i < Events.size(); i++ ) {
int count = Events.size();
for ( int i = 0; i < count; i++ ) {
m_ids.set( i, Events.get( i ).InternalID );
}
}
@ -92,7 +107,7 @@ namespace Boare.Lib.Vsq {
private int getNextId( int next ) {
updateIDList();
int index = -1;
Vector<int> current = new Vector<int>( m_ids );
Vector<Integer> current = new Vector<Integer>( m_ids );
int nfound = 0;
while ( true ) {
index++;
@ -116,21 +131,26 @@ namespace Boare.Lib.Vsq {
}
public void setElement( int index, VsqEvent value ) {
value.InternalID = Events.get( index ).InternalID;
Events.set( index, value );
}
public void updateIDList() {
if ( m_ids.size() != Events.size() ) {
m_ids.clear();
for ( int i = 0; i < Events.size(); i++ ) {
int count = Events.size();
for ( int i = 0; i < count; i++ ) {
m_ids.add( Events.get( i ).InternalID );
}
} else {
for ( int i = 0; i < Events.size(); i++ ) {
int count = Events.size();
for ( int i = 0; i < count; i++ ) {
m_ids.set( i, Events.get( i ).InternalID );
}
}
}
}
#if !JAVA
}
#endif

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,406 @@
/*
* VsqHandle.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.
*/
#if JAVA
package org.kbinani.vsq;
import java.io.*;
import java.util.*;
import org.kbinani.*;
#else
using System;
using bocoree;
using bocoree.java.io;
using bocoree.java.util;
namespace Boare.Lib.Vsq {
using boolean = System.Boolean;
using Integer = System.Int32;
#endif
/// <summary>
/// ハンドルを取り扱います。ハンドルにはLyricHandle、VibratoHandle、IconHandleおよびNoteHeadHandleがある
/// </summary>
#if JAVA
public class VsqHandle implements Serializable {
#else
[Serializable]
public class VsqHandle {
#endif
public VsqHandleType m_type;
public int Index;
public String IconID = "";
public String IDS = "";
public Lyric L0;
public Vector<Lyric> Trailing = new Vector<Lyric>();
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 int Duration;
public int Depth;
public VsqHandle() {
}
public int getLength() {
return Length;
}
public void setLength( int value ) {
Length = value;
}
public LyricHandle castToLyricHandle() {
LyricHandle ret = new LyricHandle();
ret.L0 = L0;
ret.Index = Index;
ret.Trailing = Trailing;
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.setLength( 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.setLength( Length );
ret.Original = Original;
ret.Program = Program;
return ret;
}
public NoteHeadHandle castToNoteHeadHandle() {
NoteHeadHandle ret = new NoteHeadHandle();
ret.Caption = Caption;
ret.Depth = Depth;
ret.Duration = Duration;
ret.IconID = IconID;
ret.IDS = IDS;
ret.setLength( Length );
ret.Original = Original;
return ret;
}
/// <summary>
/// インスタンスをストリームに書き込みます。
/// encode=trueの場合、2バイト文字をエンコードして出力します。
/// </summary>
/// <param name="sw">書き込み対象</param>
private void writeCor( ITextWriter sw )
#if JAVA
throws IOException
#endif
{
sw.writeLine( this.toString() );
}
public void write( TextMemoryStream sw )
#if JAVA
throws IOException
#endif
{
writeCor( sw );
}
public void write( BufferedWriter sw )
#if JAVA
throws IOException
#endif
{
writeCor( new WrappedStreamWriter( sw ) );
}
/// <summary>
/// FileStreamから読み込みながらコンストラクト
/// </summary>
/// <param name="sr">読み込み対象</param>
public VsqHandle( TextMemoryStream 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;
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.value = sr.readLine();
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 = PortUtil.parseInt( spl[1] );
} else if ( search.Equals( "Program" ) ) {
Program = PortUtil.parseInt( spl[1] );
} else if ( search.Equals( "IconID" ) ) {
IconID = spl[1];
} else if ( search.Equals( "IDS" ) ) {
IDS = spl[1];
} else if ( search.Equals( "Original" ) ) {
Original = PortUtil.parseInt( 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 = PortUtil.parseInt( spl[1] );
} else if ( search.Equals( "StartDepth" ) ) {
StartDepth = PortUtil.parseInt( spl[1] );
} else if ( search.Equals( "DepthBPNum" ) ) {
depth_bp_num = PortUtil.parseInt( 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 = PortUtil.parseInt( spl[1] );
} else if ( search.Equals( "RateBPNum" ) ) {
rate_bp_num = PortUtil.parseInt( 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 = PortUtil.parseInt( spl[1] );
} else if ( search.Equals( "Depth" ) ) {
Duration = PortUtil.parseInt( spl[1] );
} else if ( search.StartsWith( "L" ) && PortUtil.getStringLength( search ) >= 2 ){
String num = search.Substring( 1 );
ByRef<Integer> vals = new ByRef<Integer>( 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{
Trailing.set( index - 1, lyric );
}
}
}
if ( sr.peek() < 0 ) {
break;
}
last_line.value = 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 = PortUtil.splitString( tmpRateBPX, new char[] { ',' } );
for ( int i = 0; i < rate_bp_num; i++ ) {
rate_bp_x[i] = PortUtil.parseFloat( spl2[i] );
}
int[] rate_bp_y = new int[rate_bp_num];
spl2 = PortUtil.splitString( tmpRateBPY, new char[] { ',' } );
for ( int i = 0; i < rate_bp_num; i++ ) {
rate_bp_y[i] = PortUtil.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 = PortUtil.splitString( tmpDepthBPX, new char[] { ',' } );
for ( int i = 0; i < depth_bp_num; i++ ) {
depth_bp_x[i] = PortUtil.parseFloat( spl2[i] );
}
int[] depth_bp_y = new int[depth_bp_num];
spl2 = PortUtil.splitString( tmpDepthBPY, new char[] { ',' } );
for ( int i = 0; i < depth_bp_num; i++ ) {
depth_bp_y[i] = PortUtil.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();
}
}
/// <summary>
/// ハンドル指定子(例えば"h#0123"という文字列)からハンドル番号を取得します
/// </summary>
/// <param name="_string">ハンドル指定子</param>
/// <returns>ハンドル番号</returns>
public static int HandleIndexFromString( String _string ) {
String[] spl = PortUtil.splitString( _string, new char[] { '#' } );
return PortUtil.parseInt( spl[1] );
}
/// <summary>
/// インスタンスをテキストファイルに出力します
/// </summary>
/// <param name="sw">出力先</param>
public void print( BufferedWriter sw )
#if JAVA
throws IOException
#endif
{
String result = this.ToString();
sw.write( result );
sw.newLine();
}
/// <summary>
/// インスタンスをコンソール画面に出力します
/// </summary>
private void print() {
String result = this.ToString();
PortUtil.println( result );
}
/// <summary>
/// インスタンスを文字列に変換します
/// </summary>
/// <param name="encode">2バイト文字をエンコードするか否かを指定するフラグ</param>
/// <returns>インスタンスを変換した文字列</returns>
public String toString() {
String result = "";
result += "[h#" + PortUtil.formatDecimal( "0000", Index ) + "]";
if ( m_type == VsqHandleType.Lyric ) {
result += "\n" + "L0=" + L0.toString();
int c = Trailing.size();
for( int i = 0; i < c; i++ ){
result += "\n" + "L" + (i + 1) + Trailing.get( i ).toString();
}
} else if ( m_type == VsqHandleType.Vibrato ) {
result += "\n" + "IconID=" + IconID + "\n";
result += "IDS=" + IDS + "\n";
result += "Original=" + Original + "\n";
result += "Caption=" + Caption + "\n";
result += "Length=" + Length + "\n";
result += "StartDepth=" + StartDepth + "\n";
result += "DepthBPNum=" + DepthBP.getCount() + "\n";
if ( DepthBP.getCount() > 0 ) {
result += "DepthBPX=" + PortUtil.formatDecimal( "0.000000", DepthBP.getElement( 0 ).X );
for ( int i = 1; i < DepthBP.getCount(); i++ ) {
result += "," + PortUtil.formatDecimal( "0.000000", DepthBP.getElement( i ).X );
}
result += "\n" + "DepthBPY=" + DepthBP.getElement( 0 ).Y;
for ( int i = 1; i < DepthBP.getCount(); i++ ) {
result += "," + DepthBP.getElement( i ).Y;
}
result += "\n";
}
result += "StartRate=" + StartRate + "\n";
result += "RateBPNum=" + RateBP.getCount();
if ( RateBP.getCount() > 0 ) {
result += "\n" + "RateBPX=" + PortUtil.formatDecimal( "0.000000", RateBP.getElement( 0 ).X );
for ( int i = 1; i < RateBP.getCount(); i++ ) {
result += "," + PortUtil.formatDecimal( "0.000000", RateBP.getElement( i ).X );
}
result += "\n" + "RateBPY=" + RateBP.getElement( 0 ).Y;
for ( int i = 1; i < RateBP.getCount(); i++ ) {
result += "," + RateBP.getElement( i ).Y;
}
}
} else if ( m_type == VsqHandleType.Singer ) {
result += "\n" + "IconID=" + IconID + "\n";
result += "IDS=" + IDS + "\n";
result += "Original=" + Original + "\n";
result += "Caption=" + Caption + "\n";
result += "Length=" + Length + "\n";
result += "Language=" + Language + "\n";
result += "Program=" + Program;
} else if ( m_type == VsqHandleType.NoteHeadHandle ) {
result += "\n" + "IconID=" + IconID + "\n";
result += "IDS=" + IDS + "\n";
result += "Original=" + Original + "\n";
result += "Caption=" + Caption + "\n";
result += "Length=" + Length + "\n";
result += "Duration=" + Duration + "\n";
result += "Depth=" + Depth;
}
return result;
}
#if !JAVA
public override string ToString() {
return toString();
}
#endif
}
#if !JAVA
}
#endif

View File

@ -0,0 +1,29 @@
/*
* VsqHandleType.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.
*/
#if JAVA
package org.kbinani.vsq;
#else
namespace Boare.Lib.Vsq {
#endif
public enum VsqHandleType {
Lyric,
Vibrato,
Singer,
NoteHeadHandle,
}
#if !JAVA
}
#endif

View File

@ -0,0 +1,334 @@
/*
* VsqID.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.
*/
#if JAVA
package org.kbinani.vsq;
import java.io.*;
import org.kbinani.*;
#else
using System;
using bocoree;
using bocoree.java.io;
namespace Boare.Lib.Vsq {
using boolean = System.Boolean;
#endif
/// <summary>
/// メタテキストに埋め込まれるIDを表すクラス。
/// </summary>
#if JAVA
public class VsqID implements Cloneable, Serializable {
#else
[Serializable]
public class VsqID : ICloneable {
#endif
public const int MAX_NOTE_LENGTH = 16383;
#if JAVA
public int value;
public int IconHandle_index;
public int LyricHandle_index;
public int VibratoHandle_index;
public int NoteHeadHandle_index;
#else
internal int value;
internal int IconHandle_index;
internal int LyricHandle_index;
internal int VibratoHandle_index;
internal int NoteHeadHandle_index;
#endif
public VsqIDType type;
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 LyricHandle LyricHandle;
public VibratoHandle VibratoHandle;
public int VibratoDelay;
public NoteHeadHandle NoteHeadHandle;
public int pMeanOnsetFirstNote = 0x0a;
public int vMeanNoteTransition = 0x0c;
public int d4mean = 0x18;
public int pMeanEndingNote = 0x0c;
public static VsqID EOS = new VsqID( -1 );
public int getLength() {
return Length;
}
public void setLength( int value ) {
Length = value;
}
#if JAVA
public static boolean isXmlIgnored( String name ){
if( name.equals( "IconHandle_index" ) ){
return true;
}else if( name.equals( "value" ) ){
return true;
}else if( name.equals( "LyricHandle_index" ) ){
return true;
}else if( name.equals( "NoteHeadHandle_index" ) ){
return true;
}else if( name.equals( "VibratoHandle_index" ) ){
return true;
}
return false;
}
public static String getXmlElementName( String name ){
return name;
}
#endif
/// <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.setLength( 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;
result.d4mean = this.d4mean;
result.pMeanOnsetFirstNote = this.pMeanOnsetFirstNote;
result.vMeanNoteTransition = this.vMeanNoteTransition;
result.pMeanEndingNote = this.pMeanEndingNote;
if ( this.LyricHandle != null ) {
result.LyricHandle = (LyricHandle)this.LyricHandle.clone();
}
if ( this.VibratoHandle != null ) {
result.VibratoHandle = (VibratoHandle)this.VibratoHandle.clone();
}
result.VibratoDelay = this.VibratoDelay;
if ( NoteHeadHandle != null ) {
result.NoteHeadHandle = (NoteHeadHandle)NoteHeadHandle.clone();
}
return result;
}
#if !JAVA
public object Clone() {
return clone();
}
#endif
/// <summary>
/// IDの番号ID#****の****)を指定したコンストラクタ。
/// </summary>
/// <param name="a_value">IDの番号</param>
public VsqID( int a_value ) {
value = a_value;
}
#if JAVA
public VsqID(){
this( 0 );
#else
public VsqID()
: this( 0 ) {
#endif
}
/// <summary>
/// テキストファイルからのコンストラクタ
/// </summary>
/// <param name="sr">読み込み対象</param>
/// <param name="value"></param>
/// <param name="last_line">読み込んだ最後の行が返されます</param>
public VsqID( TextMemoryStream sr, int value, ByRef<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.NoteHeadHandle_index = -1;
this.setLength( 0 );
this.Note = 0;
this.Dynamics = 64;
this.PMBendDepth = 8;
this.PMBendLength = 0;
this.PMbPortamentoUse = 0;
this.DEMdecGainRate = 50;
this.DEMaccent = 50;
//this.LyricHandle_index = -2;
//this.VibratoHandle_index = -2;
this.VibratoDelay = 0;
last_line.value = sr.readLine();
while ( !last_line.value.StartsWith( "[" ) ) {
spl = PortUtil.splitString( last_line.value, new char[] { '=' } );
String search = spl[0];
if ( search.Equals( "Type" ) ) {
if ( spl[1].Equals( "Anote" ) ) {
type = VsqIDType.Anote;
} else if ( spl[1].Equals( "Singer" ) ) {
type = VsqIDType.Singer;
} else {
type = VsqIDType.Unknown;
}
} else if ( search.Equals( "Length" ) ) {
this.setLength( PortUtil.parseInt( spl[1] ) );
} else if ( search.Equals( "Note#" ) ) {
this.Note = PortUtil.parseInt( spl[1] );
} else if ( search.Equals( "Dynamics" ) ) {
this.Dynamics = PortUtil.parseInt( spl[1] );
} else if ( search.Equals( "PMBendDepth" ) ) {
this.PMBendDepth = PortUtil.parseInt( spl[1] );
} else if ( search.Equals( "PMBendLength" ) ) {
this.PMBendLength = PortUtil.parseInt( spl[1] );
} else if ( search.Equals( "DEMdecGainRate" ) ) {
this.DEMdecGainRate = PortUtil.parseInt( spl[1] );
} else if ( search.Equals( "DEMaccent" ) ) {
this.DEMaccent = PortUtil.parseInt( spl[1] );
} else if ( search.Equals( "LyricHandle" ) ) {
this.LyricHandle_index = VsqHandle.HandleIndexFromString( spl[1] );
} else if ( search.Equals( "IconHandle" ) ) {
this.IconHandle_index = VsqHandle.HandleIndexFromString( spl[1] );
} else if ( search.Equals( "VibratoHandle" ) ) {
this.VibratoHandle_index = VsqHandle.HandleIndexFromString( spl[1] );
} else if ( search.Equals( "VibratoDelay" ) ) {
this.VibratoDelay = PortUtil.parseInt( spl[1] );
} else if ( search.Equals( "PMbPortamentoUse" ) ) {
PMbPortamentoUse = PortUtil.parseInt( spl[1] );
} else if ( search.Equals( "NoteHeadHandle" ) ) {
NoteHeadHandle_index = VsqHandle.HandleIndexFromString( spl[1] );
}
if ( sr.peek() < 0 ) {
break;
}
last_line.value = sr.readLine();
}
}
public override String ToString() {
String ret = "{Type=" + type;
if ( type == 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#" + PortUtil.formatDecimal( "0000", LyricHandle_index );
}
if ( VibratoHandle != null ) {
ret += ", VibratoHandle=h#" + PortUtil.formatDecimal( "0000", VibratoHandle_index );
ret += ", VibratoDelay=" + VibratoDelay;
}
} else if ( type == VsqIDType.Singer ) {
ret += ", IconHandle=h#" + PortUtil.formatDecimal( "0000", IconHandle_index );
}
ret += "}";
return ret;
}
/// <summary>
/// VsqIDを構築するテストを行います。
/// </summary>
/// <returns>テストに成功すればtrue、そうでなければfalseを返します</returns>
public static boolean test() {
String fpath = PortUtil.createTempFile();
BufferedWriter sw = null;
try {
sw = new BufferedWriter( new OutputStreamWriter( new FileOutputStream( fpath ), "UTF-8" ) );
sw.write( "Type=Anote" );
sw.newLine();
sw.write( "Length=320" );
sw.newLine();
sw.write( "Note#=67" );
sw.newLine();
sw.write( "Dynamics=64" );
sw.newLine();
sw.write( "PMBendDepth=8" );
sw.newLine();
sw.write( "PMBendLength=1" );
sw.newLine();
sw.write( "PMbPortamentoUse=1" );
sw.newLine();
sw.write( "DEMdecGainRate=50" );
sw.newLine();
sw.write( "DEMaccent=50" );
sw.newLine();
sw.write( "LyricHandle=h#0111" );
sw.newLine();
sw.write( "[ID#0104]" );
sw.newLine();
} catch ( Exception ex ) {
} finally {
if ( sw != null ) {
try {
sw.close();
} catch ( Exception ex2 ) {
}
}
}
ByRef<String> last_line = new ByRef<String>( "" );
boolean result = false;
TextMemoryStream sr = null;
try {
sr = new TextMemoryStream( fpath, "UTF8" );
VsqID vsqID = new VsqID( sr, 103, last_line );
if ( vsqID.type == VsqIDType.Anote &&
vsqID.getLength() == 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.Equals( "[ID#0104]" ) ) {
result = true;
} else {
result = false;
}
} catch ( Exception ex ) {
} finally {
if ( sr != null ) {
try {
sr.close();
} catch ( Exception ex2 ) {
}
}
}
PortUtil.deleteFile( fpath );
return result;
}
}
#if !JAVA
}
#endif

View File

@ -0,0 +1,28 @@
/*
* VsqIDType.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.
*/
#if JAVA
package org.kbinani.vsq;
#else
namespace Boare.Lib.Vsq {
#endif
public enum VsqIDType {
Singer,
Anote,
Unknown
}
#if !JAVA
}
#endif

View File

@ -0,0 +1,148 @@
/*
* VsqMaster.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.
*/
#if JAVA
package org.kbinani.vsq;
import java.io.*;
import org.kbinani.*;
#else
using System;
using bocoree;
using bocoree.java.io;
namespace Boare.Lib.Vsq {
using boolean = System.Boolean;
#endif
/// <summary>
/// vsqファイルのメタテキストの[Master]に記録される内容を取り扱う
/// </summary>
#if JAVA
public class VsqMaster implements Cloneable, Serializable {
#else
[Serializable]
public class VsqMaster : ICloneable {
#endif
public int PreMeasure;
public Object clone() {
VsqMaster res = new VsqMaster( PreMeasure );
return res;
}
#if !JAVA
public object Clone() {
return clone();
}
#endif
#if JAVA
public VsqMaster(){
this( 1 );
#else
public VsqMaster()
: this( 1 ) {
#endif
}
/// <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, ByRef<String> last_line ) {
PreMeasure = 0;
String[] spl;
last_line.value = sr.readLine();
while ( !last_line.value.StartsWith( "[" ) ) {
spl = PortUtil.splitString( last_line.value, new char[] { '=' } );
if ( spl[0].Equals( "PreMeasure" ) ) {
this.PreMeasure = PortUtil.parseInt( spl[1] );
}
if ( sr.peek() < 0 ) {
break;
}
last_line.value = 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 boolean test() {
String fpath = PortUtil.createTempFile();
BufferedWriter sw = null;
try {
sw = new BufferedWriter( new OutputStreamWriter( new FileOutputStream( fpath ), "UTF8" ) );
sw.write( "PreMeasure=2" );
sw.newLine();
sw.write( "[Mixer]" );
sw.newLine();
} catch ( Exception ex ) {
} finally {
if ( sw != null ) {
try {
sw.close();
} catch ( Exception ex2 ) {
}
}
}
boolean result = false;
TextMemoryStream sr = null;
try {
sr = new TextMemoryStream( fpath, "UTF8" );
ByRef<String> last_line = new ByRef<String>( "" );
VsqMaster vsqMaster = new VsqMaster( sr, last_line );
if ( vsqMaster.PreMeasure == 2 &&
last_line.value.Equals( "[Mixer]" ) ) {
result = true;
} else {
result = false;
}
} catch ( Exception ex ) {
} finally {
if ( sr != null ) {
try {
sr.close();
} catch ( Exception ex2 ) {
}
}
}
PortUtil.deleteFile( fpath );
return result;
}
}
#if !JAVA
}
#endif

View File

@ -1,34 +1,42 @@
/*
* 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.Drawing;
using System.IO;
using System.Text;
* 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.
*/
#if JAVA
package org.kbinani.vsq;
import java.util.*;
import java.io.*;
import org.kbinani.*;
#else
using System;
using bocoree;
using bocoree.java.util;
using bocoree.java.io;
namespace Boare.Lib.Vsq {
using boolean = System.Boolean;
using Integer = System.Int32;
#endif
/// <summary>
/// vsqのメタテキストの中身を処理するためのクラス
/// </summary>
#if JAVA
public class VsqMetaText implements Cloneable, Serializable {
#else
[Serializable]
public class VsqMetaText : ICloneable {
#endif
public VsqCommon Common;
public VsqMaster master;
public VsqMixer mixer;
@ -90,228 +98,211 @@ namespace Boare.Lib.Vsq {
/// </summary>
public VsqBPList OPE;
public object Clone() {
public Object clone() {
VsqMetaText res = new VsqMetaText();
if ( Common != null ) {
res.Common = (VsqCommon)Common.Clone();
res.Common = (VsqCommon)Common.clone();
}
if ( master != null ) {
res.master = (VsqMaster)master.Clone();
res.master = (VsqMaster)master.clone();
}
if ( mixer != null ) {
res.mixer = (VsqMixer)mixer.Clone();
res.mixer = (VsqMixer)mixer.clone();
}
if ( Events != null ) {
res.Events = new VsqEventList();
for ( Iterator itr = Events.iterator(); itr.hasNext(); ) {
res.Events.add( (VsqEvent)((VsqEvent)itr.next()).clone() );
VsqEvent item = (VsqEvent)itr.next();
res.Events.add( (VsqEvent)item.clone(), item.InternalID );
}
}
if ( PIT != null ) {
res.PIT = (VsqBPList)PIT.Clone();
res.PIT = (VsqBPList)PIT.clone();
}
if ( PBS != null ) {
res.PBS = (VsqBPList)PBS.Clone();
res.PBS = (VsqBPList)PBS.clone();
}
if ( DYN != null ) {
res.DYN = (VsqBPList)DYN.Clone();
res.DYN = (VsqBPList)DYN.clone();
}
if ( BRE != null ) {
res.BRE = (VsqBPList)BRE.Clone();
res.BRE = (VsqBPList)BRE.clone();
}
if ( BRI != null ) {
res.BRI = (VsqBPList)BRI.Clone();
res.BRI = (VsqBPList)BRI.clone();
}
if ( CLE != null ) {
res.CLE = (VsqBPList)CLE.Clone();
res.CLE = (VsqBPList)CLE.clone();
}
if ( reso1FreqBPList != null ) {
res.reso1FreqBPList = (VsqBPList)reso1FreqBPList.Clone();
res.reso1FreqBPList = (VsqBPList)reso1FreqBPList.clone();
}
if ( reso2FreqBPList != null ) {
res.reso2FreqBPList = (VsqBPList)reso2FreqBPList.Clone();
res.reso2FreqBPList = (VsqBPList)reso2FreqBPList.clone();
}
if ( reso3FreqBPList != null ) {
res.reso3FreqBPList = (VsqBPList)reso3FreqBPList.Clone();
res.reso3FreqBPList = (VsqBPList)reso3FreqBPList.clone();
}
if ( reso4FreqBPList != null ) {
res.reso4FreqBPList = (VsqBPList)reso4FreqBPList.Clone();
res.reso4FreqBPList = (VsqBPList)reso4FreqBPList.clone();
}
if ( reso1BWBPList != null ) {
res.reso1BWBPList = (VsqBPList)reso1BWBPList.Clone();
res.reso1BWBPList = (VsqBPList)reso1BWBPList.clone();
}
if ( reso2BWBPList != null ) {
res.reso2BWBPList = (VsqBPList)reso2BWBPList.Clone();
res.reso2BWBPList = (VsqBPList)reso2BWBPList.clone();
}
if ( reso3BWBPList != null ) {
res.reso3BWBPList = (VsqBPList)reso3BWBPList.Clone();
res.reso3BWBPList = (VsqBPList)reso3BWBPList.clone();
}
if ( reso4BWBPList != null ) {
res.reso4BWBPList = (VsqBPList)reso4BWBPList.Clone();
res.reso4BWBPList = (VsqBPList)reso4BWBPList.clone();
}
if ( reso1AmpBPList != null ) {
res.reso1AmpBPList = (VsqBPList)reso1AmpBPList.Clone();
res.reso1AmpBPList = (VsqBPList)reso1AmpBPList.clone();
}
if ( reso2AmpBPList != null ) {
res.reso2AmpBPList = (VsqBPList)reso2AmpBPList.Clone();
res.reso2AmpBPList = (VsqBPList)reso2AmpBPList.clone();
}
if ( reso3AmpBPList != null ) {
res.reso3AmpBPList = (VsqBPList)reso3AmpBPList.Clone();
res.reso3AmpBPList = (VsqBPList)reso3AmpBPList.clone();
}
if ( reso4AmpBPList != null ) {
res.reso4AmpBPList = (VsqBPList)reso4AmpBPList.Clone();
res.reso4AmpBPList = (VsqBPList)reso4AmpBPList.clone();
}
if ( harmonics != null ) {
res.harmonics = (VsqBPList)harmonics.Clone();
res.harmonics = (VsqBPList)harmonics.clone();
}
if ( fx2depth != null ) {
res.fx2depth = (VsqBPList)fx2depth.Clone();
res.fx2depth = (VsqBPList)fx2depth.clone();
}
if ( GEN != null ) {
res.GEN = (VsqBPList)GEN.Clone();
res.GEN = (VsqBPList)GEN.clone();
}
if ( POR != null ) {
res.POR = (VsqBPList)POR.Clone();
res.POR = (VsqBPList)POR.clone();
}
if ( OPE != null ) {
res.OPE = (VsqBPList)OPE.Clone();
res.OPE = (VsqBPList)OPE.clone();
}
return res;
}
#if !JAVA
public object Clone() {
return clone();
}
#endif
public VsqEventList getEventList() {
return Events;
}
internal VsqBPList getElement( String curve ) {
switch ( curve.Trim().ToLower() ) {
case "bre":
public VsqBPList getElement( String curve ) {
String search = curve.Trim().ToLower();
if ( search.Equals( "bre" ) ) {
return this.BRE;
case "bri":
} else if ( search.Equals( "bri" ) ) {
return this.BRI;
case "cle":
} else if ( search.Equals( "cle" ) ) {
return this.CLE;
case "dyn":
} else if ( search.Equals( "dyn" ) ) {
return this.DYN;
case "gen":
} else if ( search.Equals( "gen" ) ) {
return this.GEN;
case "ope":
} else if ( search.Equals( "ope" ) ) {
return this.OPE;
case "pbs":
} else if ( search.Equals( "pbs" ) ) {
return this.PBS;
case "pit":
} else if ( search.Equals( "pit" ) ) {
return this.PIT;
case "por":
} else if ( search.Equals( "por" ) ) {
return this.POR;
case "harmonics":
} else if ( search.Equals( "harmonics" ) ) {
return this.harmonics;
case "fx2depth":
} else if ( search.Equals( "fx2depth" ) ) {
return this.fx2depth;
case "reso1amp":
} else if ( search.Equals( "reso1amp" ) ) {
return this.reso1AmpBPList;
case "reso1bw":
} else if ( search.Equals( "reso1bw" ) ) {
return this.reso1BWBPList;
case "reso1freq":
} else if ( search.Equals( "reso1freq" ) ) {
return this.reso1FreqBPList;
case "reso2amp":
} else if ( search.Equals( "reso2amp" ) ) {
return this.reso2AmpBPList;
case "reso2bw":
} else if ( search.Equals( "reso2bw" ) ) {
return this.reso2BWBPList;
case "reso2freq":
} else if ( search.Equals( "reso2freq" ) ) {
return this.reso2FreqBPList;
case "reso3amp":
} else if ( search.Equals( "reso3amp" ) ) {
return this.reso3AmpBPList;
case "reso3bw":
} else if ( search.Equals( "reso3bw" ) ) {
return this.reso3BWBPList;
case "reso3freq":
} else if ( search.Equals( "reso3freq" ) ) {
return this.reso3FreqBPList;
case "reso4amp":
} else if ( search.Equals( "reso4amp" ) ) {
return this.reso4AmpBPList;
case "reso4bw":
} else if ( search.Equals( "reso4bw" ) ) {
return this.reso4BWBPList;
case "reso4freq":
} else if ( search.Equals( "reso4freq" ) ) {
return this.reso4FreqBPList;
default:
} else {
return null;
}
}
internal void setElement( String curve, VsqBPList value ) {
switch ( curve.Trim().ToLower() ) {
case "bre":
public void setElement( String curve, VsqBPList value ) {
String search = curve.Trim().ToLower();
if ( search.Equals( "bre" ) ) {
this.BRE = value;
break;
case "bri":
} else if ( search.Equals( "bri" ) ) {
this.BRI = value;
break;
case "cle":
} else if ( search.Equals( "cle" ) ) {
this.CLE = value;
break;
case "dyn":
} else if ( search.Equals( "dyn" ) ) {
this.DYN = value;
break;
case "gen":
} else if ( search.Equals( "gen" ) ) {
this.GEN = value;
break;
case "ope":
} else if ( search.Equals( "ope" ) ) {
this.OPE = value;
break;
case "pbs":
} else if ( search.Equals( "pbs" ) ) {
this.PBS = value;
break;
case "pit":
} else if ( search.Equals( "pit" ) ) {
this.PIT = value;
break;
case "por":
} else if ( search.Equals( "por" ) ) {
this.POR = value;
break;
case "harmonics":
} else if ( search.Equals( "harmonics" ) ) {
this.harmonics = value;
break;
case "fx2depth":
} else if ( search.Equals( "fx2depth" ) ) {
this.fx2depth = value;
break;
case "reso1amp":
} else if ( search.Equals( "reso1amp" ) ) {
this.reso1AmpBPList = value;
break;
case "reso1bw":
} else if ( search.Equals( "reso1bw" ) ) {
this.reso1BWBPList = value;
break;
case "reso1freq":
} else if ( search.Equals( "reso1freq" ) ) {
this.reso1FreqBPList = value;
break;
case "reso2amp":
} else if ( search.Equals( "reso2amp" ) ) {
this.reso2AmpBPList = value;
break;
case "reso2bw":
} else if ( search.Equals( "reso2bw" ) ) {
this.reso2BWBPList = value;
break;
case "reso2freq":
} else if ( search.Equals( "reso2freq" ) ) {
this.reso2FreqBPList = value;
break;
case "reso3amp":
} else if ( search.Equals( "reso3amp" ) ) {
this.reso3AmpBPList = value;
break;
case "reso3bw":
} else if ( search.Equals( "reso3bw" ) ) {
this.reso3BWBPList = value;
break;
case "reso3freq":
} else if ( search.Equals( "reso3freq" ) ) {
this.reso3FreqBPList = value;
break;
case "reso4amp":
} else if ( search.Equals( "reso4amp" ) ) {
this.reso4AmpBPList = value;
break;
case "reso4bw":
} else if ( search.Equals( "reso4bw" ) ) {
this.reso4BWBPList = value;
break;
case "reso4freq":
} else if ( search.Equals( "reso4freq" ) ) {
this.reso4FreqBPList = value;
break;
default:
} else {
#if DEBUG
Console.WriteLine( "VsqMetaText#setElement; warning:unknown curve; curve=" + curve );
PortUtil.println( "VsqMetaText#setElement; warning:unknown curve; curve=" + curve );
#endif
break;
}
}
@ -417,33 +408,24 @@ namespace Boare.Lib.Vsq {
}
/// <summary>
/// このインスタンスから、IDとHandleのリストを構築します
/// このインスタンスから、Handleのリストを作成すると同時に、Eventsに登録されているVsqEventのvalue値および各ハンドルのvalue値を更新します
/// </summary>
/// <param name="id"></param>
/// <param name="handle"></param>
void BuildIDHandleList( out Vector<VsqID> id, out Vector<VsqHandle> handle ) {
id = new Vector<VsqID>();
handle = new Vector<VsqHandle>();
/// <returns></returns>
private Vector<VsqHandle> buildHandleList() {
Vector<VsqHandle> handle = new Vector<VsqHandle>();
int current_id = -1;
int current_handle = -1;
Vector<VsqEvent> events = new Vector<VsqEvent>();
for ( Iterator itr = Events.iterator(); itr.hasNext(); ) {
events.add( (VsqEvent)itr.next() );
}
Collections.sort( events );
for ( int i = 0; i < events.size(); i++ ) {
VsqEvent item = events.get( i );
VsqID id_item = (VsqID)item.ID.clone();
VsqEvent item = (VsqEvent)itr.next();
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;
item.ID.IconHandle_index = current_handle;
}
// LyricHandle
if ( item.ID.LyricHandle != null ) {
@ -451,7 +433,7 @@ namespace Boare.Lib.Vsq {
VsqHandle handle_item = item.ID.LyricHandle.castToVsqHandle();
handle_item.Index = current_handle;
handle.add( handle_item );
id_item.LyricHandle_index = current_handle;
item.ID.LyricHandle_index = current_handle;
}
// VibratoHandle
if ( item.ID.VibratoHandle != null ) {
@ -459,7 +441,7 @@ namespace Boare.Lib.Vsq {
VsqHandle handle_item = item.ID.VibratoHandle.castToVsqHandle();
handle_item.Index = current_handle;
handle.add( handle_item );
id_item.VibratoHandle_index = current_handle;
item.ID.VibratoHandle_index = current_handle;
}
// NoteHeadHandle
if ( item.ID.NoteHeadHandle != null ) {
@ -467,10 +449,10 @@ namespace Boare.Lib.Vsq {
VsqHandle handle_item = item.ID.NoteHeadHandle.castToVsqHandle();
handle_item.Index = current_handle;
handle.add( handle_item );
id_item.NoteHeadHandle_index = current_handle;
item.ID.NoteHeadHandle_index = current_handle;
}
id.add( id_item );
}
return handle;
}
/// <summary>
@ -478,7 +460,11 @@ namespace Boare.Lib.Vsq {
/// </summary>
/// <param name="sw"></param>
/// <param name="encode"></param>
public void print( TextMemoryStream sw, boolean encode, int eos, int start ) {
public void print( TextMemoryStream sw, int eos, int start )
#if JAVA
throws IOException
#endif
{
if ( Common != null ) {
Common.write( sw );
}
@ -488,16 +474,13 @@ namespace Boare.Lib.Vsq {
if ( mixer != null ) {
mixer.write( sw );
}
Vector<VsqID> id;
Vector<VsqHandle> handle;
BuildIDHandleList( out id, out handle );
writeEventList( sw, eos );
int i;
for ( i = 0; i < id.size(); i++ ) {
id.get( i ).write( sw );
Vector<VsqHandle> handle = writeEventList( sw, eos );
for ( Iterator itr = Events.iterator(); itr.hasNext(); ) {
VsqEvent item = (VsqEvent)itr.next();
item.write( sw );
}
for ( i = 0; i < handle.size(); i++ ) {
handle.get( i ).write( sw, encode );
for ( int i = 0; i < handle.size(); i++ ) {
handle.get( i ).write( sw );
}
String version = Common.Version;
if ( PIT.size() > 0 ) {
@ -579,8 +562,13 @@ namespace Boare.Lib.Vsq {
}
}
private void writeEventList( TextMemoryStream sw, int eos ) {
sw.writeLine( "[EventList]" );
private Vector<VsqHandle> writeEventListCor( ITextWriter writer, int eos )
#if JAVA
throws IOException
#endif
{
Vector<VsqHandle> handles = buildHandleList();
writer.writeLine( "[EventList]" );
Vector<VsqEvent> temp = new Vector<VsqEvent>();
for ( Iterator itr = Events.iterator(); itr.hasNext(); ) {
temp.add( (VsqEvent)itr.next() );
@ -590,17 +578,34 @@ namespace Boare.Lib.Vsq {
while ( i < temp.size() ) {
VsqEvent item = temp.get( i );
if ( !item.ID.Equals( VsqID.EOS ) ) {
String ids = "ID#" + i.ToString( "0000" );
String ids = "ID#" + PortUtil.formatDecimal( "0000", item.ID.value );
int clock = temp.get( i ).Clock;
while ( i + 1 < temp.size() && clock == temp.get( i + 1 ).Clock ) {
i++;
ids += ",ID#" + i.ToString( "0000" );
ids += ",ID#" + PortUtil.formatDecimal( "0000", temp.get( i + 1 ).ID.value );
}
sw.writeLine( clock + "=" + ids );
writer.writeLine( clock + "=" + ids );
}
i++;
}
sw.writeLine( eos + "=EOS" );
writer.writeLine( eos + "=EOS" );
return handles;
}
public Vector<VsqHandle> writeEventList( TextMemoryStream sw, int eos )
#if JAVA
throws IOException
#endif
{
return writeEventListCor( sw, eos );
}
public Vector<VsqHandle> writeEventList( BufferedWriter stream_writer, int eos )
#if JAVA
throws IOException
#endif
{
return writeEventListCor( new WrappedStreamWriter( stream_writer ), eos );
}
/// <summary>
@ -612,20 +617,30 @@ namespace Boare.Lib.Vsq {
/// <summary>
/// 最初のトラック以外の一般のメタテキストを構築。(Masterが作られない)
/// </summary>
#if JAVA
public VsqMetaText( String name, String singer ){
this( name, 0, singer, false );
#else
public VsqMetaText( String name, String singer )
: this( name, 0, singer, false ) {
#endif
}
/// <summary>
/// 最初のトラックのメタテキストを構築。(Masterが作られる)
/// </summary>
/// <param name="pre_measure"></param>
#if JAVA
public VsqMetaText( String name, String singer, int pre_measure ){
this( name, pre_measure, singer, true );
#else
public VsqMetaText( String name, String singer, int pre_measure )
: this( name, pre_measure, singer, true ) {
#endif
}
private VsqMetaText( String name, int pre_measure, String singer, boolean is_first_track ) {
Common = new VsqCommon( name, Color.FromArgb( 179, 181, 123 ), 1, 1 );
Common = new VsqCommon( name, 179, 181, 123, 1, 1 );
PIT = new VsqBPList( 0, -8192, 8191 );
//PIT.add( 0, PIT.getDefault() );
@ -707,20 +722,20 @@ namespace Boare.Lib.Vsq {
id.IconHandle.IDS = singer;
id.IconHandle.Original = 0;
id.IconHandle.Caption = "";
id.IconHandle.Length = 1;
id.IconHandle.setLength( 1 );
id.IconHandle.Language = 0;
id.IconHandle.Program = 0;
Events.add( new VsqEvent( 0, id ) );
}
public VsqMetaText( TextMemoryStream sr ) {
Vector<KeyValuePair<Integer, Integer>> t_event_list = new Vector<KeyValuePair<Integer, Integer>>();
Vector<ValuePair<Integer, Integer>> t_event_list = new Vector<ValuePair<Integer, Integer>>();
TreeMap<Integer, VsqID> __id = new TreeMap<Integer, VsqID>();
TreeMap<Integer, VsqHandle> __handle = new TreeMap<Integer, VsqHandle>();
PIT = new VsqBPList( 0, -8192, 8191 );
PBS = new VsqBPList( 2, 0, 24 );
DYN = new VsqBPList( 64, 0, 127 );
BRE = new VsqBPList( 0 , 0, 127);
BRE = new VsqBPList( 0, 0, 127 );
BRI = new VsqBPList( 64, 0, 127 );
CLE = new VsqBPList( 0, 0, 127 );
reso1FreqBPList = new VsqBPList( 64, 0, 127 );
@ -741,126 +756,102 @@ namespace Boare.Lib.Vsq {
POR = new VsqBPList( 64, 0, 127 );
OPE = new VsqBPList( 127, 0, 127 );
String last_line = sr.readLine();
ByRef<String> last_line = new ByRef<String>( sr.readLine() );
while ( true ) {
#region "TextMemoryStreamから順次読込み"
if ( last_line.Length == 0 ) {
if ( PortUtil.getStringLength( last_line.value ) == 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] );
if ( last_line.value.Equals( "[Common]" ) ) {
Common = new VsqCommon( sr, last_line );
} else if ( last_line.value.Equals( "[Master]" ) ) {
master = new VsqMaster( sr, last_line );
} else if ( last_line.value.Equals( "[Mixer]" ) ) {
mixer = new VsqMixer( sr, last_line );
} else if ( last_line.value.Equals( "[EventList]" ) ) {
last_line.value = sr.readLine();
while ( !last_line.value.StartsWith( "[" ) ) {
String[] spl2 = PortUtil.splitString( last_line.value, new char[] { '=' } );
int clock = PortUtil.parseInt( spl2[0] );
int id_number = -1;
if ( spl2[1] != "EOS" ) {
String[] ids = spl2[1].Split( ",".ToCharArray() );
String[] ids = PortUtil.splitString( spl2[1], ',' );
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 ) );
String[] spl3 = PortUtil.splitString( ids[i], new char[] { '#' } );
id_number = PortUtil.parseInt( spl3[1] );
t_event_list.add( new ValuePair<Integer, Integer>( clock, id_number ) );
}
} else {
t_event_list.add( new KeyValuePair<int,int>( clock, -1) );
t_event_list.add( new ValuePair<Integer, Integer>( clock, -1 ) );
}
if ( sr.peek() < 0 ) {
break;
} else {
last_line = sr.readLine();
last_line.value = 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 "[EpRSineBPList]":
last_line = harmonics.appendFromText( sr );
break;
case "[VibTremDepthBPList]":
last_line = fx2depth.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;
} else if ( last_line.value.Equals( "[PitchBendBPList]" ) ) {
last_line.value = PIT.appendFromText( sr );
} else if ( last_line.value.Equals( "[PitchBendSensBPList]" ) ) {
last_line.value = PBS.appendFromText( sr );
} else if ( last_line.value.Equals( "[DynamicsBPList]" ) ) {
last_line.value = DYN.appendFromText( sr );
} else if ( last_line.value.Equals( "[EpRResidualBPList]" ) ) {
last_line.value = BRE.appendFromText( sr );
} else if ( last_line.value.Equals( "[EpRESlopeBPList]" ) ) {
last_line.value = BRI.appendFromText( sr );
} else if ( last_line.value.Equals( "[EpRESlopeDepthBPList]" ) ) {
last_line.value = CLE.appendFromText( sr );
} else if ( last_line.value.Equals( "[EpRSineBPList]" ) ) {
last_line.value = harmonics.appendFromText( sr );
} else if ( last_line.value.Equals( "[VibTremDepthBPList]" ) ) {
last_line.value = fx2depth.appendFromText( sr );
} else if ( last_line.value.Equals( "[Reso1FreqBPList]" ) ) {
last_line.value = reso1FreqBPList.appendFromText( sr );
} else if ( last_line.value.Equals( "[Reso2FreqBPList]" ) ) {
last_line.value = reso2FreqBPList.appendFromText( sr );
} else if ( last_line.value.Equals( "[Reso3FreqBPList]" ) ) {
last_line.value = reso3FreqBPList.appendFromText( sr );
} else if ( last_line.value.Equals( "[Reso4FreqBPList]" ) ) {
last_line.value = reso4FreqBPList.appendFromText( sr );
} else if ( last_line.value.Equals( "[Reso1BWBPList]" ) ) {
last_line.value = reso1BWBPList.appendFromText( sr );
} else if ( last_line.value.Equals( "[Reso2BWBPList]" ) ) {
last_line.value = reso2BWBPList.appendFromText( sr );
} else if ( last_line.value.Equals( "[Reso3BWBPList]" ) ) {
last_line.value = reso3BWBPList.appendFromText( sr );
} else if ( last_line.value.Equals( "[Reso4BWBPList]" ) ) {
last_line.value = reso4BWBPList.appendFromText( sr );
} else if ( last_line.value.Equals( "[Reso1AmpBPList]" ) ) {
last_line.value = reso1AmpBPList.appendFromText( sr );
} else if ( last_line.value.Equals( "[Reso2AmpBPList]" ) ) {
last_line.value = reso2AmpBPList.appendFromText( sr );
} else if ( last_line.value.Equals( "[Reso3AmpBPList]" ) ) {
last_line.value = reso3AmpBPList.appendFromText( sr );
} else if ( last_line.value.Equals( "[Reso4AmpBPList]" ) ) {
last_line.value = reso4AmpBPList.appendFromText( sr );
} else if ( last_line.value.Equals( "[GenderFactorBPList]" ) ) {
last_line.value = GEN.appendFromText( sr );
} else if ( last_line.value.Equals( "[PortamentoTimingBPList]" ) ) {
last_line.value = POR.appendFromText( sr );
} else if ( last_line.value.Equals( "[OpeningBPList]" ) ) {
last_line.value = OPE.appendFromText( sr );
} else {
String buffer = last_line.value;
buffer = buffer.Replace( "[", "" );
buffer = buffer.Replace( "]", "" );
String[] spl = buffer.Split( new char[] { '#' } );
int index = int.Parse( spl[1] );
if ( last_line.StartsWith( "[ID#" ) ) {
__id.put( index, new VsqID( sr, index, ref last_line ) );
} else if ( last_line.StartsWith( "[h#" ) ) {
__handle.put( index, new VsqHandle( sr, index, ref last_line ) );
String[] spl = PortUtil.splitString( buffer, new char[] { '#' } );
#if DEBUG
if ( spl.Length < 2 ) {
PortUtil.println( "VsqMetaText#.ctor; spl.Length=" + spl.Length + "; buffer=" + buffer );
}
#endif
int index = PortUtil.parseInt( spl[1] );
if ( last_line.value.StartsWith( "[ID#" ) ) {
__id.put( index, new VsqID( sr, index, last_line ) );
} else if ( last_line.value.StartsWith( "[h#" ) ) {
__handle.put( index, new VsqHandle( sr, index, last_line ) );
}
break;
#endregion
}
@ -888,53 +879,19 @@ namespace Boare.Lib.Vsq {
// idをeventListに埋め込み
Events = new VsqEventList();
for ( int i = 0; i < t_event_list.size(); i++ ) {
int clock = t_event_list.get( i ).Key;
int id_number = t_event_list.get( i ).Value;
int clock = t_event_list.get( i ).getKey();
int id_number = t_event_list.get( i ).getValue();
if ( __id.containsKey( id_number ) ) {
Events.add( new VsqEvent( clock, (VsqID)__id.get( id_number ).clone() ) );
}
}
}
public static boolean 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();
//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;
if ( Common == null ) {
Common = new VsqCommon();
}
}
honmono.Close();
copy.close();
return true;
}
}
public enum VsqIDType {
Singer,
Anote,
Unknown
}
public enum VsqHandleType {
Lyric,
Vibrato,
Singer,
NoteHeadHandle,
}
#if !JAVA
}
#endif

View File

@ -1,157 +0,0 @@
/*
* 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;
using bocoree;
namespace Boare.Lib.Vsq {
using boolean = System.Boolean;
/// <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;
}
public VsqCommon()
: this( "Miku", System.Drawing.Color.FromArgb( 179, 181, 123 ), 1, 1 ) {
}
/// <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 boolean 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 );
}
boolean result;
if ( vsqCommon.Version.Equals( "DSB301" ) &&
vsqCommon.Name.Equals( "Voice1" ) &&
vsqCommon.Color.Equals( "181,162,123" ) &&
vsqCommon.DynamicsMode == 1 &&
vsqCommon.PlayMode == 1 &&
last_line.Equals( "[Master]" ) ) {
result = true;
} else {
result = false;
}
File.Delete( fpath );
return result;
}
}
}

View File

@ -1,151 +0,0 @@
/*
* 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ファイルのメタテキストの[Common]セクションに記録される内容を取り扱う
/// </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>
/// 各パラメータを指定したコンストラクタ
/// </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 = Integer.parseInt( spl[1] );
break;
case "PlayMode":
this.PlayMode = Integer.parseInt( 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

@ -1,537 +0,0 @@
/*
* 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;
using bocoree;
namespace Boare.Lib.Vsq {
using boolean = System.Boolean;
[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 IconHandle() {
}
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;
public 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(){
StartRate = 64;
StartDepth = 64;
RateBP = new VibratoBPList();
DepthBP = new VibratoBPList();
}
/*public static VibratoHandle[] fromVED( String ved_file, int original ){
}*/
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;
}
}
[Serializable]
public class NoteHeadHandle : ICloneable {
public int Index;
public String IconID;
public String IDS;
public int Original;
public String Caption;
public int Length;
public int Duration;
public int Depth;
public NoteHeadHandle() {
}
public object Clone() {
NoteHeadHandle result = new NoteHeadHandle();
result.Index = Index;
result.IconID = IconID;
result.IDS = this.IDS;
result.Original = this.Original;
result.Caption = this.Caption;
result.Length = this.Length;
result.Duration = Duration;
result.Depth = Depth;
return result;
}
public VsqHandle castToVsqHandle() {
VsqHandle ret = new VsqHandle();
ret.m_type = VsqHandleType.NoteHeadHandle;
ret.Index = Index;
ret.IconID = IconID;
ret.IDS = IDS;
ret.Original = Original;
ret.Caption = Caption;
ret.Length = Length;
ret.Duration = Duration;
ret.Depth = Depth;
return ret;
}
}
/// <summary>
/// ハンドルを取り扱います。ハンドルにはLyricHandle、VibratoHandle、IconHandleおよびNoteHeadHandleがある
/// </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 int Duration;
public int Depth;
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;
}
public NoteHeadHandle castToNoteHeadHandle() {
NoteHeadHandle ret = new NoteHeadHandle();
ret.Caption = Caption;
ret.Depth = Depth;
ret.Duration = Duration;
ret.IconID = IconID;
ret.IDS = IDS;
ret.Length = Length;
ret.Original = Original;
return ret;
}
internal VsqHandle() {
}
/// <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 ) );
}
/// <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;
Duration = 0;
Depth = 64;
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":
m_type = VsqHandleType.Singer;
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":
m_type = VsqHandleType.Vibrato;
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;
case "Duration":
m_type = VsqHandleType.NoteHeadHandle;
Duration = int.Parse( spl[1] );
break;
case "Depth":
Duration = int.Parse( 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( boolean 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;
case VsqHandleType.NoteHeadHandle:
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 += "Duration=" + Duration + Environment.NewLine;
result += "Depth=" + Depth;
break;
default:
break;
}
return result;
}
}
}

View File

@ -1,311 +0,0 @@
/*
* 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;
using bocoree;
namespace Boare.Lib.Vsq {
using boolean = System.Boolean;
/// <summary>
/// メタテキストに埋め込まれるIDを表すクラス。
/// </summary>
[Serializable]
public class VsqID : ICloneable {
public const int MAX_NOTE_LENGTH = 16383;
internal int value;
public VsqIDType type;
internal int IconHandle_index;
public IconHandle IconHandle;
private int m_length;
public int Note;
public int Dynamics;
public int PMBendDepth;
public int PMBendLength;
public int PMbPortamentoUse;
public int DEMdecGainRate;
public int DEMaccent;
internal int LyricHandle_index;
public LyricHandle LyricHandle;
internal int VibratoHandle_index;
public VibratoHandle VibratoHandle;
public int VibratoDelay;
internal int NoteHeadHandle_index;
public NoteHeadHandle NoteHeadHandle;
public int pMeanOnsetFirstNote = 0x0a;
public int vMeanNoteTransition = 0x0c;
public int d4mean = 0x18;
public int pMeanEndingNote = 0x0c;
public static VsqID EOS = new VsqID( -1 );
public int Length {
get {
return m_length;
}
set {
m_length = value;
}
}
/// <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;
result.d4mean = this.d4mean;
result.pMeanOnsetFirstNote = this.pMeanOnsetFirstNote;
result.vMeanNoteTransition = this.vMeanNoteTransition;
result.pMeanEndingNote = this.pMeanEndingNote;
if ( this.LyricHandle != null ) {
result.LyricHandle = (LyricHandle)this.LyricHandle.Clone();
}
if ( this.VibratoHandle != null ) {
result.VibratoHandle = (VibratoHandle)this.VibratoHandle.Clone();
}
result.VibratoDelay = this.VibratoDelay;
if ( NoteHeadHandle != null ) {
result.NoteHeadHandle = (NoteHeadHandle)NoteHeadHandle.Clone();
}
return result;
}
public object Clone() {
return clone();
}
/// <summary>
/// IDの番号ID#****の****)を指定したコンストラクタ。
/// </summary>
/// <param name="a_value">IDの番号</param>
public VsqID( int a_value ) {
value = a_value;
}
public VsqID()
: this( 0 ) {
}
/// <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.NoteHeadHandle_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].Equals( "Anote" ) ) {
type = VsqIDType.Anote;
} else if ( spl[1].Equals( "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;
case "NoteHeadHandle":
NoteHeadHandle_index = VsqHandle.HandleIndexFromString( 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 );
}
if ( NoteHeadHandle != null ) {
sw.writeLine( "NoteHeadHandle=h#" + NoteHeadHandle_index.ToString( "0000" ) );
}
break;
case VsqIDType.Singer:
sw.writeLine( "IconHandle=h#" + IconHandle_index.ToString( "0000" ) );
break;
}
}
/// <summary>
/// VsqIDを構築するテストを行います。
/// </summary>
/// <returns>テストに成功すればtrue、そうでなければfalseを返します</returns>
public static boolean 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 = "";
boolean 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.Equals( "[ID#0104]" ) ) {
result = true;
} else {
result = false;
}
}
File.Delete( fpath );
return result;
}
}
}

View File

@ -1,107 +0,0 @@
/*
* 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.IO;
using System.Text;
using bocoree;
namespace Boare.Lib.Vsq {
using boolean = System.Boolean;
/// <summary>
/// vsqファイルのメタテキストの[Master]に記録される内容を取り扱う
/// </summary>
[Serializable]
public class VsqMaster : ICloneable {
public int PreMeasure;
public object Clone() {
VsqMaster res = new VsqMaster( PreMeasure );
return res;
}
public VsqMaster()
: this( 1 ) {
}
/// <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 boolean test() {
String fpath = Path.GetTempFileName();
using ( StreamWriter sw = new StreamWriter( fpath, false, Encoding.Unicode ) ) {
sw.WriteLine( "PreMeasure=2" );
sw.WriteLine( "[Mixer]" );
}
boolean 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.Equals( "[Mixer]" ) ) {
result = true;
} else {
result = false;
}
}
File.Delete( fpath );
return result;
}
}
}

View File

@ -1,279 +0,0 @@
/*
* 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.IO;
using System.Text;
using bocoree;
namespace Boare.Lib.Vsq {
using boolean = System.Boolean;
/// <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 Vector<VsqMixerEntry> Slave = new Vector<VsqMixerEntry>();
public object Clone() {
VsqMixer res = new VsqMixer( MasterFeder, MasterPanpot, MasterMute, OutputMode );
res.Slave = new Vector<VsqMixerEntry>();
for ( Iterator itr = Slave.iterator(); itr.hasNext(); ){
VsqMixerEntry item = (VsqMixerEntry)itr.next();
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 Vector<VsqMixerEntry>();
}
public VsqMixer()
: this( 0, 0, 0, 0 ) {
}
/// <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 Vector<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.get( index ).Feder = int.Parse( spl2[1] );
} else if ( spl2[0].StartsWith( "Panpot" ) ) {
ind = spl2[0].Replace( "Panpot", "" );
index = int.Parse( ind );
Slave.get( index ).Panpot = int.Parse( spl2[1] );
} else if ( spl2[0].StartsWith( "Mute" ) ) {
ind = spl2[0].Replace( "Mute", "" );
index = int.Parse( ind );
Slave.get( index ).Mute = int.Parse( spl2[1] );
} else if ( spl2[0].StartsWith( "Solo" ) ) {
ind = spl2[0].Replace( "Solo", "" );
index = int.Parse( ind );
Slave.get( 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.size() );
for ( int i = 0; i < Slave.size(); i++ ) {
sw.writeLine( "Feder" + i + "=" + Slave.get( i ).Feder );
sw.writeLine( "Panpot" + i + "=" + Slave.get( i ).Panpot );
sw.writeLine( "Mute" + i + "=" + Slave.get( i ).Mute );
sw.writeLine( "Solo" + i + "=" + Slave.get( i ).Solo );
}
}
/// <summary>
/// VsqMixerのインスタンスを構築するテストを行います
/// </summary>
/// <returns>テストに成功すればtrue、そうでなければfalseを返します</returns>
public static boolean 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.size() == 8 ){
for( int i = 0; i < vsqMixer.Slave.size(); i++ ){
int start = 4 * i;
if ( vsqMixer.Slave.get( i ).Feder != start + 1 ||
vsqMixer.Slave.get( i ).Panpot != start + 2 ||
vsqMixer.Slave.get( i ).Mute != start + 3 ||
vsqMixer.Slave.get( 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;
}
public VsqMixerEntry()
: this( 0, 0, 0, 0 ) {
}
}
}

View File

@ -0,0 +1,183 @@
/*
* VsqMixer.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.
*/
#if JAVA
package org.kbinani.vsq;
import java.io.*;
import java.util.*;
import org.kbinani.*;
#else
using System;
using bocoree;
using bocoree.java.util;
namespace Boare.Lib.Vsq {
#endif
/// <summary>
/// vsqファイルのメタテキストの[Mixer]セクションに記録される内容を取り扱う
/// </summary>
#if JAVA
public class VsqMixer implements Cloneable, Serializable {
#else
[Serializable]
public class VsqMixer : ICloneable {
#endif
public int MasterFeder;
public int MasterPanpot;
public int MasterMute;
public int OutputMode;
/// <summary>
/// vsqファイルの各トラックのfader, panpot, muteおよびoutputmode値を保持します
/// </summary>
public Vector<VsqMixerEntry> Slave = new Vector<VsqMixerEntry>();
public Object clone() {
VsqMixer res = new VsqMixer( MasterFeder, MasterPanpot, MasterMute, OutputMode );
res.Slave = new Vector<VsqMixerEntry>();
for ( Iterator itr = Slave.iterator(); itr.hasNext(); ) {
VsqMixerEntry item = (VsqMixerEntry)itr.next();
res.Slave.add( (VsqMixerEntry)item.clone() );
}
return res;
}
#if !JAVA
public object Clone() {
return clone();
}
#endif
/// <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 Vector<VsqMixerEntry>();
}
#if JAVA
public VsqMixer(){
this( 0, 0, 0, 0 );
#else
public VsqMixer()
: this( 0, 0, 0, 0 ) {
#endif
}
/// <summary>
/// テキストファイルからのコンストラクタ
/// </summary>
/// <param name="sr">読み込み対象</param>
/// <param name="last_line">最後に読み込んだ行が返されます</param>
public VsqMixer( TextMemoryStream sr, ByRef<String> last_line ) {
MasterFeder = 0;
MasterPanpot = 0;
MasterMute = 0;
OutputMode = 0;
//Tracks = 1;
int tracks = 0;
String[] spl;
String buffer = "";
last_line.value = sr.readLine();
while ( !last_line.value.StartsWith( "[" ) ) {
spl = PortUtil.splitString( last_line.value, new char[] { '=' } );
if ( spl[0].Equals( "MasterFeder" ) ) {
MasterFeder = PortUtil.parseInt( spl[1] );
} else if ( spl[0].Equals( "MasterPanpot" ) ) {
MasterPanpot = PortUtil.parseInt( spl[1] );
} else if ( spl[0].Equals( "MasterMute" ) ) {
MasterMute = PortUtil.parseInt( spl[1] );
} else if ( spl[0].Equals( "OutputMode" ) ) {
OutputMode = PortUtil.parseInt( spl[1] );
} else if ( spl[0].Equals( "Tracks" ) ) {
tracks = PortUtil.parseInt( spl[1] );
} else {
if ( spl[0].StartsWith( "Feder" ) ||
spl[0].StartsWith( "Panpot" ) ||
spl[0].StartsWith( "Mute" ) ||
spl[0].StartsWith( "Solo" ) ) {
buffer += spl[0] + "=" + spl[1] + "\n";
}
}
if ( sr.peek() < 0 ) {
break;
}
last_line.value = sr.readLine();
}
Slave = new Vector<VsqMixerEntry>();
for ( int i = 0; i < tracks; i++ ) {
Slave.add( new VsqMixerEntry( 0, 0, 0, 0 ) );
}
spl = PortUtil.splitString( buffer, new String[] { "\n" }, true );
String[] spl2;
for ( int i = 0; i < spl.Length; i++ ) {
String ind = "";
int index;
spl2 = PortUtil.splitString( spl[i], new char[] { '=' } );
if ( spl2[0].StartsWith( "Feder" ) ) {
ind = spl2[0].Replace( "Feder", "" );
index = PortUtil.parseInt( ind );
Slave.get( index ).Feder = PortUtil.parseInt( spl2[1] );
} else if ( spl2[0].StartsWith( "Panpot" ) ) {
ind = spl2[0].Replace( "Panpot", "" );
index = PortUtil.parseInt( ind );
Slave.get( index ).Panpot = PortUtil.parseInt( spl2[1] );
} else if ( spl2[0].StartsWith( "Mute" ) ) {
ind = spl2[0].Replace( "Mute", "" );
index = PortUtil.parseInt( ind );
Slave.get( index ).Mute = PortUtil.parseInt( spl2[1] );
} else if ( spl2[0].StartsWith( "Solo" ) ) {
ind = spl2[0].Replace( "Solo", "" );
index = PortUtil.parseInt( ind );
Slave.get( index ).Solo = PortUtil.parseInt( 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 );
int count = Slave.size();
sw.writeLine( "Tracks=" + count );
for ( int i = 0; i < count; i++ ) {
VsqMixerEntry item = Slave.get( i );
sw.writeLine( "Feder" + i + "=" + item.Feder );
sw.writeLine( "Panpot" + i + "=" + item.Panpot );
sw.writeLine( "Mute" + i + "=" + item.Mute );
sw.writeLine( "Solo" + i + "=" + item.Solo );
}
}
}
#if !JAVA
}
#endif

View File

@ -0,0 +1,75 @@
/*
* VsqMixerEntry.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.
*/
#if JAVA
package org.kbinani.vsq;
import java.io.*;
#else
using System;
namespace Boare.Lib.Vsq {
#endif
/// <summary>
/// VsqMixerのSlave要素に格納される各エントリ
/// </summary>
#if JAVA
public class VsqMixerEntry implements Cloneable, Serializable {
#else
[Serializable]
public class VsqMixerEntry : ICloneable {
#endif
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;
}
#if !JAVA
public object Clone() {
return clone();
}
#endif
/// <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;
}
#if JAVA
public VsqMixerEntry(){
this( 0, 0, 0, 0 );
#else
public VsqMixerEntry()
: this( 0, 0, 0, 0 ) {
#endif
}
}
#if !JAVA
}
#endif

View File

@ -11,26 +11,31 @@
* 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;
#if JAVA
package org.kbinani.vsq;
using bocoree;
import java.io.*;
#else
using System;
namespace Boare.Lib.Vsq {
using boolean = System.Boolean;
#endif
/// <summary>
/// 音階を表現するためのクラス
/// </summary>
#if JAVA
public class VsqNote implements Serializable {
#else
[Serializable]
public class VsqNote {
#endif
/// <summary>
/// このインスタンスが表す音階のノート値
/// </summary>
public int Value;
private static readonly boolean[] _KEY_TYPE = new boolean[128] {
private static readonly boolean[] _KEY_TYPE = new boolean[] {
true,
false,
true,
@ -232,9 +237,17 @@ namespace Boare.Lib.Vsq {
}
}
override public String ToString() {
#if !JAVA
public override string ToString() {
return toString();
}
#endif
public String toString() {
return getNoteString( Value );
}
}
#if !JAVA
}
#endif

View File

@ -11,25 +11,33 @@
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*/
using System;
using System.Collections.Generic;
#if JAVA
package org.kbinani.vsq;
import java.util.*;
#else
using System;
using bocoree;
using bocoree.java.util;
namespace Boare.Lib.Vsq {
using boolean = System.Boolean;
#endif
#if JAVA
public class VsqNrpn implements Comparable<VsqNrpn> {
#else
public struct VsqNrpn : IComparable<VsqNrpn> {
#endif
public int Clock;
public ushort Nrpn;
public int Nrpn;
public byte DataMsb;
public byte DataLsb;
public boolean DataLsbSpecified;
public boolean msbOmitRequired;
private Vector<VsqNrpn> m_list;
public VsqNrpn( int clock, ushort nrpn, byte data_msb ) {
public VsqNrpn( int clock, int nrpn, byte data_msb ) {
Clock = clock;
Nrpn = nrpn;
DataMsb = data_msb;
@ -39,7 +47,7 @@ namespace Boare.Lib.Vsq {
m_list = new Vector<VsqNrpn>();
}
public VsqNrpn( int clock, ushort nrpn, byte data_msb, byte data_lsb ) {
public VsqNrpn( int clock, int nrpn, byte data_msb, byte data_lsb ) {
Clock = clock;
Nrpn = nrpn;
DataMsb = data_msb;
@ -61,9 +69,9 @@ namespace Boare.Lib.Vsq {
ret.add( v );
}
for ( int i = 0; i < m_list.size(); i++ ) {
ret.addAll( m_list.get( i ).expand() );
ret.addAll( Arrays.asList( m_list.get( i ).expand() ) );
}
return ret.toArray( new VsqNrpn[]{} );
return ret.toArray( new VsqNrpn[] { } );
}
public static Vector<VsqNrpn> sort( Vector<VsqNrpn> list ) {
@ -120,66 +128,74 @@ namespace Boare.Lib.Vsq {
ret.add( src2[i] );
}
Collections.sort( ret );
return ret.toArray( new VsqNrpn[]{} );
return ret.toArray( new VsqNrpn[] { } );
}
public static NrpnData[] convert( VsqNrpn[] source ) {
ushort nrpn = (ushort)source[0].Nrpn;
int nrpn = source[0].Nrpn;
byte msb = (byte)(nrpn >> 8);
byte lsb = (byte)(nrpn - (nrpn << 8));
Vector<NrpnData> ret = new Vector<NrpnData>();
ret.add( new NrpnData( source[0].Clock, 0x63, msb ) );
ret.add( new NrpnData( source[0].Clock, 0x62, lsb ) );
ret.add( new NrpnData( source[0].Clock, 0x06, source[0].DataMsb ) );
ret.add( new NrpnData( source[0].Clock, (byte)0x63, msb ) );
ret.add( new NrpnData( source[0].Clock, (byte)0x62, lsb ) );
ret.add( new NrpnData( source[0].Clock, (byte)0x06, source[0].DataMsb ) );
if ( source[0].DataLsbSpecified ) {
ret.add( new NrpnData( source[0].Clock, 0x26, source[0].DataLsb ) );
ret.add( new NrpnData( source[0].Clock, (byte)0x26, source[0].DataLsb ) );
}
for ( int i = 1; i < source.Length; i++ ) {
VsqNrpn item = source[i];
ushort tnrpn = item.Nrpn;
int tnrpn = item.Nrpn;
msb = (byte)(tnrpn >> 8);
lsb = (byte)(tnrpn - (tnrpn << 8));
if ( item.msbOmitRequired ) {
ret.add( new NrpnData( item.Clock, 0x62, lsb ) );
ret.add( new NrpnData( item.Clock, 0x06, item.DataMsb ) );
ret.add( new NrpnData( item.Clock, (byte)0x62, lsb ) );
ret.add( new NrpnData( item.Clock, (byte)0x06, item.DataMsb ) );
if ( item.DataLsbSpecified ) {
ret.add( new NrpnData( item.Clock, 0x26, item.DataLsb ) );
ret.add( new NrpnData( item.Clock, (byte)0x26, item.DataLsb ) );
}
} else {
ret.add( new NrpnData( item.Clock, 0x63, msb ) );
ret.add( new NrpnData( item.Clock, 0x62, lsb ) );
ret.add( new NrpnData( item.Clock, 0x06, item.DataMsb ) );
ret.add( new NrpnData( item.Clock, (byte)0x63, msb ) );
ret.add( new NrpnData( item.Clock, (byte)0x62, lsb ) );
ret.add( new NrpnData( item.Clock, (byte)0x06, item.DataMsb ) );
if ( item.DataLsbSpecified ) {
ret.add( new NrpnData( item.Clock, 0x26, item.DataLsb ) );
ret.add( new NrpnData( item.Clock, (byte)0x26, item.DataLsb ) );
}
}
}
return ret.toArray( new NrpnData[]{} );
return ret.toArray( new NrpnData[] { } );
}
public int CompareTo( VsqNrpn item ) {
public int compareTo( VsqNrpn item ) {
return Clock - item.Clock;
}
public void append( ushort nrpn, byte data_msb ) {
#if !JAVA
public int CompareTo( VsqNrpn item ) {
return compareTo( item );
}
#endif
public void append( int nrpn, byte data_msb ) {
m_list.add( new VsqNrpn( Clock, nrpn, data_msb ) );
}
public void append( ushort nrpn, byte data_msb, byte data_lsb ) {
public void append( int nrpn, byte data_msb, byte data_lsb ) {
m_list.add( new VsqNrpn( Clock, nrpn, data_msb, data_lsb ) );
}
public void append( ushort nrpn, byte data_msb, boolean msb_omit_required ) {
public void append( int nrpn, byte data_msb, boolean msb_omit_required ) {
VsqNrpn v = new VsqNrpn( Clock, nrpn, data_msb );
v.msbOmitRequired = msb_omit_required;
m_list.add( v );
}
public void append( ushort nrpn, byte data_msb, byte data_lsb, boolean msb_omit_required ) {
public void append( int nrpn, byte data_msb, byte data_lsb, boolean msb_omit_required ) {
VsqNrpn v = new VsqNrpn( Clock, nrpn, data_msb, data_lsb );
v.msbOmitRequired = msb_omit_required;
m_list.add( v );
}
}
#if !JAVA
}
#endif

View File

@ -11,118 +11,120 @@
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*/
#if JAVA
package org.kbinani.vsq;
#else
using System;
using bocoree;
namespace Boare.Lib.Vsq {
using boolean = System.Boolean;
#endif
public class VsqPhoneticSymbol {
private static String[] _SYMBOL_VOWEL_JP = new String[]{
@"a",
@"i",
@"M",
@"e",
@"o",
"a",
"i",
"M",
"e",
"o",
};
private static String[] _SYMBOL_CONSONANT_JP = new String[]{
@"k",
@"k'",
@"g",
@"g'",
@"N",
@"N'",
@"s",
@"S",
@"z",
@"Z",
@"dz",
@"dZ",
@"t",
@"t'",
@"ts",
@"tS",
@"d",
@"d'",
@"n",
@"J",
@"h",
@"h\",
@"C",
@"p\",
@"p\'",
@"b",
@"b'",
@"p",
@"p'",
@"m",
@"m'",
@"j",
@"4",
@"4'",
@"w",
@"N\",
"k",
"k'",
"g",
"g'",
"N",
"N'",
"s",
"S",
"z",
"Z",
"dz",
"dZ",
"t",
"t'",
"ts",
"tS",
"d",
"d'",
"n",
"J",
"h",
"h\\",
"C",
"p\\",
"p\\'",
"b",
"b'",
"p",
"p'",
"m",
"m'",
"j",
"4",
"4'",
"w",
"N\\",
};
private static String[] _SYMBOL_EN = new String[]{
@"@",
@"V",
@"e",
@"e",
@"I",
@"i:",
@"{",
@"O:",
@"Q",
@"U",
@"u:",
@"@r",
@"eI",
@"aI",
@"OI",
@"@U",
@"aU",
@"I@",
@"e@",
@"U@",
@"O@",
@"Q@",
@"w",
@"j",
@"b",
@"d",
@"g",
@"bh",
@"dh",
@"gh",
@"dZ",
@"v",
@"D",
@"z",
@"Z",
@"m",
@"n",
@"N",
@"r",
@"l",
@"l0",
@"p",
@"t",
@"k",
@"ph",
@"th",
@"kh",
@"tS",
@"f",
@"T",
@"s",
@"S",
@"h",
"@",
"V",
"e",
"e",
"I",
"i:",
"{",
"O:",
"Q",
"U",
"u:",
"@r",
"eI",
"aI",
"OI",
"@U",
"aU",
"I@",
"e@",
"U@",
"O@",
"Q@",
"w",
"j",
"b",
"d",
"g",
"bh",
"dh",
"gh",
"dZ",
"v",
"D",
"z",
"Z",
"m",
"n",
"N",
"r",
"l",
"l0",
"p",
"t",
"k",
"ph",
"th",
"kh",
"tS",
"f",
"T",
"s",
"S",
"h",
};
public static boolean isConsonant( String symbol ) {
for ( int i = 0; i < _SYMBOL_CONSONANT_JP.Length; i++ ){
for ( int i = 0; i < _SYMBOL_CONSONANT_JP.Length; i++ ) {
String s = _SYMBOL_CONSONANT_JP[i];
if ( s.Equals( symbol ) ) {
return true;
@ -132,19 +134,19 @@ namespace Boare.Lib.Vsq {
}
public static boolean isValidSymbol( String symbol ) {
for ( int i = 0; i < _SYMBOL_VOWEL_JP.Length; i++ ){
for ( int i = 0; i < _SYMBOL_VOWEL_JP.Length; i++ ) {
String s = _SYMBOL_VOWEL_JP[i];
if ( s.Equals( symbol ) ) {
return true;
}
}
for ( int i = 0; i < _SYMBOL_CONSONANT_JP.Length; i++ ){
for ( int i = 0; i < _SYMBOL_CONSONANT_JP.Length; i++ ) {
String s = _SYMBOL_CONSONANT_JP[i];
if ( s.Equals( symbol ) ) {
return true;
}
}
for ( int i = 0; i < _SYMBOL_EN.Length; i++ ){
for ( int i = 0; i < _SYMBOL_EN.Length; i++ ) {
String s = _SYMBOL_EN[i];
if ( s.Equals( symbol ) ) {
return true;
@ -154,4 +156,6 @@ namespace Boare.Lib.Vsq {
}
}
#if !JAVA
}
#endif

View File

@ -11,22 +11,31 @@
* 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.IO;
using System.Text;
#if JAVA
package org.kbinani.vsq;
import java.io.*;
import java.util.*;
import org.kbinani.*;
#else
using System;
using bocoree;
using bocoree.java.util;
using bocoree.java.io;
namespace Boare.Lib.Vsq {
using boolean = System.Boolean;
#endif
/// <summary>
/// Stores the data of a vsq track.
/// </summary>
#if JAVA
public class VsqTrack implements Cloneable, Serializable {
#else
[Serializable]
public partial class VsqTrack : ICloneable {
public class VsqTrack : ICloneable {
#endif
public String Tag;
/// <summary>
/// トラックの名前。
@ -36,7 +45,11 @@ namespace Boare.Lib.Vsq {
private int m_edited_start = int.MaxValue;
private int m_edited_end = int.MinValue;
#if JAVA
private class SingerEventIterator implements Iterator{
#else
private class SingerEventIterator : Iterator {
#endif
VsqEventList m_list;
int m_pos;
@ -54,7 +67,7 @@ namespace Boare.Lib.Vsq {
return false;
}
public object next() {
public Object next() {
for ( int i = m_pos + 1; i < m_list.getCount(); i++ ) {
VsqEvent item = m_list.getElement( i );
if ( item.ID.type == VsqIDType.Singer ) {
@ -72,7 +85,11 @@ namespace Boare.Lib.Vsq {
}
}
#if JAVA
private class NoteEventIterator implements Iterator{
#else
private class NoteEventIterator : Iterator {
#endif
VsqEventList m_list;
int m_pos;
@ -82,7 +99,8 @@ namespace Boare.Lib.Vsq {
}
public boolean hasNext() {
for ( int i = m_pos + 1; i < m_list.getCount(); i++ ) {
int count = m_list.getCount();
for ( int i = m_pos + 1; i < count; i++ ) {
if ( m_list.getElement( i ).ID.type == VsqIDType.Anote ) {
return true;
}
@ -90,8 +108,9 @@ namespace Boare.Lib.Vsq {
return false;
}
public object next() {
for ( int i = m_pos + 1; i < m_list.getCount(); i++ ) {
public Object next() {
int count = m_list.getCount();
for ( int i = m_pos + 1; i < count; i++ ) {
VsqEvent item = m_list.getElement( i );
if ( item.ID.type == VsqIDType.Anote ) {
m_pos = i;
@ -108,7 +127,11 @@ namespace Boare.Lib.Vsq {
}
}
private class EventIterator : Iterator{
#if JAVA
private class EventIterator implements Iterator{
#else
private class EventIterator : Iterator {
#endif
private VsqEventList m_list;
private int m_pos;
@ -117,7 +140,7 @@ namespace Boare.Lib.Vsq {
m_pos = -1;
}
public Boolean hasNext() {
public boolean hasNext() {
if ( 0 <= m_pos + 1 && m_pos + 1 < m_list.getCount() ) {
return true;
}
@ -137,7 +160,7 @@ namespace Boare.Lib.Vsq {
}
public String getName() {
if ( MetaText == null ) {
if ( MetaText == null || (MetaText != null && MetaText.Common == null) ) {
return "Master Track";
} else {
return MetaText.Common.Name;
@ -146,10 +169,14 @@ namespace Boare.Lib.Vsq {
public void setName( String value ) {
if ( MetaText != null ) {
if ( MetaText.Common == null ) {
MetaText.Common = new VsqCommon();
}
MetaText.Common.Name = value;
}
}
#if !JAVA
[Obsolete]
public String Name {
get {
@ -159,6 +186,7 @@ namespace Boare.Lib.Vsq {
setName( value );
}
}
#endif
/// <summary>
/// ピッチベンド。Cent単位
@ -220,24 +248,43 @@ namespace Boare.Lib.Vsq {
/// <param name="encode"></param>
/// <param name="eos"></param>
/// <param name="start"></param>
public void printMetaText( TextMemoryStream sw, int eos, int start ) {
MetaText.print( sw, false, eos, start );
public void printMetaText( TextMemoryStream sw, int eos, int start )
#if JAVA
throws IOException
#endif
{
MetaText.print( sw, eos, start );
}
/// <summary>
/// メタテキストを,指定されたファイルに出力します
/// </summary>
/// <param name="file"></param>
public void printMetaText( String file ) {
public void printMetaText( String file )
#if JAVA
throws IOException
#endif
{
TextMemoryStream tms = new TextMemoryStream();
int count = MetaText.getEventList().getCount();
int clLast = MetaText.getEventList().getElement( count - 1 ).Clock + 480;
MetaText.print( tms, true, clLast, 0 );
using ( StreamWriter sw = new StreamWriter( file ) ) {
MetaText.print( tms, clLast, 0 );
BufferedWriter sw = null;
try {
sw = new BufferedWriter( new FileWriter( file ) );
tms.rewind();
while ( tms.peek() >= 0 ) {
String line = tms.readLine();
sw.WriteLine( line );
sw.write( line );
sw.newLine();
}
} catch ( Exception ex ) {
} finally {
if ( sw != null ) {
try {
sw.close();
} catch ( Exception ex2 ) {
}
}
}
}
@ -249,7 +296,7 @@ namespace Boare.Lib.Vsq {
return MetaText.master;
}
internal void setMaster( VsqMaster value ) {
public void setMaster( VsqMaster value ) {
MetaText.master = value;
}
@ -260,7 +307,7 @@ namespace Boare.Lib.Vsq {
return MetaText.mixer;
}
internal void setMixer( VsqMixer value ) {
public void setMixer( VsqMixer value ) {
MetaText.mixer = value;
}
@ -280,28 +327,31 @@ namespace Boare.Lib.Vsq {
/// <param name="singers"></param>
public void changeRenderer( String new_renderer, Vector<VsqID> singers ) {
VsqID default_id = null;
if ( singers.size() <= 0 ) {
int singers_size = singers.size();
if ( singers_size <= 0 ) {
default_id = new VsqID();
default_id.type = VsqIDType.Singer;
default_id.IconHandle = new IconHandle();
default_id.IconHandle.IconID = "$0701" + 0.ToString( "0000" );
default_id.IconHandle.IconID = "$0701" + PortUtil.toHexString( 0, 4 );
default_id.IconHandle.IDS = "Unknown";
default_id.IconHandle.Index = 0;
default_id.IconHandle.Language = 0;
default_id.IconHandle.Length = 1;
default_id.IconHandle.setLength( 1 );
default_id.IconHandle.Original = 0;
default_id.IconHandle.Program = 0;
default_id.IconHandle.Caption = "";
} else {
default_id = singers.get( 0 );
}
for ( Iterator itr = getSingerEventIterator(); itr.hasNext(); ) {
VsqEvent ve = (VsqEvent)itr.next();
int program = ve.ID.IconHandle.Program;
boolean found = false;
for ( int i = 0; i < singers.size(); i++ ) {
if ( program == singers.get( i ).IconHandle.Program ) {
ve.ID = (VsqID)singers.get( i ).clone();
for ( int i = 0; i < singers_size; i++ ) {
VsqID id = singers.get( i );
if ( program == id.IconHandle.Program ) {
ve.ID = (VsqID)id.clone();
found = true;
break;
}
@ -398,7 +448,7 @@ namespace Boare.Lib.Vsq {
VsqTrack res = new VsqTrack();
res.setName( getName() );
if ( MetaText != null ) {
res.MetaText = (VsqMetaText)MetaText.Clone();
res.MetaText = (VsqMetaText)MetaText.clone();
}
res.m_edited_start = m_edited_start;
res.m_edited_end = m_edited_end;
@ -406,9 +456,11 @@ namespace Boare.Lib.Vsq {
return res;
}
#if !JAVA
public object Clone() {
return clone();
}
#endif
/// <summary>
/// Master Trackを構築
@ -431,8 +483,13 @@ namespace Boare.Lib.Vsq {
MetaText = new VsqMetaText( name, singer );
}
#if JAVA
public VsqTrack(){
this( "Voice1", "Miku" );
#else
public VsqTrack()
: this( "Voice1", "Miku" ) {
#endif
}
/// <summary>
@ -449,31 +506,57 @@ namespace Boare.Lib.Vsq {
return counter;
}
public VsqTrack( Vector<Boare.Lib.Vsq.MidiEvent> midi_event, Encoding encoding ) {
public VsqTrack( Vector<MidiEvent> midi_event, String encoding ) {
#if DEBUG
bocoree.debug.push_log( "VsqTrack..ctor" );
#endif
String track_name = "";
using ( TextMemoryStream sw = new TextMemoryStream() ) {
for ( int i = 0; i < midi_event.size(); i++ ) {
if ( midi_event.get( i ).firstByte == 0xff && midi_event.get( i ).data.Length > 0 ) {
TextMemoryStream sw = null;
try {
sw = new TextMemoryStream();
int count = midi_event.size();
Vector<Byte> buffer = new Vector<Byte>();
for ( int i = 0; i < count; i++ ) {
MidiEvent item = midi_event.get( i );
if ( item.firstByte == 0xff && item.data.Length > 0 ) {
// meta textを抽出
byte type = midi_event.get( i ).data[0];
byte type = item.data[0];
if ( type == 0x01 || type == 0x03 ) {
/*char[] ch = new char[midi_event.get( i ).data.Length - 1];
for ( int j = 1; j < midi_event.get( i ).data.Length; j++ ) {
ch[j - 1] = (char)midi_event.get( i ).data[j];
//String line = PortUtil.getDecodedString( encoding, dat, 1, dat.Length - 1 );
if ( type == 0x01 ) {
int colon_count = 0;
for ( int j = 0; j < item.data.Length - 1; j++ ) {
byte d = item.data[j + 1];
if ( d == 0x3a ) {
colon_count++;
if ( colon_count <= 2 ) {
continue;
}
}
if ( colon_count < 2 ) {
continue;
}
buffer.add( d );
}
String line = new String( ch );*/
byte[] dat = midi_event.get( i ).data;
String line = encoding.GetString( dat, 1, dat.Length - 1 );
if ( type == 0x01 ) {
int second_colon = line.IndexOf( ':', 3 );
int index_0x0a = buffer.indexOf( 0x0a );
while ( index_0x0a >= 0 ) {
byte[] cpy = new byte[index_0x0a];
for ( int j = 0; j < index_0x0a; j++ ) {
cpy[j] = buffer.get( 0 );
buffer.removeElementAt( 0 );
}
String line = PortUtil.getDecodedString( encoding, cpy );
sw.writeLine( line );
buffer.removeElementAt( 0 );
index_0x0a = buffer.indexOf( 0x0a );
}
/*int second_colon = line.IndexOf( ':', 3 );
line = line.Substring( second_colon + 1 );
line = line.Replace( "\\n", "\n" );
//line = line.Replace( "\n", Environment.NewLine );
String[] lines = line.Split( '\n' );
String[] lines = PortUtil.splitString( line, '\n' );
int c = lines.Length;
for ( int j = 0; j < c; j++ ) {
if ( j < c - 1 ) {
@ -481,10 +564,17 @@ namespace Boare.Lib.Vsq {
} else {
sw.write( lines[j] );
}
}
//sw.write( line );
}*/
} else {
track_name = line;
for ( int j = 0; j < item.data.Length - 1; j++ ) {
buffer.add( item.data[j + 1] );
}
track_name = PortUtil.getDecodedString( encoding,
PortUtil.convertByteArray( buffer.toArray( new Byte[] { } ) ) );
#if DEBUG
Console.WriteLine( "VsqTrack#.ctor; track_name=" + track_name );
#endif
buffer.clear();
}
}
} else {
@ -494,8 +584,19 @@ namespace Boare.Lib.Vsq {
sw.rewind();
MetaText = new VsqMetaText( sw );
setName( track_name );
} catch ( Exception ex ) {
PortUtil.println( "com.boare.vsq.VsqTrack#.ctor; ex=" + ex );
} finally {
if ( sw != null ) {
try {
sw.close();
} catch ( Exception ex2 ) {
}
}
}
}
}
#if !JAVA
}
#endif

View File

@ -11,24 +11,26 @@
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*/
#if JAVA
package org.kbinani.vsq;
#else
namespace Boare.Lib.Vsq {
#endif
/// <summary>
/// Represents the voice language of singer.
/// </summary>
public enum VsqVoiceLanguage : int {
/// <summary>
/// Default value, equivalent to "Japanese".
/// </summary>
Default = 0,
public enum VsqVoiceLanguage {
/// <summary>
/// Japanese
/// </summary>
Japanese = 0,
Japanese,
/// <summary>
/// English
/// </summary>
English = 1,
English,
}
#if !JAVA
}
#endif

View File

@ -0,0 +1,65 @@
/*
* WrappedStreamWriter.cs
* Copyright (c) 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.
*/
#if JAVA
package org.kbinani.vsq;
import java.io.*;
#else
using System;
using bocoree;
using bocoree.java.io;
namespace Boare.Lib.Vsq {
#endif
#if JAVA
public class WrappedStreamWriter implements ITextWriter {
#else
public class WrappedStreamWriter : ITextWriter {
#endif
BufferedWriter m_writer;
public WrappedStreamWriter( BufferedWriter stream_writer ) {
m_writer = stream_writer;
}
public void write( String value )
#if JAVA
throws IOException
#endif
{
m_writer.write( value );
}
public void writeLine( String value )
#if JAVA
throws IOException
#endif
{
m_writer.write( value );
m_writer.newLine();
}
public void close()
#if JAVA
throws IOException
#endif
{
m_writer.close();
}
}
#if !JAVA
}
#endif

Some files were not shown because too many files have changed in this diff Show More