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

This commit is contained in:
kbinani 2009-07-29 17:03:20 +00:00
parent 0453ea1636
commit 8ab2a598b3
49 changed files with 3567 additions and 1370 deletions

View File

@ -429,11 +429,11 @@ namespace Boare.Lib.AppUtil {
protected override void OnSizeChanged( EventArgs e ) {
#if DEBUG
Console.WriteLine( "BSplitContainer+OnSizeChanged" );
//Console.WriteLine( "BSplitContainer+OnSizeChanged" );
//Console.WriteLine( " FixedPanel=" + FixedPanel );
//Console.WriteLine( " m_splitter_distance=" + m_splitter_distance );
Console.WriteLine( " Width=" + Width );
Console.WriteLine( " Height=" + Height );
//Console.WriteLine( " Width=" + Width );
//Console.WriteLine( " Height=" + Height );
//Console.WriteLine( " m_panel2_distance=" + m_panel2_distance );
#endif
base.OnSizeChanged( e );

View File

@ -3,15 +3,18 @@
<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>{0C58B068-272F-4390-A14F-3D72AFCF3DFB}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Boare.Lib.AppUtil</RootNamespace>
<AssemblyName>Boare.Lib.AppUtil</AssemblyName>
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
<TargetFrameworkVersion>v2.0</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<SignAssembly>false</SignAssembly>
<AssemblyOriginatorKeyFile>
</AssemblyOriginatorKeyFile>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
@ -49,9 +52,6 @@
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
<Reference Include="System.Drawing" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml.Linq">
@ -74,6 +74,10 @@
<Compile Include="BitmapEx.cs" />
<Compile Include="ColorBar.cs" />
<Compile Include="CubicSpline.cs" />
<Compile Include="CursorUtil.cs" />
<Compile Include="DockPanelContainer.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="InputBox.cs">
<SubType>Form</SubType>
</Compile>
@ -81,6 +85,7 @@
<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" />

View File

@ -21,7 +21,7 @@ namespace Boare.Lib.AppUtil {
public class MessageBody {
public string lang;
public string po_header = "";
public Dictionary<string, string> list = new Dictionary<string,string>();
public Dictionary<string, MessageBodyEntry> list = new Dictionary<string, MessageBodyEntry>();
public MessageBody( string lang_ ) {
lang = lang_;
@ -29,55 +29,81 @@ namespace Boare.Lib.AppUtil {
public MessageBody( string lang, string[] ids, string[] messages ) {
this.lang = lang;
list = new Dictionary<string, string>();
list = new Dictionary<string, MessageBodyEntry>();
for( int i = 0; i < ids.Length; i++ ) {
list.Add( ids[i], messages[i] );
list.Add( ids[i], new MessageBodyEntry( messages[i], new string[] { } ) );
}
}
public MessageBody( string lang_, string file ) {
lang = lang_;
//Dictionary<string, string> list = new Dictionary<string, string>();
po_header = "";
using ( StreamReader sr = new StreamReader( file ) ) {
while ( sr.Peek() >= 0 ) {
string msgid;
string first_line = sr.ReadLine();
string last_line = ReadTillMessageEnd( sr, first_line, "msgid", out msgid );
string[] location;
string last_line = ReadTillMessageEnd( sr, first_line, "msgid", out msgid, out location );
string msgstr;
last_line = ReadTillMessageEnd( sr, last_line, "msgstr", out msgstr );
//if ( msgid.Length > 0 && msgstr.Length > 0 ) {
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] = msgstr;
list[msgid] = new MessageBodyEntry( msgstr, location );
} else {
list.Add( msgid, msgstr );
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 = "";
int count = 0;
foreach ( string line in spl ) {
string[] spl2 = line.Split( 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";
} else {
po_header += (count == 0 ? "" : "\n") + line;
}
} else {
po_header += (count == 0 ? "" : "\n") + line;
}
count++;
}
}
}
}
string[] ids = new string[list.Keys.Count];
string[] msgs = new string[ids.Length];
int i = -1;
foreach ( string id in list.Keys ) {
i++;
ids[i] = id;
msgs[i] = list[ids[i]];
}
#if DEBUG
Console.WriteLine( "MessageBody..ctor; po_header=" + po_header );
#endif
}
public string GetMessage( string id ) {
if ( list.ContainsKey( id ) ) {
string ret = list[id];
string ret = list[id].Message;
if ( ret == "" ) {
return id;
} else {
return list[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[] { } );
} else {
return list[id];
}
}
return id;
return new MessageBodyEntry( id, new string[] { } );
}
public void Write( string file ) {
@ -85,19 +111,26 @@ namespace Boare.Lib.AppUtil {
if ( po_header != "" ) {
sw.WriteLine( "msgid \"\"" );
sw.WriteLine( "msgstr \"\"" );
sw.WriteLine( po_header );
string[] spl = po_header.Split( new char[] { (char)0x0d, (char)0x0a }, StringSplitOptions.RemoveEmptyEntries );
foreach ( string line in spl ) {
sw.WriteLine( "\"" + line + "\\" + "n\"" );
}
sw.WriteLine();
} 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( "\"Content-Type: text/plain; charset=UTF-8\\" + "n\"" );
sw.WriteLine( "\"Content-Transfer-Encoding: 8bit\\" + "n\"" );
sw.WriteLine();
}
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] );
}
sw.WriteLine( "msgid \"" + skey + "\"" );
string s = list[key];
s = s.Replace( "\n", "\\n\"\n\"" );
sw.WriteLine( "msgstr \"" + s + "\"" );
sw.WriteLine();
@ -120,28 +153,35 @@ namespace Boare.Lib.AppUtil {
message = message.Substring( 0, message.Length - 1 );
}
private static string ReadTillMessageEnd( StreamReader sr, string first_line, string entry, out string msg ) {
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;
if ( line.StartsWith( entry ) ) {
// 1行目がすでに"entry"の行だった場合
string dum, dum2;
SeparateEntryAndMessage( line, out dum, out dum2 );
msg += dum2;
} else {
while ( sr.Peek() >= 0 ) {
line = sr.ReadLine();
if ( line.StartsWith( "#" ) ) {
continue;
}
if ( line.StartsWith( entry ) ) {
while ( true ) {
if ( line.StartsWith( "#:" ) ) {
line = line.Substring( 2 ).Trim();
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 {
break;
}
}
}
locations = location.ToArray();
string ret = "";
while ( sr.Peek() >= 0 ) {
line = sr.ReadLine();

View File

@ -91,6 +91,18 @@ namespace Boare.Lib.AppUtil {
s_messages.Add( new MessageBody( Path.GetFileNameWithoutExtension( file ), file ) );
}
public static MessageBodyEntry GetMessageDetail( string id ) {
if ( s_lang.Length <= 0 ) {
s_lang = "en";
}
foreach ( MessageBody mb in s_messages ) {
if ( mb.lang == s_lang ) {
return mb.GetMessageDetail( id );
}
}
return new MessageBodyEntry( id, new string[] { } );
}
public static string GetMessage( string id ) {
if ( s_lang.Length <= 0 ) {
s_lang = "en";

View File

@ -13,16 +13,120 @@
*/
using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using System.Windows.Forms;
using System.Drawing.Imaging;
using System.Reflection;
using System.IO;
using System.Reflection;
using System.Windows.Forms;
namespace Boare.Lib.AppUtil {
public static partial class Misc {
public static void ApplyContextMenuFontRecurse( ContextMenuStrip item, Font font ) {
item.Font = font;
foreach ( ToolStripItem tsi in item.Items ) {
ApplyToolStripFontRecurse( tsi, font );
}
}
public static void ApplyToolStripFontRecurse( ToolStripItem item, Font font ) {
item.Font = font;
if ( item is ToolStripMenuItem ) {
ToolStripMenuItem tsmi = (ToolStripMenuItem)item;
foreach ( ToolStripItem tsi in tsmi.DropDownItems ) {
ApplyToolStripFontRecurse( tsi, font );
}
} else if ( item is ToolStripDropDownItem ) {
ToolStripDropDownItem tsdd = (ToolStripDropDownItem)item;
foreach ( ToolStripItem tsi in tsdd.DropDownItems ) {
ApplyToolStripFontRecurse( tsi, font );
}
}
}
/// <summary>
/// 指定したフォントを描画するとき、描画指定したy座標と、描かれる文字の中心線のズレを調べます
/// </summary>
/// <param name="font"></param>
/// <returns></returns>
public static int GetStringDrawOffset( Font font ) {
int ret = 0;
string pangram = "cozy lummox gives smart squid who asks for job pen. 01234567890 THE QUICK BROWN FOX JUMPED OVER THE LAZY DOGS.";
SizeF size = new SizeF();
using ( Bitmap b = new Bitmap( 1, 1 ) ) {
using ( Graphics g = Graphics.FromImage( b ) ) {
size = g.MeasureString( pangram, font );
}
}
if ( size.Height <= 0 ) {
return 0;
}
using ( Bitmap b = new Bitmap( (int)size.Width * 3, (int)size.Height * 3 ) ) {
using ( Graphics g = Graphics.FromImage( b ) ) {
g.Clear( Color.White );
g.DrawString( pangram, font, Brushes.Black, new PointF( (int)size.Width, (int)size.Height ) );
}
using ( BitmapEx b2 = new BitmapEx( b ) ) {
// 上端に最初に現れる色つきピクセルを探す
int firsty = 0;
bool found = false;
for ( int y = 0; y < b2.Height; y++ ) {
for ( int x = 0; x < b2.Width; x++ ) {
Color c = b2.GetPixel( x, y );
if ( c.R != 255 || c.G != 255 || c.B != 255 ) {
found = true;
firsty = y;
break;
}
}
if ( found ) {
break;
}
}
// 下端
int endy = b2.Height - 1;
found = false;
for ( int y = b2.Height - 1; y >= 0; y-- ) {
for ( int x = 0; x < b2.Width; x++ ) {
Color c = b2.GetPixel( x, y );
if ( c.R != 255 || c.G != 255 || c.B != 255 ) {
found = true;
endy = y;
break;
}
}
if ( found ) {
break;
}
}
int center = (firsty + endy) / 2;
ret = center - (int)size.Height;
}
}
return ret;
}
/// <summary>
/// 指定した言語コードの表す言語が、右から左へ記述する言語かどうかを調べます
/// </summary>
/// <param name="language_code"></param>
/// <returns></returns>
public static bool IsRightToLeftLanguage( string language_code ) {
language_code = language_code.ToLower();
switch ( language_code ) {
case "ar":
case "he":
case "iw":
case "fa":
case "ur":
return true;
default:
return false;
}
}
/// <summary>
/// 指定したディレクトリに作成可能な、一時ファイル名を取得します
/// </summary>
@ -92,19 +196,19 @@ namespace Boare.Lib.AppUtil {
public static string GetExtensionFromImageFormat( ImageFormat format ) {
switch ( format.ToString().ToLower() ) {
case "bmp":
return "bmp";
return ".bmp";
case "emf":
return "emf";
return ".emf";
case "gif":
return "gif";
return ".gif";
case "jpeg":
return "jpg";
return ".jpg";
case "png":
return "png";
return ".png";
case "tiff":
return "tiff";
return ".tiff";
case "wmf":
return "wmf";
return ".wmf";
default:
return "";
@ -169,44 +273,6 @@ namespace Boare.Lib.AppUtil {
v = imax;
}
/*public static void RgbToHsv( double r, double g, double b, out double h, out double s, out double v ) {
double tmph, imax, imin;
const double sqrt3 = 1.7320508075688772935274463415059;
const double deg2rad = 180.0 / Math.PI;
imax = Math.Max( r, Math.Max( g, b ) );
imin = Math.Min( r, Math.Min( g, b ) );
if ( imax == 0.0 ) {
h = 0;
s = 0;
v = 0;
return;
} else if ( imax == imin ) {
tmph = 0;
} else {
double x = 2.0 * r - g - b;
double y = sqrt3 * (g - b);
if ( x == 0.0 ) {
if ( y > 0.0 ) {
tmph = 90.0;
} else {
tmph = 270.0;
}
} else {
tmph = Math.Atan2( y, x );
tmph = tmph * deg2rad;
}
}
while ( tmph < 0.0 ) {
tmph = tmph + 360.0;
}
while ( tmph >= 360.0 ) {
tmph = tmph - 360.0;
}
h = tmph / 360.0;
s = (imax - imin) / imax;
v = imax;
}*/
public static Color HsvToColor( double h, double s, double v ) {
double dr, dg, db;
HsvToRgb( h, s, v, out dr, out dg, out db );
@ -286,7 +352,7 @@ namespace Boare.Lib.AppUtil {
}
/// <summary>
/// 指定したコントロールと、その子コントロールのフォントを変更します
/// 指定したコントロールと、その子コントロールのフォントを再帰的に変更します
/// </summary>
/// <param name="c"></param>
/// <param name="font"></param>

View File

@ -179,6 +179,7 @@ namespace Boare.Lib.AppUtil {
m_last_speed = 0f;
m_last_t = 0f;
m_shift = 0f;
timer.Enabled = true;
} else {
timer.Enabled = false;

View File

@ -1,4 +1,17 @@
using System;
/*
* XmlSerializeWithDescription.cs
* Copyright (c) 2009 kbinani
*
* This file is part of Boare.Lib.AppUtil.
*
* Boare.Lib.AppUtil is free software; you can redistribute it and/or
* modify it under the terms of the BSD License.
*
* Boare.Lib.AppUtil 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.Xml;
@ -41,9 +54,6 @@ namespace Boare.Lib.AppUtil {
/// フィールドおよびプロパティを、XmlItemDescription属性の文字列を付加しながらXmlシリアライズする
/// </summary>
public class XmlSerializeWithDescription {
[XmlItemDescription( "mio" )]
private string foo;
private XmlTextWriter m_writer;
private Type m_type;
@ -69,28 +79,11 @@ namespace Boare.Lib.AppUtil {
if ( t.IsGenericType ) {
List<int> f = new List<int>();
Type list_type = f.GetType().GetGenericTypeDefinition();
#if DEBUG
Console.WriteLine( "t.GetGenericTypeDefinition().Equals( list_type )=" + t.GetGenericTypeDefinition().Equals( list_type ) );
#endif
if ( t.GetGenericTypeDefinition().Equals( list_type ) ) {
Type[] gen = t.GetGenericArguments();
#if DEBUG
Console.WriteLine( "gen.Length=" + gen.Length );
#endif
if ( gen.Length == 1 ) {
PropertyInfo count_property = t.GetProperty( "Count", typeof( int ) );
int count = (int)count_property.GetValue( obj, new object[] { } );
#if DEBUG
Console.WriteLine( "count=" + count );
Console.WriteLine( "Properties" );
foreach ( PropertyInfo pi in t.GetProperties() ) {
Console.WriteLine( " " + pi );
}
Console.WriteLine( "Methods" );
foreach ( MethodInfo mi in t.GetMethods() ) {
Console.WriteLine( " " + mi );
}
#endif
Type returntype = gen[0];
MethodInfo indexer = t.GetMethod( "get_Item", new Type[] { typeof( int ) } );
string name = "";
@ -134,9 +127,6 @@ namespace Boare.Lib.AppUtil {
xid = (XmlItemDescription)attr[0];
}
WriteContents( fi.Name, fi.GetValue( obj ), xid );
#if DEBUG
m_writer.Flush();
#endif
}
foreach ( PropertyInfo pi in t.GetProperties() ) {
if ( !pi.CanRead | !pi.CanWrite ) {
@ -154,9 +144,6 @@ namespace Boare.Lib.AppUtil {
xid = (XmlItemDescription)attr[0];
}
WriteContents( pi.Name, pi.GetValue( obj, new object[] { } ), xid );
#if DEBUG
m_writer.Flush();
#endif
}
}
}

View File

@ -6,12 +6,6 @@ Boare.Lib.AppUtil.dll: *.cs bocoree.dll
gmcs $(OPT) -recurse:*.cs -unsafe+ -target:library -out:Boare.Lib.AppUtil.dll \
-r:bocoree.dll,System.Drawing,System.Windows.Forms
bocoree.dll: ../bocoree/bocoree.dll
cp ../bocoree/bocoree.dll bocoree.dll
../bocoree/bocoree.dll:
cd ../bocoree/ && $(MAKE) OPT=$(OPT)
clean:
$(RM) Boare.Lib.AppUtil.dll
$(RM) bocoree.dll

View File

@ -15,6 +15,9 @@
<TargetFrameworkVersion>v2.0</TargetFrameworkVersion>
<UpgradeBackupLocation>
</UpgradeBackupLocation>
<SignAssembly>false</SignAssembly>
<AssemblyOriginatorKeyFile>
</AssemblyOriginatorKeyFile>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
@ -63,6 +66,7 @@
<Compile Include="IAviWriter.cs" />
<Compile Include="MediaPlayer.cs" />
<Compile Include="MidiInDevice.cs" />
<Compile Include="MidiOutDevice.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="RawAvi2Writer.cs" />
<Compile Include="PipedAviWriter.cs" />

View File

@ -24,23 +24,10 @@ namespace Boare.Lib.Media {
public class MidiInDevice : IDisposable {
delegate void MidiInProcDelegate( uint hMidiIn, uint wMsg, int dwInstance, int dwParam1, int dwParam2 );
private const int CALLBACK_EVENT = 0x50000;
private const int CALLBACK_FUNCTION = 0x30000;
private const int CALLBACK_NULL = 0;
private const int CALLBACK_TASK = 0x20000;
private const int CALLBACK_THREAD = 0x20000;
private const int CALLBACK_TYPEMASK = 0x70000;
private const int CALLBACK_WINDOW = 0x10000;
private volatile MidiInProcDelegate m_delegate;
private IntPtr m_delegate_pointer;
private uint m_hmidiin = 0;
private int m_port_number;
private const int MM_MIM_CLOSE = 0x3c2;
private const int MM_MIM_DATA = 0x3c3;
private const int MM_MIM_ERROR = 0x3c5;
private const int MM_MIM_LONGDATA = 0x3c4;
private const int MM_MIM_LONGERROR = 0x3c6;
private const int MM_MIM_OPEN = 0x3c1;
public event MidiReceivedEventHandler MidiReceived;
@ -48,7 +35,7 @@ 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, CALLBACK_FUNCTION );
windows.midiInOpen( ref m_hmidiin, port_number, m_delegate_pointer, 0, windows.CALLBACK_FUNCTION );
}
public void Start() {
@ -116,14 +103,14 @@ namespace Boare.Lib.Media {
return ret.ToArray();
}
private void MidiInProc( uint hMidiIn, uint wMsg, int dwInstance, int dwParam1, int dwParam2 ) {
public void MidiInProc( uint hMidiIn, uint wMsg, int dwInstance, int dwParam1, int dwParam2 ) {
try {
switch ( wMsg ) {
case MM_MIM_OPEN:
case windows.MM_MIM_OPEN:
return;
case MM_MIM_CLOSE:
case windows.MM_MIM_CLOSE:
return;
case MM_MIM_DATA:
case windows.MM_MIM_DATA:
int receive = dwParam1;
DateTime now = DateTime.Now;
switch ( receive & 0xF0 ) {
@ -147,11 +134,11 @@ namespace Boare.Lib.Media {
break;
}
return;
case MM_MIM_LONGDATA:
case windows.MM_MIM_LONGDATA:
return;
case MM_MIM_ERROR:
case windows.MM_MIM_ERROR:
return;
case MM_MIM_LONGERROR:
case windows.MM_MIM_LONGERROR:
return;
}
} catch ( Exception ex ) {

View File

@ -85,6 +85,44 @@ namespace Boare.Lib.Media {
}
}
#endif
public unsafe double TEST_GetF0( uint time, double[] window_function ) {
int window_size = window_function.Length;
double[] formanto = GetFormanto( time, window_function );
#if DEBUG
if ( s_test ) {
using ( StreamWriter sw = new StreamWriter( @"C:\TEST_GetF0_formanto.txt" ) ) {
for ( int i = 0; i < formanto.Length; i++ ) {
sw.WriteLine( Math.Abs( formanto[i] ) );
}
}
}
#endif
int size = formanto.Length;
double[] wv = new double[size + 1];
for ( int i = 0; i < size; i++ ) {
wv[i] = formanto[i];
}
int nmaxsqrt = (int)Math.Sqrt( size );
int[] ip_ = new int[nmaxsqrt + 2];
double[] w_ = new double[size * 5 / 4];
ip_[0] = 0;
fixed ( int* ip = &ip_[0] )
fixed ( double* w = &w_[0] )
fixed ( double* a = &wv[0] ) {
fft.rdft( size, 1, a, ip, w );
}
#if DEBUG
if ( s_test ) {
using ( StreamWriter sw = new StreamWriter( @"C:\TEST_GetF0_fft_formanto.txt" ) ) {
for ( int i = 0; i < wv.Length; i++ ) {
sw.WriteLine( Math.Abs( wv[i] ) );
}
}
}
#endif
return 0;
}
public double GetF0( uint time, double[] window_function ) {
return GetF0( time, window_function, new FormantoDetectionArguments() );

View File

@ -71,21 +71,15 @@ namespace Boare.Lib.Media {
} else {
index_done = dwuser;
}
#if DEBUG
bocoree.debug.push_log( "dwuser=" + dwuser );
bocoree.debug.push_log( "index_done=" + index_done );
#endif
s_done[index_done] = true;
if ( s_last_buffer == index_done ) {
s_playing = false;
if ( 0 <= index_done && index_done < _NUM_BUF ) {
s_done[index_done] = true;
if ( s_last_buffer == index_done ) {
s_playing = false;
}
if ( dwuser >= _NUM_BUF ) {
s_wave_header[index_done].dwUser = new IntPtr( index_done );
}
}
if ( dwuser >= _NUM_BUF ) {
s_wave_header[index_done].dwUser = new IntPtr( index_done );
}
#if DEBUG
bocoree.debug.push_log( "whdr.dwUser=" + whdr.dwUser.ToInt32() );
bocoree.debug.push_log( "dwParam1=0x" + Convert.ToString( dwParam1, 16 ) + "; dwParam2=0x" + Convert.ToString( dwParam2, 16 ) );
#endif
}
}

View File

@ -40,7 +40,7 @@ namespace Boare.Lib.Media {
if ( m_opened ) {
m_stream.Close();
}
m_stream = new FileStream( file, FileMode.Open );
m_stream = new FileStream( file, FileMode.Open, FileAccess.Read );
// RIFF
byte[] buf = new byte[4];
@ -116,13 +116,13 @@ namespace Boare.Lib.Media {
}
}
public void Read( int start, int length, out float[] left, out float[] right ) {
left = new float[length];
right = new float[length];
public void Read( long start, int length, out double[] left, out double[] right ) {
left = new double[length];
right = new double[length];
if ( !m_opened ) {
return;
}
int loc = 0x2e + m_byte_per_sample * m_channel * start;
long loc = 0x2e + m_byte_per_sample * m_channel * start;
m_stream.Seek( loc, SeekOrigin.Begin );
if ( m_byte_per_sample == 2 ) {
@ -191,7 +191,82 @@ namespace Boare.Lib.Media {
}
}
public unsafe void Read( int start, int length, out IntPtr ptr_left, out IntPtr ptr_right ) {
public void Read( long start, int length, out float[] left, out float[] right ) {
left = new float[length];
right = new float[length];
if ( !m_opened ) {
return;
}
long loc = 0x2e + m_byte_per_sample * m_channel * start;
m_stream.Seek( loc, SeekOrigin.Begin );
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 );
if ( ret < 4 ) {
for ( int j = i; j < length; j++ ) {
left[j] = 0.0f;
right[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;
}
} else {
byte[] buf = new byte[2];
for ( int i = 0; i < length; i++ ) {
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;
}
break;
}
short l = (short)(buf[0] | buf[1] << 8);
left[i] = l / 32768.0f;
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 );
if ( ret < 2 ) {
for ( int j = i; j < length; j++ ) {
left[j] = 0.0f;
right[j] = 0.0f;
}
break;
}
left[i] = (buf[0] - 64.0f) / 64.0f;
right[i] = (buf[1] - 64.0f) / 64.0f;
}
} else {
byte[] buf = new byte[1];
for ( int i = 0; i < length; i++ ) {
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;
}
break;
}
left[i] = (buf[0] - 64.0f) / 64.0f;
right[i] = left[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 );
float* left = (float*)ptr_left.ToPointer();
@ -199,7 +274,7 @@ namespace Boare.Lib.Media {
if ( !m_opened ) {
return;
}
int loc = 0x2e + m_byte_per_sample * m_channel * start;
long loc = 0x2e + m_byte_per_sample * m_channel * start;
m_stream.Seek( loc, SeekOrigin.Begin );
if ( m_byte_per_sample == 2 ) {
@ -272,6 +347,7 @@ namespace Boare.Lib.Media {
m_opened = false;
if ( m_stream != null ) {
m_stream.Close();
m_stream = null;
}
}

View File

@ -30,7 +30,7 @@ namespace Boare.Lib.Media {
public WaveWriter( string path, WaveChannel channel, ushort bit_per_sample, uint sample_rate ) {
m_path = path;
m_stream = new FileStream( m_path, FileMode.Create );
m_stream = new FileStream( m_path, FileMode.Create, FileAccess.Write );
m_channel = channel;
m_bit_per_sample = bit_per_sample;
m_sample_rate = sample_rate;

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>
@ -15,6 +15,9 @@
<TargetFrameworkVersion>v2.0</TargetFrameworkVersion>
<UpgradeBackupLocation>
</UpgradeBackupLocation>
<SignAssembly>false</SignAssembly>
<AssemblyOriginatorKeyFile>
</AssemblyOriginatorKeyFile>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
@ -60,14 +63,20 @@
<Compile Include="PortUtil.cs" />
<Compile Include="NRPN.cs" />
<Compile Include="SingerConfig.cs" />
<Compile Include="SingerConfigSys.cs" />
<Compile Include="SMF\MidiFile.cs" />
<Compile Include="SymbolTable.cs" />
<Compile Include="UstEnvelope.cs" />
<Compile Include="UstEvent.cs" />
<Compile Include="UstFile.cs" />
<Compile Include="UstPortamento.cs" />
<Compile Include="UstTrack.cs" />
<Compile Include="UstVibrato.cs" />
<Compile Include="VibratoBPList.cs" />
<Compile Include="VibratoBPPair.cs" />
<Compile Include="VibratoType.cs" />
<Compile Include="VocaloSingerConfigSys.cs" />
<Compile Include="VocaloSysUtil.cs" />
<Compile Include="VsqEventList.cs" />
<Compile Include="VsqNrpn.cs" />
<Compile Include="NrpnData.cs" />
@ -91,7 +100,7 @@
<Compile Include="VsqNote.cs" />
<Compile Include="VsqPhoneticSymbol.cs" />
<Compile Include="VsqTrack.cs" />
<Compile Include="VsqUtil.cs" />
<Compile Include="VsqVoiceLanguage.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\bocoree\bocoree.csproj">

View File

@ -11,239 +11,736 @@
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*/
using System;
using System.Reflection;
using System.Collections.Generic;
namespace Boare.Lib.Vsq {
public enum NRPN : ushort {
public static class NRPN {
/// <summary>
/// (0x5000) Version number(MSB) &amp;, Device number(LSB)
/// </summary>
CVM_NM_VERSION_AND_DEVICE = 0x5000,
public const ushort CVM_NM_VERSION_AND_DEVICE = 0x5000;
/// <summary>
/// (0x5001) Delay in millisec(MSB, LSB)
/// </summary>
CVM_NM_DELAY = 0x5001,
public const ushort CVM_NM_DELAY = 0x5001;
/// <summary>
/// (0x5002) Note number(MSB)
/// </summary>
CVM_NM_NOTE_NUMBER = 0x5002,
public const ushort CVM_NM_NOTE_NUMBER = 0x5002;
/// <summary>
/// (0x5003) Velocity(MSB)
/// </summary>
CVM_NM_VELOCITY = 0x5003,
public const ushort CVM_NM_VELOCITY = 0x5003;
/// <summary>
/// (0x5004) Note Duration in millisec(MSB, LSB)
/// </summary>
CVM_NM_NOTE_DURATION = 0x5004,
public const ushort CVM_NM_NOTE_DURATION = 0x5004;
/// <summary>
/// (0x5005) Note Location(MSB)
/// </summary>
CVM_NM_NOTE_LOCATION = 0x5005,
public const ushort CVM_NM_NOTE_LOCATION = 0x5005;
/// <summary>
/// (0x5006) Attack Type(MSB, LSB)
/// </summary>
public const ushort CVM_NM_ATTACK_TYPE = 0x5006;
/// <summary>
/// (0x5007) Attack Duration in millisec(MSB, LSB)
/// </summary>
public const ushort CVM_NM_ATTACK_DURATION = 0x5007;
/// <summary>
/// (0x5008) Attack Depth(MSB)
/// </summary>
public const ushort CVM_NM_ATTACK_DEPTH = 0x5008;
/// <summary>
/// (0x500c) Index of Vibrato DB(MSB: ID_H00, LSB:ID_L00)
/// </summary>
CVM_NM_INDEX_OF_VIBRATO_DB = 0x500c,
public const ushort CVM_NM_INDEX_OF_VIBRATO_DB = 0x500c;
/// <summary>
/// (0x500d) Vibrato configuration(MSB: Index of Vibrato Type, LSB: Duration &amp;, Configuration parameter of vibrato)
/// </summary>
CVM_NM_VIBRATO_CONFIG = 0x500d,
public const ushort CVM_NM_VIBRATO_CONFIG = 0x500d;
/// <summary>
/// (0x500e) Vibrato Delay(MSB)
/// </summary>
CVM_NM_VIBRATO_DELAY = 0x500e,
public const ushort CVM_NM_VIBRATO_DELAY = 0x500e;
/*/// <summary>
/// (0x5011) Unknonw(MSB), only used in VOCALOID1
/// </summary>
public const ushort CVM_NM_UNKNOWN1 = 0x5011;*/
/// <summary>
/// (0x5012) Number of phonetic symbols in bytes(MSB)
/// </summary>
CVM_NM_PHONETIC_SYMBOL_BYTES = 0x5012,
public const ushort CVM_NM_PHONETIC_SYMBOL_BYTES = 0x5012;
/// <summary>
/// (0x5013) Phonetic symbol 1(MSB:Phonetic symbol 1, LSB: Consonant adjustment 1)
/// </summary>
CVM_NM_PHONETIC_SYMBOL1 = 0x5013,
public const ushort 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;
/// <summary>
/// (0x5015) Phonetic symbol 3(MSB:Phonetic symbol 3, LSB: Consonant adjustment 3)
/// </summary>
public const ushort 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;
/// <summary>
/// (0x5017) Phonetic symbol 5(MSB:Phonetic symbol 5, LSB: Consonant adjustment 5)
/// </summary>
public const ushort 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;
/// <summary>
/// (0x5019) Phonetic symbol 7(MSB:Phonetic symbol 7, LSB: Consonant adjustment 7)
/// </summary>
public const ushort 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;
/// <summary>
/// (0x501b) Phonetic symbol 9(MSB:Phonetic symbol 9, LSB: Consonant adjustment 9)
/// </summary>
public const ushort 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;
/// <summary>
/// (0x501d) Phonetic symbol 11(MSB:Phonetic symbol 11, LSB: Consonant adjustment 11)
/// </summary>
public const ushort 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;
/// <summary>
/// (0x501f) Phonetic symbol 13(MSB:Phonetic symbol 13, LSB: Consonant adjustment 13)
/// </summary>
public const ushort 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;
/// <summary>
/// (0x5021) Phonetic symbol 15(MSB:Phonetic symbol 15, LSB: Consonant adjustment 15)
/// </summary>
public const ushort 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;
/// <summary>
/// (0x5023) Phonetic symbol 17(MSB:Phonetic symbol 17, LSB: Consonant adjustment 17)
/// </summary>
public const ushort 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;
/// <summary>
/// (0x5025) Phonetic symbol 19(MSB:Phonetic symbol 19, LSB: Consonant adjustment 19)
/// </summary>
public const ushort 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;
/// <summary>
/// (0x5027) Phonetic symbol 21(MSB:Phonetic symbol 21, LSB: Consonant adjustment 21)
/// </summary>
public const ushort 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;
/// <summary>
/// (0x5029) Phonetic symbol 23(MSB:Phonetic symbol 23, LSB: Consonant adjustment 23)
/// </summary>
public const ushort 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;
/// <summary>
/// (0x502b) Phonetic symbol 25(MSB:Phonetic symbol 25, LSB: Consonant adjustment 25)
/// </summary>
public const ushort 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;
/// <summary>
/// (0x502d) Phonetic symbol 27(MSB:Phonetic symbol 27, LSB: Consonant adjustment 27)
/// </summary>
public const ushort 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;
/// <summary>
/// (0x502f) Phonetic symbol 29(MSB:Phonetic symbol 29, LSB: Consonant adjustment 29)
/// </summary>
public const ushort 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;
/// <summary>
/// (0x5031) Phonetic symbol 31(MSB:Phonetic symbol 31, LSB: Consonant adjustment 31)
/// </summary>
public const ushort 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;
/// <summary>
/// (0x5033) Phonetic symbol 33(MSB:Phonetic symbol 33, LSB: Consonant adjustment 33)
/// </summary>
public const ushort 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;
/// <summary>
/// (0x5035) Phonetic symbol 35(MSB:Phonetic symbol 35, LSB: Consonant adjustment 35)
/// </summary>
public const ushort 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;
/// <summary>
/// (0x5037) Phonetic symbol 37(MSB:Phonetic symbol 37, LSB: Consonant adjustment 37)
/// </summary>
public const ushort 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;
/// <summary>
/// (0x5039) Phonetic symbol 39(MSB:Phonetic symbol 39, LSB: Consonant adjustment 39)
/// </summary>
public const ushort 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;
/// <summary>
/// (0x503b) Phonetic symbol 41(MSB:Phonetic symbol 41, LSB: Consonant adjustment 41)
/// </summary>
public const ushort 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;
/// <summary>
/// (0x503d) Phonetic symbol 43(MSB:Phonetic symbol 43, LSB: Consonant adjustment 43)
/// </summary>
public const ushort 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;
/// <summary>
/// (0x503f) Phonetic symbol 45(MSB:Phonetic symbol 45, LSB: Consonant adjustment 45)
/// </summary>
public const ushort 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;
/// <summary>
/// (0x5041) Phonetic symbol 47(MSB:Phonetic symbol 47, LSB: Consonant adjustment 47)
/// </summary>
public const ushort 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;
/// <summary>
/// (0x5043) Phonetic symbol 49(MSB:Phonetic symbol 49, LSB: Consonant adjustment 49)
/// </summary>
public const ushort 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;
/// <summary>
/// (0x5045) Phonetic symbol 51(MSB:Phonetic symbol 51, LSB: Consonant adjustment 51)
/// </summary>
public const ushort 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;
/// <summary>
/// (0x5047) Phonetic symbol 53(MSB:Phonetic symbol 53, LSB: Consonant adjustment 53)
/// </summary>
public const ushort 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;
/// <summary>
/// (0x5049) Phonetic symbol 55(MSB:Phonetic symbol 55, LSB: Consonant adjustment 55)
/// </summary>
public const ushort 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;
/// <summary>
/// (0x504b) Phonetic symbol 57(MSB:Phonetic symbol 57, LSB: Consonant adjustment 57)
/// </summary>
public const ushort 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;
/// <summary>
/// (0x504d) Phonetic symbol 59(MSB:Phonetic symbol 59, LSB: Consonant adjustment 59)
/// </summary>
public const ushort 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;
/// <summary>
/// (0x504f) Phonetic symbol continuation(MSB, 0x7f=end, 0x00=continue)
/// </summary>
CVM_NM_PHONETIC_SYMBOL_CONTINUATION = 0x504f,
public const ushort CVM_NM_PHONETIC_SYMBOL_CONTINUATION = 0x504f;
/// <summary>
/// (0x5050) v1mean in Cent/5(MSB)
/// </summary>
CVM_NM_V1MEAN = 0x5050,
public const ushort CVM_NM_V1MEAN = 0x5050;
/// <summary>
/// (0x5051) d1mean in millisec/5(MSB)
/// </summary>
CVM_NM_D1MEAN = 0x5051,
public const ushort CVM_NM_D1MEAN = 0x5051;
/// <summary>
/// (0x5052) d1meanFirstNote in millisec/5(MSB)
/// </summary>
CVM_NM_D1MEAN_FIRST_NOTE = 0x5052,
public const ushort CVM_NM_D1MEAN_FIRST_NOTE = 0x5052;
/// <summary>
/// (0x5053) d2mean in millisec/5(MSB)
/// </summary>
CVM_NM_D2MEAN = 0x5053,
public const ushort CVM_NM_D2MEAN = 0x5053;
/// <summary>
/// (0x5054) d4mean in millisec/5(MSB)
/// </summary>
CVM_NM_D4MEAN = 0x5054,
public const ushort CVM_NM_D4MEAN = 0x5054;
/// <summary>
/// (0x5055) pMeanOnsetFirstNote in Cent/5(MSB)
/// </summary>
CVM_NM_PMEAN_ONSET_FIRST_NOTE = 0x5055,
public const ushort CVM_NM_PMEAN_ONSET_FIRST_NOTE = 0x5055;
/// <summary>
/// (0x5056) vMeanNoteTransition in Cent/5(MSB)
/// </summary>
CVM_NM_VMEAN_NOTE_TRNSITION = 0x5056,
public const ushort CVM_NM_VMEAN_NOTE_TRNSITION = 0x5056;
/// <summary>
/// (0x5057) pMeanEndingNote in Cent/5(MSB)
/// </summary>
CVM_NM_PMEAN_ENDING_NOTE = 0x5057,
public const ushort CVM_NM_PMEAN_ENDING_NOTE = 0x5057;
/// <summary>
/// (0x5058) AddScooptoUpIntervals &amp;, AddPortamentoToDownIntervals(MSB)
/// </summary>
CVM_NM_ADD_PORTAMENTO = 0x5058,
public const ushort CVM_NM_ADD_PORTAMENTO = 0x5058;
/// <summary>
/// (0x5059) changAfterPeak(MSB)
/// </summary>
CVM_NM_CHANGE_AFTER_PEAK = 0x5059,
public const ushort CVM_NM_CHANGE_AFTER_PEAK = 0x5059;
/// <summary>
/// (0x505a) Accent(MSB)
/// </summary>
CVM_NM_ACCENT = 0x505a,
public const ushort CVM_NM_ACCENT = 0x505a;
/// <summary>
/// (0x597f) Note message continuation(MSB)
/// (0x507f) Note message continuation(MSB)
/// </summary>
CVM_NM_NOTE_MESSAGE_CONTINUATION = 0x507f,
public const ushort 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;
/// <summary>
/// (0x5076) Extended Note message; Flags length in bytes(MSB, LSB)
/// </summary>
public const ushort CVM_EXNM_FLAGS_BYTES = 0x5076;
/// <summary>
/// (0x5077) Extended Note message; Flag(MSB)
/// </summary>
public const ushort 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;
/// <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;
/// <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;
/// <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;
/// <summary>
/// (0x507d) Extended Note message; Envelope: value2(MSB, LSB)
/// </summary>
public const ushort CVM_EXNM_ENV_DATA2 = 0x507d;
/// <summary>
/// (0x507c) Extended Note message; Envelope: value3(MSB)
/// </summary>
public const ushort 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;
/// <summary>
/// (0x6000) Version number &amp;, Device number(MSB, LSB)
/// </summary>
CC_BS_VERSION_AND_DEVICE = 0x6000,
public const ushort CC_BS_VERSION_AND_DEVICE = 0x6000;
/// <summary>
/// (0x6001) Delay in millisec(MSB, LSB)
/// </summary>
CC_BS_DELAY = 0x6001,
public const ushort CC_BS_DELAY = 0x6001;
/// <summary>
/// (0x6002) Laugnage type(MSB, optional LSB)
/// </summary>
CC_BS_LANGUAGE_TYPE = 0x6002,
public const ushort CC_BS_LANGUAGE_TYPE = 0x6002;
/// <summary>
/// (0x6100) Version number &amp;, device number(MSB, LSB)
/// </summary>
CC_CV_VERSION_AND_DEVICE = 0x6100,
public const ushort CC_CV_VERSION_AND_DEVICE = 0x6100;
/// <summary>
/// (0x6101) Delay in millisec(MSB, LSB)
/// </summary>
CC_CV_DELAY = 0x6101,
public const ushort CC_CV_DELAY = 0x6101;
/// <summary>
/// (0x6102) Volume value(MSB)
/// </summary>
CC_CV_VOLUME = 0x6102,
public const ushort CC_CV_VOLUME = 0x6102;
/// <summary>
/// (0x6200) Version number &amp;, device number(MSB, LSB)
/// </summary>
CC_P_VERSION_AND_DEVICE = 0x6200,
public const ushort CC_P_VERSION_AND_DEVICE = 0x6200;
/// <summary>
/// (0x6201) Delay in millisec(MSB, LSB)
/// </summary>
CC_P_DELAY = 0x6201,
public const ushort CC_P_DELAY = 0x6201;
/// <summary>
/// (0x6202) Pan value(MSB)
/// </summary>
CC_PAN = 0x6202,
public const ushort CC_PAN = 0x6202;
/// <summary>
/// (0x6300) Version number &amp;, device number(MSB, LSB)
/// </summary>
CC_E_VESION_AND_DEVICE = 0x6300,
public const ushort CC_E_VESION_AND_DEVICE = 0x6300;
/// <summary>
/// (0x6301) Delay in millisec(MSB, LSB)
/// </summary>
CC_E_DELAY = 0x6301,
public const ushort CC_E_DELAY = 0x6301;
/// <summary>
/// (0x6302) Expression vlaue(MSB)
/// </summary>
CC_E_EXPRESSION = 0x6302,
public const ushort CC_E_EXPRESSION = 0x6302;
/// <summary>
/// (0x6400) Version number &amp;, device number(MSB, LSB)
/// </summary>
CC_VR_VERSION_AND_DEVICE = 0x6400,
public const ushort CC_VR_VERSION_AND_DEVICE = 0x6400;
/// <summary>
/// (0x6401) Delay in millisec(MSB, LSB)
/// </summary>
CC_VR_DELAY = 0x6401,
public const ushort CC_VR_DELAY = 0x6401;
/// <summary>
/// (0x6402) Vibrato Rate value(MSB)
/// </summary>
CC_VR_VIBRATO_RATE = 0x6402,
public const ushort CC_VR_VIBRATO_RATE = 0x6402;
/// <summary>
/// (0x6500) Version number &amp;, device number(MSB, LSB)
/// </summary>
CC_VD_VERSION_AND_DEVICE = 0x6500,
public const ushort CC_VD_VERSION_AND_DEVICE = 0x6500;
/// <summary>
/// (0x6501) Delay in millisec(MSB, LSB)
/// </summary>
CC_VD_DELAY = 0x6501,
public const ushort CC_VD_DELAY = 0x6501;
/// <summary>
/// (0x6502) Vibrato Depth value(MSB)
/// </summary>
CC_VD_VIBRATO_DEPTH = 0x6502,
public const ushort CC_VD_VIBRATO_DEPTH = 0x6502;
/// <summary>
/// (0x6600) Version number &amp;, device number(MSB, LSB)
/// </summary>
public const ushort CC_FX2_VERSION_AND_DEVICE = 0x6600;
/// <summary>
/// (0x6601) Delay in millisec(MSB, LSB)
/// </summary>
public const ushort CC_FX2_DELAY = 0x6601;
/// <summary>
/// (0x6602) Effect2 Depth(MSB)
/// </summary>
public const ushort CC_FX2_EFFECT2_DEPTH = 0x6602;
/// <summary>
/// (0x6700) Version number &amp;, device number(MSB, LSB)
/// </summary>
CC_PBS_VERSION_AND_DEVICE = 0x6700,
public const ushort CC_PBS_VERSION_AND_DEVICE = 0x6700;
/// <summary>
/// (0x6701) Delay in millisec(MSB, LSB)
/// </summary>
CC_PBS_DELAY = 0x6701,
public const ushort CC_PBS_DELAY = 0x6701;
/// <summary>
/// (0x6702) Pitch Bend Sensitivity(MSB, LSB)
/// </summary>
CC_PBS_PITCH_BEND_SENSITIVITY = 0x6702,
public const ushort CC_PBS_PITCH_BEND_SENSITIVITY = 0x6702;
/// <summary>
/// (0x5300) Version number &amp;, device number(MSB, LSB)
/// </summary>
PC_VERSION_AND_DEVICE = 0x5300,
public const ushort PC_VERSION_AND_DEVICE = 0x5300;
/// <summary>
/// (0x5301) Delay in millisec(MSB, LSB)
/// </summary>
PC_DELAY = 0x5301,
public const ushort PC_DELAY = 0x5301;
/// <summary>
/// (0x5302) Voice Type(MSB)
/// </summary>
PC_VOICE_TYPE = 0x5302,
public const ushort PC_VOICE_TYPE = 0x5302;
/// <summary>
/// (0x5400) Version number &amp;, device number(MSB, LSB)
/// </summary>
PB_VERSION_AND_DEVICE = 0x5400,
public const ushort PB_VERSION_AND_DEVICE = 0x5400;
/// <summary>
/// (0x5401) Delay in millisec(MSB, LSB)
/// </summary>
PB_DELAY = 0x5401,
public const ushort PB_DELAY = 0x5401;
/// <summary>
/// (0x5402) Pitch Bend value(MSB, LSB)
/// </summary>
PB_PITCH_BEND = 0x5402,
public const ushort PB_PITCH_BEND = 0x5402;
/// <summary>
/// (0x5500) Version number &amp;, device number(MSB, LSB)
/// </summary>
VCP_VERSION_AND_DEVICE = 0x5500,
public const ushort VCP_VERSION_AND_DEVICE = 0x5500;
/// <summary>
/// (0x5501) Delay in millisec(MSB, LSB)
/// </summary>
VCP_DELAY = 0x5501,
public const ushort VCP_DELAY = 0x5501;
/// <summary>
/// (0x5502) Voice Change Parameter ID(MSB)
/// </summary>
VCP_VOICE_CHANGE_PARAMETER_ID = 0x5502,
public const ushort VCP_VOICE_CHANGE_PARAMETER_ID = 0x5502;
/// <summary>
/// (0x5503) Voice Change Parameter value(MSB)
/// </summary>
VCP_VOICE_CHANGE_PARAMETER = 0x5503,
public const ushort VCP_VOICE_CHANGE_PARAMETER = 0x5503;
private class NrpnIterator : Iterator {
private List<ushort> nrpns = new List<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 bool hasNext() {
if ( 0 <= m_pos + 1 && m_pos + 1 < nrpns.Count ) {
return true;
} else {
return false;
}
}
public Object next() {
m_pos++;
return nrpns[m_pos];
}
public void remove() {
}
}
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;
}
}
}
return "";
}
/// <summary>
/// 指定したコントロールに対応するVoice Change Parameter IDの値を調べます
/// </summary>
/// <param name="curve_name"></param>
/// <returns></returns>
public static byte getVoiceChangeParameterID( string curve_name ) {
byte lsb = 0x31;
switch ( curve_name.ToLower() ) {
case "harmonics":
lsb = 0x30;
break;
case "bre":
lsb = 0x31;
break;
case "bri":
lsb = 0x32;
break;
case "cle":
lsb = 0x33;
break;
case "por":
lsb = 0x34;
break;
case "ope":
lsb = 0x35;
break;
case "reso1freq":
lsb = 0x40;
break;
case "reso2freq":
lsb = 0x41;
break;
case "reso3freq":
lsb = 0x42;
break;
case "reso4freq":
lsb = 0x43;
break;
case "reso1bw":
lsb = 0x50;
break;
case "reso2bw":
lsb = 0x51;
break;
case "reso3bw":
lsb = 0x52;
break;
case "reso4bw":
lsb = 0x53;
break;
case "reso1amp":
lsb = 0x60;
break;
case "reso2amp":
lsb = 0x61;
break;
case "reso3amp":
lsb = 0x62;
break;
case "reso4amp":
lsb = 0x63;
break;
case "gen":
lsb = 0x70;
break;
}
return lsb;
}
public static bool is_require_data_lsb( ushort nrpn ) {
switch ( nrpn ) {
case CVM_NM_VERSION_AND_DEVICE:
case CVM_NM_DELAY:
case CVM_NM_NOTE_DURATION:
case CVM_NM_INDEX_OF_VIBRATO_DB:
case CVM_NM_VIBRATO_CONFIG:
case CVM_NM_PHONETIC_SYMBOL1:
case CC_BS_VERSION_AND_DEVICE:
case CC_BS_DELAY:
case CC_BS_LANGUAGE_TYPE:
case CC_CV_VERSION_AND_DEVICE:
case CC_CV_DELAY:
case CC_P_VERSION_AND_DEVICE:
case CC_P_DELAY:
case CC_E_VESION_AND_DEVICE:
case CC_E_DELAY:
case CC_VR_VERSION_AND_DEVICE:
case CC_VR_DELAY:
case CC_VD_VERSION_AND_DEVICE:
case CC_VD_DELAY:
case CC_FX2_VERSION_AND_DEVICE:
case CC_FX2_DELAY:
case CC_PBS_VERSION_AND_DEVICE:
case CC_PBS_DELAY:
case CC_PBS_PITCH_BEND_SENSITIVITY:
case PC_VERSION_AND_DEVICE:
case PC_DELAY:
case PB_VERSION_AND_DEVICE:
case PB_DELAY:
case PB_PITCH_BEND:
case VCP_VERSION_AND_DEVICE:
case VCP_DELAY:
case CVM_EXNM_ENV_DATA1:
case CVM_EXNM_ENV_DATA2:
return true;
case CVM_NM_NOTE_NUMBER:
case CVM_NM_VELOCITY:
case CVM_NM_NOTE_LOCATION:
case CVM_NM_VIBRATO_DELAY:
//case CVM_NM_UNKNOWN1:
case CVM_NM_PHONETIC_SYMBOL_BYTES:
case CVM_NM_PHONETIC_SYMBOL_CONTINUATION:
case CVM_NM_V1MEAN:
case CVM_NM_D1MEAN:
case CVM_NM_D1MEAN_FIRST_NOTE:
case CVM_NM_D2MEAN:
case CVM_NM_D4MEAN:
case CVM_NM_PMEAN_ONSET_FIRST_NOTE:
case CVM_NM_VMEAN_NOTE_TRNSITION:
case CVM_NM_PMEAN_ENDING_NOTE:
case CVM_NM_ADD_PORTAMENTO:
case CVM_NM_CHANGE_AFTER_PEAK:
case CVM_NM_ACCENT:
case CVM_NM_NOTE_MESSAGE_CONTINUATION:
case CC_CV_VOLUME:
case CC_PAN:
case CC_E_EXPRESSION:
case CC_VR_VIBRATO_RATE:
case CC_VD_VIBRATO_DEPTH:
case CC_FX2_EFFECT2_DEPTH:
case PC_VOICE_TYPE:
case VCP_VOICE_CHANGE_PARAMETER_ID:
case VCP_VOICE_CHANGE_PARAMETER:
case CVM_EXNM_ENV_DATA3:
case CVM_EXNM_ENV_DATA_CONTINUATION:
return false;
}
return false;
}
}
}

View File

@ -61,7 +61,11 @@ namespace Boare.Lib.Vsq {
private static long readDeltaClock( Stream stream ) {
long ret = 0;
while ( true ) {
byte d = (byte)stream.ReadByte();
int i = stream.ReadByte();
if ( i < 0 ) {
break;
}
byte d = (byte)i;
ret = (ret << 7) | ((long)d & 0x7f);
if ( (d & 0x80) == 0x00 ) {
break;
@ -203,11 +207,8 @@ namespace Boare.Lib.Vsq {
private ushort m_format;
private ushort m_time_format;
public MidiFile( string path )
: this( new FileStream( path, FileMode.Open ) ) {
}
public MidiFile( Stream stream ) {
public MidiFile( string path ){
Stream stream = new FileStream( path, FileMode.Open, FileAccess.Read );
// ヘッダ
byte[] byte4 = new byte[4];
stream.Read( byte4, 0, 4 );
@ -251,9 +252,66 @@ namespace Boare.Lib.Vsq {
long clock = 0;
byte last_status_byte = 0x00;
while ( stream.Position < startpos + size ) {
m_events[track].Add( MidiEvent.read( stream, ref clock, ref last_status_byte ) );
MidiEvent mi = MidiEvent.read( stream, ref clock, ref last_status_byte );
m_events[track].Add( mi );
}
if ( m_time_format != 480 ) {
int count = m_events[track].Count;
for ( int i = 0; i < count; i++ ) {
MidiEvent mi = m_events[track][i];
mi.Clock = mi.Clock * 480 / m_time_format;
m_events[track][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.Count; 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[track].Count; i++ ) {
if ( m_events[track][i].FirstByte == 0xb0 ) {
switch ( m_events[track][i].Data[0] ) {
case 0x63:
msb = m_events[track][i].Data[1];
lsb = 0x0;
break;
case 0x62:
lsb = m_events[track][i].Data[1];
break;
case 0x06:
data_msb = m_events[track][i].Data[1];
ushort nrpn = (ushort)(msb << 8 | lsb);
string name = NRPN.getName( nrpn );
if ( name == "" ) {
name = "* * UNKNOWN * *";
sw.WriteLine( string.Format( format0, m_events[track][i].Clock, nrpn, name, data_msb ) );
} else {
//if ( !NRPN.is_require_data_lsb( nrpn ) ) {
sw.WriteLine( string.Format( format0, m_events[track][i].Clock, nrpn, name, data_msb ) );
//}
}
break;
case 0x26:
data_lsb = m_events[track][i].Data[1];
ushort nrpn2 = (ushort)(msb << 8 | lsb);
string name2 = NRPN.getName( nrpn2 );
if ( name2 == "" ) {
name2 = "* * UNKNOWN * *";
}
sw.WriteLine( string.Format( format, m_events[track][i].Clock, nrpn2, name2, data_msb, data_lsb ) );
break;
}
}
}
}
}
#endif
stream.Close();
}

View File

@ -17,17 +17,37 @@ using System.Collections.Generic;
namespace Boare.Lib.Vsq {
public class SingerConfig {
public string ID;
public string FORMAT;
public string VOICEIDSTR;
public string VOICENAME;
public class SingerConfig : ICloneable {
public string ID = "";
public string FORMAT = "";
public string VOICEIDSTR = "";
public string VOICENAME = "Unknown";
public int Breathiness;
public int Brightness;
public int Clearness;
public int Opening;
public int GenderFactor;
public int Original;
public int Program;
public SingerConfig() {
}
public object Clone() {
SingerConfig ret = new SingerConfig();
ret.ID = ID;
ret.FORMAT = FORMAT;
ret.VOICEIDSTR = VOICEIDSTR;
ret.VOICENAME = VOICENAME;
ret.Breathiness = Breathiness;
ret.Brightness = Brightness;
ret.Clearness = Clearness;
ret.Opening = Opening;
ret.GenderFactor = GenderFactor;
ret.Original = Original;
ret.Program = Program;
return ret;
}
public static void decode_vvd_bytes( ref byte[] dat ) {
for ( int i = 0; i < dat.Length; i++ ) {
@ -115,18 +135,19 @@ namespace Boare.Lib.Vsq {
return 0x0;
}
public SingerConfig( string file, int original ) {
original = original;
ID = "VOCALOID:VIRTUAL:VOICE";
FORMAT = "2.0.0.0";
VOICEIDSTR = "";
VOICENAME = "Miku";
Breathiness = 0;
Brightness = 0;
Clearness = 0;
Opening = 0;
GenderFactor = 0;
original = 0;
public static SingerConfig readSingerConfig( string file, int original ) {
SingerConfig sc = new SingerConfig();
//original = original;
sc.ID = "VOCALOID:VIRTUAL:VOICE";
sc.FORMAT = "2.0.0.0";
sc.VOICEIDSTR = "";
sc.VOICENAME = "Miku";
sc.Breathiness = 0;
sc.Brightness = 0;
sc.Clearness = 0;
sc.Opening = 0;
sc.GenderFactor = 0;
sc.Original = original; //original = 0;
FileStream fs = null;
try {
fs = new FileStream( file, FileMode.Open, FileAccess.Read );
@ -156,36 +177,36 @@ namespace Boare.Lib.Vsq {
value = value.Substring( 1, value.Length - 2 );
value = value.Replace( "\\\"", "\"" );
if ( id == "ID" ) {
ID = value;
sc.ID = value;
} else if ( id == "FORMAT" ) {
FORMAT = value;
sc.FORMAT = value;
} else if ( id == "VOICEIDSTR" ) {
VOICEIDSTR = value;
sc.VOICEIDSTR = value;
} else if ( id == "VOICENAME" ) {
VOICENAME = value;
sc.VOICENAME = value;
} else if ( id == "Breathiness" ) {
try {
Breathiness = int.Parse( value );
sc.Breathiness = int.Parse( value );
} catch {
}
} else if ( id == "Brightness" ) {
try {
Brightness = int.Parse( value );
sc.Brightness = int.Parse( value );
} catch {
}
} else if ( id == "Clearness" ) {
try {
Clearness = int.Parse( value );
sc.Clearness = int.Parse( value );
} catch {
}
} else if ( id == "Opening" ) {
try {
Opening = int.Parse( value );
sc.Opening = int.Parse( value );
} catch {
}
} else if ( id == "Gender:Factor" ) {
try {
GenderFactor = int.Parse( value );
sc.GenderFactor = int.Parse( value );
} catch {
}
}
@ -197,6 +218,7 @@ namespace Boare.Lib.Vsq {
fs.Close();
}
}
return sc;
}
/// <summary>
@ -226,7 +248,7 @@ namespace Boare.Lib.Vsq {
return end;
}
public new string[] ToString() {
public string[] ToStringArray() {
List<string> ret = new List<string>();
ret.Add( "\"ID\":=:\"" + ID + "\"" );
ret.Add( "\"FORMAT\":=:\"" + FORMAT + "\"" );
@ -239,6 +261,15 @@ namespace Boare.Lib.Vsq {
ret.Add( "\"Gender:Factor\":=:\"" + GenderFactor + "\"" );
return ret.ToArray();
}
public override string ToString() {
string[] r = ToStringArray();
string ret = "";
foreach ( string s in r ) {
ret += s + "\n";
}
return ret;
}
}
}

View File

@ -480,7 +480,7 @@ namespace Boare.Lib.Vsq {
int count = 0;
// 辞書フォルダからの読込み
string editor_path = VsqUtil.getEditorPath();
string editor_path = VocaloSysUtil.getEditorPath2();
if ( editor_path.Length > 0 ) {
string path = Path.Combine( Path.GetDirectoryName( editor_path ), "UDIC" );
if ( !Directory.Exists( path ) ) {

View File

@ -16,6 +16,133 @@ using System.Collections.Generic;
namespace Boare.Lib.Vsq {
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 List<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 List<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 List<TempoTableEntry>();
for ( int i = 0; i < m_tempo_table.Count; i++ ) {
ret.m_tempo_table.Add( m_tempo_table[i] );
}
ret.update();
return ret;
}
public void add( int clock, int tempo ) {
bool found = false;
for ( int i = 0; i < m_tempo_table.Count; i++ ) {
if ( m_tempo_table[i].Clock == clock ) {
found = true;
m_tempo_table[i] = new TempoTableEntry( clock, tempo, 0.0 );
break;
}
}
if ( !found ) {
m_tempo_table.Add( new TempoTableEntry( clock, tempo, 0.0 ) );
}
m_tempo_table.Sort();
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.Count; i++ ) {
long sum = 0;
for ( int k = 0; k < i; k++ ) {
sum += (m_tempo_table[k].Tempo * (m_tempo_table[k + 1].Clock - m_tempo_table[k].Clock));
}
double time = sum / (m_tpq * 1e6);
m_tempo_table[i] = new TempoTableEntry( m_tempo_table[i].Clock, m_tempo_table[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.Count == 0 ) {
tempo = m_base_tempo;
base_clock = 0;
base_time = 0f;
} else if ( m_tempo_table.Count == 1 ) {
tempo = m_tempo_table[0].Tempo;
base_clock = m_tempo_table[0].Clock;
base_time = m_tempo_table[0].Time;
} else {
for ( int i = m_tempo_table.Count - 1; i >= 0; i-- ) {
if ( m_tempo_table[i].Time < time ) {
return m_tempo_table[i].Clock + (time - m_tempo_table[i].Time) * m_tpq * 1000000.0 / m_tempo_table[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.Count - 1; i >= 0; i-- ) {
if ( m_tempo_table[i].Clock < clock ) {
double init = m_tempo_table[i].Time;
int dclock = clock - m_tempo_table[i].Clock;
double sec_per_clock1 = m_tempo_table[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;
}
}
[Serializable]
public class TempoTableEntry : IComparable<TempoTableEntry>, ICloneable {
public int Clock;
@ -32,6 +159,9 @@ namespace Boare.Lib.Vsq {
this.Time = _time;
}
public TempoTableEntry() {
}
public int CompareTo( TempoTableEntry entry ) {
return this.Clock - entry.Clock;
}

View File

@ -45,6 +45,9 @@ namespace Boare.Lib.Vsq{
BarCount = bar_count;
}
public TimeSigTableEntry() {
}
public override string ToString() {
return "{Clock=" + Clock + ", Numerator=" + Numerator + ", Denominator=" + Denominator + ", BarCount=" + BarCount + "}";
}

View File

@ -18,8 +18,9 @@ using System.Text;
namespace Boare.Lib.Vsq {
[Serializable]
public class UstEvent : ICloneable {
public object Tag;
public string Tag;
public int Length = 0;
public string Lyric = "";
public int Note = -1;
@ -27,6 +28,16 @@ namespace Boare.Lib.Vsq {
public int PBType = -1;
public float[] Pitches = null;
public float Tempo = -1;
public UstVibrato Vibrato = null;
public UstPortamento Portamento = null;
public int PreUtterance = 0;
public int VoiceOverlap = 0;
public UstEnvelope Envelope = null;
public string Flags = "";
public int Moduration = 100;
public UstEvent(){
}
public object Clone() {
UstEvent ret = new UstEvent();
@ -42,6 +53,20 @@ namespace Boare.Lib.Vsq {
}
}
ret.Tempo = Tempo;
if ( Vibrato != null ) {
ret.Vibrato = (UstVibrato)Vibrato.Clone();
}
if ( Portamento != null ) {
ret.Portamento = (UstPortamento)Portamento.Clone();
}
if ( Envelope != null ) {
ret.Envelope = (UstEnvelope)Envelope.Clone();
}
ret.PreUtterance = PreUtterance;
ret.VoiceOverlap = VoiceOverlap;
ret.Flags = Flags;
ret.Moduration = Moduration;
ret.Tag = Tag;
return ret;
}
@ -68,6 +93,27 @@ namespace Boare.Lib.Vsq {
if ( Tempo > 0 ) {
sw.WriteLine( "Tempo=" + Tempo );
}
if ( Vibrato != null ) {
sw.WriteLine( Vibrato.ToString() );
}
if ( Portamento != null ) {
Portamento.print( sw );
}
if ( Envelope != null ) {
if ( PreUtterance >= 0 ) {
sw.WriteLine( "PreUtterance=" + PreUtterance );
}
if ( VoiceOverlap != 0 ) {
sw.WriteLine( "VoiceOverlap=" + VoiceOverlap );
}
sw.WriteLine( Envelope.ToString() );
}
if ( Flags != "" ) {
sw.WriteLine( "Flags=" + Flags );
}
if ( Moduration >= 0 ) {
sw.WriteLine( "Moduration=" + Moduration );
}
}
}

View File

@ -22,7 +22,7 @@ namespace Boare.Lib.Vsq{
public class UstFile : ICloneable {
public object Tag;
private float m_tempo = 125.00f;
private float m_tempo = 120.00f;
private string m_project_name = "";
private string m_voice_dir = "";
private string m_out_file = "";
@ -115,6 +115,33 @@ namespace Boare.Lib.Vsq{
if ( float.TryParse( spl[1], out v ) ){
ue.Tempo = v;
}
} else if ( spl[0] == "VBR" ) {
ue.Vibrato = new UstVibrato( line );
/*
PBW=50,50,46,48,56,50,50,50,50
PBS=-87
PBY=-15.9,-20,-31.5,-26.6
PBM=,s,r,j,s,s,s,s,s
*/
} else if ( spl[0] == "PBW" || spl[0] == "PBS" || spl[0] == "PBY" || spl[0] == "PBM" ) {
if ( ue.Portamento == null ) {
ue.Portamento = new UstPortamento();
}
ue.Portamento.ParseLine( line );
} else if ( spl[0] == "Envelope" ) {
ue.Envelope = new UstEnvelope( line );
//PreUtterance=1
//VoiceOverlap=6
} else if ( spl[0] == "VoiceOverlap" ) {
if ( spl[1] != "" ) {
ue.VoiceOverlap = int.Parse( spl[1] );
}
} else if ( spl[0] == "PreUtterance" ) {
if ( spl[1] != "" ) {
ue.PreUtterance = int.Parse( spl[1] );
}
} else if ( spl[0] == "Flags" ) {
ue.Flags = line.Substring( 6 );
}
}
line = sr.ReadLine();

View File

@ -16,6 +16,7 @@ using System.Collections.Generic;
namespace Boare.Lib.Vsq {
[Serializable]
public class VibratoBPList : ICloneable {
private List<VibratoBPPair> m_list;
@ -38,6 +39,24 @@ namespace Boare.Lib.Vsq {
m_list.Sort();
}
public int getValue( float x, int default_value ) {
if ( m_list.Count <= 0 ) {
return default_value;
}
int index = -1;
for ( int i = 0; i < m_list.Count; i++ ) {
if ( x < m_list[i].X ) {
break;
}
index = i;
}
if ( index == -1 ) {
return default_value;
} else {
return m_list[index].Y;
}
}
public object Clone() {
VibratoBPList ret = new VibratoBPList();
for ( int i = 0; i < m_list.Count; i++ ) {
@ -57,6 +76,30 @@ namespace Boare.Lib.Vsq {
public void setElement( int index, VibratoBPPair value ) {
m_list[index] = value;
}
/// <summary>
/// XMLシリアライズ用
/// </summary>
public string Data {
get {
string ret = "";
for ( int i = 0; i < m_list.Count; i++ ) {
ret += (i == 0 ? "" : ",") + m_list[i].X + "=" + m_list[i].Y;
}
return ret;
}
set {
m_list.Clear();
string[] spl = value.Split( ',' );
for ( int i = 0; i < spl.Length; i++ ) {
string[] spl2 = spl[i].Split( '=' );
if ( spl2.Length < 2 ) {
continue;
}
m_list.Add( new VibratoBPPair( float.Parse( spl2[0] ), int.Parse( spl2[1] ) ) );
}
}
}
}
}

View File

@ -15,10 +15,14 @@ using System;
namespace Boare.Lib.Vsq {
[Serializable]
public class VibratoBPPair : IComparable<VibratoBPPair> {
public float X;
public int Y;
public VibratoBPPair() {
}
public VibratoBPPair( float x, int y ) {
X = x;
Y = y;

View File

@ -24,9 +24,9 @@ namespace Boare.Lib.Vsq {
[Serializable]
public class VsqBPList : ICloneable {
private SortedList<int, int> m_list = new SortedList<int, int>();
private int m_default = 0;
private int m_maximum = 127;
private int m_minimum = 0;
public int Default = 0;
public int Maximum = 127;
public int Minimum = 0;
private class KeyClockIterator : Iterator {
private SortedList<int, int> m_list;
@ -58,12 +58,49 @@ namespace Boare.Lib.Vsq {
}
}
public VsqBPList()
: this( 0, 0, 64 ) {
}
/// <summary>
/// XMLシリアライズ用
/// </summary>
public string Data {
get {
string ret = "";
int count = -1;
foreach ( int key in m_list.Keys ) {
count++;
ret += (count == 0 ? "" : "," ) + key + "=" + m_list[key];
}
return ret;
}
set {
m_list.Clear();
string[] spl = value.Split( ',' );
for ( int i = 0; i < spl.Length; i++ ) {
string[] spl2 = spl[i].Split( '=' );
if ( spl2.Length < 2 ) {
continue;
}
try {
m_list.Add( int.Parse( spl2[0] ), int.Parse( spl2[1] ) );
} catch ( Exception ex ) {
#if DEBUG
Console.WriteLine( " ex=" + ex );
Console.WriteLine( " i=" + i + "; spl2[0]=" + spl2[0] + "; spl2[1]=" + spl2[1] );
#endif
}
}
}
}
/// <summary>
/// このVsqBPListの同一コピーを作成します
/// </summary>
/// <returns></returns>
public object Clone() {
VsqBPList res = new VsqBPList( m_default, m_minimum, m_maximum );
VsqBPList res = new VsqBPList( Default, Minimum, Maximum );
foreach ( int key in m_list.Keys ) {
res.m_list.Add( key, m_list[key] );
}
@ -75,23 +112,23 @@ namespace Boare.Lib.Vsq {
/// </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;
Default = default_value;
Maximum = maximum;
Minimum = minimum;
}
/// <summary>
/// このリストに設定された最大値を取得します。
/// </summary>
public int getMaximum() {
return m_maximum;
return Maximum;
}
/// <summary>
/// このリストに設定された最小値を取得します
/// </summary>
public int getMinimum() {
return m_minimum;
return Minimum;
}
public Iterator keyClockIterator() {
@ -113,7 +150,10 @@ namespace Boare.Lib.Vsq {
}
public int[] getKeys() {
List<int> t = new List<int>( m_list.Keys );
List<int> t = new List<int>();
foreach( int key in m_list.Keys ){
t.Add( key );
}
return t.ToArray();
}
@ -136,9 +176,59 @@ namespace Boare.Lib.Vsq {
}
}
public int getElement( int clock ) {
public int getElement( int index ) {
return m_list[m_list.Keys[index]];
}
public int getKeyClock( int index ) {
return m_list.Keys[index];
}
public int getValue( int clock, ref int index ) {
if ( m_list.Count == 0 ) {
return getDefault();
return Default;
} else {
if ( index < 0 ) {
index = 0;
}
for ( int i = index ; i < m_list.Keys.Count; i++ ) {
int keyclock = m_list.Keys[i];
if ( clock < keyclock ) {
if ( i > 0 ) {
index = i;
return m_list[m_list.Keys[i - 1]];
} else {
index = i;
return Default;
}
}
}
index = m_list.Keys.Count - 1;
return m_list[m_list.Keys[m_list.Keys.Count - 1]];
}
}
public int getValue( int clock ) {
if ( m_list.Count == 0 ) {
return 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]];
} else {
return Default;
}
}
}
return m_list[m_list.Keys[m_list.Keys.Count - 1]];
}
}
public int OLD_getElement( int clock ) {
if ( m_list.Count == 0 ) {
return Default;
} else {
if ( m_list.ContainsKey( clock ) ) {
return m_list[clock];
@ -155,7 +245,7 @@ namespace Boare.Lib.Vsq {
if ( m_list.ContainsKey( index ) ) {
return m_list[index];
} else {
return m_default;
return Default;
}
}
}
@ -165,7 +255,7 @@ namespace Boare.Lib.Vsq {
/// このBPListのデフォルト値を取得します
/// </summary>
public int getDefault() {
return m_default;
return Default;
}
/// <summary>

View File

@ -37,18 +37,8 @@ namespace Boare.Lib.Vsq {
/// <summary>
/// VsqCommandはgenerateCommand*からコンストラクトしなければならない。
/// なので、無引数のコンストラクタを隠蔽するためのもの。
/// </summary>
internal VsqCommand() {
}
public static VsqCommand generateCommandTrackChangeRenderer( int track, string renderer ) {
VsqCommand command = new VsqCommand();
command.Type = VsqCommandType.TrackChangeRenderer;
command.Args = new object[2];
command.Args[0] = track;
command.Args[1] = renderer;
return command;
public VsqCommand() {
}
public static VsqCommand generateCommandRoot() {
@ -163,6 +153,15 @@ namespace Boare.Lib.Vsq {
return command;
}
public static VsqCommand generateCommandTrackChangePlayMode( int track, int play_mode ) {
VsqCommand command = new VsqCommand();
command.Type = VsqCommandType.TrackChangePlayMode;
command.Args = new object[2];
command.Args[0] = track;
command.Args[1] = play_mode;
return command;
}
/// <summary>
/// VsqIDとClockを同時に変更するコマンドを発行します
/// </summary>
@ -296,6 +295,28 @@ namespace Boare.Lib.Vsq {
return command;
}
public static VsqCommand generateCommandEventReplace( int track, VsqEvent item ) {
VsqCommand command = new VsqCommand();
command.Type = VsqCommandType.EventReplace;
command.Args = new object[2];
command.Args[0] = track;
command.Args[1] = item.Clone();
return command;
}
public static VsqCommand generateCommandEventReplaceRange( int track, VsqEvent[] items ) {
VsqCommand command = new VsqCommand();
command.Type = VsqCommandType.EventReplaceRange;
command.Args = new object[2];
command.Args[0] = track;
VsqEvent[] objs = new VsqEvent[items.Length];
for( int i = 0; i < items.Length; i++ ){
objs[i] = (VsqEvent)items[i].Clone();
}
command.Args[1] = objs;
return command;
}
/// <summary>
/// 指定したトラックの、音符のアクセント(Accent)を変更するコマンドを発行します。
/// リストaccent_listには、音符を指定するInternalIDと、変更したいアクセント値のペアを登録します

View File

@ -44,7 +44,9 @@ namespace Boare.Lib.Vsq {
EventChangeIDContaintsRange,
TrackReplace,
Replace,
TrackChangeRenderer,
TrackChangePlayMode,
EventReplace,
EventReplaceRange,
}
}

View File

@ -20,21 +20,26 @@ namespace Boare.Lib.Vsq {
/// </summary>
[Serializable]
public class VsqEvent : IComparable<VsqEvent>, ICloneable {
public object Tag;
public string Tag;
/// <summary>
/// 内部で使用するインスタンス固有のID
/// </summary>
public int InternalID;
public int Clock;
public VsqID ID;
public UstEvent UstEvent = new UstEvent();
/// <summary>
/// このオブジェクトのコピーを作成します
/// </summary>
/// <returns></returns>
public object Clone() {
VsqEvent ret = new VsqEvent( Clock, ID );
VsqEvent ret = new VsqEvent( Clock, (VsqID)ID.Clone() );
ret.InternalID = InternalID;
if ( UstEvent != null ) {
ret.UstEvent = (UstEvent)UstEvent.Clone();
}
ret.Tag = Tag;
return ret;
}
@ -59,9 +64,13 @@ namespace Boare.Lib.Vsq {
}
}
public VsqEvent()
: this( 0, new VsqID() ) {
}
public VsqEvent( int clock, VsqID id /*, int internal_id*/ ) {
Clock = clock;
ID = (VsqID)id.Clone();
ID = id;
//InternalID = internal_id;
InternalID = 0;
}

View File

@ -21,43 +21,56 @@ namespace Boare.Lib.Vsq {
/// </summary>
[Serializable]
public class VsqEventList {
private List<VsqEvent> m_list;
public List<VsqEvent> Events;
private List<int> m_ids;
/// <summary>
/// コンストラクタ
/// </summary>
public VsqEventList() {
m_list = new List<VsqEvent>();
Events = new List<VsqEvent>();
m_ids = new List<int>();
}
public void sort() {
lock ( this ) {
Events.Sort();
for ( int i = 0; i < Events.Count; i++ ) {
m_ids[i] = Events[i].InternalID;
}
}
}
public void clear() {
m_list.Clear();
Events.Clear();
m_ids.Clear();
}
public Iterator iterator() {
return new ListIterator<VsqEvent>( m_list );
updateIDList();
return new ListIterator<VsqEvent>( Events );
}
public void add( VsqEvent item ) {
updateIDList();
int new_id = getNextId( 0 );
item.InternalID = new_id;
m_list.Add( item );
Events.Add( item );
m_ids.Add( new_id );
m_list.Sort();
for ( int i = 0; i < m_list.Count; i++ ) {
m_ids[i] = m_list[i].InternalID;
Events.Sort();
for ( int i = 0; i < Events.Count; i++ ) {
m_ids[i] = Events[i].InternalID;
}
}
public void removeAt( int index ) {
m_list.RemoveAt( index );
updateIDList();
Events.RemoveAt( index );
m_ids.RemoveAt( index );
}
private int getNextId( int next ) {
updateIDList();
int index = -1;
List<int> current = new List<int>( m_ids );
int nfound = 0;
@ -75,15 +88,24 @@ namespace Boare.Lib.Vsq {
}
public int getCount() {
return m_list.Count;
return Events.Count;
}
public VsqEvent getElement( int index ) {
return m_list[index];
return Events[index];
}
public void setElement( int index, VsqEvent value ) {
m_list[index] = value;
Events[index] = value;
}
public void updateIDList() {
if ( m_ids.Count != Events.Count ) {
m_ids.Clear();
for ( int i = 0; i < Events.Count; i++ ) {
m_ids.Add( Events[i].InternalID );
}
}
}
}

File diff suppressed because it is too large Load Diff

View File

@ -56,6 +56,10 @@ namespace Boare.Lib.Vsq {
this.PlayMode = play_mode;
}
public VsqCommon()
: this( "Miku", System.Drawing.Color.FromArgb( 179, 181, 123 ), 1, 1 ) {
}
/// <summary>
/// MetaTextのテキストファイルからのコンストラクタ
/// </summary>

View File

@ -29,6 +29,9 @@ namespace Boare.Lib.Vsq {
public int Program;
public int Language;
public IconHandle() {
}
public object Clone() {
IconHandle ret = new IconHandle();
ret.Caption = Caption;
@ -61,7 +64,7 @@ namespace Boare.Lib.Vsq {
public Lyric L0;
public int Index;
internal LyricHandle() {
public LyricHandle() {
}
/// <summary>
@ -104,6 +107,8 @@ namespace Boare.Lib.Vsq {
public int Length;
public VibratoHandle(){
StartRate = 64;
StartDepth = 64;
RateBP = new VibratoBPList();
DepthBP = new VibratoBPList();
}
@ -140,8 +145,50 @@ namespace Boare.Lib.Vsq {
}
}
[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がある
/// ハンドルを取り扱います。ハンドルにはLyricHandle、VibratoHandle、IconHandleおよびNoteHeadHandleがある
/// </summary>
[Serializable]
public class VsqHandle {
@ -159,6 +206,8 @@ namespace Boare.Lib.Vsq {
public VibratoBPList RateBP;
public int Language;
public int Program;
public int Duration;
public int Depth;
public LyricHandle castToLyricHandle() {
LyricHandle ret = new LyricHandle();
@ -197,6 +246,18 @@ namespace Boare.Lib.Vsq {
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() {
}
@ -235,6 +296,8 @@ namespace Boare.Lib.Vsq {
int rate_bp_num = 0;
Language = 0;
Program = 0;
Duration = 0;
Depth = 64;
string tmpDepthBPX = "";
string tmpDepthBPY = "";
@ -247,6 +310,7 @@ namespace Boare.Lib.Vsq {
spl = last_line.Split( new char[] { '=' } );
switch ( spl[0] ) {
case "Language":
m_type = VsqHandleType.Singer;
Language = int.Parse( spl[1] );
break;
case "Program":
@ -283,6 +347,7 @@ namespace Boare.Lib.Vsq {
tmpDepthBPY = spl[1];
break;
case "StartRate":
m_type = VsqHandleType.Vibrato;
StartRate = int.Parse( spl[1] );
break;
case "RateBPNum":
@ -298,19 +363,26 @@ namespace Boare.Lib.Vsq {
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" ) {
/*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 ) {
@ -438,6 +510,15 @@ namespace Boare.Lib.Vsq {
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;
}

View File

@ -23,9 +23,9 @@ namespace Boare.Lib.Vsq {
/// </summary>
[Serializable]
public class VsqID : ICloneable {
public int value;
internal int value;
public VsqIDType type;
public int IconHandle_index;
internal int IconHandle_index;
public IconHandle IconHandle;
public int Length;
public int Note;
@ -35,11 +35,13 @@ namespace Boare.Lib.Vsq {
public int PMbPortamentoUse;
public int DEMdecGainRate;
public int DEMaccent;
public int LyricHandle_index;
internal int LyricHandle_index;
public LyricHandle LyricHandle;
public int VibratoHandle_index;
internal int VibratoHandle_index;
public VibratoHandle VibratoHandle;
public int VibratoDelay;
internal int NoteHeadHandle_index;
public NoteHeadHandle NoteHeadHandle;
public static VsqID EOS = new VsqID( -1 );
@ -68,6 +70,9 @@ namespace Boare.Lib.Vsq {
result.VibratoHandle = (VibratoHandle)this.VibratoHandle.Clone();
}
result.VibratoDelay = this.VibratoDelay;
if ( NoteHeadHandle != null ) {
result.NoteHeadHandle = (NoteHeadHandle)NoteHeadHandle.Clone();
}
return result;
}
@ -80,6 +85,9 @@ namespace Boare.Lib.Vsq {
value = a_value;
}
public VsqID()
: this( 0 ) {
}
/// <summary>
/// テキストファイルからのコンストラクタ
@ -94,6 +102,7 @@ namespace Boare.Lib.Vsq {
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;
@ -154,6 +163,10 @@ namespace Boare.Lib.Vsq {
case "PMbPortamentoUse":
PMbPortamentoUse = int.Parse( spl[1] );
break;
case "NoteHeadHandle":
NoteHeadHandle_index = VsqHandle.HandleIndexFromString( spl[1] );
break;
}
if ( sr.peek() < 0 ) {
break;
@ -162,7 +175,6 @@ namespace Boare.Lib.Vsq {
}
}
public override string ToString() {
string ret = "{Type=" + type;
switch ( type ) {
@ -191,7 +203,6 @@ namespace Boare.Lib.Vsq {
return ret;
}
/// <summary>
/// インスタンスをテキストファイルに出力します
/// </summary>
@ -216,6 +227,9 @@ namespace Boare.Lib.Vsq {
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" ) );

View File

@ -64,7 +64,7 @@ namespace Boare.Lib.Vsq {
UnknownFloat = 0.000000f;
}
private Lyric() {
public Lyric() {
}
/// <summary>
@ -97,6 +97,18 @@ namespace Boare.Lib.Vsq {
}
}
/// <summary>
/// XMLシリアライズ用
/// </summary>
public string PhoneticSymbol {
get {
return getPhoneticSymbol();
}
set {
setPhoneticSymbol( value );
}
}
public string[] getPhoneticSymbolList() {
string[] ret = new string[m_phonetic_symbol.Length];
for ( int i = 0; i < m_phonetic_symbol.Length; i++ ) {

View File

@ -12,9 +12,8 @@
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*/
using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.Text;
namespace Boare.Lib.Vsq {
@ -30,6 +29,10 @@ namespace Boare.Lib.Vsq {
return res;
}
public VsqMaster()
: this( 1 ) {
}
/// <summary>
/// プリメジャー値を指定したコンストラクタ
/// </summary>

View File

@ -13,8 +13,8 @@
*/
using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.Text;
namespace Boare.Lib.Vsq {
@ -57,6 +57,10 @@ namespace Boare.Lib.Vsq {
Slave = new List<VsqMixerEntry>();
}
public VsqMixer()
: this( 0, 0, 0, 0 ) {
}
/// <summary>
/// テキストファイルからのコンストラクタ
/// </summary>
@ -261,6 +265,10 @@ namespace Boare.Lib.Vsq {
this.Mute = mute;
this.Solo = solo;
}
public VsqMixerEntry()
: this( 0, 0, 0, 0 ) {
}
}
}

View File

@ -13,10 +13,9 @@
*/
using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.Drawing;
using System.Windows.Forms;
using System.IO;
using System.Text;
namespace Boare.Lib.Vsq {
@ -26,9 +25,9 @@ namespace Boare.Lib.Vsq {
[Serializable]
public class VsqMetaText : ICloneable {
public VsqCommon Common;
internal VsqMaster master;
internal VsqMixer mixer;
private VsqEventList m_events;
public VsqMaster master;
public VsqMixer mixer;
public VsqEventList Events;
/// <summary>
/// PIT。ピッチベンド(pitchBendBPList)。default=0
/// </summary>
@ -53,18 +52,26 @@ namespace Boare.Lib.Vsq {
/// CLE。クリアネス(epRESlopeDepthBPList)。default=0
/// </summary>
public VsqBPList CLE;
private VsqBPList reso1FreqBPList;
private VsqBPList reso2FreqBPList;
private VsqBPList reso3FreqBPList;
private VsqBPList reso4FreqBPList;
private VsqBPList reso1BWBPList;
private VsqBPList reso2BWBPList;
private VsqBPList reso3BWBPList;
private VsqBPList reso4BWBPList;
private VsqBPList reso1AmpBPList;
private VsqBPList reso2AmpBPList;
private VsqBPList reso3AmpBPList;
private VsqBPList reso4AmpBPList;
public VsqBPList reso1FreqBPList;
public VsqBPList reso2FreqBPList;
public VsqBPList reso3FreqBPList;
public VsqBPList reso4FreqBPList;
public VsqBPList reso1BWBPList;
public VsqBPList reso2BWBPList;
public VsqBPList reso3BWBPList;
public VsqBPList reso4BWBPList;
public VsqBPList reso1AmpBPList;
public VsqBPList reso2AmpBPList;
public VsqBPList reso3AmpBPList;
public VsqBPList reso4AmpBPList;
/// <summary>
/// Harmonics。(EpRSineBPList)default = 64
/// </summary>
public VsqBPList harmonics;
/// <summary>
/// Effect2 Depth。
/// </summary>
public VsqBPList fx2depth;
/// <summary>
/// GEN。ジェンダーファクター(genderFactorBPList)。default=64
/// </summary>
@ -89,10 +96,10 @@ namespace Boare.Lib.Vsq {
if ( mixer != null ) {
res.mixer = (VsqMixer)mixer.Clone();
}
if ( m_events != null ) {
res.m_events = new VsqEventList();
for ( Iterator itr = m_events.iterator(); itr.hasNext(); ) {
res.m_events.add( (VsqEvent)((VsqEvent)itr.next()).Clone() );
if ( Events != null ) {
res.Events = new VsqEventList();
for ( Iterator itr = Events.iterator(); itr.hasNext(); ) {
res.Events.add( (VsqEvent)((VsqEvent)itr.next()).Clone() );
}
}
if ( PIT != null ) {
@ -149,6 +156,12 @@ namespace Boare.Lib.Vsq {
if ( reso4AmpBPList != null ) {
res.reso4AmpBPList = (VsqBPList)reso4AmpBPList.Clone();
}
if ( harmonics != null ) {
res.harmonics = (VsqBPList)harmonics.Clone();
}
if ( fx2depth != null ) {
res.fx2depth = (VsqBPList)fx2depth.Clone();
}
if ( GEN != null ) {
res.GEN = (VsqBPList)GEN.Clone();
}
@ -162,7 +175,7 @@ namespace Boare.Lib.Vsq {
}
public VsqEventList getEventList() {
return m_events;
return Events;
}
internal VsqBPList getElement( string curve ) {
@ -185,6 +198,34 @@ namespace Boare.Lib.Vsq {
return this.PIT;
case "por":
return this.POR;
case "harmonics":
return this.harmonics;
case "fx2depth":
return this.fx2depth;
case "reso1amp":
return this.reso1AmpBPList;
case "reso1bw":
return this.reso1BWBPList;
case "reso1freq":
return this.reso1FreqBPList;
case "reso2amp":
return this.reso2AmpBPList;
case "reso2bw":
return this.reso2BWBPList;
case "reso2freq":
return this.reso2FreqBPList;
case "reso3amp":
return this.reso2AmpBPList;
case "reso3bw":
return this.reso3BWBPList;
case "reso3freq":
return this.reso3FreqBPList;
case "reso4amp":
return this.reso4AmpBPList;
case "reso4bw":
return this.reso4BWBPList;
case "reso4freq":
return this.reso4FreqBPList;
default:
return null;
}
@ -289,7 +330,7 @@ namespace Boare.Lib.Vsq {
/// Singerプロパティに指定されている
/// </summary>
public string getSinger() {
for ( Iterator itr = m_events.iterator(); itr.hasNext(); ) {
for ( Iterator itr = Events.iterator(); itr.hasNext(); ) {
VsqEvent item = (VsqEvent)itr.next();
if ( item.ID.type == VsqIDType.Singer ) {
return item.ID.IconHandle.IDS;
@ -299,7 +340,7 @@ namespace Boare.Lib.Vsq {
}
public void setSinger( string value ) {
for ( Iterator itr = m_events.iterator(); itr.hasNext(); ) {
for ( Iterator itr = Events.iterator(); itr.hasNext(); ) {
VsqEvent item = (VsqEvent)itr.next();
if ( item.ID.type == VsqIDType.Singer ) {
item.ID.IconHandle.IDS = value;
@ -314,9 +355,9 @@ namespace Boare.Lib.Vsq {
/// <returns></returns>
public int getIndexOfEOS() {
int result;
if ( m_events.getCount() > 0 ) {
int ilast = m_events.getCount() - 1;
result = m_events.getElement( ilast ).Clock;
if ( Events.getCount() > 0 ) {
int ilast = Events.getCount() - 1;
result = Events.getElement( ilast ).Clock;
} else {
result = -1;
}
@ -334,11 +375,11 @@ namespace Boare.Lib.Vsq {
int current_id = -1;
int current_handle = -1;
List<VsqEvent> events = new List<VsqEvent>();
for ( Iterator itr = m_events.iterator(); itr.hasNext(); ) {
for ( Iterator itr = Events.iterator(); itr.hasNext(); ) {
events.Add( (VsqEvent)itr.next() );
}
events.Sort();
for( int i = 0; i < events.Count; i++ ){
for ( int i = 0; i < events.Count; i++ ) {
VsqEvent item = events[i];
VsqID id_item = (VsqID)item.ID.Clone();
current_id++;
@ -368,6 +409,14 @@ namespace Boare.Lib.Vsq {
handle.Add( handle_item );
id_item.VibratoHandle_index = current_handle;
}
// NoteHeadHandle
if ( item.ID.NoteHeadHandle != null ) {
current_handle++;
VsqHandle handle_item = item.ID.NoteHeadHandle.castToVsqHandle();
handle_item.Index = current_handle;
handle.Add( handle_item );
id_item.NoteHeadHandle_index = current_handle;
}
id.Add( id_item );
}
}
@ -398,6 +447,7 @@ namespace Boare.Lib.Vsq {
for ( i = 0; i < handle.Count; i++ ) {
handle[i].write( sw, encode );
}
string version = Common.Version;
if ( PIT.getCount() > 0 ) {
PIT.print( sw, start, "[PitchBendBPList]" );
}
@ -416,44 +466,52 @@ namespace Boare.Lib.Vsq {
if ( CLE.getCount() > 0 ) {
CLE.print( sw, start, "[EpRESlopeDepthBPList]" );
}
if ( version.StartsWith( "DSB2" ) ) {
if ( harmonics.getCount() > 0 ) {
harmonics.print( sw, start, "[EpRSineBPList]" );
}
if ( fx2depth.getCount() > 0 ) {
fx2depth.print( sw, start, "[VibTremDepthBPList]" );
}
if ( reso1FreqBPList.getCount() > 0 ) {
reso1FreqBPList.print( sw, start, "[Reso1FreqBPList]" );
}
if ( reso2FreqBPList.getCount() > 0 ) {
reso2FreqBPList.print( sw, start, "[Reso2FreqBPList]" );
}
if ( reso3FreqBPList.getCount() > 0 ) {
reso3FreqBPList.print( sw, start, "[Reso3FreqBPList]" );
}
if ( reso4FreqBPList.getCount() > 0 ) {
reso4FreqBPList.print( sw, start, "[Reso4FreqBPList]" );
}
if ( reso1FreqBPList.getCount() > 0 ) {
reso1FreqBPList.print( sw, start, "[Reso1FreqBPList]" );
}
if ( reso2FreqBPList.getCount() > 0 ) {
reso2FreqBPList.print( sw, start, "[Reso2FreqBPList]" );
}
if ( reso3FreqBPList.getCount() > 0 ) {
reso3FreqBPList.print( sw, start, "[Reso3FreqBPList]" );
}
if ( reso4FreqBPList.getCount() > 0 ) {
reso4FreqBPList.print( sw, start, "[Reso4FreqBPList]" );
}
if ( reso1BWBPList.getCount() > 0 ) {
reso1BWBPList.print( sw, start, "[Reso1BWBPList]" );
}
if ( reso2BWBPList.getCount() > 0 ) {
reso2BWBPList.print( sw, start, "[Reso2BWBPList]" );
}
if ( reso3BWBPList.getCount() > 0 ) {
reso3BWBPList.print( sw, start, "[Reso3BWBPList]" );
}
if ( reso4BWBPList.getCount() > 0 ) {
reso4BWBPList.print( sw, start, "[Reso4BWBPList]" );
}
if ( reso1BWBPList.getCount() > 0 ) {
reso1BWBPList.print( sw, start, "[Reso1BWBPList]" );
}
if ( reso2BWBPList.getCount() > 0 ) {
reso2BWBPList.print( sw, start, "[Reso2BWBPList]" );
}
if ( reso3BWBPList.getCount() > 0 ) {
reso3BWBPList.print( sw, start, "[Reso3BWBPList]" );
}
if ( reso4BWBPList.getCount() > 0 ) {
reso4BWBPList.print( sw, start, "[Reso4BWBPList]" );
}
if ( reso1AmpBPList.getCount() > 0 ) {
reso1AmpBPList.print( sw, start, "[Reso1AmpBPList]" );
}
if ( reso2AmpBPList.getCount() > 0 ) {
reso2AmpBPList.print( sw, start, "[Reso2AmpBPList]" );
}
if ( reso3AmpBPList.getCount() > 0 ) {
reso3AmpBPList.print( sw, start, "[Reso3AmpBPList]" );
}
if ( reso4AmpBPList.getCount() > 0 ) {
reso4AmpBPList.print( sw, start, "[Reso4AmpBPList]" );
if ( reso1AmpBPList.getCount() > 0 ) {
reso1AmpBPList.print( sw, start, "[Reso1AmpBPList]" );
}
if ( reso2AmpBPList.getCount() > 0 ) {
reso2AmpBPList.print( sw, start, "[Reso2AmpBPList]" );
}
if ( reso3AmpBPList.getCount() > 0 ) {
reso3AmpBPList.print( sw, start, "[Reso3AmpBPList]" );
}
if ( reso4AmpBPList.getCount() > 0 ) {
reso4AmpBPList.print( sw, start, "[Reso4AmpBPList]" );
}
}
if ( GEN.getCount() > 0 ) {
@ -462,15 +520,17 @@ namespace Boare.Lib.Vsq {
if ( POR.getCount() > 0 ) {
POR.print( sw, start, "[PortamentoTimingBPList]" );
}
if ( OPE.getCount() > 0 ) {
OPE.print( sw, start, "[OpeningBPList]" );
if ( version.StartsWith( "DSB3" ) ) {
if ( OPE.getCount() > 0 ) {
OPE.print( sw, start, "[OpeningBPList]" );
}
}
}
private void writeEventList( TextMemoryStream sw, int eos ) {
sw.writeLine( "[EventList]" );
List<VsqEvent> temp = new List<VsqEvent>();
for ( Iterator itr = m_events.iterator(); itr.hasNext(); ) {
for ( Iterator itr = Events.iterator(); itr.hasNext(); ) {
temp.Add( (VsqEvent)itr.next() );
}
temp.Sort();
@ -514,75 +574,80 @@ namespace Boare.Lib.Vsq {
private VsqMetaText( string name, int pre_measure, string singer, bool is_first_track ) {
Common = new VsqCommon( name, Color.FromArgb( 179, 181, 123 ), 1, 1 );
PIT = new VsqBPList( 0, -8192, 8192 );
PIT.add( 0, PIT.getDefault() );
PIT = new VsqBPList( 0, -8192, 8191 );
//PIT.add( 0, PIT.getDefault() );
PBS = new VsqBPList( 2, 0, 24 );
PBS.add( 0, PBS.getDefault() );
//PBS.add( 0, PBS.getDefault() );
DYN = new VsqBPList( 64, 0, 127 );
DYN.add( 0, DYN.getDefault() );
//DYN.add( 0, DYN.getDefault() );
BRE = new VsqBPList( 0, 0, 127 );
BRE.add( 0, BRE.getDefault() );
//BRE.add( 0, BRE.getDefault() );
BRI = new VsqBPList( 64, 0, 127 );
BRI.add( 0, BRI.getDefault() );
//BRI.add( 0, BRI.getDefault() );
CLE = new VsqBPList( 0, 0, 127 );
CLE.add( 0, CLE.getDefault() );
//CLE.add( 0, CLE.getDefault() );
reso1FreqBPList = new VsqBPList( 255, 0, 255 );
reso1FreqBPList.add( 0, reso1FreqBPList.getDefault() );
reso1FreqBPList = new VsqBPList( 64, 0, 127 );
//reso1FreqBPList.add( 0, reso1FreqBPList.getDefault() );
reso2FreqBPList = new VsqBPList( 255, 0, 255 );
reso2FreqBPList.add( 0, reso2FreqBPList.getDefault() );
reso2FreqBPList = new VsqBPList( 64, 0, 127 );
//reso2FreqBPList.add( 0, reso2FreqBPList.getDefault() );
reso3FreqBPList = new VsqBPList( 255, 0, 255 );
reso3FreqBPList.add( 0, reso3FreqBPList.getDefault() );
reso3FreqBPList = new VsqBPList( 64, 0, 127 );
//reso3FreqBPList.add( 0, reso3FreqBPList.getDefault() );
reso4FreqBPList = new VsqBPList( 255, 0, 255 );
reso4FreqBPList.add( 0, reso4FreqBPList.getDefault() );
reso4FreqBPList = new VsqBPList( 64, 0, 127 );
//reso4FreqBPList.add( 0, reso4FreqBPList.getDefault() );
reso1BWBPList = new VsqBPList( 255, 0, 255 );
reso1BWBPList.add( 0, reso1BWBPList.getDefault() );
reso1BWBPList = new VsqBPList( 64, 0, 127 );
//reso1BWBPList.add( 0, reso1BWBPList.getDefault() );
reso2BWBPList = new VsqBPList( 255, 0, 255 );
reso2BWBPList.add( 0, reso2BWBPList.getDefault() );
reso2BWBPList = new VsqBPList( 64, 0, 127 );
//reso2BWBPList.add( 0, reso2BWBPList.getDefault() );
reso3BWBPList = new VsqBPList( 255, 0, 255 );
reso3BWBPList.add( 0, reso3BWBPList.getDefault() );
reso3BWBPList = new VsqBPList( 64, 0, 127 );
//reso3BWBPList.add( 0, reso3BWBPList.getDefault() );
reso4BWBPList = new VsqBPList( 255, 0, 255 );
reso4BWBPList.add( 0, reso4BWBPList.getDefault() );
reso4BWBPList = new VsqBPList( 64, 0, 127 );
//reso4BWBPList.add( 0, reso4BWBPList.getDefault() );
reso1AmpBPList = new VsqBPList( 255, 0, 255 );
reso1AmpBPList.add( 0, reso1AmpBPList.getDefault() );
reso1AmpBPList = new VsqBPList( 64, 0, 127 );
//reso1AmpBPList.add( 0, reso1AmpBPList.getDefault() );
reso2AmpBPList = new VsqBPList( 255, 0, 255 );
reso2AmpBPList.add( 0, reso2AmpBPList.getDefault() );
reso2AmpBPList = new VsqBPList( 64, 0, 127 );
//reso2AmpBPList.add( 0, reso2AmpBPList.getDefault() );
reso3AmpBPList = new VsqBPList( 255, 0, 255 );
reso3AmpBPList.add( 0, reso3AmpBPList.getDefault() );
reso3AmpBPList = new VsqBPList( 64, 0, 127 );
//reso3AmpBPList.add( 0, reso3AmpBPList.getDefault() );
reso4AmpBPList = new VsqBPList( 255, 0, 255 );
reso4AmpBPList.add( 0, reso4AmpBPList.getDefault() );
reso4AmpBPList = new VsqBPList( 64, 0, 127 );
//reso4AmpBPList.add( 0, reso4AmpBPList.getDefault() );
harmonics = new VsqBPList( 64, 0, 127 );
//harmonics.add( 0, harmonics.getDefault() );
fx2depth = new VsqBPList( 64, 0, 127 );
GEN = new VsqBPList( 64, 0, 127 );
GEN.add( 0, GEN.getDefault() );
//GEN.add( 0, GEN.getDefault() );
POR = new VsqBPList( 64, 0, 127 );
POR.add( 0, POR.getDefault() );
//POR.add( 0, POR.getDefault() );
OPE = new VsqBPList( 127, 0, 127 );
OPE.add( 0, OPE.getDefault() );
//OPE.add( 0, OPE.getDefault() );
if ( is_first_track ) {
master = new VsqMaster( pre_measure );
} else {
master = null;
}
m_events = new VsqEventList();
Events = new VsqEventList();
VsqID id = new VsqID( 0 );
id.type = VsqIDType.Singer;
id.IconHandle = new IconHandle();
@ -593,31 +658,33 @@ namespace Boare.Lib.Vsq {
id.IconHandle.Length = 1;
id.IconHandle.Language = 0;
id.IconHandle.Program = 0;
m_events.add( new VsqEvent( 0, id ) );
Events.add( new VsqEvent( 0, id ) );
}
public VsqMetaText( TextMemoryStream sr ) {
List<KeyValuePair<int, int>> t_event_list = new List<KeyValuePair<int, int>>();
Dictionary<int, VsqID> __id = new Dictionary<int, VsqID>();
Dictionary<int, VsqHandle> __handle = new Dictionary<int, VsqHandle>();
PIT = new VsqBPList( 0, -8192, 8192 );
PIT = new VsqBPList( 0, -8192, 8191 );
PBS = new VsqBPList( 2, 0, 24 );
DYN = new VsqBPList( 64, 0, 127 );
BRE = new VsqBPList( 0 , 0, 127);
BRI = new VsqBPList( 64, 0, 127 );
CLE = new VsqBPList( 0, 0, 127 );
reso1FreqBPList = new VsqBPList( 255, 0, 255 );
reso2FreqBPList = new VsqBPList( 255, 0, 255 );
reso3FreqBPList = new VsqBPList( 255, 0, 255 );
reso4FreqBPList = new VsqBPList( 255, 0, 255 );
reso1BWBPList = new VsqBPList( 255, 0, 255 );
reso2BWBPList = new VsqBPList( 255, 0, 255 );
reso3BWBPList = new VsqBPList( 255, 0, 255 );
reso4BWBPList = new VsqBPList( 255, 0, 255 );
reso1AmpBPList = new VsqBPList( 255, 0, 255 );
reso2AmpBPList = new VsqBPList( 255, 0, 255 );
reso3AmpBPList = new VsqBPList( 255, 0, 255 );
reso4AmpBPList = new VsqBPList( 255, 0, 255 );
reso1FreqBPList = new VsqBPList( 64, 0, 127 );
reso2FreqBPList = new VsqBPList( 64, 0, 127 );
reso3FreqBPList = new VsqBPList( 64, 0, 127 );
reso4FreqBPList = new VsqBPList( 64, 0, 127 );
reso1BWBPList = new VsqBPList( 64, 0, 127 );
reso2BWBPList = new VsqBPList( 64, 0, 127 );
reso3BWBPList = new VsqBPList( 64, 0, 127 );
reso4BWBPList = new VsqBPList( 64, 0, 127 );
reso1AmpBPList = new VsqBPList( 64, 0, 127 );
reso2AmpBPList = new VsqBPList( 64, 0, 127 );
reso3AmpBPList = new VsqBPList( 64, 0, 127 );
reso4AmpBPList = new VsqBPList( 64, 0, 127 );
harmonics = new VsqBPList( 64, 0, 127 );
fx2depth = new VsqBPList( 64, 0, 127 );
GEN = new VsqBPList( 64, 0, 127 );
POR = new VsqBPList( 64, 0, 127 );
OPE = new VsqBPList( 127, 0, 127 );
@ -679,6 +746,12 @@ namespace Boare.Lib.Vsq {
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;
@ -755,15 +828,18 @@ namespace Boare.Lib.Vsq {
if ( __handle.ContainsKey( __id[i].VibratoHandle_index ) ) {
__id[i].VibratoHandle = __handle[__id[i].VibratoHandle_index].castToVibratoHandle();
}
if ( __handle.ContainsKey( __id[i].NoteHeadHandle_index ) ) {
__id[i].NoteHeadHandle = __handle[__id[i].NoteHeadHandle_index].castToNoteHeadHandle();
}
}
// idをeventListに埋め込み
m_events = new VsqEventList();
Events = new VsqEventList();
for ( int i = 0; i < t_event_list.Count; i++ ) {
int clock = t_event_list[i].Key;
int id_number = t_event_list[i].Value;
if ( __id.ContainsKey( id_number ) ) {
m_events.add( new VsqEvent( clock, (VsqID)__id[id_number].Clone() ) );
Events.add( new VsqEvent( clock, (VsqID)__id[id_number].Clone() ) );
}
}
}
@ -805,7 +881,8 @@ namespace Boare.Lib.Vsq {
public enum VsqHandleType {
Lyric,
Vibrato,
Singer
Singer,
NoteHeadHandle,
}
}

View File

@ -16,18 +16,19 @@ using System.Collections.Generic;
namespace Boare.Lib.Vsq {
public class VsqNrpn : IComparable<VsqNrpn> {
public struct VsqNrpn : IComparable<VsqNrpn> {
public int Clock;
public ushort Nrpn;
public byte DataMsb;
public byte DataLsb;
public bool DataLsbSpecified = false;
public bool DataLsbSpecified;
private List<VsqNrpn> m_list;
public VsqNrpn( int clock, ushort nrpn, byte data_msb ) {
Clock = clock;
Nrpn = nrpn;
DataMsb = data_msb;
DataLsb = 0x0;
DataLsbSpecified = false;
m_list = new List<VsqNrpn>();
}
@ -41,9 +42,6 @@ namespace Boare.Lib.Vsq {
m_list = new List<VsqNrpn>();
}
private VsqNrpn() {
}
public VsqNrpn[] expand() {
List<VsqNrpn> ret = new List<VsqNrpn>();
if ( DataLsbSpecified ) {
@ -57,6 +55,51 @@ namespace Boare.Lib.Vsq {
return ret.ToArray();
}
public static List<VsqNrpn> sort( List<VsqNrpn> list ) {
List<VsqNrpn> ret = new List<VsqNrpn>();
list.Sort();
if ( list.Count >= 2 ) {
List<VsqNrpn> work = new List<VsqNrpn>(); //workには、clockが同じNRPNだけが入る
int last_clock = list[0].Clock;
work.Add( list[0] );
for ( int i = 1; i < list.Count; i++ ) {
if ( list[i].Clock == last_clock ) {
work.Add( list[i] );
} else {
// まずworkを並べ替え
last_clock = list[i].Clock;
bool changed = true;
while ( changed ) {
changed = false;
for ( int j = 0; j < work.Count - 1; j++ ) {
byte nrpn_msb0 = (byte)((work[j].Nrpn >> 8) & 0xff);
byte nrpn_msb1 = (byte)((work[j + 1].Nrpn >> 8) & 0xff);
if ( nrpn_msb1 > nrpn_msb0 ) {
VsqNrpn buf = work[j];
work[j] = work[j + 1];
work[j + 1] = buf;
changed = true;
}
}
}
for ( int j = 0; j < work.Count; j++ ) {
ret.Add( work[j] );
}
work.Clear();
work.Add( list[i] );
}
}
for ( int j = 0; j < work.Count; j++ ) {
ret.Add( work[j] );
}
} else {
for ( int i = 0; i < list.Count; i++ ) {
ret.Add( list[i] );
}
}
return ret;
}
public static VsqNrpn[] merge( VsqNrpn[] src1, VsqNrpn[] src2 ) {
List<VsqNrpn> ret = new List<VsqNrpn>();
for ( int i = 0; i < src1.Length; i++ ) {
@ -104,12 +147,12 @@ namespace Boare.Lib.Vsq {
return Clock - item.Clock;
}
public void append( NRPN nrpn, byte data_msb ) {
m_list.Add( new VsqNrpn( Clock, (ushort)nrpn, data_msb ) );
public void append( ushort nrpn, byte data_msb ) {
m_list.Add( new VsqNrpn( Clock, nrpn, data_msb ) );
}
public void append( NRPN nrpn, byte data_msb, byte data_lsb ) {
m_list.Add( new VsqNrpn( Clock, (ushort)nrpn, data_msb, data_lsb ) );
public void append( ushort nrpn, byte data_msb, byte data_lsb ) {
m_list.Add( new VsqNrpn( Clock, nrpn, data_msb, data_lsb ) );
}
}

View File

@ -22,16 +22,14 @@ namespace Boare.Lib.Vsq {
/// </summary>
[Serializable]
public partial class VsqTrack : ICloneable {
public object Tag;
public string Tag;
/// <summary>
/// トラックの名前。
/// </summary>
public string Name;
private VsqMetaText m_meta_text;
private List<Boare.Lib.Vsq.MidiEvent> m_midi_event;
public VsqMetaText MetaText;
private int m_edited_start = int.MaxValue;
private int m_edited_end = int.MinValue;
public string Renderer = "VOCALOID2";
private class SingerEventIterator : Iterator {
VsqEventList m_list;
@ -133,13 +131,16 @@ namespace Boare.Lib.Vsq {
}
}
public void sortEvent() {
MetaText.Events.sort();
}
/// <summary>
/// 歌手変更イベントを曲の先頭から順に返すIteratorを取得します
/// </summary>
/// <returns></returns>
public Iterator getSingerEventIterator() {
return new SingerEventIterator( m_meta_text.getEventList() );
return new SingerEventIterator( MetaText.getEventList() );
}
/// <summary>
@ -147,7 +148,11 @@ namespace Boare.Lib.Vsq {
/// </summary>
/// <returns></returns>
public Iterator getNoteEventIterator() {
return new NoteEventIterator( m_meta_text.getEventList() );
if ( MetaText == null ) {
return new NoteEventIterator( new VsqEventList() );
} else {
return new NoteEventIterator( MetaText.getEventList() );
}
}
/// <summary>
@ -158,7 +163,7 @@ namespace Boare.Lib.Vsq {
/// <param name="eos"></param>
/// <param name="start"></param>
public void printMetaText( TextMemoryStream sw, int eos, int start ) {
m_meta_text.print( sw, false, eos, start );
MetaText.print( sw, false, eos, start );
}
/// <summary>
@ -167,9 +172,9 @@ namespace Boare.Lib.Vsq {
/// <param name="file"></param>
public void printMetaText( string file ) {
TextMemoryStream tms = new TextMemoryStream( FileAccess.ReadWrite );
int count = m_meta_text.getEventList().getCount();
int clLast = m_meta_text.getEventList().getElement( count - 1 ).Clock + 480;
m_meta_text.print( tms, true, clLast, 0 );
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 ) ) {
tms.rewind();
while ( tms.peek() >= 0 ) {
@ -183,22 +188,73 @@ namespace Boare.Lib.Vsq {
/// Masterを取得します
/// </summary>
public VsqMaster getMaster() {
return m_meta_text.master;
return MetaText.master;
}
internal void setMaster( VsqMaster value ) {
m_meta_text.master = value;
MetaText.master = value;
}
/// <summary>
/// Mixerを取得します
/// </summary>
public VsqMixer getMixer() {
return m_meta_text.mixer;
return MetaText.mixer;
}
internal void setMixer( VsqMixer value ) {
m_meta_text.mixer = value;
MetaText.mixer = value;
}
/// <summary>
/// Commonを取得します
/// </summary>
/// <returns></returns>
public VsqCommon getCommon() {
return MetaText.Common;
}
/// <summary>
/// 指定したトラックのレンダラーを変更します
/// </summary>
/// <param name="track"></param>
/// <param name="new_renderer"></param>
/// <param name="singers"></param>
public void changeRenderer( string new_renderer, List<VsqID> singers ) {
VsqID default_id = null;
if ( singers.Count <= 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.IDS = "Unknown";
default_id.IconHandle.Index = 0;
default_id.IconHandle.Language = 0;
default_id.IconHandle.Length = 1;
default_id.IconHandle.Original = 0;
default_id.IconHandle.Program = 0;
default_id.IconHandle.Caption = "";
} else {
default_id = singers[0];
}
for ( Iterator itr = getSingerEventIterator(); itr.hasNext(); ) {
VsqEvent ve = (VsqEvent)itr.next();
int program = ve.ID.IconHandle.Program;
bool found = false;
for ( int i = 0; i < singers.Count; i++ ) {
if ( program == singers[i].IconHandle.Program ) {
ve.ID = (VsqID)singers[i].Clone();
found = true;
break;
}
}
if ( !found ) {
VsqID add = (VsqID)default_id.Clone();
add.IconHandle.Program = program;
ve.ID = add;
}
}
MetaText.Common.Version = new_renderer;
}
/// <summary>
@ -207,46 +263,45 @@ namespace Boare.Lib.Vsq {
/// <param name="curve"></param>
/// <returns></returns>
public VsqBPList getCurve( string curve ) {
return m_meta_text.getElement( curve );
return MetaText.getElement( curve );
}
public void setCurve( string curve, VsqBPList value ) {
m_meta_text.setElement( curve, value );
MetaText.setElement( curve, value );
}
public int getEventCount() {
return m_meta_text.getEventList().getCount();
return MetaText.getEventList().getCount();
}
public VsqEvent getEvent( int index ) {
return m_meta_text.getEventList().getElement( index );
return MetaText.getEventList().getElement( index );
}
public void setEvent( int index, VsqEvent item ) {
m_meta_text.getEventList().setElement( index, item );
MetaText.getEventList().setElement( index, item );
}
public void addEvent( VsqEvent item ) {
m_meta_text.getEventList().add( item );
MetaText.getEventList().add( item );
}
public Iterator getEventIterator() {
return new EventIterator( m_meta_text.getEventList() );
return new EventIterator( MetaText.getEventList() );
}
public void removeEvent( int index ) {
m_meta_text.getEventList().removeAt( index );
MetaText.getEventList().removeAt( index );
}
/// <summary>
/// このトラックの,最後に編集が加えられた範囲の,開始位置(クロック)を取得します.
/// このインスタンスを保持しているVsqFileインスタンスのExecuteメソッドによって自動的に更新されます
/// </summary>
public int getEditedStart() {
return m_edited_start;
}
internal void setEditedStart( int value ) {
public void setEditedStart( int value ) {
if ( value < m_edited_start ) {
m_edited_start = value;
}
@ -254,13 +309,12 @@ namespace Boare.Lib.Vsq {
/// <summary>
/// このトラックの,最後に編集が加えられた範囲の,終了位置(クロック)を取得します.
/// このインスタンスを保持しているVsqFileインスタンスのExecuteメソッドによって自動的に更新されます
/// </summary>
public int getEditedEnd() {
return m_edited_end;
}
internal void setEditedEnd( int value ) {
public void setEditedEnd( int value ) {
if ( m_edited_end < value ) {
m_edited_end = value;
}
@ -281,21 +335,15 @@ namespace Boare.Lib.Vsq {
public object Clone() {
VsqTrack res = new VsqTrack();
res.Name = Name;
if ( m_meta_text != null ) {
res.m_meta_text = (VsqMetaText)m_meta_text.Clone();
}
if ( m_midi_event != null ) {
res.m_midi_event = new List<MidiEvent>( m_midi_event );
if ( MetaText != null ) {
res.MetaText = (VsqMetaText)MetaText.Clone();
}
res.m_edited_start = m_edited_start;
res.m_edited_end = m_edited_end;
res.Renderer = Renderer;
res.Tag = Tag;
return res;
}
private VsqTrack() {
}
/// <summary>
/// Master Trackを構築
/// </summary>
@ -304,24 +352,7 @@ namespace Boare.Lib.Vsq {
/// <param name="denominator"></param>
public VsqTrack( int tempo, int numerator, int denominator ) {
this.Name = "Master Track";
this.m_meta_text = null;
m_midi_event = new List<MidiEvent>();
// テンポを設定
MidiEvent mi_tempo = new MidiEvent();
mi_tempo.Clock = 0;
mi_tempo.FirstByte = 0xff;
byte b1 = (byte)(tempo & 0xff);
tempo = tempo >> 8;
byte b2 = (byte)(tempo & 0xff);
tempo = tempo >> 8;
byte b3 = (byte)(tempo & 0xff);
mi_tempo.Data = new byte[5] { 0x51, 0x03, b3, b2, b1 };
m_midi_event.Add( mi_tempo );
// 拍子を設定
MidiEvent mi_timesig = MidiEvent.generateTimeSigEvent( 0, numerator, denominator );
m_midi_event.Add( mi_timesig );
this.MetaText = null;
}
/// <summary>
@ -331,8 +362,11 @@ namespace Boare.Lib.Vsq {
/// <param name="singer"></param>
public VsqTrack( string name, string singer ) {
Name = name;
m_meta_text = new VsqMetaText( name, singer );
m_midi_event = new List<MidiEvent>();
MetaText = new VsqMetaText( name, singer );
}
public VsqTrack()
: this( "Voice1", "Miku" ) {
}
/// <summary>
@ -341,29 +375,28 @@ namespace Boare.Lib.Vsq {
/// <returns></returns>
public int getLyricLength() {
int counter = 0;
for ( int i = 0; i < m_meta_text.getEventList().getCount(); i++ ) {
if ( m_meta_text.getEventList().getElement( i ).ID.type == VsqIDType.Anote ) {
for ( int i = 0; i < MetaText.getEventList().getCount(); i++ ) {
if ( MetaText.getEventList().getElement( i ).ID.type == VsqIDType.Anote ) {
counter++;
}
}
return counter;
}
public VsqTrack( List<Boare.Lib.Vsq.MidiEvent> midi_events ) {
m_midi_event = new List<MidiEvent>( midi_events );
public VsqTrack( List<Boare.Lib.Vsq.MidiEvent> midi_event ) {
Name = "";
#if DEBUG
bocoree.debug.push_log( "VsqTrack..ctor" );
#endif
using ( TextMemoryStream sw = new TextMemoryStream() ) {
for ( int i = 0; i < m_midi_event.Count; i++ ) {
if ( m_midi_event[i].FirstByte == 0xff && m_midi_event[i].Data.Length > 0 ) {
for ( int i = 0; i < midi_event.Count; i++ ) {
if ( midi_event[i].FirstByte == 0xff && midi_event[i].Data.Length > 0 ) {
// meta textを抽出
byte type = m_midi_event[i].Data[0];
byte type = midi_event[i].Data[0];
if ( type == 0x01 || type == 0x03 ) {
char[] ch = new char[m_midi_event[i].Data.Length - 1];
for ( int j = 1; j < midi_events[i].Data.Length; j++ ) {
ch[j - 1] = (char)midi_events[i].Data[j];
char[] ch = new char[midi_event[i].Data.Length - 1];
for ( int j = 1; j < midi_event[i].Data.Length; j++ ) {
ch[j - 1] = (char)midi_event[i].Data[j];
}
string line = new string( ch );
if ( type == 0x01 ) {
@ -381,33 +414,9 @@ namespace Boare.Lib.Vsq {
}
}
sw.rewind();
m_meta_text = new VsqMetaText( sw );
MetaText = new VsqMetaText( sw );
}
}
public List<MidiEvent> getTempoList() {
List<MidiEvent> list = new List<MidiEvent>();
for ( int i = 0; i < m_midi_event.Count; i++ ) {
if ( m_midi_event[i].FirstByte == 0xff && m_midi_event[i].Data.Length >= 4 && m_midi_event[i].Data[0] == 0x51 ) {
list.Add( m_midi_event[i] );
}
}
return list;
}
/// <summary>
/// MidiEventの中から拍子情報を抽出します
/// </summary>
/// <returns></returns>
public List<MidiEvent> getTimeSigList() {
List<MidiEvent> list = new List<MidiEvent>();
for ( int i = 0; i < m_midi_event.Count; i++ ) {
if ( m_midi_event[i].FirstByte == 0xff && m_midi_event[i].Data.Length >= 5 && m_midi_event[i].Data[0] == 0x58 ) {
list.Add( m_midi_event[i] );
}
}
return list;
}
}
}

View File

@ -1,21 +1,14 @@
CP=cp
RM=rm
all: Boare.Lib.Vsq.dll libvsq.exe
all: Boare.Lib.Vsq.dll
Boare.Lib.Vsq.dll: *.cs bocoree.dll
gmcs -recurse:*.cs -target:library -define:MONO -out:Boare.Lib.Vsq.dll -r:bocoree.dll,System,System.Windows.Forms,System.Drawing
bocoree.dll: ../bocoree/bocoree.dll
cp ../bocoree/bocoree.dll bocoree.dll
../bocoree/bocoree.dll:
cd ../bocoree/ && $(MAKE)
libvsq.exe: common.cpp TextMemoryStream.cpp VsqCommon.cpp main.cpp
g++ common.cpp TextMemoryStream.cpp VsqCommon.cpp main.cpp -o libvsq.exe
#libvsq.exe: common.cpp TextMemoryStream.cpp VsqCommon.cpp main.cpp
# g++ common.cpp TextMemoryStream.cpp VsqCommon.cpp main.cpp -o libvsq.exe
clean:
$(RM) Boare.Lib.Vsq.dll
$(RM) bocoree.dll
cd ../bocoree/ && $(MAKE) RM=$(RM) clean

View File

@ -712,7 +712,9 @@ namespace LipSync {
} else {
#region
copy_enabled = true;//エントリがクリックされたので、エントリの個数は1個以上
if ( m_clicked.type != TimeTableType.vsq ) {
if ( m_clicked.type == TimeTableType.vsq ) {
cmenu.Items.Add( _( "Generate Lipsync from this track" ), null, new EventHandler( h_genMouthFromVsq ) );
} else {
cmenu.Items.Add( _( "Note OFF" ) + "(&O)", null, new EventHandler( h_noteOFF ) );
if ( m_clicked.type == TimeTableType.character ) {
cmenu.Items.Add( _( "Image Preview" ), null, new EventHandler( h_previewImage ) );
@ -2331,21 +2333,21 @@ namespace LipSync {
VsqFile vsqFile = new VsqFile( openVsqDialog.FileName );
AppManager.SaveData.m_totalSec = (float)vsqFile.getTotalSec();
AppManager.SaveData.m_timesig_ex = new List<TimeSigTableEntry>( vsqFile.getTimeSigList().ToArray() );
AppManager.SaveData.m_tempo = new List<TempoTableEntry>( vsqFile.getTempoList().ToArray() );
AppManager.SaveData.m_timesig_ex = new List<TimeSigTableEntry>( vsqFile.TimesigTable.ToArray() );
AppManager.SaveData.m_tempo = new List<TempoTableEntry>( vsqFile.TempoTable.ToArray() );
AppManager.SaveData.m_base_tempo = vsqFile.getBaseTempo();
// 歌詞の含まれるトラック数を取得
{
int most_lyrics = 0;
for ( int i = 0; i < vsqFile.getTrackCount(); i++ ) {
int track_num = vsqFile.getTrack( i ).getLyricLength();
for ( int i = 0; i < vsqFile.Track.Count; i++ ) {
int track_num = vsqFile.Track[i].getLyricLength();
if ( most_lyrics < track_num ) {
most_lyrics_track = i;
most_lyrics = track_num;
}
if ( track_num > 0 ) {
track_name.Add( vsqFile.getTrack( i ).Name );
track_name.Add( vsqFile.Track[i].Name );
tracks++;
}
}
@ -2353,8 +2355,8 @@ namespace LipSync {
most_lyrics_track--;
// tableを更新
for ( int track = 0; track < vsqFile.getTrackCount(); track++ ) {
int lyrics = vsqFile.getTrack( track ).getLyricLength();
for ( int track = 0; track < vsqFile.Track.Count; track++ ) {
int lyrics = vsqFile.Track[track].getLyricLength();
if ( lyrics <= 0 ) {
continue;
}
@ -2370,7 +2372,8 @@ namespace LipSync {
} else {
UstFile ust_file = new UstFile( openVsqDialog.FileName );
for ( int track = 0; track < ust_file.getTrackCount(); track++ ) {
foreach ( UstEvent ue in ust_file.getTrack( track ).getNoteEventEnumerator() ) {
for( Iterator itr = ust_file.getTrack( track ).getNoteEventIterator(); itr.hasNext(); ){
UstEvent ue = (UstEvent)itr.next();
if ( ue.Lyric == "u" ) {
ue.Lyric = "う";
}

View File

@ -267,10 +267,10 @@ namespace LipSync {
AppManager.SaveData.m_totalSec = Math.Max( AppManager.SaveData.m_totalSec, (float)ust.getTotalSec() );
} else {
VsqFile vsqFile = new VsqFile( filename );
int tracks = vsqFile.getTrackCount();
int tracks = vsqFile.Track.Count;
string[] track_names = new string[tracks];
for ( int track = 0; track < tracks; track++ ) {
track_names[track] = vsqFile.getTrack( track ).Name;
track_names[track] = vsqFile.Track[track].Name;
}
using ( TrackSelecter selecter = new TrackSelecter( filename, track_names ) ) {
selecter.ImportTempoAndTimesig = false;
@ -290,8 +290,8 @@ namespace LipSync {
AppManager.SaveData.m_tempo.Clear();
AppManager.SaveData.m_tempo = null;
}
AppManager.SaveData.m_timesig_ex = new List<TimeSigTableEntry>( vsqFile.getTimeSigList().ToArray() );
AppManager.SaveData.m_tempo = new List<TempoTableEntry>( vsqFile.getTempoList().ToArray() );
AppManager.SaveData.m_timesig_ex = new List<TimeSigTableEntry>( vsqFile.TimesigTable.ToArray() );
AppManager.SaveData.m_tempo = new List<TempoTableEntry>( vsqFile.TempoTable.ToArray() );
AppManager.SaveData.m_base_tempo = vsqFile.getBaseTempo();
}
}
@ -1258,7 +1258,7 @@ namespace LipSync {
private void addTimeLineFromTrack( VsqFile vsqFile, int track_number, bool enable_undo ) {
string tmp_lyric = Path.GetTempFileName();
vsqFile.printLyricTable( track_number, tmp_lyric );
using ( TimeTable temp = new TimeTable( vsqFile.getTrack( track_number ).Name, 0, TimeTableType.vsq, null ) ) {
using ( TimeTable temp = new TimeTable( vsqFile.Track[track_number].Name, 0, TimeTableType.vsq, null ) ) {
using ( StreamReader sr = new StreamReader( tmp_lyric ) ) {
string line;
while ( sr.Peek() >= 0 ) {

View File

@ -3,7 +3,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>{C8AAE632-9C6C-4372-8175-811528A66742}</ProjectGuid>
<OutputType>Library</OutputType>
@ -12,6 +12,9 @@
<AssemblyName>bocoree</AssemblyName>
<TargetFrameworkVersion>v2.0</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<SignAssembly>false</SignAssembly>
<AssemblyOriginatorKeyFile>
</AssemblyOriginatorKeyFile>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>

View File

@ -1,6 +1,6 @@
CP=cp
RM=rm
SRC=cp932.cs fft.cs math.cs windows.cs wingdi.cs
bocoree.dll: *.cs
gmcs -recurse:*.cs -unsafe+ -target:library -out:bocoree.dll -r:System,System.Drawing,System.Windows.Forms

View File

@ -122,24 +122,43 @@ namespace bocoree {
private static string s_path = "";
public static void force_logfile_path( string path ) {
try {
if ( s_debug_out != null ) {
s_debug_out.Close();
s_debug_out = new StreamWriter( path );
}
} catch {
}
s_path = path;
}
public static void push_log( string s ) {
if ( s_debug_out == null ) {
if ( s_path == "" ) {
s_debug_out = new StreamWriter( Path.Combine( System.Windows.Forms.Application.StartupPath, "run.log" ) );
} else {
s_debug_out = new StreamWriter( s_path );
try {
if ( s_debug_out == null ) {
if ( s_path == "" ) {
s_debug_out = new StreamWriter( Path.Combine( System.Windows.Forms.Application.StartupPath, "run.log" ) );
} else {
s_debug_out = new StreamWriter( s_path );
}
s_debug_out.AutoFlush = true;
s_debug_out.WriteLine( "************************************************************************" );
s_debug_out.WriteLine( " Date: " + DateTime.Now.ToString() );
s_debug_out.WriteLine( "------------------------------------------------------------------------" );
}
s_debug_out.AutoFlush = true;
s_debug_out.WriteLine( "************************************************************************" );
s_debug_out.WriteLine( " Date: " + DateTime.Now.ToString() );
s_debug_out.WriteLine( "------------------------------------------------------------------------" );
s_debug_out.WriteLine( s );
} catch ( Exception ex ) {
Console.WriteLine( "bocoree.debug.push_log; log file I/O Exception" );
}
s_debug_out.WriteLine( s );
Console.WriteLine( s );
}
public static void close() {
if ( s_debug_out != null ) {
s_debug_out.Close();
s_debug_out = null;
s_path = "";
}
}
}
}

View File

@ -36,7 +36,7 @@ namespace bocoree {
public const int LOAD_LIBRARY_AS_DATAFILE_EXCLUSIVE = 0x00000040;
[DllImport( "kernel32.dll" )]
public static extern IntPtr LoadLibraryExW( [MarshalAs( UnmanagedType.LPWStr)]string lpFileName, IntPtr hFile, uint dwFlags );
public static extern IntPtr LoadLibraryExW( [MarshalAs( UnmanagedType.LPWStr )]string lpFileName, IntPtr hFile, uint dwFlags );
[DllImport( "kernel32.dll", CharSet = CharSet.Ansi, EntryPoint = "GetProcAddress", ExactSpelling = true )]
public static extern IntPtr GetProcAddress( IntPtr hModule, string lpProcName );
@ -158,8 +158,29 @@ namespace bocoree {
#region windef.h
public const int MAX_PATH = 260;
#endregion
}
#region winuser.h
public const int WM_MOUSEMOVE = 512;
public const int WM_LBUTTONDOWN = 513;
public const int WM_LBUTTONUP = 514;
public const int WM_LBUTTONDBLCLK = 515;
public const int WM_RBUTTONDOWN = 516;
public const int WM_RBUTTONUP = 517;
public const int WM_RBUTTONDBLCLK = 518;
public const int WM_MBUTTONDOWN = 519;
public const int WM_MBUTTONUP = 520;
public const int WM_MBUTTONDBLCLK = 521;
public const int WM_MOUSEWHEEL = 522;
#endregion
public const uint SHGFI_ICON = 0x100;
public const uint SHGFI_LARGEICON = 0x0; // 'Large icon
public const uint SHGFI_SMALLICON = 0x1; // 'Small icon
[DllImport( "shell32.dll" )]
public static extern IntPtr SHGetFileInfo( string pszPath, uint dwFileAttributes, ref SHFILEINFO psfi, uint cbSizeFileInfo, uint uFlags );
}
#region windef.h
public struct FILETIME {
@ -168,4 +189,14 @@ namespace bocoree {
}
#endregion
[StructLayout( LayoutKind.Sequential )]
public struct SHFILEINFO {
public IntPtr hIcon;
public IntPtr iIcon;
public uint dwAttributes;
[MarshalAs( UnmanagedType.ByValTStr, SizeConst = 260 )]
public string szDisplayName;
[MarshalAs( UnmanagedType.ByValTStr, SizeConst = 80 )]
public string szTypeName;
}
}

View File

@ -30,6 +30,54 @@ namespace bocoree {
public Int32 biYPelsPerMeter;
public UInt32 biClrUsed;
public UInt32 biClrImportant;
public static BITMAPINFOHEADER Read( Stream stream ) {
BITMAPINFOHEADER bifh = new BITMAPINFOHEADER();
byte[] buf = new byte[4];
bifh.biSize = readUInt32( stream );
bifh.biWidth = readInt32( stream );
bifh.biHeight = readInt32( stream );
bifh.biPlanes = readInt16( stream );
bifh.biBitCount = readInt16( stream );
bifh.biCompression = readUInt32( stream );
bifh.biSizeImage = readUInt32( stream );
bifh.biXPelsPerMeter = readInt32( stream );
bifh.biYPelsPerMeter = readInt32( stream );
bifh.biClrUsed = readUInt32( stream );
bifh.biClrImportant = readUInt32( stream );
return bifh;
}
private static uint readUInt32( Stream fs ){
byte[] buf = new byte[4];
fs.Read( buf, 0, 4 );
return BitConverter.ToUInt32( buf, 0 );
}
private static int readInt32( Stream fs ){
byte[] buf = new byte[4];
fs.Read( buf, 0, 4 );
return BitConverter.ToInt32( buf, 0 );
}
private static ushort readUInt16( Stream fs ){
byte[] buf = new byte[2];
fs.Read( buf, 0, 2 );
return BitConverter.ToUInt16( buf, 0 );
}
private static short readInt16( Stream fs ){
byte[] buf = new byte[2];
fs.Read( buf, 0, 2 );
return BitConverter.ToInt16( buf, 0 );
}
public override string ToString() {
return "{biSize=" + biSize + ", biWidth=" + biWidth + ", biHeight=" + biHeight + ", biPlanes=" + biPlanes + ", biBitCount=" + biBitCount +
", biCompression=" + biCompression + ", biSizeImage=" + biSizeImage + ", biXPelsPerMeter=" + biXPelsPerMeter + ", biYPelsPerMeter=" + biYPelsPerMeter +
", biClrUsed=" + biClrUsed + ", biClrImportant=" + biClrImportant + "}";
}
public void Write( BinaryWriter bw ) {
bw.Write( biSize );
bw.Write( (uint)biWidth );

View File

@ -13,6 +13,7 @@
*/
using System;
using System.Runtime.InteropServices;
using bocoree;
namespace bocoree {
@ -131,138 +132,38 @@ namespace bocoree {
public uint reserved; // reserved for driver
}
/*typedef struct mmtime_tag
{
UINT wType; // indicates the contents of the union
union
{
DWORD ms; // milliseconds
DWORD sample; // samples
DWORD cb; // byte count
DWORD ticks; // ticks in MIDI stream
// SMPTE
struct
{
BYTE hour; // hours
BYTE min; // minutes
BYTE sec; // seconds
BYTE frame; // frames
BYTE fps; // frames per second
BYTE dummy; // pad
#ifdef _WIN32
BYTE pad[2];
#endif
} smpte;
// MIDI
struct
{
DWORD songptrpos; // song pointer position
} midi;
} u;
}*/
[StructLayout( LayoutKind.Explicit )]
public struct MMTIME {
[FieldOffset( 0 )]
public UInt32 wType;
[FieldOffset( 4 )]
public UInt32 ms;
[FieldOffset( 4 )]
public UInt32 sample;
[FieldOffset( 4 )]
public UInt32 cb;
[FieldOffset( 4 )]
public UInt32 ticks;
[FieldOffset( 4 )]
public Byte smpteHour;
[FieldOffset( 5 )]
public Byte smpteMin;
[FieldOffset( 6 )]
public Byte smpteSec;
[FieldOffset( 7 )]
public Byte smpteFrame;
[FieldOffset( 8 )]
public Byte smpteFps;
[FieldOffset( 9 )]
public Byte smpteDummy;
[FieldOffset( 10 )]
public Byte smptePad0;
[FieldOffset( 11 )]
public Byte smptePad1;
[FieldOffset( 4 )]
public UInt32 midiSongPtrPos;
}
[StructLayout(LayoutKind.Sequential, Pack = 1 )]
public unsafe struct _MMTIME {
public UINT wType;
byte b1;
byte b2;
byte b3;
byte b4;
byte b5;
byte b6;
byte b7;
byte b8;
public struct SMPTE {
public BYTE hour; // hours
public BYTE min; // minutes
public BYTE sec; // seconds
public BYTE frame; // frames
public BYTE fps; // frames per second
public BYTE dummy; // pad
public fixed BYTE pad[2];
}
public SMPTE smpte {
get {
SMPTE ret = new SMPTE();
ret.hour = b1;
ret.min = b2;
ret.sec = b3;
ret.frame = b4;
ret.fps = b5;
ret.dummy = b6;
ret.pad[0] = b7;
ret.pad[1] = b8;
return ret;
}
}
[StructLayout( LayoutKind.Sequential, Pack = 1 )]
public struct MIDI {
public DWORD songptrpos; // song pointer position
}
public MIDI midi {
get {
MIDI ret = new MIDI();
ret.songptrpos = ms;
return ret;
}
[StructLayout( LayoutKind.Sequential, Pack = 1 )]
public unsafe struct SMPTE {
public BYTE hour; // hours
public BYTE min; // minutes
public BYTE sec; // seconds
public BYTE frame; // frames
public BYTE fps; // frames per second
public BYTE dummy; // pad
public fixed BYTE pad[2];
}
public uint ms {
get {
return (uint)b1 | (uint)(b2 << 8) | (uint)(b3 << 16) | (uint)(b4 << 32);
}
}
public uint sample {
get {
return ms;
}
}
public uint cb {
get {
return ms;
}
}
public uint ticks {
get {
return ms;
}
}
[FieldOffset( 0 )]
public uint wType;
[FieldOffset( 4 )]
public SMPTE smpte;
[FieldOffset( 4 )]
public MIDI midi;
[FieldOffset( 4 )]
public uint ms;
[FieldOffset( 4 )]
public uint sample;
[FieldOffset( 4 )]
public uint cb;
[FieldOffset( 4 )]
public uint ticks;
}
[StructLayout( LayoutKind.Sequential, CharSet = CharSet.Ansi )]
@ -279,7 +180,40 @@ namespace bocoree {
}
}
[StructLayout( LayoutKind.Sequential )]
public unsafe struct MIDIHDR {
public byte* lpData;
public DWORD dwBufferLength;
public DWORD dwBytesRecorded;
public DWORD dwUser;
public DWORD dwFlags;
public MIDIHDR* lpNext;
public DWORD reserved;
public DWORD dwOffset;
public fixed DWORD dwReserved[8];
}
[StructLayout( LayoutKind.Sequential )]
public struct MIDIOUTCAPSA {
public WORD wMid;
public WORD wPid;
public uint vDriverVersion;
[MarshalAs( UnmanagedType.ByValTStr, SizeConst = windows.MAXPNAMELEN )]
public string szPname;
public WORD wTechnology;
public WORD wVoices;
public WORD wNotes;
public WORD wChannelMask;
public DWORD dwSupport;
}
public static partial class windows {
private enum DllStatus {
Unknown,
Found,
NotFound,
}
public const uint JOYERR_NOERROR = 0;
public const ushort JOY_RETURNX = 0x00000001;
public const ushort JOY_RETURNY = 0x00000002;
@ -336,40 +270,496 @@ namespace bocoree {
public const int WHDR_ENDLOOP = 0x00000008; /* loop end block */
public const int WHDR_INQUEUE = 0x00000010; /* reserved for driver */
public const int TIME_MS = 0x0001; /* time in milliseconds */
public const int TIME_SAMPLES= 0x0002; /* number of wave samples */
public const int TIME_BYTES= 0x0004; /* current byte offset */
public const int TIME_SMPTE = 0x0008; /* SMPTE time */
public const int TIME_MIDI = 0x0010; /* MIDI time */
public const int TIME_MS = 0x0001; /* time in milliseconds */
public const int TIME_SAMPLES = 0x0002; /* number of wave samples */
public const int TIME_BYTES = 0x0004; /* current byte offset */
public const int TIME_SMPTE = 0x0008; /* SMPTE time */
public const int TIME_MIDI = 0x0010; /* MIDI time */
public const int TIME_TICKS = 0x0020; /* Ticks within MIDI stream */
public const int MAXPNAMELEN = 32;
public const int MAX_JOYSTICKOEMVXDNAME = 260;
public const uint MMSYSERR_NOERROR = 0;
public const uint MMSYSERR_ERROR = 1;
public const uint MMSYSERR_BADDEVICEID = 2;
public const uint MMSYSERR_NOTENABLED = 3;
public const uint MMSYSERR_ALLOCATED = 4;
public const uint MMSYSERR_INVALHANDLE = 5;
public const uint MMSYSERR_NODRIVER = 6;
public const uint MMSYSERR_NOMEM = 7;
public const uint MMSYSERR_NOTSUPPORTED = 8;
public const uint MMSYSERR_BADERRNUM = 9;
public const uint MMSYSERR_INVALFLAG = 10;
public const uint MMSYSERR_INVALPARAM = 11;
public const uint MMSYSERR_HANDLEBUSY = 12;
public const uint MMSYSERR_INVALIDALIAS = 13;
public const uint MMSYSERR_BADDB = 14;
public const uint MMSYSERR_KEYNOTFOUND = 15;
public const uint MMSYSERR_READERROR = 16;
public const uint MMSYSERR_WRITEERROR = 17;
public const uint MMSYSERR_DELETEERROR = 18;
public const uint MMSYSERR_VALNOTFOUND = 19;
public const uint MMSYSERR_NODRIVERCB = 20;
public const uint MMSYSERR_LASTERROR = 20;
private static DllStatus status_winmm = DllStatus.Unknown;
private static DllStatus status_winmm_so = DllStatus.Unknown;
#region midi
[DllImport( "winmm.dll" )]
public static extern UINT midiInGetNumDevs();
[DllImport( "winmm.dll" )]
public static unsafe extern MMRESULT midiInOpen( HMIDIIN* lphMidiIn,
UINT uDeviceID,
DWORD dwCallback,
DWORD dwCallbackInstance,
DWORD dwFlags );
[DllImport( "winmm", EntryPoint = "midiInGetDevCaps", CharSet = CharSet.Ansi )]
[return: MarshalAs( UnmanagedType.U4 )]
private static extern uint __midiInGetDevCaps( [MarshalAs( UnmanagedType.U4 )]uint uDeviceID, ref MIDIINCAPS lpMidiInCaps, [MarshalAs( UnmanagedType.U4 )]uint cbMidiInCaps );
[DllImport( "winmm.dll.so", EntryPoint = "midiInGetDevCaps", CharSet = CharSet.Ansi )]
[return: MarshalAs( UnmanagedType.U4 )]
private static extern uint __so_midiInGetDevCaps( [MarshalAs( UnmanagedType.U4 )]uint uDeviceID, ref MIDIINCAPS lpMidiInCaps, [MarshalAs( UnmanagedType.U4 )]uint cbMidiInCaps );
public static uint midiInGetDevCaps( uint uDeviceID, ref MIDIINCAPS lpMidiInCaps, uint cbMidiInCaps ) {
uint ret = MMSYSERR_ERROR;
if ( status_winmm != DllStatus.NotFound ) {
try {
ret = __midiInGetDevCaps( uDeviceID, ref lpMidiInCaps, cbMidiInCaps );
status_winmm = DllStatus.Found;
} catch ( DllNotFoundException ex ) {
status_winmm = DllStatus.NotFound;
}
} else if ( status_winmm_so != DllStatus.NotFound ) {
try {
ret = __so_midiInGetDevCaps( uDeviceID, ref lpMidiInCaps, cbMidiInCaps );
} catch ( DllNotFoundException ex ) {
status_winmm_so = DllStatus.NotFound;
}
}
return ret;
}
[DllImport( "winmm", EntryPoint = "midiInClose" )]
[return: MarshalAs( UnmanagedType.U4 )]
private static extern uint __midiInClose( uint hMidiIn );
[DllImport( "winmm.dll.so", EntryPoint = "midiInClose" )]
[return: MarshalAs( UnmanagedType.U4 )]
private static extern uint __so_midiInClose( uint hMidiIn );
public static uint midiInClose( uint hMidiIn ) {
uint ret = MMSYSERR_ERROR;
if ( status_winmm != DllStatus.NotFound ) {
try {
ret = __midiInClose( hMidiIn );
} catch ( DllNotFoundException ex ) {
status_winmm = DllStatus.NotFound;
}
} else if ( status_winmm_so != DllStatus.NotFound ) {
try {
ret = __so_midiInClose( hMidiIn );
} catch ( DllNotFoundException ex ) {
status_winmm_so = DllStatus.NotFound;
}
}
return ret;
}
[DllImport( "winmm", EntryPoint = "midiInStart" )]
[return: MarshalAs( UnmanagedType.U4 )]
private static extern uint __midiInStart( uint hMidiIn );
[DllImport( "winmm.dll.so", EntryPoint = "midiInStart" )]
[return: MarshalAs( UnmanagedType.U4 )]
private static extern uint __so_midiInStart( uint hMidiIn );
public static uint midiInStart( uint hMidiIn ) {
uint ret = MMSYSERR_ERROR;
if ( status_winmm != DllStatus.NotFound ) {
try {
ret = __midiInStart( hMidiIn );
} catch ( DllNotFoundException ex ) {
status_winmm = DllStatus.NotFound;
}
} else if ( status_winmm_so != DllStatus.NotFound ) {
try {
ret = __so_midiInStart( hMidiIn );
} catch ( DllNotFoundException ex ) {
status_winmm_so = DllStatus.NotFound;
}
}
return ret;
}
[DllImport( "winmm", EntryPoint = "midiInReset" )]
[return: MarshalAs( UnmanagedType.U4 )]
private static extern uint __midiInReset( uint hMidiIn );
[DllImport( "winmm.dll.so", EntryPoint = "midiInReset" )]
[return: MarshalAs( UnmanagedType.U4 )]
private static extern uint __so_midiInReset( uint hMidiIn );
public static uint midiInReset( uint hMidiIn ) {
uint ret = MMSYSERR_ERROR;
if ( status_winmm != DllStatus.NotFound ) {
try {
ret = __midiInReset( hMidiIn );
} catch ( DllNotFoundException ex ) {
status_winmm = DllStatus.NotFound;
}
} else if ( status_winmm_so != DllStatus.NotFound ) {
try {
ret = __so_midiInReset( hMidiIn );
} catch ( DllNotFoundException ex ) {
status_winmm_so = DllStatus.NotFound;
}
}
return ret;
}
[DllImport( "winmm", EntryPoint = "midiInGetNumDevs" )]
[return: MarshalAs( UnmanagedType.U4 )]
private static extern uint __midiInGetNumDevs();
[DllImport( "winmm.dll.so", EntryPoint = "midiInGetNumDevs" )]
[return: MarshalAs( UnmanagedType.U4 )]
private static extern uint __so_midiInGetNumDevs();
public static uint midiInGetNumDevs() {
uint ret = 0;
if ( status_winmm != DllStatus.NotFound ) {
try {
ret = __midiInGetNumDevs();
} catch ( DllNotFoundException ex ) {
status_winmm = DllStatus.NotFound;
}
} else if ( status_winmm_so != DllStatus.NotFound ) {
try {
ret = __so_midiInGetNumDevs();
} catch ( DllNotFoundException ex ) {
status_winmm_so = DllStatus.NotFound;
}
}
return ret;
}
[DllImport( "winmm", EntryPoint = "midiInOpen" )]
private static extern uint __midiInOpen( ref uint lphMidiIn,
int uDeviceID,
IntPtr dwCallback,
int dwCallbackInstance,
int dwFlags );
[DllImport( "winmm.dll.so", EntryPoint = "midiInOpen" )]
private static extern uint __so_midiInOpen( ref uint lphMidiIn,
int uDeviceID,
IntPtr dwCallback,
int dwCallbackInstance,
int dwFlags );
public static uint midiInOpen( ref uint lphMidiIn,
int uDeviceID,
IntPtr dwCallback,
int dwCallbackInstance,
int dwFlags ) {
uint ret = MMSYSERR_ERROR;
if ( status_winmm != DllStatus.NotFound ) {
try {
ret = __midiInOpen( ref lphMidiIn, uDeviceID, dwCallback, dwCallbackInstance, dwFlags );
} catch ( DllNotFoundException ex ) {
status_winmm = DllStatus.NotFound;
}
} else if ( status_winmm_so != DllStatus.NotFound ) {
try {
ret = __so_midiInOpen( ref lphMidiIn, uDeviceID, dwCallback, dwCallbackInstance, dwFlags );
} catch ( DllNotFoundException ex ) {
status_winmm_so = DllStatus.NotFound;
}
}
return ret;
}
[DllImport( "winmm", EntryPoint = "midiOutGetNumDevs" )]
[return: MarshalAs( UnmanagedType.U4 )]
private static extern uint __midiOutGetNumDevs();
[DllImport( "winmm.dll.so", EntryPoint = "midiOutGetNumDevs" )]
[return: MarshalAs( UnmanagedType.U4 )]
private static extern uint __so_midiOutGetNumDevs();
public static uint midiOutGetNumDevs() {
uint ret = MMSYSERR_ERROR;
if ( status_winmm != DllStatus.NotFound ) {
try {
ret = __midiOutGetNumDevs();
} catch ( DllNotFoundException ex ) {
status_winmm = DllStatus.NotFound;
}
} else if ( status_winmm_so != DllStatus.NotFound ) {
try {
ret = __so_midiOutGetNumDevs();
} catch ( DllNotFoundException ex ) {
status_winmm_so = DllStatus.NotFound;
}
}
return ret;
}
[DllImport( "winmm", EntryPoint = "midiOutGetDevCapsA", CharSet = CharSet.Ansi )]
[return: MarshalAs( UnmanagedType.U4 )]
private static extern uint __midiOutGetDevCapsA( [MarshalAs( UnmanagedType.U4 )] uint uDeviceID,
ref MIDIOUTCAPSA pMidiOutCaps,
[MarshalAs( UnmanagedType.U4 )] uint cbMidiOutCaps );
[DllImport( "winmm.dll.so", EntryPoint = "midiOutGetDevCapsA", CharSet = CharSet.Ansi )]
[return: MarshalAs( UnmanagedType.U4 )]
private static extern uint __so_midiOutGetDevCapsA( [MarshalAs( UnmanagedType.U4 )] uint uDeviceID,
ref MIDIOUTCAPSA pMidiOutCaps,
[MarshalAs( UnmanagedType.U4 )] uint cbMidiOutCaps );
public static uint midiOutGetDevCapsA( uint uDeviceID, ref MIDIOUTCAPSA pMidiOutCaps, uint cbMidiOutCaps ) {
uint ret = MMSYSERR_ERROR;
if ( status_winmm != DllStatus.NotFound ) {
try {
ret = __midiOutGetDevCapsA( uDeviceID, ref pMidiOutCaps, cbMidiOutCaps );
} catch ( DllNotFoundException ex ) {
status_winmm = DllStatus.NotFound;
}
} else if ( status_winmm_so != DllStatus.NotFound ) {
try {
ret = __so_midiOutGetDevCapsA( uDeviceID, ref pMidiOutCaps, cbMidiOutCaps );
} catch ( DllNotFoundException ex ) {
status_winmm_so = DllStatus.NotFound;
}
}
return ret;
}
[DllImport( "winmm", EntryPoint = "midiOutOpen" )]
[return: MarshalAs( UnmanagedType.U4 )]
private static extern uint __midiOutOpen( [MarshalAs( UnmanagedType.SysUInt )] ref IntPtr lphMidiOut,
[MarshalAs( UnmanagedType.U4 )] uint uDeviceID,
[MarshalAs( UnmanagedType.FunctionPtr )] Delegate dwCallback,
[MarshalAs( UnmanagedType.U4 )] uint dwInstance,
[MarshalAs( UnmanagedType.U4 )] uint dwFlags );
[DllImport( "winmm.dll.so", EntryPoint = "midiOutOpen" )]
[return: MarshalAs( UnmanagedType.U4 )]
private static extern uint __so_midiOutOpen( [MarshalAs( UnmanagedType.SysUInt )] ref IntPtr lphMidiOut,
[MarshalAs( UnmanagedType.U4 )] uint uDeviceID,
[MarshalAs( UnmanagedType.FunctionPtr )] Delegate dwCallback,
[MarshalAs( UnmanagedType.U4 )] uint dwInstance,
[MarshalAs( UnmanagedType.U4 )] uint dwFlags );
public static uint midiOutOpen( ref IntPtr lphMidiOut,
uint uDeviceID,
Delegate dwCallback,
uint dwInstance,
uint dwFlags ) {
uint ret = MMSYSERR_ERROR;
if ( status_winmm != DllStatus.NotFound ) {
try {
ret = __midiOutOpen( ref lphMidiOut, uDeviceID, dwCallback, dwInstance, dwFlags );
} catch ( DllNotFoundException ex ) {
status_winmm = DllStatus.NotFound;
}
} else if ( status_winmm_so != DllStatus.NotFound ) {
try {
ret = __so_midiOutOpen( ref lphMidiOut, uDeviceID, dwCallback, dwInstance, dwFlags );
} catch ( DllNotFoundException ex ) {
status_winmm_so = DllStatus.NotFound;
}
}
return ret;
}
[DllImport( "winmm", EntryPoint = "midiOutClose" )]
[return: MarshalAs( UnmanagedType.U4 )]
private static extern uint __midiOutClose( [MarshalAs( UnmanagedType.SysUInt )] IntPtr hMidiOut );
[DllImport( "winmm.dll.so", EntryPoint = "midiOutClose" )]
[return: MarshalAs( UnmanagedType.U4 )]
private static extern uint __so_midiOutClose( [MarshalAs( UnmanagedType.SysUInt )] IntPtr hMidiOut );
public static uint midiOutClose( IntPtr hMidiOut ) {
uint ret = MMSYSERR_ERROR;
if ( status_winmm != DllStatus.NotFound ) {
try {
ret = __midiOutClose( hMidiOut );
} catch ( DllNotFoundException ex ) {
status_winmm = DllStatus.NotFound;
}
} else if ( status_winmm_so != DllStatus.NotFound ) {
try {
ret = __so_midiOutClose( hMidiOut );
} catch ( DllNotFoundException ex ) {
status_winmm_so = DllStatus.NotFound;
}
}
return ret;
}
[DllImport( "winmm", EntryPoint = "midiOutShortMsg" )]
[return: MarshalAs( UnmanagedType.U4 )]
private static extern uint __midiOutShortMsg( [MarshalAs( UnmanagedType.SysUInt )] IntPtr hMidiOut, [MarshalAs( UnmanagedType.U4 )] uint dwMsg );
[DllImport( "winmm.dll.so", EntryPoint = "midiOutShortMsg" )]
[return: MarshalAs( UnmanagedType.U4 )]
private static extern uint __so_midiOutShortMsg( [MarshalAs( UnmanagedType.SysUInt )] IntPtr hMidiOut, [MarshalAs( UnmanagedType.U4 )] uint dwMsg );
public static uint midiOutShortMsg( IntPtr hMidiOut, uint dwMsg ) {
uint ret = MMSYSERR_ERROR;
if ( status_winmm != DllStatus.NotFound ) {
try {
ret = __midiOutShortMsg( hMidiOut, dwMsg );
} catch ( DllNotFoundException ex ) {
status_winmm = DllStatus.NotFound;
}
} else if ( status_winmm_so != DllStatus.NotFound ) {
try {
ret = __so_midiOutShortMsg( hMidiOut, dwMsg );
} catch ( DllNotFoundException ex ) {
status_winmm_so = DllStatus.NotFound;
}
}
return ret;
}
[DllImport( "winmm", EntryPoint = "midiOutLongMsg" )]
[return: MarshalAs( UnmanagedType.U4 )]
private static extern uint __midiOutLongMsg( [MarshalAs( UnmanagedType.SysUInt )] IntPtr hMidiOut, ref MIDIHDR lpMidiOutHdr, [MarshalAs( UnmanagedType.U4 )] uint uSize );
[DllImport( "winmm.dll.so", EntryPoint = "midiOutLongMsg" )]
[return: MarshalAs( UnmanagedType.U4 )]
private static extern uint __so_midiOutLongMsg( [MarshalAs( UnmanagedType.SysUInt )] IntPtr hMidiOut, ref MIDIHDR lpMidiOutHdr, [MarshalAs( UnmanagedType.U4 )] uint uSize );
public static uint midiOutLongMsg( IntPtr hMidiOut, ref MIDIHDR lpMidiOutHdr, uint uSize ) {
uint ret = MMSYSERR_ERROR;
if ( status_winmm != DllStatus.NotFound ) {
try {
ret = __midiOutLongMsg( hMidiOut, ref lpMidiOutHdr, uSize );
} catch ( DllNotFoundException ex ) {
status_winmm = DllStatus.NotFound;
}
} else if ( status_winmm_so != DllStatus.NotFound ) {
try {
ret = __so_midiOutLongMsg( hMidiOut, ref lpMidiOutHdr, uSize );
} catch ( DllNotFoundException ex ) {
status_winmm_so = DllStatus.NotFound;
}
}
return ret;
}
[DllImport( "winmm", EntryPoint = "midiOutPrepareHeader" )]
[return: MarshalAs( UnmanagedType.U4 )]
private static extern uint __midiOutPrepareHeader( [MarshalAs( UnmanagedType.SysUInt )] IntPtr hMidiOut, ref MIDIHDR lpMidiOutHdr, [MarshalAs( UnmanagedType.U4 )] uint uSize );
[DllImport( "winmm.dll.so", EntryPoint = "midiOutPrepareHeader" )]
[return: MarshalAs( UnmanagedType.U4 )]
private static extern uint __so_midiOutPrepareHeader( [MarshalAs( UnmanagedType.SysUInt )] IntPtr hMidiOut, ref MIDIHDR lpMidiOutHdr, [MarshalAs( UnmanagedType.U4 )] uint uSize );
public static uint midiOutPrepareHeader( IntPtr hMidiOut, ref MIDIHDR lpMidiOutHdr, uint uSize ) {
uint ret = MMSYSERR_ERROR;
if ( status_winmm != DllStatus.NotFound ) {
try {
ret = __midiOutPrepareHeader( hMidiOut, ref lpMidiOutHdr, uSize );
} catch ( DllNotFoundException ex ) {
status_winmm = DllStatus.NotFound;
}
} else if ( status_winmm_so != DllStatus.NotFound ) {
try {
ret = __so_midiOutPrepareHeader( hMidiOut, ref lpMidiOutHdr, uSize );
} catch ( DllNotFoundException ex ) {
status_winmm_so = DllStatus.NotFound;
}
}
return ret;
}
[DllImport( "winmm", EntryPoint = "midiOutUnprepareHeader" )]
[return: MarshalAs( UnmanagedType.U4 )]
private static extern uint __midiOutUnprepareHeader( [MarshalAs( UnmanagedType.SysUInt )] IntPtr hMidiOut, ref MIDIHDR lpMidiOutHdr, [MarshalAs( UnmanagedType.U4 )] uint uSize );
[DllImport( "winmm.dll.so", EntryPoint = "midiOutUnprepareHeader" )]
[return: MarshalAs( UnmanagedType.U4 )]
private static extern uint __so_midiOutUnprepareHeader( [MarshalAs( UnmanagedType.SysUInt )] IntPtr hMidiOut, ref MIDIHDR lpMidiOutHdr, [MarshalAs( UnmanagedType.U4 )] uint uSize );
public static uint midiOutUnprepareHeader( IntPtr hMidiOut, ref MIDIHDR lpMidiOutHdr, uint uSize ) {
uint ret = MMSYSERR_ERROR;
if ( status_winmm != DllStatus.NotFound ) {
try {
ret = __midiOutUnprepareHeader( hMidiOut, ref lpMidiOutHdr, uSize );
} catch ( DllNotFoundException ex ) {
status_winmm = DllStatus.NotFound;
}
} else if ( status_winmm_so != DllStatus.NotFound ) {
try {
ret = __so_midiOutUnprepareHeader( hMidiOut, ref lpMidiOutHdr, uSize );
} catch ( DllNotFoundException ex ) {
status_winmm_so = DllStatus.NotFound;
}
}
return ret;
}
#endregion
#region joy
[DllImport( "winmm.dll" )]
[DllImport( "winmm", EntryPoint = "joyGetNumDevs" )]
[return: MarshalAs( UnmanagedType.U4 )]
public static extern uint joyGetNumDevs();
private static extern uint __joyGetNumDevs();
[DllImport( "winmm.dll" )]
public static extern uint joyGetPos( uint uJoyID, ref JOYINFO pji );
public static uint joyGetNumDevs() {
uint ret = 0;
if ( status_winmm != DllStatus.NotFound ) {
try {
ret = __joyGetNumDevs();
} catch ( DllNotFoundException ex ) {
status_winmm = DllStatus.NotFound;
}
}
return ret;
}
[DllImport( "winmm.dll" )]
public static extern uint joyGetDevCapsW( uint uJoyID, ref JOYCAPSW pjc, uint cbjc );
[DllImport( "winmm", EntryPoint = "joyGetPos" )]
private static extern uint __joyGetPos( uint uJoyID, ref JOYINFO pji );
[DllImport( "winmm.dll" )]
public static extern uint joyGetPosEx( uint uJoyID, ref JOYINFOEX pji );
public static uint joyGetPos( uint uJoyID, ref JOYINFO pji ) {
uint ret = MMSYSERR_ERROR;
if ( status_winmm != DllStatus.NotFound ) {
try {
ret = __joyGetPos( uJoyID, ref pji );
} catch ( DllNotFoundException ex ) {
status_winmm = DllStatus.NotFound;
}
}
return ret;
}
[DllImport( "winmm", EntryPoint = "joyGetDevCapsW" )]
private static extern uint __joyGetDevCapsW( uint uJoyID, ref JOYCAPSW pjc, uint cbjc );
public static uint joyGetDevCapsW( uint uJoyID, ref JOYCAPSW pjc, uint cbjc ) {
uint ret = MMSYSERR_ERROR;
if ( status_winmm != DllStatus.NotFound ) {
try {
ret = __joyGetDevCapsW( uJoyID, ref pjc, cbjc );
} catch ( DllNotFoundException ex ) {
status_winmm = DllStatus.NotFound;
}
}
return ret;
}
[DllImport( "winmm", EntryPoint = "joyGetPosEx" )]
private static extern uint __joyGetPosEx( uint uJoyID, ref JOYINFOEX pji );
public static uint joyGetPosEx( uint uJoyID, ref JOYINFOEX pji ) {
uint ret = MMSYSERR_ERROR;
if ( status_winmm != DllStatus.NotFound ) {
try {
ret = __joyGetPosEx( uJoyID, ref pji );
} catch ( DllNotFoundException ex ) {
status_winmm = DllStatus.NotFound;
}
}
return ret;
}
#endregion
#region wave
@ -384,16 +774,16 @@ namespace bocoree {
IntPtr dwInstance,
uint dwFlags );
//public static extern uint waveOutOpen( ref IntPtr phwo, UINT uDeviceID, ref WAVEFORMATEX pwfx, delegateWaveOutProc dwCallback, IntPtr dwInstance, uint fdwOpen );
[DllImport("winmm.dll")]
public static extern uint waveOutPrepareHeader( IntPtr hwo, ref WAVEHDR pwh, UINT cbwh);
[DllImport( "winmm.dll")]
public static extern uint waveOutGetPosition( IntPtr hwo, ref MMTIME pmmt, UINT cbmmt);
[DllImport("winmm.dll")]
public static extern uint waveOutReset( IntPtr hwo);
[DllImport("winmm.dll")]
public static extern uint waveOutUnprepareHeader( IntPtr hwo, ref WAVEHDR pwh, UINT cbwh);
[DllImport("winmm.dll")]
public static extern uint waveOutClose( IntPtr hwo);
[DllImport( "winmm.dll" )]
public static extern uint waveOutPrepareHeader( IntPtr hwo, ref WAVEHDR pwh, UINT cbwh );
[DllImport( "winmm.dll" )]
public static extern uint waveOutGetPosition( IntPtr hwo, ref MMTIME pmmt, UINT cbmmt );
[DllImport( "winmm.dll" )]
public static extern uint waveOutReset( IntPtr hwo );
[DllImport( "winmm.dll" )]
public static extern uint waveOutUnprepareHeader( IntPtr hwo, ref WAVEHDR pwh, UINT cbwh );
[DllImport( "winmm.dll" )]
public static extern uint waveOutClose( IntPtr hwo );
#endregion
#region mci