From c089432c27b1ba3fe86e18ce67a1110bcece4049 Mon Sep 17 00:00:00 2001 From: kbinani Date: Mon, 7 Sep 2009 10:44:18 +0000 Subject: [PATCH] git-svn-id: http://svn.sourceforge.jp/svnroot/lipsync@14 b1f601f4-4f45-0410-8980-aecacb008692 --- trunk/Boare.Lib.Vsq/AttackConfig.cs | 21 +- trunk/Boare.Lib.Vsq/BPPair.cs | 14 +- trunk/Boare.Lib.Vsq/Boare.Lib.Vsq.csproj | 1 + trunk/Boare.Lib.Vsq/ExpressionConfigSys.cs | 48 +- trunk/Boare.Lib.Vsq/NRPN.cs | 20 +- trunk/Boare.Lib.Vsq/PortUtil.cs | 52 +- trunk/Boare.Lib.Vsq/SMF/MidiFile.cs | 116 +- trunk/Boare.Lib.Vsq/SingerConfig.cs | 102 +- trunk/Boare.Lib.Vsq/SingerConfigSys.cs | 51 +- trunk/Boare.Lib.Vsq/SymbolTable.cs | 77 +- trunk/Boare.Lib.Vsq/TempoTableEntry.cs | 66 +- trunk/Boare.Lib.Vsq/TextMemoryStream.cs | 50 +- trunk/Boare.Lib.Vsq/TimeSigTableEntry.cs | 4 +- trunk/Boare.Lib.Vsq/UstEnvelope.cs | 12 +- trunk/Boare.Lib.Vsq/UstEvent.cs | 19 +- trunk/Boare.Lib.Vsq/UstFile.cs | 353 +++-- trunk/Boare.Lib.Vsq/UstPortamento.cs | 56 +- trunk/Boare.Lib.Vsq/UstTrack.cs | 20 +- trunk/Boare.Lib.Vsq/UstVibrato.cs | 8 +- trunk/Boare.Lib.Vsq/VibratoBPList.cs | 46 +- trunk/Boare.Lib.Vsq/VibratoConfig.cs | 28 +- trunk/Boare.Lib.Vsq/VibratoType.cs | 10 +- trunk/Boare.Lib.Vsq/VocaloSysUtil.cs | 361 +++-- trunk/Boare.Lib.Vsq/VsqBPList.cs | 202 ++- trunk/Boare.Lib.Vsq/VsqBPPair.cs | 20 +- trunk/Boare.Lib.Vsq/VsqBPPairSearchContext.cs | 9 + trunk/Boare.Lib.Vsq/VsqBarLineType.cs | 8 +- trunk/Boare.Lib.Vsq/VsqCommand.cs | 184 ++- trunk/Boare.Lib.Vsq/VsqCommandType.cs | 69 +- trunk/Boare.Lib.Vsq/VsqEvent.cs | 18 +- trunk/Boare.Lib.Vsq/VsqEventList.cs | 63 +- trunk/Boare.Lib.Vsq/VsqFile.cs | 1376 +++++++++-------- trunk/Boare.Lib.Vsq/VsqMetaText/Common.cs | 34 +- trunk/Boare.Lib.Vsq/VsqMetaText/Handle.cs | 60 +- trunk/Boare.Lib.Vsq/VsqMetaText/ID.cs | 39 +- trunk/Boare.Lib.Vsq/VsqMetaText/Lyric.cs | 53 +- trunk/Boare.Lib.Vsq/VsqMetaText/Master.cs | 18 +- trunk/Boare.Lib.Vsq/VsqMetaText/Mixer.cs | 69 +- .../Boare.Lib.Vsq/VsqMetaText/VsqMetaText.cs | 240 +-- trunk/Boare.Lib.Vsq/VsqNote.cs | 14 +- trunk/Boare.Lib.Vsq/VsqNrpn.cs | 126 +- trunk/Boare.Lib.Vsq/VsqPhoneticSymbol.cs | 30 +- trunk/Boare.Lib.Vsq/VsqTrack.cs | 118 +- .../LipSync/Editor/AviOutputArguments.cs | 1 + trunk/LipSync/LipSync/Editor/Form1.cs | 12 +- trunk/LipSync/LipSync/Editor/Form1Util.cs | 3 +- .../Editor/FormSeriesImage.Designer.cs | 71 +- .../LipSync/LipSync/Editor/FormSeriesImage.cs | 20 +- trunk/LipSync/LipSync/LipSync.csproj | 3 + .../LipSync/Properties/AssemblyInfo.cs | 2 +- trunk/bocoree/Collections.cs | 25 + trunk/bocoree/Graphics.cs | 64 + trunk/bocoree/Iterator.cs | 22 + trunk/bocoree/ListIterator.cs | 58 + trunk/bocoree/TreeMap.cs | 106 ++ trunk/bocoree/Vector.cs | 174 +++ trunk/bocoree/bocoree.csproj | 8 +- trunk/bocoree/misc.cs | 80 + trunk/memo.txt | 3 - 59 files changed, 3083 insertions(+), 1854 deletions(-) create mode 100644 trunk/Boare.Lib.Vsq/VsqBPPairSearchContext.cs create mode 100644 trunk/bocoree/Collections.cs create mode 100644 trunk/bocoree/Graphics.cs create mode 100644 trunk/bocoree/Iterator.cs create mode 100644 trunk/bocoree/ListIterator.cs create mode 100644 trunk/bocoree/TreeMap.cs create mode 100644 trunk/bocoree/Vector.cs diff --git a/trunk/Boare.Lib.Vsq/AttackConfig.cs b/trunk/Boare.Lib.Vsq/AttackConfig.cs index 9b07c62..58fb615 100644 --- a/trunk/Boare.Lib.Vsq/AttackConfig.cs +++ b/trunk/Boare.Lib.Vsq/AttackConfig.cs @@ -11,10 +11,17 @@ * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. */ +#if JAVA +package com.boare.vsq; +import java.io.*; +#else using System; using System.IO; +using bocoree; + namespace Boare.Lib.Vsq { +#endif public class AttackConfig { public int number; @@ -36,7 +43,7 @@ namespace Boare.Lib.Vsq { if ( line.StartsWith( "[" ) ) { current_entry = line; continue; - } else if ( line == "" || line.StartsWith( ";" ) ) { + } else if ( line.Equals( "" ) || line.StartsWith( ";" ) ) { continue; } @@ -46,20 +53,20 @@ namespace Boare.Lib.Vsq { } spl[0] = spl[0].Trim(); spl[1] = spl[1].Trim(); - if ( current_entry == "[Common]" ) { - if ( spl[0] == "Articulation" ) { + if ( current_entry.Equals( "[Common]" ) ) { + if ( spl[0].Equals( "Articulation" ) ) { articulation = spl[1]; } - } else if ( current_entry == "[Parameter]" ) { - if ( spl[0] == "Length" ) { + } else if ( current_entry.Equals( "[Parameter]" ) ) { + if ( spl[0].Equals( "Length" ) ) { try { this.contents.Length = int.Parse( spl[1] ); } catch { } - } else if ( spl[0] == "Duration" ) { + } else if ( spl[0].Equals( "Duration" ) ) { try { this.contents.Duration = int.Parse( spl[1] ); } catch { } - } else if ( spl[0] == "Depth" ) { + } else if ( spl[0].Equals( "Depth" ) ) { try { this.contents.Depth = int.Parse( spl[1] ); } catch { } diff --git a/trunk/Boare.Lib.Vsq/BPPair.cs b/trunk/Boare.Lib.Vsq/BPPair.cs index 0e3cdd5..8ef236c 100644 --- a/trunk/Boare.Lib.Vsq/BPPair.cs +++ b/trunk/Boare.Lib.Vsq/BPPair.cs @@ -11,15 +11,23 @@ * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. */ +#if JAVA +package com.boare.vsq; +#else using System; namespace Boare.Lib.Vsq { +#endif /// /// Stores the paired value of "Clock" and integer. Mainly used in VsqBPList /// +#if JAVA + class BPPair implements Comparable { +#else [Serializable] public class BPPair : IComparable { +#endif public int Clock; public int Value; @@ -28,7 +36,7 @@ namespace Boare.Lib.Vsq { /// /// /// - public int CompareTo( BPPair item ) { + public int compareTo( BPPair item ) { if ( Clock > item.Clock ) { return 1; } else if ( Clock < item.Clock ) { @@ -38,6 +46,10 @@ namespace Boare.Lib.Vsq { } } + public int CompareTo( BPPair item ) { + return compareTo( item ); + } + public BPPair( int clock_, int value_ ) { Clock = clock_; Value = value_; diff --git a/trunk/Boare.Lib.Vsq/Boare.Lib.Vsq.csproj b/trunk/Boare.Lib.Vsq/Boare.Lib.Vsq.csproj index 28ee08f..afa6219 100644 --- a/trunk/Boare.Lib.Vsq/Boare.Lib.Vsq.csproj +++ b/trunk/Boare.Lib.Vsq/Boare.Lib.Vsq.csproj @@ -81,6 +81,7 @@ + diff --git a/trunk/Boare.Lib.Vsq/ExpressionConfigSys.cs b/trunk/Boare.Lib.Vsq/ExpressionConfigSys.cs index 1b42411..b43a300 100644 --- a/trunk/Boare.Lib.Vsq/ExpressionConfigSys.cs +++ b/trunk/Boare.Lib.Vsq/ExpressionConfigSys.cs @@ -11,27 +11,35 @@ * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. */ +#if JAVA +package com.boare.vsq; +#else using System; using System.Collections.Generic; using System.IO; using System.Text; +using bocoree; + namespace Boare.Lib.Vsq { +#endif public class ExpressionConfigSys { private const int MAX_VIBRATO = 0x400; - private List m_vibrato_configs; - private List m_attack_configs; + private Vector m_vibrato_configs; + private Vector m_attack_configs; public ExpressionConfigSys( String path_expdb ) { - m_vibrato_configs = new List(); - m_attack_configs = new List(); + m_vibrato_configs = new Vector(); + m_attack_configs = new Vector(); String expression = Path.Combine( path_expdb, "expression.map" ); if ( !File.Exists( expression ) ) { return; } - using ( FileStream fs = new FileStream( expression, FileMode.Open, FileAccess.Read ) ) { + FileStream fs = null; + try { + new FileStream( expression, FileMode.Open, FileAccess.Read ); byte[] dat = new byte[8]; fs.Seek( 0x20, SeekOrigin.Begin ); for ( int i = 0; i < MAX_VIBRATO; i++ ) { @@ -51,19 +59,21 @@ namespace Boare.Lib.Vsq { continue; } - string NL = (char)0x0D + "" + (char)0x0A; - using ( FileStream fs_ved = new FileStream( ved, FileMode.Open, FileAccess.Read ) ){ + String NL = (char)0x0D + "" + (char)0x0A; + FileStream fs_ved = null; + try { + fs_ved = new FileStream( ved, FileMode.Open, FileAccess.Read ); byte[] byte_ved = new byte[fs_ved.Length]; fs_ved.Read( byte_ved, 0, byte_ved.Length ); TransCodeUtil.decodeBytes( ref byte_ved ); String str = new String( Encoding.ASCII.GetChars( byte_ved ) ); - String[] spl = str.Split( new String[]{ NL }, StringSplitOptions.RemoveEmptyEntries ); + String[] spl = str.Split( new String[] { NL }, StringSplitOptions.RemoveEmptyEntries ); String current_entry = ""; for ( int j = 0; j < spl.Length; j++ ) { if ( spl[j].StartsWith( "[" ) ) { current_entry = spl[j]; continue; - } else if ( spl[j] == "" ) { + } else if ( spl[j].Equals( "" ) ) { continue; } if ( current_entry.Equals( "[VIBRATO]" ) ) { @@ -84,13 +94,13 @@ namespace Boare.Lib.Vsq { continue; } item.parseAic( aic_file ); - } if ( current_entry == "[NOTEATTACK]" ) { + } if ( current_entry.Equals( "[NOTEATTACK]" ) ) { String[] spl2 = spl[j].Split( ',' ); if ( spl2.Length < 6 ) { continue; } // ex: 1,1,"normal","normal2_type1.aic","[Normal]:Type:1","Standard","YAMAHA",0 - AttackConfig item = new AttackConfig(); + AttackConfig item = new AttackConfig(); item.number = int.Parse( spl2[0] ); item.contents.IDS = spl2[2].Replace( "\"", "" ); item.file = spl2[3].Replace( "\"", "" ); @@ -104,6 +114,22 @@ namespace Boare.Lib.Vsq { item.parseAic( aic_file ); } } + } catch ( Exception ex ) { + } finally { + if ( fs_ved != null ) { + try { + fs_ved.Close(); + } catch ( Exception ex2 ) { + } + } + } + } + } catch ( Exception ex ) { + } finally { + if ( fs != null ) { + try { + fs.Close(); + } catch ( Exception ex2 ) { } } } diff --git a/trunk/Boare.Lib.Vsq/NRPN.cs b/trunk/Boare.Lib.Vsq/NRPN.cs index b57dc32..88c9596 100644 --- a/trunk/Boare.Lib.Vsq/NRPN.cs +++ b/trunk/Boare.Lib.Vsq/NRPN.cs @@ -15,8 +15,12 @@ using System; using System.Reflection; using System.Collections.Generic; +using bocoree; + namespace Boare.Lib.Vsq { + using boolean = System.Boolean; + public static class NRPN { /// /// (0x5000) Version number(MSB) &, Device number(LSB) @@ -556,20 +560,20 @@ namespace Boare.Lib.Vsq { public const ushort VCP_VOICE_CHANGE_PARAMETER = 0x5503; private class NrpnIterator : Iterator { - private List nrpns = new List(); + private Vector nrpns = new Vector(); 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 ) ); + nrpns.add( (ushort)fi.GetValue( t ) ); } } } - public bool hasNext() { - if ( 0 <= m_pos + 1 && m_pos + 1 < nrpns.Count ) { + public boolean hasNext() { + if ( 0 <= m_pos + 1 && m_pos + 1 < nrpns.size() ) { return true; } else { return false; @@ -578,7 +582,7 @@ namespace Boare.Lib.Vsq { public Object next() { m_pos++; - return nrpns[m_pos]; + return nrpns.get( m_pos ); } public void remove() { @@ -589,7 +593,7 @@ namespace Boare.Lib.Vsq { return new NrpnIterator(); } - public static string getName( ushort nrpn ) { + 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 ) ); @@ -606,7 +610,7 @@ namespace Boare.Lib.Vsq { /// /// /// - public static byte getVoiceChangeParameterID( string curve_name ) { + public static byte getVoiceChangeParameterID( String curve_name ) { byte lsb = 0x31; switch ( curve_name.ToLower() ) { case "harmonics": @@ -670,7 +674,7 @@ namespace Boare.Lib.Vsq { return lsb; } - public static bool is_require_data_lsb( ushort nrpn ) { + public static boolean is_require_data_lsb( ushort nrpn ) { switch ( nrpn ) { case CVM_NM_VERSION_AND_DEVICE: case CVM_NM_DELAY: diff --git a/trunk/Boare.Lib.Vsq/PortUtil.cs b/trunk/Boare.Lib.Vsq/PortUtil.cs index cbb9e48..108a42d 100644 --- a/trunk/Boare.Lib.Vsq/PortUtil.cs +++ b/trunk/Boare.Lib.Vsq/PortUtil.cs @@ -14,56 +14,8 @@ using System; using System.Collections.Generic; +using bocoree; + namespace Boare.Lib.Vsq { - public class Vector : List { - public int size() { - return base.Count; - } - - public T get( int index ) { - return base[index]; - } - - public void set( int index, T value ) { - base[index] = value; - } - } - - public interface Iterator { - bool hasNext(); - object next(); - void remove(); - } - - public class ListIterator : Iterator { - private List m_list; - private int m_pos; - - public ListIterator( List list ) { - m_list = list; - m_pos = -1; - } - - public Boolean hasNext() { - if ( m_list != null && 0 <= m_pos + 1 && m_pos + 1 < m_list.Count ) { - return true; - } else { - return false; - } - } - - public Object next() { - if ( m_list == null ) { - return null; - } - m_pos++; - return m_list[m_pos]; - } - - public void remove() { - m_list.RemoveAt( m_pos ); - } - } - } diff --git a/trunk/Boare.Lib.Vsq/SMF/MidiFile.cs b/trunk/Boare.Lib.Vsq/SMF/MidiFile.cs index 5a4b9cb..1eed05d 100644 --- a/trunk/Boare.Lib.Vsq/SMF/MidiFile.cs +++ b/trunk/Boare.Lib.Vsq/SMF/MidiFile.cs @@ -15,8 +15,12 @@ using System; using System.IO; using System.Collections.Generic; +using bocoree; + namespace Boare.Lib.Vsq { + using boolean = System.Boolean; + /// /// midiイベント。メタイベントは、メタイベントのデータ長をData[1]に格納せず、生のデータをDataに格納するので、注意が必要 /// @@ -53,7 +57,7 @@ namespace Boare.Lib.Vsq { } private static void writeDeltaClock( Stream stream, long number ) { - bool[] bits = new bool[64]; + boolean[] bits = new boolean[64]; long val = 0x1; bits[0] = (number & val) == val; for ( int i = 1; i < 64; i++ ) { @@ -203,7 +207,43 @@ namespace Boare.Lib.Vsq { } public int CompareTo( MidiEvent item ) { - return (int)(clock - item.clock); + if ( clock != item.clock ) { + return (int)(clock - item.clock); + } else { + int first_this = firstByte & 0xf0; + int first_item = item.firstByte & 0xf0; + + if ( (first_this == 0x80 || first_this == 0x90) && (first_item == 0x80 || first_item == 0x90) ) { + if ( data != null && data.Length >= 2 && item.data != null && item.data.Length >= 2 ) { + if ( first_item == 0x90 && item.data[1] == 0 ) { + first_item = 0x80; + } + if ( first_this == 0x90 && data[1] == 0 ) { + first_this = 0x80; + } + if ( data[0] == item.data[0] ) { + if ( first_this == 0x90 ) { + if ( first_item == 0x80 ) { + // ON -> OFF + return 1; + } else { + // ON -> ON + return 0; + } + } else { + if ( first_item == 0x80 ) { + // OFF -> OFF + return 0; + } else { + // OFF -> ON + return -1; + } + } + } + } + } + return (int)(clock - item.clock); + } } public static MidiEvent generateTimeSigEvent( int clock, int numerator, int denominator ) { @@ -233,11 +273,11 @@ namespace Boare.Lib.Vsq { } public class MidiFile : IDisposable { - private List> m_events; + private Vector> m_events; private ushort m_format; private ushort m_time_format; - public MidiFile( string path ){ + public MidiFile( String path ){ Stream stream = new FileStream( path, FileMode.Open, FileAccess.Read ); // ヘッダ byte[] byte4 = new byte[4]; @@ -264,14 +304,14 @@ namespace Boare.Lib.Vsq { m_time_format = makeUint16( byte4 ); // 各トラックを読込み - m_events = new List>(); + m_events = new Vector>(); for ( int track = 0; track < tracks; track++ ) { // ヘッダー stream.Read( byte4, 0, 4 ); if ( makeUInt32( byte4 ) != 0x4d54726b ) { throw new ApplicationException( "header error; MTrk" ); } - m_events.Add( new List() ); + m_events.add( new Vector() ); // チャンクサイズ stream.Read( byte4, 0, 4 ); @@ -283,58 +323,58 @@ namespace Boare.Lib.Vsq { byte last_status_byte = 0x00; while ( stream.Position < startpos + size ) { MidiEvent mi = MidiEvent.read( stream, ref clock, ref last_status_byte ); - m_events[track].Add( mi ); + m_events.get( track ).add( mi ); } if ( m_time_format != 480 ) { - int count = m_events[track].Count; + int count = m_events.get( track ).size(); for ( int i = 0; i < count; i++ ) { - MidiEvent mi = m_events[track][i]; + MidiEvent mi = m_events.get( track ).get( i ); mi.clock = mi.clock * 480 / m_time_format; - m_events[track][i] = mi; + m_events.get( track ).set( i, mi ); } } } m_time_format = 480; #if DEBUG - string dbg = Path.Combine( Path.GetDirectoryName( path ), Path.GetFileNameWithoutExtension( path ) + ".txt" ); + 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++ ) { + const String format = " {0,8} 0x{1:X4} {2,-35} 0x{3:X2} 0x{4:X2}"; + const String format0 = " {0,8} 0x{1:X4} {2,-35} 0x{3:X2}"; + for ( int track = 1; track < m_events.size(); track++ ) { sw.WriteLine( "MidiFile..ctor; track=" + track ); byte msb, lsb, data_msb, data_lsb; msb = lsb = data_msb = data_lsb = 0x0; - for ( int i = 0; i < m_events[track].Count; i++ ) { - if ( m_events[track][i].firstByte == 0xb0 ) { - switch ( m_events[track][i].data[0] ) { + for ( int i = 0; i < m_events.get( track ).size(); i++ ) { + if ( m_events.get( track ).get( i ).firstByte == 0xb0 ) { + switch ( m_events.get( track ).get( i ).data[0] ) { case 0x63: - msb = m_events[track][i].data[1]; + msb = m_events.get( track ).get( i ).data[1]; lsb = 0x0; break; case 0x62: - lsb = m_events[track][i].data[1]; + lsb = m_events.get( track ).get( i ).data[1]; break; case 0x06: - data_msb = m_events[track][i].data[1]; + data_msb = m_events.get( track ).get( i ).data[1]; ushort nrpn = (ushort)(msb << 8 | lsb); - string name = NRPN.getName( nrpn ); - if ( name == "" ) { + String name = NRPN.getName( nrpn ); + if ( name.Equals( "" ) ) { name = "* * UNKNOWN * *"; - sw.WriteLine( string.Format( format0, m_events[track][i].clock, nrpn, name, data_msb ) ); + sw.WriteLine( String.Format( format0, m_events.get( track ).get( i ).clock, nrpn, name, data_msb ) ); } else { //if ( !NRPN.is_require_data_lsb( nrpn ) ) { - sw.WriteLine( string.Format( format0, m_events[track][i].clock, nrpn, name, data_msb ) ); + sw.WriteLine( String.Format( format0, m_events.get( track ).get( i ).clock, nrpn, name, data_msb ) ); //} } break; case 0x26: - data_lsb = m_events[track][i].data[1]; + data_lsb = m_events.get( track ).get( i ).data[1]; ushort nrpn2 = (ushort)(msb << 8 | lsb); - string name2 = NRPN.getName( nrpn2 ); - if ( name2 == "" ) { + String name2 = NRPN.getName( nrpn2 ); + if ( name2.Equals( "" ) ) { name2 = "* * UNKNOWN * *"; } - sw.WriteLine( string.Format( format, m_events[track][i].clock, nrpn2, name2, data_msb, data_lsb ) ); + sw.WriteLine( String.Format( format, m_events.get( track ).get( i ).clock, nrpn2, name2, data_msb, data_lsb ) ); break; } } @@ -345,16 +385,16 @@ namespace Boare.Lib.Vsq { stream.Close(); } - /*public void Write( string path ) { + /*public void Write( String path ) { }*/ - public List getMidiEventList( int track ) { + public Vector getMidiEventList( int track ) { if ( m_events == null ) { - return new List(); - } else if ( 0 <= track && track < m_events.Count ) { - return m_events[track]; + return new Vector(); + } else if ( 0 <= track && track < m_events.size() ) { + return m_events.get( track ); } else { - return new List(); + return new Vector(); } } @@ -362,7 +402,7 @@ namespace Boare.Lib.Vsq { if ( m_events == null ) { return 0; } else { - return m_events.Count; + return m_events.size(); } } @@ -372,10 +412,10 @@ namespace Boare.Lib.Vsq { public void Close() { if ( m_events != null ) { - for ( int i = 0; i < m_events.Count; i++ ) { - m_events[i].Clear(); + for ( int i = 0; i < m_events.size(); i++ ) { + m_events.get( i ).clear(); } - m_events.Clear(); + m_events.clear(); } } diff --git a/trunk/Boare.Lib.Vsq/SingerConfig.cs b/trunk/Boare.Lib.Vsq/SingerConfig.cs index 561b0fc..799e2f6 100644 --- a/trunk/Boare.Lib.Vsq/SingerConfig.cs +++ b/trunk/Boare.Lib.Vsq/SingerConfig.cs @@ -15,13 +15,15 @@ using System; using System.IO; using System.Collections.Generic; +using bocoree; + namespace Boare.Lib.Vsq { public class SingerConfig : ICloneable { - public string ID = ""; - public string FORMAT = ""; - public string VOICEIDSTR = ""; - public string VOICENAME = "Unknown"; + public String ID = ""; + public String FORMAT = ""; + public String VOICEIDSTR = ""; + public String VOICENAME = "Unknown"; public int Breathiness; public int Brightness; public int Clearness; @@ -75,7 +77,7 @@ namespace Boare.Lib.Vsq { return ret; } - public static SingerConfig fromVvd( string file, int original ) { + public static SingerConfig fromVvd( String file, int original ) { SingerConfig sc = new SingerConfig(); //original = original; sc.ID = "VOCALOID:VIRTUAL:VOICE"; @@ -95,69 +97,69 @@ namespace Boare.Lib.Vsq { byte[] dat = new byte[length]; fs.Read( dat, 0, length ); TransCodeUtil.decodeBytes( ref dat ); - string str = bocoree.cp932.convert( dat ); + String str = bocoree.cp932.convert( dat ); #if DEBUG Console.WriteLine( "SingerConfig.readSingerConfig; str=" + str ); #endif - string crlf = ((char)0x0d).ToString() + ((char)0x0a).ToString(); - string[] spl = str.Split( new string[] { crlf }, StringSplitOptions.RemoveEmptyEntries ); + String crlf = ((char)0x0d).ToString() + ((char)0x0a).ToString(); + String[] spl = str.Split( new String[] { crlf }, StringSplitOptions.RemoveEmptyEntries ); - foreach ( string s in spl ) { + foreach ( String s in spl ) { int first = s.IndexOf( '"' ); int first_end = get_quated_string( s, first ); int second = s.IndexOf( '"', first_end + 1 ); int second_end = get_quated_string( s, second ); char[] chs = s.ToCharArray(); - string id = new string( chs, first, first_end - first + 1 ); - string value = new string( chs, second, second_end - second + 1 ); + String id = new String( chs, first, first_end - first + 1 ); + String value = new String( chs, second, second_end - second + 1 ); id = id.Substring( 1, id.Length - 2 ); value = value.Substring( 1, value.Length - 2 ); value = value.Replace( "\\\"", "\"" ); int parsed_int = 64; int.TryParse( value, out parsed_int ); - if ( id == "ID" ) { + if ( id.Equals( "ID" ) ) { sc.ID = value; - } else if ( id == "FORMAT" ) { + } else if ( id.Equals( "FORMAT" ) ) { sc.FORMAT = value; - } else if ( id == "VOICEIDSTR" ) { + } else if ( id.Equals( "VOICEIDSTR" ) ) { sc.VOICEIDSTR = value; - } else if ( id == "VOICENAME" ) { + } else if ( id.Equals( "VOICENAME" ) ) { sc.VOICENAME = value; - } else if ( id == "Breathiness" || id == "Noise" ) { + } else if ( id.Equals( "Breathiness" ) || id.Equals( "Noise" ) ) { sc.Breathiness = parsed_int; - } else if ( id == "Brightness" ) { + } else if ( id.Equals( "Brightness" ) ) { sc.Brightness = parsed_int; - } else if ( id == "Clearness" ) { + } else if ( id.Equals( "Clearness" ) ) { sc.Clearness = parsed_int; - } else if ( id == "Opening" ) { + } else if ( id.Equals( "Opening" ) ) { sc.Opening = parsed_int; - } else if ( id == "Gender:Factor" ) { + } else if ( id.Equals( "Gender:Factor" ) ) { sc.GenderFactor = parsed_int; - } else if ( id == "Resonance1:Frequency" ) { + } else if ( id.Equals( "Resonance1:Frequency" ) ) { sc.Resonance1Frequency = parsed_int; - } else if ( id == "Resonance1:Band:Width" ) { + } else if ( id.Equals( "Resonance1:Band:Width" ) ) { sc.Resonance1BandWidth = parsed_int; - } else if ( id == "Resonance1:Amplitude" ) { + } else if ( id.Equals( "Resonance1:Amplitude" ) ) { sc.Resonance1Amplitude = parsed_int; - } else if ( id == "Resonance2:Frequency" ) { + } else if ( id.Equals( "Resonance2:Frequency" ) ) { sc.Resonance2Frequency = parsed_int; - } else if ( id == "Resonance2:Band:Width" ) { + } else if ( id.Equals( "Resonance2:Band:Width" ) ) { sc.Resonance2BandWidth = parsed_int; - } else if ( id == "Resonance2:Amplitude" ) { + } else if ( id.Equals( "Resonance2:Amplitude" ) ) { sc.Resonance2Amplitude = parsed_int; - } else if ( id == "Resonance3:Frequency" ) { + } else if ( id.Equals( "Resonance3:Frequency" ) ) { sc.Resonance3Frequency = parsed_int; - } else if ( id == "Resonance3:Band:Width" ) { + } else if ( id.Equals( "Resonance3:Band:Width" ) ) { sc.Resonance3BandWidth = parsed_int; - } else if ( id == "Resonance3:Amplitude" ) { + } else if ( id.Equals( "Resonance3:Amplitude" ) ) { sc.Resonance3Amplitude = parsed_int; - } else if ( id == "Resonance4:Frequency" ) { + } else if ( id.Equals( "Resonance4:Frequency" ) ) { sc.Resonance4Frequency = parsed_int; - } else if ( id == "Resonance4:Band:Width" ) { + } else if ( id.Equals( "Resonance4:Band:Width" ) ) { sc.Resonance4BandWidth = parsed_int; - } else if ( id == "Resonance4:Amplitude" ) { + } else if ( id.Equals( "Resonance4:Amplitude" ) ) { sc.Resonance4Amplitude = parsed_int; - } else if ( id == "Harmonics" ) { + } else if ( id.Equals( "Harmonics" ) ) { sc.Harmonics = parsed_int; } } @@ -177,7 +179,7 @@ namespace Boare.Lib.Vsq { /// /// /// - static int get_quated_string( string s, int position ) { + static int get_quated_string( String s, int position ) { if ( position < 0 ) { return -1; } @@ -198,24 +200,24 @@ namespace Boare.Lib.Vsq { return end; } - public string[] ToStringArray() { - List ret = new List(); - ret.Add( "\"ID\":=:\"" + ID + "\"" ); - ret.Add( "\"FORMAT\":=:\"" + FORMAT + "\"" ); - ret.Add( "\"VOICEIDSTR\":=:\"" + VOICEIDSTR + "\"" ); - ret.Add( "\"VOICENAME\":=:\"" + VOICENAME.Replace( "\"", "\\\"" ) + "\"" ); - ret.Add( "\"Breathiness\":=:\"" + Breathiness + "\"" ); - ret.Add( "\"Brightness\":=:\"" + Brightness + "\"" ); - ret.Add( "\"Clearness\":=:\"" + Clearness + "\"" ); - ret.Add( "\"Opening\":=:\"" + Opening + "\"" ); - ret.Add( "\"Gender:Factor\":=:\"" + GenderFactor + "\"" ); - return ret.ToArray(); + public String[] ToStringArray() { + Vector ret = new Vector(); + ret.add( "\"ID\":=:\"" + ID + "\"" ); + ret.add( "\"FORMAT\":=:\"" + FORMAT + "\"" ); + ret.add( "\"VOICEIDSTR\":=:\"" + VOICEIDSTR + "\"" ); + ret.add( "\"VOICENAME\":=:\"" + VOICENAME.Replace( "\"", "\\\"" ) + "\"" ); + ret.add( "\"Breathiness\":=:\"" + Breathiness + "\"" ); + ret.add( "\"Brightness\":=:\"" + Brightness + "\"" ); + ret.add( "\"Clearness\":=:\"" + Clearness + "\"" ); + ret.add( "\"Opening\":=:\"" + Opening + "\"" ); + ret.add( "\"Gender:Factor\":=:\"" + GenderFactor + "\"" ); + return ret.toArray( new String[]{} ); } - public override string ToString() { - string[] r = ToStringArray(); - string ret = ""; - foreach ( string s in r ) { + public override String ToString() { + String[] r = ToStringArray(); + String ret = ""; + foreach ( String s in r ) { ret += s + "\n"; } return ret; diff --git a/trunk/Boare.Lib.Vsq/SingerConfigSys.cs b/trunk/Boare.Lib.Vsq/SingerConfigSys.cs index 4383dce..cf661bf 100644 --- a/trunk/Boare.Lib.Vsq/SingerConfigSys.cs +++ b/trunk/Boare.Lib.Vsq/SingerConfigSys.cs @@ -15,22 +15,24 @@ using System; using System.Collections.Generic; using System.IO; +using bocoree; + namespace Boare.Lib.Vsq { public class SingerConfigSys { private const int MAX_SINGERS = 0x4000; - private List m_installed_singers = new List(); - private List m_singer_configs = new List(); + private Vector m_installed_singers = new Vector(); + private Vector m_singer_configs = new Vector(); /// /// /// /// 音源のデータディレクトリ(ex:"C:\Program Files\VOCALOID2\voicedbdir") - /// 音源のインストールディレクトリ(ex:new string[]{ "C:\Program Files\VOCALOID2\voicedbdir\BXXXXXXXXXXXXXXX", "D:\singers\BNXXXXXXXXXX" }) - public SingerConfigSys( string path_voicedb, string[] path_installed_singers ) { - m_installed_singers = new List(); - m_singer_configs = new List(); + /// 音源のインストールディレクトリ(ex:new String[]{ "C:\Program Files\VOCALOID2\voicedbdir\BXXXXXXXXXXXXXXX", "D:\singers\BNXXXXXXXXXX" }) + public SingerConfigSys( String path_voicedb, String[] path_installed_singers ) { + m_installed_singers = new Vector(); + m_singer_configs = new Vector(); String map = Path.Combine( path_voicedb, "voice.map" ); if ( !File.Exists( map ) ) { return; @@ -47,8 +49,9 @@ namespace Boare.Lib.Vsq { item.Program = i; int original = -1; - foreach ( SingerConfig sc in m_installed_singers ) { - if ( sc.VOICEIDSTR == item.VOICEIDSTR ) { + for ( Iterator itr = m_installed_singers.iterator(); itr.hasNext(); ){ + SingerConfig sc = (SingerConfig)itr.next(); + if ( sc.VOICEIDSTR.Equals( item.VOICEIDSTR ) ) { original = sc.Program; break; } @@ -56,12 +59,12 @@ namespace Boare.Lib.Vsq { if ( original < 0 ) { foreach ( String ipath in path_installed_singers ) { if ( ipath.EndsWith( item.VOICEIDSTR ) ) { - string[] vvds = Directory.GetFiles( ipath, "*.vvd" ); + String[] vvds = Directory.GetFiles( ipath, "*.vvd" ); if ( vvds.Length > 0 ) { - original = m_installed_singers.Count; + original = m_installed_singers.size(); SingerConfig installed = SingerConfig.fromVvd( vvds[0], original ); installed.Program = original; - m_installed_singers.Add( installed ); + m_installed_singers.add( installed ); break; } } @@ -69,14 +72,14 @@ namespace Boare.Lib.Vsq { } item.Original = original; - m_singer_configs.Add( item ); + m_singer_configs.add( item ); } } } } public SingerConfig[] getInstalledSingers() { - return m_installed_singers.ToArray(); + return m_installed_singers.toArray( new SingerConfig[]{} ); } /// @@ -84,13 +87,13 @@ namespace Boare.Lib.Vsq { /// /// /// - public VsqID getSingerID( string singer ) { + public VsqID getSingerID( String singer ) { VsqID ret = new VsqID( 0 ); ret.type = VsqIDType.Singer; SingerConfig sc = null; - for ( int i = 0; i < m_singer_configs.Count; i++ ) { - if ( m_singer_configs[i].VOICENAME == singer ) { - sc = m_singer_configs[i]; + for ( int i = 0; i < m_singer_configs.size(); i++ ) { + if ( m_singer_configs.get( i ).VOICENAME.Equals( singer ) ) { + sc = m_singer_configs.get( i ); break; } } @@ -98,8 +101,9 @@ namespace Boare.Lib.Vsq { sc = new SingerConfig(); } int lang = 0; - foreach ( SingerConfig sc2 in m_installed_singers ) { - if ( sc.VOICEIDSTR == sc2.VOICEIDSTR ) { + for( Iterator itr = m_installed_singers.iterator(); itr.hasNext(); ){ + SingerConfig sc2 = (SingerConfig)itr.next(); + if ( sc.VOICEIDSTR.Equals( sc2.VOICEIDSTR ) ) { lang = (int)VocaloSysUtil.getLanguageFromName( sc.VOICENAME ); break; } @@ -121,9 +125,10 @@ namespace Boare.Lib.Vsq { /// /// /// - public SingerConfig getSingerInfo( string singer ) { - foreach ( SingerConfig item in m_singer_configs ) { - if ( item.VOICENAME == singer ) { + public SingerConfig getSingerInfo( String singer ) { + for ( Iterator itr = m_installed_singers.iterator(); itr.hasNext(); ){ + SingerConfig item = (SingerConfig)itr.next(); + if ( item.VOICENAME.Equals( singer ) ) { return item; } } @@ -135,7 +140,7 @@ namespace Boare.Lib.Vsq { /// /// public SingerConfig[] getSingerConfigs() { - return m_singer_configs.ToArray(); + return m_singer_configs.toArray( new SingerConfig[]{} ); } } diff --git a/trunk/Boare.Lib.Vsq/SymbolTable.cs b/trunk/Boare.Lib.Vsq/SymbolTable.cs index ce3f07a..65492d1 100644 --- a/trunk/Boare.Lib.Vsq/SymbolTable.cs +++ b/trunk/Boare.Lib.Vsq/SymbolTable.cs @@ -21,16 +21,18 @@ using bocoree; namespace Boare.Lib.Vsq { + using boolean = System.Boolean; + public class SymbolTable : ICloneable { - private Dictionary m_dict; - private string m_name; - private bool m_enabled; + private TreeMap m_dict; + private String m_name; + private boolean m_enabled; #region Static Field private static SortedList s_table = new SortedList(); private static SymbolTable s_default_jp = null; - private static bool s_initialized = false; - public static readonly string[,] _KEY_JP = { + private static boolean s_initialized = false; + public static readonly String[,] _KEY_JP = { {"あ", "a"}, {"い", "i"}, {"う", "M"}, @@ -480,35 +482,35 @@ namespace Boare.Lib.Vsq { int count = 0; // 辞書フォルダからの読込み - string editor_path = VocaloSysUtil.getEditorPath2(); - if ( editor_path.Length > 0 ) { - string path = Path.Combine( Path.GetDirectoryName( editor_path ), "UDIC" ); + String editor_path = VocaloSysUtil.getEditorPath2(); + if ( editor_path != "" ) { + String path = Path.Combine( Path.GetDirectoryName( editor_path ), "UDIC" ); if ( !Directory.Exists( path ) ) { return; } - string[] files = Directory.GetFiles( path, "*.udc" ); + String[] files = Directory.GetFiles( path, "*.udc" ); for ( int i = 0; i < files.Length; i++ ) { files[i] = Path.GetFileName( files[i] ); #if DEBUG Console.WriteLine( " files[i]=" + files[i] ); #endif count++; - string dict = Path.Combine( path, files[i] ); + String dict = Path.Combine( path, files[i] ); s_table.Add( count, new SymbolTable( dict, true, false ) ); } } // 起動ディレクトリ - string path2 = Path.Combine( Application.StartupPath, "udic" ); + String path2 = Path.Combine( Application.StartupPath, "udic" ); if ( Directory.Exists( path2 ) ) { - string[] files2 = Directory.GetFiles( path2, "*.eudc" ); + String[] files2 = Directory.GetFiles( path2, "*.eudc" ); for ( int i = 0; i < files2.Length; i++ ) { files2[i] = Path.GetFileName( files2[i] ); #if DEBUG Console.WriteLine( " files2[i]=" + files2[i] ); #endif count++; - string dict = Path.Combine( path2, files2[i] ); + String dict = Path.Combine( path2, files2[i] ); s_table.Add( count, new SymbolTable( dict, false, false ) ); } } @@ -516,7 +518,7 @@ namespace Boare.Lib.Vsq { } - public static bool attatch( string phrase, out string result ) { + public static boolean attatch( String phrase, out String result ) { #if DEBUG Console.WriteLine( "SymbolTable.Attatch" ); Console.WriteLine( " phrase=" + phrase ); @@ -540,7 +542,7 @@ namespace Boare.Lib.Vsq { return s_table.Count; } - public static void changeOrder( KeyValuePair[] list ) { + public static void changeOrder( KeyValuePair[] list ) { #if DEBUG Console.WriteLine( "SymbolTable.Sort()" ); #endif @@ -555,7 +557,7 @@ namespace Boare.Lib.Vsq { #endif for ( int j = 0; j < buff.Keys.Count; j++ ) { int key = buff.Keys[j]; - if ( buff[key].getName() == list[i].Key ) { + if ( buff[key].getName().Equals( list[i].Key ) ) { buff[key].setEnabled( list[i].Value ); s_table.Add( i, buff[key] ); break; @@ -567,9 +569,10 @@ namespace Boare.Lib.Vsq { public object Clone() { SymbolTable ret = new SymbolTable(); - ret.m_dict = new Dictionary(); - foreach ( string key in m_dict.Keys ) { - ret.m_dict.Add( key, m_dict[key] ); + ret.m_dict = new TreeMap(); + for ( Iterator itr = m_dict.keySet().iterator(); itr.hasNext(); ){ + String key = (String)itr.next(); + ret.m_dict.put( key, m_dict.get( key ) ); } ret.m_name = m_name; ret.m_enabled = m_enabled; @@ -579,20 +582,20 @@ namespace Boare.Lib.Vsq { private SymbolTable() { } - public string getName() { + public String getName() { return m_name; } - public bool isEnabled() { + public boolean isEnabled() { return m_enabled; } - public void setEnabled( bool value ){ + public void setEnabled( boolean value ){ m_enabled = value; } - public SymbolTable( string path, bool is_udc_mode, bool enabled ) { - m_dict = new Dictionary(); + public SymbolTable( String path, boolean is_udc_mode, boolean enabled ) { + m_dict = new TreeMap(); m_enabled = enabled; if ( !File.Exists( path ) ) { return; @@ -612,18 +615,18 @@ namespace Boare.Lib.Vsq { return; } } - string line; + String line; int peek = (is_udc_mode) ? sr1.Peek() : sr2.Peek(); while ( peek >= 0 ) { line = (is_udc_mode) ? sr1.ReadLine() : sr2.ReadLine(); if ( !line.StartsWith( "//" ) ) { - string[] spl = line.Split( "\t".ToCharArray(), 2, StringSplitOptions.RemoveEmptyEntries ); + String[] spl = line.Split( "\t".ToCharArray(), 2, StringSplitOptions.RemoveEmptyEntries ); if ( spl.Length >= 2 ) { - if ( m_dict.ContainsKey( spl[0] ) ) { + if ( m_dict.containsKey( spl[0] ) ) { bocoree.debug.push_log( "SymbolTable..ctor" ); bocoree.debug.push_log( " dictionary already contains key: " + spl[0] ); } else { - m_dict.Add( spl[0], spl[1] ); + m_dict.put( spl[0], spl[1] ); } } } @@ -642,10 +645,10 @@ namespace Boare.Lib.Vsq { } } - private bool attatchImp( string phrase, out string result ) { - string s = phrase.ToLower(); - if ( m_dict.ContainsKey( s ) ) { - result = m_dict[s]; + private boolean attatchImp( String phrase, out String result ) { + String s = phrase.ToLower(); + if ( m_dict.containsKey( s ) ) { + result = m_dict.get( s ); return true; } else { result = "a"; @@ -653,21 +656,21 @@ namespace Boare.Lib.Vsq { } } - private SymbolTable( string name, string[,] key, bool enabled ) { + private SymbolTable( String name, String[,] key, boolean enabled ) { #if DEBUG - Console.WriteLine( "SymolTable.ctor(string,string[,])" ); + Console.WriteLine( "SymolTable.ctor(String,String[,])" ); Console.WriteLine( " key.GetLength(0)=" + key.GetLength( 0 ) ); #endif m_enabled = enabled; m_name = name; - m_dict = new Dictionary(); + m_dict = new TreeMap(); for ( int i = 0; i < key.GetLength( 0 ); i++ ) { - if ( m_dict.ContainsKey( key[i, 0] ) ) { + if ( m_dict.containsKey( key[i, 0] ) ) { #if DEBUG throw new ApplicationException( "dictionary already contains key: " + key[i, 0] ); #endif } else { - m_dict.Add( key[i, 0], key[i, 1] ); + m_dict.put( key[i, 0], key[i, 1] ); } } } diff --git a/trunk/Boare.Lib.Vsq/TempoTableEntry.cs b/trunk/Boare.Lib.Vsq/TempoTableEntry.cs index cbc8b57..be6f172 100644 --- a/trunk/Boare.Lib.Vsq/TempoTableEntry.cs +++ b/trunk/Boare.Lib.Vsq/TempoTableEntry.cs @@ -14,8 +14,12 @@ using System; using System.Collections.Generic; +using bocoree; + namespace Boare.Lib.Vsq { + using boolean = System.Boolean; + public class TempoTable : ICloneable { private struct TempoTableEntry : IComparable { public int Clock; @@ -33,7 +37,7 @@ namespace Boare.Lib.Vsq { } } - private List m_tempo_table; + private Vector m_tempo_table; private int m_base_tempo; private int m_tpq; @@ -43,51 +47,51 @@ namespace Boare.Lib.Vsq { public TempoTable( int base_tempo, int clock_per_quoter ) { m_base_tempo = base_tempo; m_tpq = clock_per_quoter; - m_tempo_table = new List(); - m_tempo_table.Add( new TempoTableEntry( 0, base_tempo, 0.0 ) ); + m_tempo_table = new Vector(); + 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(); - for ( int i = 0; i < m_tempo_table.Count; i++ ) { - ret.m_tempo_table.Add( m_tempo_table[i] ); + ret.m_tempo_table = new Vector(); + for ( int i = 0; i < m_tempo_table.size(); i++ ) { + ret.m_tempo_table.add( m_tempo_table.get( i ) ); } ret.update(); return ret; } public void add( int clock, int tempo ) { - bool found = false; - for ( int i = 0; i < m_tempo_table.Count; i++ ) { - if ( m_tempo_table[i].Clock == clock ) { + boolean found = false; + for ( int i = 0; i < m_tempo_table.size(); i++ ) { + if ( m_tempo_table.get( i ).Clock == clock ) { found = true; - m_tempo_table[i] = new TempoTableEntry( clock, tempo, 0.0 ); + m_tempo_table.set( i, new TempoTableEntry( clock, tempo, 0.0 ) ); break; } } if ( !found ) { - m_tempo_table.Add( new TempoTableEntry( clock, tempo, 0.0 ) ); + m_tempo_table.add( new TempoTableEntry( clock, tempo, 0.0 ) ); } - m_tempo_table.Sort(); + Collections.sort( m_tempo_table ); update(); } public void clear( int base_tempo ) { - m_tempo_table.Clear(); - m_tempo_table.Add( new TempoTableEntry( 0, base_tempo, 0.0 ) ); + 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++ ) { + for ( int i = 0; i < m_tempo_table.size(); 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)); + sum += (m_tempo_table.get( k ).Tempo * (m_tempo_table.get( k + 1 ).Clock - m_tempo_table.get( k ).Clock)); } double time = sum / (m_tpq * 1e6); - m_tempo_table[i] = new TempoTableEntry( m_tempo_table[i].Clock, m_tempo_table[i].Tempo, time ); + m_tempo_table.set( i, new TempoTableEntry( m_tempo_table.get( i ).Clock, m_tempo_table.get( i ).Tempo, time ) ); } } @@ -101,18 +105,18 @@ namespace Boare.Lib.Vsq { int tempo = m_base_tempo; double base_clock = 0; double base_time = 0f; - if ( m_tempo_table.Count == 0 ) { + if ( m_tempo_table.size() == 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 if ( m_tempo_table.size() == 1 ) { + tempo = m_tempo_table.get( 0 ).Tempo; + base_clock = m_tempo_table.get( 0 ).Clock; + base_time = m_tempo_table.get( 0 ).Time; } else { - for ( int i = m_tempo_table.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; + for ( int i = m_tempo_table.size() - 1; i >= 0; i-- ) { + if ( m_tempo_table.get( i ).Time < time ) { + return m_tempo_table.get( i ).Clock + (time - m_tempo_table.get( i ).Time) * m_tpq * 1000000.0 / m_tempo_table.get( i ).Tempo; } } } @@ -126,11 +130,11 @@ namespace Boare.Lib.Vsq { /// /// 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; + for ( int i = m_tempo_table.size() - 1; i >= 0; i-- ) { + if ( m_tempo_table.get( i ).Clock < clock ) { + double init = m_tempo_table.get( i ).Time; + int dclock = clock - m_tempo_table.get( i ).Clock; + double sec_per_clock1 = m_tempo_table.get( i ).Tempo * 1e-6 / 480.0; return init + dclock * sec_per_clock1; } } @@ -166,7 +170,7 @@ namespace Boare.Lib.Vsq { return this.Clock - entry.Clock; } - public bool Equals( TempoTableEntry entry ) { + public boolean Equals( TempoTableEntry entry ) { if ( this.Clock == entry.Clock ) { return true; } else { diff --git a/trunk/Boare.Lib.Vsq/TextMemoryStream.cs b/trunk/Boare.Lib.Vsq/TextMemoryStream.cs index f656b63..0da581b 100644 --- a/trunk/Boare.Lib.Vsq/TextMemoryStream.cs +++ b/trunk/Boare.Lib.Vsq/TextMemoryStream.cs @@ -16,56 +16,58 @@ using System.IO; using System.Text; using System.Collections.Generic; +using bocoree; + namespace Boare.Lib.Vsq { public class TextMemoryStream : IDisposable { - private static readonly string NL = (char)0x0d + "" + (char)0x0a; + private static readonly String NL = (char)0x0d + "" + (char)0x0a; - private List m_lines; + private Vector m_lines; private int m_index; public TextMemoryStream() { - m_lines = new List(); - m_lines.Add( "" ); + m_lines = new Vector(); + m_lines.add( "" ); m_index = 0; } - public TextMemoryStream( string path, Encoding encoding ) { - m_lines = new List(); + public TextMemoryStream( String path, Encoding encoding ) { + m_lines = new Vector(); m_index = 0; if ( File.Exists( path ) ) { using ( StreamReader sr = new StreamReader( path, encoding ) ) { while ( sr.Peek() >= 0 ) { - string line = sr.ReadLine(); - m_lines.Add( line ); + String line = sr.ReadLine(); + m_lines.add( line ); m_index++; } } } } - public void write( string value ) { + public void write( String value ) { appendString( value ); } - public void writeLine( string value ) { + public void writeLine( String value ) { appendString( value + NL ); } - private void appendString( string value ) { - string[] lines = value.Split( new string[] { NL }, StringSplitOptions.None ); - List lines2 = new List(); + private void appendString( String value ) { + String[] lines = value.Split( new String[] { NL }, StringSplitOptions.None ); + Vector lines2 = new Vector(); for ( int i = 0; i < lines.Length; i++ ) { - string[] spl = lines[i].Split( (char)0x0d, (char)0x0a ); + String[] spl = lines[i].Split( (char)0x0d, (char)0x0a ); for ( int j = 0; j < spl.Length; j++ ) { - lines2.Add( spl[j] ); + lines2.add( spl[j] ); } } - int count = lines2.Count; + int count = lines2.size(); if ( count > 0 ) { - m_lines[m_index] += lines2[0]; + m_lines.set( m_index, m_lines.get( m_index ) + lines2.get( 0 ) ); for ( int i = 1; i < count; i++ ) { - m_lines.Add( lines2[i] ); + m_lines.add( lines2.get( i ) ); m_index++; } } @@ -75,17 +77,17 @@ namespace Boare.Lib.Vsq { m_index = 0; } - public string readLine() { + public String readLine() { m_index++; - return m_lines[m_index - 1]; + return m_lines.get( m_index - 1 ); } public int peek() { - if ( m_index < m_lines.Count ) { - if ( m_lines[m_index] == "" ) { + if ( m_index < m_lines.size() ) { + if ( m_lines.get( m_index ).Equals( "" ) ) { return -1; } else { - return (int)m_lines[m_index][0]; + return (int)m_lines.get( m_index )[0]; } } else { return -1; @@ -93,7 +95,7 @@ namespace Boare.Lib.Vsq { } public void close() { - m_lines.Clear(); + m_lines.clear(); } public void Dispose() { diff --git a/trunk/Boare.Lib.Vsq/TimeSigTableEntry.cs b/trunk/Boare.Lib.Vsq/TimeSigTableEntry.cs index 5140ab3..61b8468 100644 --- a/trunk/Boare.Lib.Vsq/TimeSigTableEntry.cs +++ b/trunk/Boare.Lib.Vsq/TimeSigTableEntry.cs @@ -13,6 +13,8 @@ */ using System; +using bocoree; + namespace Boare.Lib.Vsq{ [Serializable] @@ -48,7 +50,7 @@ namespace Boare.Lib.Vsq{ public TimeSigTableEntry() { } - public override string ToString() { + public override String ToString() { return "{Clock=" + Clock + ", Numerator=" + Numerator + ", Denominator=" + Denominator + ", BarCount=" + BarCount + "}"; } diff --git a/trunk/Boare.Lib.Vsq/UstEnvelope.cs b/trunk/Boare.Lib.Vsq/UstEnvelope.cs index b864160..fa31bc3 100644 --- a/trunk/Boare.Lib.Vsq/UstEnvelope.cs +++ b/trunk/Boare.Lib.Vsq/UstEnvelope.cs @@ -13,6 +13,8 @@ */ using System; +using bocoree; + namespace Boare.Lib.Vsq { [Serializable] @@ -24,7 +26,7 @@ namespace Boare.Lib.Vsq { public int v2 = 100; public int v3 = 100; public int v4 = 0; - //public string Separator = ""; + //public String Separator = ""; public int p4 = 0; public int p5 = 0; public int v5 = 100; @@ -32,9 +34,9 @@ namespace Boare.Lib.Vsq { public UstEnvelope() { } - public UstEnvelope( string line ) { + public UstEnvelope( String line ) { if ( line.ToLower().StartsWith( "envelope=" ) ) { - string[] spl = line.Split( '=' ); + String[] spl = line.Split( '=' ); spl = spl[1].Split( ',' ); if ( spl.Length < 7 ) { return; @@ -60,8 +62,8 @@ namespace Boare.Lib.Vsq { return new UstEnvelope( ToString() ); } - public override string ToString() { - string ret = "Envelope=" + p1 + "," + p2 + "," + p3 + "," + v1 + "," + v2 + "," + v3 + "," + v4; + public override String ToString() { + String ret = "Envelope=" + p1 + "," + p2 + "," + p3 + "," + v1 + "," + v2 + "," + v3 + "," + v4; ret += ",%," + p4 + "," + p5 + "," + v5; return ret; } diff --git a/trunk/Boare.Lib.Vsq/UstEvent.cs b/trunk/Boare.Lib.Vsq/UstEvent.cs index 612322c..f114fdb 100644 --- a/trunk/Boare.Lib.Vsq/UstEvent.cs +++ b/trunk/Boare.Lib.Vsq/UstEvent.cs @@ -16,13 +16,15 @@ using System.IO; using System.Collections.Generic; using System.Text; +using bocoree; + namespace Boare.Lib.Vsq { [Serializable] public class UstEvent : ICloneable { - public string Tag; + public String Tag; public int Length = 0; - public string Lyric = ""; + public String Lyric = ""; public int Note = -1; public int Intensity = -1; public int PBType = -1; @@ -33,8 +35,9 @@ namespace Boare.Lib.Vsq { public int PreUtterance = 0; public int VoiceOverlap = 0; public UstEnvelope Envelope = null; - public string Flags = ""; + public String Flags = ""; public int Moduration = 100; + public int Index; public UstEvent(){ } @@ -70,8 +73,14 @@ namespace Boare.Lib.Vsq { return ret; } - public void print( StreamWriter sw, uint index ) { - sw.WriteLine( string.Format( "[#{0:d4}]", index ) ); + public void print( StreamWriter sw ) { + if ( this.Index == int.MinValue ) { + sw.WriteLine( "[#PREV]" ); + } else if ( this.Index == int.MaxValue ) { + sw.WriteLine( "[#NEXT]" ); + } else { + sw.WriteLine( String.Format( "[#{0:d4}]", Index ) ); + } sw.WriteLine( "Length=" + Length ); sw.WriteLine( "Lyric=" + Lyric ); sw.WriteLine( "NoteNum=" + Note ); diff --git a/trunk/Boare.Lib.Vsq/UstFile.cs b/trunk/Boare.Lib.Vsq/UstFile.cs index db75cd6..abfbbc3 100644 --- a/trunk/Boare.Lib.Vsq/UstFile.cs +++ b/trunk/Boare.Lib.Vsq/UstFile.cs @@ -23,144 +23,181 @@ namespace Boare.Lib.Vsq{ public class UstFile : ICloneable { public object Tag; private float m_tempo = 120.00f; - private string m_project_name = ""; - private string m_voice_dir = ""; - private string m_out_file = ""; - private string m_cache_dir = ""; - private string m_tool1 = ""; - private string m_tool2 = ""; - private List m_tracks = new List(); - private List m_tempo_table; + private String m_project_name = ""; + private String m_voice_dir = ""; + private String m_out_file = ""; + private String m_cache_dir = ""; + private String m_tool1 = ""; + private String m_tool2 = ""; + private Vector m_tracks = new Vector(); + private Vector m_tempo_table; - public UstFile( string path ){ - cp932reader sr = new cp932reader( path ); - string line = sr.ReadLine(); - if ( line != "[#SETTING]" ) { - throw new Exception( "invalid ust file" ); - } - UstTrack track = new UstTrack(); - int type = 0; //0 => reading "SETTING" section - while( true ) { - UstEvent ue = null; - if ( type == 1 ) { - ue = new UstEvent(); + public UstFile( String path ){ + try { + cp932reader sr = new cp932reader( path ); +#if DEBUG + bocoree.debug.push_log( "path=" + path ); + bocoree.debug.push_log( "(sr==null)=" + (sr == null) ); +#endif + String line = sr.ReadLine(); + if ( line != "[#SETTING]" ) { + throw new Exception( "invalid ust file" ); } - if ( line == "[#TRACKEND]" ) { - break; - } - line = sr.ReadLine(); // "[#" ̍s - while( !line.StartsWith( "[#" ) ){ - string[] spl = line.Split( "=".ToCharArray(), 2 ); - if ( type == 0 ) { - // reading "SETTING" section - if ( spl[0] == "Tempo" ) { - m_tempo = 125f; - float v = 125f; - if ( float.TryParse( spl[1], out v ) ) { - m_tempo = v; - } - } else if ( spl[0] == "ProjectName" ) { - m_project_name = spl[1]; - } else if ( spl[0] == "VoiceDir" ) { - m_voice_dir = spl[1]; - } else if ( spl[0] == "OutFile" ) { - m_out_file = spl[1]; - } else if ( spl[0] == "CacheDir" ) { - m_cache_dir = spl[1]; - } else if ( spl[0] == "Tool1" ) { - m_tool1 = spl[1]; - } else if ( spl[0] == "Tool2" ) { - m_tool2 = spl[1]; - } - } else if ( type == 1 ) { - // readin event section - if ( spl[0] == "Length" ) { - ue.Length = 0; - int v = 0; - if ( int.TryParse( spl[1], out v ) ){ - ue.Length =v; - } - } else if ( spl[0] == "Lyric" ) { - ue.Lyric = spl[1]; - } else if ( spl[0] == "NoteNum" ) { - ue.Note = 0; - int v = 0; - if ( int.TryParse( spl[1], out v ) ) { - ue.Note = v; - } - } else if ( spl[0] == "Intensity" ) { - ue.Intensity =64; - int v = 64; - if ( int.TryParse( spl[1], out v ) ) { - ue.Intensity = v; - } - } else if ( spl[0] == "PBType" ) { - ue.PBType = 5; - int v = 5; - if ( int.TryParse( spl[1], out v ) ) { - ue.PBType = v; - } - } else if ( spl[0] == "Piches" ) { - string[] spl2 = spl[1].Split( ",".ToCharArray() ); - float[] t = new float[spl2.Length]; - for ( int i = 0; i < spl2.Length; i++ ) { - float v = 0; - float.TryParse( spl2[i], out v ); - t[i] = v; - } - ue.Pitches = t; - } else if ( spl[0] == "Tempo" ) { - ue.Tempo = 125f; - float v; - 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 ); - } + UstTrack track = new UstTrack(); + int type = 0; //0 => reading "SETTING" section + while ( true ) { +#if DEBUG + bocoree.debug.push_log( "line=" + line ); +#endif + UstEvent ue = null; + if ( type == 1 ) { + ue = new UstEvent(); + } + int index = 0; + if ( line.Equals( "[#TRACKEND]" ) ) { + break; + } else if ( line.ToUpper().Equals( "[#NEXT]" ) ) { + index = int.MaxValue; + } else if ( line.ToUpper().Equals( "[#PREV]" ) ) { + index = int.MinValue; + } else { + String s = line.Replace( "[#", "" ).Replace( "#", "" ).Trim(); + int.TryParse( s, out index ); + } +#if DEBUG + bocoree.debug.push_log( "index=" + index ); +#endif + line = sr.ReadLine(); // "[#" ̍s + if ( line == null ) { + break; + } + while ( !line.StartsWith( "[#" ) ) { +#if DEBUG + Console.WriteLine( "line=" + line ); +#endif + String[] spl = line.Split( "=".ToCharArray(), 2 ); + if ( type == 0 ) { + // reading "SETTING" section + if ( spl[0].Equals( "Tempo" ) ) { + m_tempo = 125f; + float v = 125f; + if ( float.TryParse( spl[1], out v ) ) { + m_tempo = v; + } + } else if ( spl[0].Equals( "ProjectName" ) ) { + m_project_name = spl[1]; + } else if ( spl[0].Equals( "VoiceDir" ) ) { + m_voice_dir = spl[1]; + } else if ( spl[0].Equals( "OutFile" ) ) { + m_out_file = spl[1]; + } else if ( spl[0].Equals( "CacheDir" ) ) { + m_cache_dir = spl[1]; + } else if ( spl[0].Equals( "Tool1" ) ) { + m_tool1 = spl[1]; + } else if ( spl[0].Equals( "Tool2" ) ) { + m_tool2 = spl[1]; + } + } else if ( type == 1 ) { + // readin event section + if ( spl[0].Equals( "Length" ) ) { + ue.Length = 0; + int v = 0; + if ( int.TryParse( spl[1], out v ) ) { + ue.Length = v; + } + } else if ( spl[0].Equals( "Lyric" ) ) { + ue.Lyric = spl[1]; + } else if ( spl[0].Equals( "NoteNum" ) ) { + ue.Note = 0; + int v = 0; + if ( int.TryParse( spl[1], out v ) ) { + ue.Note = v; + } + } else if ( spl[0].Equals( "Intensity" ) ) { + ue.Intensity = 64; + int v = 64; + if ( int.TryParse( spl[1], out v ) ) { + ue.Intensity = v; + } + } else if ( spl[0].Equals( "PBType" ) ) { + ue.PBType = 5; + int v = 5; + if ( int.TryParse( spl[1], out v ) ) { + ue.PBType = v; + } + } else if ( spl[0].Equals( "Piches" ) ) { + String[] spl2 = spl[1].Split( ",".ToCharArray() ); + float[] t = new float[spl2.Length]; + for ( int i = 0; i < spl2.Length; i++ ) { + float v = 0; + float.TryParse( spl2[i], out v ); + t[i] = v; + } + ue.Pitches = t; + } else if ( spl[0].Equals( "Tempo" ) ) { + ue.Tempo = 125f; + float v; + if ( float.TryParse( spl[1], out v ) ) { + ue.Tempo = v; + } + } else if ( spl[0].Equals( "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].Equals( "PBW" ) || spl[0].Equals( "PBS" ) || spl[0].Equals( "PBY" ) || spl[0].Equals( "PBM" ) ) { + if ( ue.Portamento == null ) { + ue.Portamento = new UstPortamento(); + } + ue.Portamento.ParseLine( line ); + } else if ( spl[0].Equals( "Envelope" ) ) { + ue.Envelope = new UstEnvelope( line ); + //PreUtterance=1 + //VoiceOverlap=6 + } else if ( spl[0].Equals( "VoiceOverlap" ) ) { + if ( spl[1] != "" ) { + ue.VoiceOverlap = int.Parse( spl[1] ); + } + } else if ( spl[0].Equals( "PreUtterance" ) ) { + if ( spl[1] != "" ) { + ue.PreUtterance = int.Parse( spl[1] ); + } + } else if ( spl[0].Equals( "Flags" ) ) { + ue.Flags = line.Substring( 6 ); + } + } + if ( sr.Peek() < 0 ) { + break; + } + line = sr.ReadLine(); + } +#if DEBUG + bocoree.debug.push_log( "(ue==null)=" + (ue == null) ); +#endif + if ( type == 0 ) { + type = 1; + } else if ( type == 1 ) { + ue.Index = index; + track.addEvent( ue ); } - line = sr.ReadLine(); - } - if ( type == 0 ) { - type = 1; - } else if ( type == 1 ) { - track.addEvent( ue ); } + m_tracks.add( track ); + sr.Close(); + updateTempoInfo(); + } catch ( Exception ex ) { +#if DEBUG + bocoree.debug.push_log( "ex=" + ex ); +#endif } - m_tracks.Add( track ); - sr.Close(); - updateTempoInfo(); } private UstFile(){ } - public string getProjectName() { + public String getProjectName() { return m_project_name; } @@ -170,26 +207,26 @@ namespace Boare.Lib.Vsq{ public double getTotalSec() { int max = 0; - for ( int track = 0; track < m_tracks.Count; track++ ) { + for ( int track = 0; track < m_tracks.size(); track++ ) { int count = 0; - for ( int i = 0; i < m_tracks[track].getEventCount(); i++ ) { - count += (int)m_tracks[track].getEvent( i ).Length; + for ( int i = 0; i < m_tracks.get( track ).getEventCount(); i++ ) { + count += (int)m_tracks.get( track ).getEvent( i ).Length; } max = Math.Max( max, count ); } return getSecFromClock( max ); } - public List getTempoList() { + public Vector getTempoList() { return m_tempo_table; } public UstTrack getTrack( int track ) { - return m_tracks[track]; + return m_tracks.get( track ); } public int getTrackCount() { - return m_tracks.Count; + return m_tracks.size(); } /// @@ -197,31 +234,31 @@ namespace Boare.Lib.Vsq{ /// /// public void updateTempoInfo() { - m_tempo_table = new List(); - if ( m_tracks.Count <= 0 ) { + m_tempo_table = new Vector(); + if ( m_tracks.size() <= 0 ) { return; } int clock = 0; double time = 0.0; int last_tempo_clock = 0; //ŌTempolĂCxg̃NbN float last_tempo = m_tempo; //ŌɑĂe|̒l - for ( int i = 0; i < m_tracks[0].getEventCount(); i++ ) { - if ( m_tracks[0].getEvent( i ).Tempo > 0f ) { + for ( int i = 0; i < m_tracks.get( 0 ).getEventCount(); i++ ) { + if ( m_tracks.get( 0 ).getEvent( i ).Tempo > 0f ) { time += (clock - last_tempo_clock) / (8.0 * last_tempo); - if ( m_tempo_table.Count == 0 && clock != 0 ) { - m_tempo_table.Add( new TempoTableEntry( 0, (int)(6e7 / m_tempo), 0.0 ) ); + if ( m_tempo_table.size() == 0 && clock != 0 ) { + m_tempo_table.add( new TempoTableEntry( 0, (int)(6e7 / m_tempo), 0.0 ) ); } - m_tempo_table.Add( new TempoTableEntry( clock, (int)(6e7 / m_tracks[0].getEvent( i ).Tempo), time ) ); - last_tempo = m_tracks[0].getEvent( i ).Tempo; + m_tempo_table.add( new TempoTableEntry( clock, (int)(6e7 / m_tracks.get( 0 ).getEvent( i ).Tempo), time ) ); + last_tempo = m_tracks.get( 0 ).getEvent( i ).Tempo; last_tempo_clock = clock; } - clock += (int)m_tracks[0].getEvent( i ).Length; + clock += (int)m_tracks.get( 0 ).getEvent( i ).Length; } #if DEBUG using ( StreamWriter sw = new StreamWriter( Path.Combine( System.Windows.Forms.Application.StartupPath, "ust_tempo_info.txt" ) ) ) { sw.WriteLine( "Clock\tTime\tTempo" ); - for ( int i = 0; i < m_tempo_table.Count; i++ ) { - sw.WriteLine( m_tempo_table[i].Clock + "\t" + m_tempo_table[i].Time + "\t" + m_tempo_table[i].Tempo ); + for ( int i = 0; i < m_tempo_table.size(); i++ ) { + sw.WriteLine( m_tempo_table.get( i ).Clock + "\t" + m_tempo_table.get( i ).Time + "\t" + m_tempo_table.get( i ).Tempo ); } } #endif @@ -233,11 +270,11 @@ namespace Boare.Lib.Vsq{ /// /// 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; + for ( int i = m_tempo_table.size() - 1; i >= 0; i-- ) { + if ( m_tempo_table.get( i ).Clock < clock ) { + double init = m_tempo_table.get( i ).Time; + int dclock = clock - m_tempo_table.get( i ).Clock; + double sec_per_clock1 = m_tempo_table.get( i ).Tempo * 1e-6 / 480.0; return init + dclock * sec_per_clock1; } } @@ -245,7 +282,7 @@ namespace Boare.Lib.Vsq{ return clock * sec_per_clock; } - public void write( string file ) { + public void write( String file ) { StreamWriter sw = new StreamWriter( file, false, Encoding.GetEncoding( "Shift_JIS" ) ); sw.WriteLine( "[#SETTING]" ); sw.WriteLine( "Tempo=" + m_tempo ); @@ -256,8 +293,8 @@ namespace Boare.Lib.Vsq{ sw.WriteLine( "CacheDir=" + m_cache_dir ); sw.WriteLine( "Tool1=" + m_tool1 ); sw.WriteLine( "Tool2=" + m_tool2 ); - for ( int i = 0; i < m_tracks[0].getEventCount(); i++ ) { - m_tracks[0].getEvent( i ).print( sw, (uint)i ); + for ( int i = 0; i < m_tracks.get( 0 ).getEventCount(); i++ ) { + m_tracks.get( 0 ).getEvent( i ).print( sw ); } sw.WriteLine( "[#TRACKEND]" ); sw.Close(); @@ -272,12 +309,12 @@ namespace Boare.Lib.Vsq{ ret.m_cache_dir = m_cache_dir; ret.m_tool1 = m_tool1; ret.m_tool2 = m_tool2; - for ( int i = 0; i < m_tracks.Count; i++ ) { - ret.m_tracks[i] = (UstTrack)m_tracks[i].Clone(); + for ( int i = 0; i < m_tracks.size(); i++ ) { + ret.m_tracks.set( i, (UstTrack)m_tracks.get( i ).Clone() ); } - ret.m_tempo_table = new List(); - for ( int i = 0; i < m_tempo_table.Count; i++ ) { - ret.m_tempo_table.Add( (TempoTableEntry)m_tempo_table[i].Clone() ); + ret.m_tempo_table = new Vector(); + for ( int i = 0; i < m_tempo_table.size(); i++ ) { + ret.m_tempo_table.add( (TempoTableEntry)m_tempo_table.get( i ).Clone() ); } return ret; } diff --git a/trunk/Boare.Lib.Vsq/UstPortamento.cs b/trunk/Boare.Lib.Vsq/UstPortamento.cs index 4b1931b..5b1ab10 100644 --- a/trunk/Boare.Lib.Vsq/UstPortamento.cs +++ b/trunk/Boare.Lib.Vsq/UstPortamento.cs @@ -15,23 +15,25 @@ using System; using System.Collections.Generic; using System.IO; +using bocoree; + namespace Boare.Lib.Vsq { [Serializable] public class UstPortamento : ICloneable { - public List Points = new List(); + public Vector Points = new Vector(); public int Start; public void print( StreamWriter sw ) { - string pbw = ""; - string pby = ""; - string pbm = ""; - for ( int i = 0; i < Points.Count; i++ ) { - string comma = (i == 0 ? "" : ","); - pbw += comma + Points[i].Step; - pby += comma + Points[i].Value; - string type = ""; - switch ( Points[i].Type ) { + String pbw = ""; + String pby = ""; + String pbm = ""; + for ( int i = 0; i < Points.size(); i++ ) { + String comma = (i == 0 ? "" : ","); + pbw += comma + Points.get( i ).Step; + pby += comma + Points.get( i ).Value; + String type = ""; + switch ( Points.get( i ).Type ) { case UstPortamentoType.S: type = ""; break; @@ -55,8 +57,8 @@ namespace Boare.Lib.Vsq { public object Clone() { UstPortamento ret = new UstPortamento(); - for ( int i = 0; i < Points.Count; i++ ) { - ret.Points.Add( Points[i] ); + for ( int i = 0; i < Points.size(); i++ ) { + ret.Points.add( Points.get( i ) ); } ret.Start = Start; return ret; @@ -68,39 +70,39 @@ namespace Boare.Lib.Vsq { PBY=-15.9,-20,-31.5,-26.6 PBM=,s,r,j,s,s,s,s,s */ - public void ParseLine( string line ) { + public void ParseLine( String line ) { line = line.ToLower(); - string[] spl = line.Split( '=' ); + String[] spl = line.Split( '=' ); if ( spl.Length == 0 ) { return; } - string[] values = spl[1].Split( ',' ); + String[] values = spl[1].Split( ',' ); if ( line.StartsWith( "pbs=" ) ) { Start = int.Parse( values[0] ); } else if ( line.StartsWith( "pbw=" ) ) { for ( int i = 0; i < values.Length; i++ ) { - if ( i >= Points.Count ) { - Points.Add( new UstPortamentoPoint() ); + if ( i >= Points.size() ) { + Points.add( new UstPortamentoPoint() ); } - UstPortamentoPoint up = Points[i]; + UstPortamentoPoint up = Points.get( i ); up.Step = int.Parse( values[i] ); - Points[i] = up; + Points.set( i, up ); } } else if ( line.StartsWith( "pby=" ) ) { for ( int i = 0; i < values.Length; i++ ) { - if ( i >= Points.Count ) { - Points.Add( new UstPortamentoPoint() ); + if ( i >= Points.size() ) { + Points.add( new UstPortamentoPoint() ); } - UstPortamentoPoint up = Points[i]; + UstPortamentoPoint up = Points.get( i ); up.Value = float.Parse( values[i] ); - Points[i] = up; + Points.set( i, up ); } } else if ( line.StartsWith( "pbm=" ) ) { for ( int i = 0; i < values.Length; i++ ) { - if ( i >= Points.Count ) { - Points.Add( new UstPortamentoPoint() ); + if ( i >= Points.size() ) { + Points.add( new UstPortamentoPoint() ); } - UstPortamentoPoint up = Points[i]; + UstPortamentoPoint up = Points.get( i ); switch ( values[i].ToLower() ) { case "s": up.Type = UstPortamentoType.Linear; @@ -115,7 +117,7 @@ namespace Boare.Lib.Vsq { up.Type = UstPortamentoType.S; break; } - Points[i] = up; + Points.set( i, up ); } } else if ( line.StartsWith( "pbs=" ) ) { diff --git a/trunk/Boare.Lib.Vsq/UstTrack.cs b/trunk/Boare.Lib.Vsq/UstTrack.cs index 9e766e1..19307e3 100644 --- a/trunk/Boare.Lib.Vsq/UstTrack.cs +++ b/trunk/Boare.Lib.Vsq/UstTrack.cs @@ -14,34 +14,36 @@ using System; using System.Collections.Generic; +using bocoree; + namespace Boare.Lib.Vsq{ public class UstTrack : ICloneable { public object Tag; - private List m_events; + private Vector m_events; public UstTrack(){ - m_events = new List(); + m_events = new Vector(); } public UstEvent getEvent( int index ) { - return m_events[index]; + return m_events.get( index ); } public void setEvent( int index, UstEvent item ) { - m_events[index] = item; + m_events.set( index, item ); } public void addEvent( UstEvent item ) { - m_events.Add( item ); + m_events.add( item ); } public void removeEvent( int index ) { - m_events.RemoveAt( index ); + m_events.removeElementAt( index ); } public int getEventCount() { - return m_events.Count; + return m_events.size(); } public Iterator getNoteEventIterator() { @@ -50,8 +52,8 @@ namespace Boare.Lib.Vsq{ public object Clone() { UstTrack ret = new UstTrack(); - for ( int i = 0; i < m_events.Count; i++ ) { - ret.m_events[i] = (UstEvent)m_events[i].Clone(); + for ( int i = 0; i < m_events.size(); i++ ) { + ret.m_events.set( i, (UstEvent)m_events.get( i ).Clone() ); } return ret; } diff --git a/trunk/Boare.Lib.Vsq/UstVibrato.cs b/trunk/Boare.Lib.Vsq/UstVibrato.cs index 20bc327..f02a10f 100644 --- a/trunk/Boare.Lib.Vsq/UstVibrato.cs +++ b/trunk/Boare.Lib.Vsq/UstVibrato.cs @@ -13,6 +13,8 @@ */ using System; +using bocoree; + namespace Boare.Lib.Vsq { [Serializable] @@ -47,9 +49,9 @@ namespace Boare.Lib.Vsq { public float Shift; public float Unknown = 100; - public UstVibrato( string line ) { + public UstVibrato( String line ) { if ( line.ToLower().StartsWith( "vbr=" ) ) { - string[] spl = line.Split( '=' ); + String[] spl = line.Split( '=' ); spl = spl[1].Split( ',' ); //VBR=65,180,70,20.0,17.6,82.8,49.8,100 if ( spl.Length >= 8 ) { @@ -68,7 +70,7 @@ namespace Boare.Lib.Vsq { public UstVibrato() { } - public override string ToString() { + public override String ToString() { return "VBR=" + Length + "," + Period + "," + Depth + "," + In + "," + Out + "," + Phase + "," + Shift + "," + Unknown; } diff --git a/trunk/Boare.Lib.Vsq/VibratoBPList.cs b/trunk/Boare.Lib.Vsq/VibratoBPList.cs index 2264746..371bd9d 100644 --- a/trunk/Boare.Lib.Vsq/VibratoBPList.cs +++ b/trunk/Boare.Lib.Vsq/VibratoBPList.cs @@ -14,14 +14,16 @@ using System; using System.Collections.Generic; +using bocoree; + namespace Boare.Lib.Vsq { [Serializable] public class VibratoBPList : ICloneable { - private List m_list; + private Vector m_list; public VibratoBPList() { - m_list = new List(); + m_list = new Vector(); } public VibratoBPList( float[] x, int[] y ){ @@ -32,20 +34,20 @@ namespace Boare.Lib.Vsq { throw new ArgumentNullException( "y" ); } int len = Math.Min( x.Length, y.Length ); - m_list = new List( len ); + m_list = new Vector( len ); for ( int i = 0; i < len; i++ ) { - m_list.Add( new VibratoBPPair( x[i], y[i] ) ); + m_list.add( new VibratoBPPair( x[i], y[i] ) ); } - m_list.Sort(); + Collections.sort( m_list ); } public int getValue( float x, int default_value ) { - if ( m_list.Count <= 0 ) { + if ( m_list.size() <= 0 ) { return default_value; } int index = -1; - for ( int i = 0; i < m_list.Count; i++ ) { - if ( x < m_list[i].X ) { + for ( int i = 0; i < m_list.size(); i++ ) { + if ( x < m_list.get( i ).X ) { break; } index = i; @@ -53,50 +55,50 @@ namespace Boare.Lib.Vsq { if ( index == -1 ) { return default_value; } else { - return m_list[index].Y; + return m_list.get( index ).Y; } } public object Clone() { VibratoBPList ret = new VibratoBPList(); - for ( int i = 0; i < m_list.Count; i++ ) { - ret.m_list.Add( new VibratoBPPair( m_list[i].X, m_list[i].Y ) ); + for ( int i = 0; i < m_list.size(); i++ ) { + ret.m_list.add( new VibratoBPPair( m_list.get( i ).X, m_list.get( i ).Y ) ); } return ret; } public int getCount() { - return m_list.Count; + return m_list.size(); } public VibratoBPPair getElement( int index ) { - return m_list[index]; + return m_list.get( index ); } public void setElement( int index, VibratoBPPair value ) { - m_list[index] = value; + m_list.set( index, value ); } /// /// XMLシリアライズ用 /// - public string Data { + 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; + String ret = ""; + for ( int i = 0; i < m_list.size(); i++ ) { + ret += (i == 0 ? "" : ",") + m_list.get( i ).X + "=" + m_list.get( i ).Y; } return ret; } set { - m_list.Clear(); - string[] spl = value.Split( ',' ); + m_list.clear(); + String[] spl = value.Split( ',' ); for ( int i = 0; i < spl.Length; i++ ) { - string[] spl2 = spl[i].Split( '=' ); + String[] spl2 = spl[i].Split( '=' ); if ( spl2.Length < 2 ) { continue; } - m_list.Add( new VibratoBPPair( float.Parse( spl2[0] ), int.Parse( spl2[1] ) ) ); + m_list.add( new VibratoBPPair( float.Parse( spl2[0] ), int.Parse( spl2[1] ) ) ); } } } diff --git a/trunk/Boare.Lib.Vsq/VibratoConfig.cs b/trunk/Boare.Lib.Vsq/VibratoConfig.cs index d1152e4..d2e4b15 100644 --- a/trunk/Boare.Lib.Vsq/VibratoConfig.cs +++ b/trunk/Boare.Lib.Vsq/VibratoConfig.cs @@ -14,6 +14,8 @@ using System; using System.IO; +using bocoree; + namespace Boare.Lib.Vsq { public class VibratoConfig { @@ -42,7 +44,7 @@ namespace Boare.Lib.Vsq { if ( line.StartsWith( "[" ) ) { current_entry = line; continue; - } else if ( line == "" || line.StartsWith( ";" ) ) { + } else if ( line.Equals( "" ) || line.StartsWith( ";" ) ) { continue; } @@ -52,38 +54,38 @@ namespace Boare.Lib.Vsq { } spl[0] = spl[0].Trim(); spl[1] = spl[1].Trim(); - if ( current_entry == "[Common]" ) { - if ( spl[0] == "Articulation" ) { + if ( current_entry.Equals( "[Common]" ) ) { + if ( spl[0].Equals( "Articulation" ) ) { articulation = spl[1]; } - } else if ( current_entry == "[Parameter]" ) { - if ( spl[0] == "Length" ) { + } else if ( current_entry.Equals( "[Parameter]" ) ) { + if ( spl[0].Equals( "Length" ) ) { try { this.contents.Length = int.Parse( spl[1] ); } catch { } - } else if ( spl[0] == "StartDepth" ) { + } else if ( spl[0].Equals( "StartDepth" ) ) { try { this.contents.StartDepth = int.Parse( spl[1] ); } catch { } - } else if ( spl[0] == "DepthBPNum" ) { + } else if ( spl[0].Equals( "DepthBPNum" ) ) { try { depth_bpnum = int.Parse( spl[1] ); } catch { } - } else if ( spl[0] == "DepthBPX" ) { + } else if ( spl[0].Equals( "DepthBPX" ) ) { depth_bpx = spl[1]; - } else if ( spl[0] == "DepthBPY" ) { + } else if ( spl[0].Equals( "DepthBPY" ) ) { depth_bpy = spl[1]; - } else if ( spl[0] == "StartRate" ) { + } else if ( spl[0].Equals( "StartRate" ) ) { try { this.contents.StartRate = int.Parse( spl[1] ); } catch { } - } else if ( spl[0] == "RateBPNum" ) { + } else if ( spl[0].Equals( "RateBPNum" ) ) { try { rate_bpnum = int.Parse( spl[1] ); } catch { } - } else if ( spl[0] == "RateBPX" ) { + } else if ( spl[0].Equals( "RateBPX" ) ) { rate_bpx = spl[1]; - } else if ( spl[0] == "RateBPY" ) { + } else if ( spl[0].Equals( "RateBPY" ) ) { rate_bpy = spl[1]; } } diff --git a/trunk/Boare.Lib.Vsq/VibratoType.cs b/trunk/Boare.Lib.Vsq/VibratoType.cs index 925f7bb..bf1bbe2 100644 --- a/trunk/Boare.Lib.Vsq/VibratoType.cs +++ b/trunk/Boare.Lib.Vsq/VibratoType.cs @@ -13,6 +13,8 @@ */ using System; +using bocoree; + namespace Boare.Lib.Vsq { /// @@ -94,7 +96,7 @@ namespace Boare.Lib.Vsq { /// /// /// - public static VibratoType getVibratoTypeFromIconID( string icon_id ) { + public static VibratoType getVibratoTypeFromIconID( String icon_id ) { switch ( icon_id ) { case "$04040001": return VibratoType.NormalType1; @@ -137,7 +139,7 @@ namespace Boare.Lib.Vsq { /// /// /// - public static string getIconIDFromVibratoType( VibratoType type ) { + public static String getIconIDFromVibratoType( VibratoType type ) { switch ( type ) { case VibratoType.NormalType1: return "$04040001"; @@ -304,12 +306,12 @@ namespace Boare.Lib.Vsq { /// /// /// - /// string str = VibratoTypeUtil.ToString( VibratoType.NormalType1 ); + /// String str = VibratoTypeUtil.ToString( VibratoType.NormalType1 ); /// // str = "[Normal] Type 1" /// /// /// - public static string ToString( VibratoType value ) { + public static String ToString( VibratoType value ) { switch ( value ) { case VibratoType.NormalType1: return "[Normal] Type 1"; diff --git a/trunk/Boare.Lib.Vsq/VocaloSysUtil.cs b/trunk/Boare.Lib.Vsq/VocaloSysUtil.cs index d151176..5f10f78 100644 --- a/trunk/Boare.Lib.Vsq/VocaloSysUtil.cs +++ b/trunk/Boare.Lib.Vsq/VocaloSysUtil.cs @@ -16,6 +16,8 @@ using System.IO; using System.Collections.Generic; using Microsoft.Win32; +using bocoree; + namespace Boare.Lib.Vsq { using boolean = Boolean; @@ -25,47 +27,63 @@ namespace Boare.Lib.Vsq { private static SingerConfigSys s_singer_config_sys2; private static ExpressionConfigSys s_exp_config_sys1; private static ExpressionConfigSys s_exp_config_sys2; - private static String s_path_vsti1; - private static String s_path_vsti2; - private static String s_path_editor1; - private static String s_path_editor2; + private static String s_path_vsti1 = ""; + private static String s_path_vsti2 = ""; + private static String s_path_editor1 = ""; + private static String s_path_editor2 = ""; static VocaloSysUtil() { - Vector dir1 = new Vector(); - RegistryKey key1 = Registry.LocalMachine.OpenSubKey( "SOFTWARE\\VOCALOID", false ); - String header1 = "HKLM\\SOFTWARE\\VOCALOID"; - print( key1, header1, dir1 ); - key1.Close(); - String path_voicedb1; - String path_expdb1; - Vector installed_singers1 = new Vector(); - extract( dir1, - header1, - out s_path_vsti1, - out path_voicedb1, - out path_expdb1, - out s_path_editor1, - installed_singers1 ); - s_singer_config_sys1 = new SingerConfigSys( path_voicedb1, installed_singers1.ToArray() ); - s_exp_config_sys1 = new ExpressionConfigSys( path_expdb1 ); + try { + Vector dir1 = new Vector(); + RegistryKey key1 = Registry.LocalMachine.OpenSubKey( "SOFTWARE\\VOCALOID", false ); + String path_voicedb1 = ""; + String path_expdb1 = ""; + Vector installed_singers1 = new Vector(); + if ( key1 != null ) { + String header1 = "HKLM\\SOFTWARE\\VOCALOID"; + print( key1, header1, dir1 ); + key1.Close(); + extract( dir1, + header1, + out s_path_vsti1, + out path_voicedb1, + out path_expdb1, + out s_path_editor1, + installed_singers1 ); + } + s_singer_config_sys1 = new SingerConfigSys( path_voicedb1, installed_singers1.toArray( new String[] { } ) ); + s_exp_config_sys1 = new ExpressionConfigSys( path_expdb1 ); + }catch( Exception ex ){ + Console.WriteLine( "VocaloSysUtil..cctor; ex=" + ex ); + s_singer_config_sys1 = new SingerConfigSys( "", new String[] { } ); + s_exp_config_sys1 = new ExpressionConfigSys( "" ); + } - Vector dir2 = new Vector(); - RegistryKey key2 = Registry.LocalMachine.OpenSubKey( "SOFTWARE\\VOCALOID2", false ); - String header2 = "HKLM\\SOFTWARE\\VOCALOID2"; - print( key2, header2 , dir2 ); - key2.Close(); - String path_voicedb2; - String path_expdb2; - Vector installed_singers2 = new Vector(); - extract( dir2, - header2, - out s_path_vsti2, - out path_voicedb2, - out path_expdb2, - out s_path_editor2, - installed_singers2 ); - s_singer_config_sys2 = new SingerConfigSys( path_voicedb2, installed_singers2.ToArray() ); - s_exp_config_sys2 = new ExpressionConfigSys( path_expdb2 ); + try{ + Vector dir2 = new Vector(); + RegistryKey key2 = Registry.LocalMachine.OpenSubKey( "SOFTWARE\\VOCALOID2", false ); + String path_voicedb2 = ""; + String path_expdb2 = ""; + Vector installed_singers2 = new Vector(); + if ( key2 != null ) { + String header2 = "HKLM\\SOFTWARE\\VOCALOID2"; + print( key2, header2, dir2 ); + key2.Close(); + extract( dir2, + header2, + out s_path_vsti2, + out path_voicedb2, + out path_expdb2, + out s_path_editor2, + installed_singers2 ); + } + s_singer_config_sys2 = new SingerConfigSys( path_voicedb2, installed_singers2.toArray( new String[] { } ) ); + s_exp_config_sys2 = new ExpressionConfigSys( path_expdb2 ); + } catch ( Exception ex ) { + Console.WriteLine( "VocaloSysUtil..cctor; ex=" + ex ); + s_singer_config_sys2 = new SingerConfigSys( "", new String[] { } ); + s_exp_config_sys2 = new ExpressionConfigSys( "" ); + } } private static void extract( Vector dir, @@ -82,18 +100,20 @@ namespace Boare.Lib.Vsq { path_expdb = ""; path_voicedb = ""; path_editor = ""; - foreach ( String s in dir ) { + for( Iterator itr = dir.iterator(); itr.hasNext(); ) { + String s = (String)itr.next(); if ( s.StartsWith( header + "\\APPLICATION" ) ) { - application.Add( s.Substring( (header + "\\APPLICATION").Length ) ); + application.add( s.Substring( (header + "\\APPLICATION").Length ) ); } else if ( s.StartsWith( header + "\\DATABASE\\EXPRESSION" ) ) { - expression.Add( s.Substring( (header + "\\DATABASE\\EXPRESSION").Length ) ); + expression.add( s.Substring( (header + "\\DATABASE\\EXPRESSION").Length ) ); } else if ( s.StartsWith( header + "\\DATABASE\\VOICE" ) ) { - voice.Add( s.Substring( (header + "\\DATABASE\\VOICE\\").Length ) ); + voice.add( s.Substring( (header + "\\DATABASE\\VOICE\\").Length ) ); } } // path_vstiを取得 - foreach ( String s in application ) { + for( Iterator itr = application.iterator(); itr.hasNext(); ){ + String s = (String)itr.next(); String[] spl = s.Split( '\t' ); if ( spl.Length >= 3 && spl[1].Equals( "PATH" ) ){ if ( spl[2].ToLower().EndsWith( ".dll" ) ) { @@ -107,7 +127,8 @@ namespace Boare.Lib.Vsq { // path_vicedbを取得 Vector voice_ids = new Vector(); // 最初はpath_voicedbの取得と、id(BHXXXXXXXXXXXXXXXX)のようなシリアルを取得 - foreach ( String s in voice ) { + for( Iterator itr = voice.iterator(); itr.hasNext(); ){ + String s = (String)itr.next(); String[] spl = s.Split( '\t' ); if ( spl.Length >= 2 ) { if ( spl[0].Equals( "VOICEDIR" ) ) { @@ -115,17 +136,19 @@ namespace Boare.Lib.Vsq { } else if ( spl.Length >= 3 ) { String[] spl2 = spl[0].Split( '\\' ); if ( spl2.Length == 1 ) { - if ( !voice_ids.Contains( spl2[0] ) ) { - voice_ids.Add( spl2[0] ); + if ( !voice_ids.contains( spl2[0] ) ) { + voice_ids.add( spl2[0] ); } } } } } // 取得したシリアルを元に、installed_singersを取得 - foreach ( String s in voice_ids ) { + for( Iterator itr = voice_ids.iterator(); itr.hasNext(); ) { + String s = (String)itr.next(); String install_dir = ""; - foreach ( String s2 in voice ) { + for( Iterator itr2 = voice.iterator(); itr2.hasNext(); ){ + String s2 = (String)itr2.next(); if ( s2.StartsWith( header + "\\" + s + "\t" ) ) { String[] spl = s2.Split( '\t' ); if ( spl.Length >= 3 && spl[1].Equals( "INSTALLDIR" ) ) { @@ -137,13 +160,14 @@ namespace Boare.Lib.Vsq { if ( install_dir.Equals( "" ) ) { install_dir = Path.Combine( path_voicedb, s ); } - installed_singers.Add( install_dir ); + installed_singers.add( install_dir ); } // path_expdbを取得 Vector exp_ids = new Vector(); // 最初はpath_expdbの取得と、id(BHXXXXXXXXXXXXXXXX)のようなシリアルを取得 - foreach ( String s in expression ) { + for( Iterator itr = expression.iterator(); itr.hasNext(); ){ + String s = (String)itr.next(); String[] spl = s.Split( '\t' ); if ( spl.Length >= 2 ) { if ( spl[0].Equals( "EXPRESSIONDIR" ) ) { @@ -151,8 +175,8 @@ namespace Boare.Lib.Vsq { } else if ( spl.Length >= 3 ) { String[] spl2 = spl[0].Split( '\\' ); if ( spl2.Length == 1 ) { - if ( !exp_ids.Contains( spl2[0] ) ) { - exp_ids.Add( spl2[0] ); + if ( !exp_ids.contains( spl2[0] ) ) { + exp_ids.add( spl2[0] ); } } } @@ -181,7 +205,8 @@ namespace Boare.Lib.Vsq { Console.WriteLine( "path_voicedb=" + path_voicedb ); Console.WriteLine( "path_expdb=" + path_expdb ); Console.WriteLine( "installed_singers=" ); - foreach ( String s in installed_singers ) { + for( Iterator itr = installed_singers.iterator(); itr.hasNext(); ){ + String s = (String)itr.next(); Console.WriteLine( " " + s ); } #endif @@ -189,6 +214,10 @@ namespace Boare.Lib.Vsq { // レジストリkey内の値を再帰的に検索し、ファイルfpに順次出力する private static void print( RegistryKey key, String parent_name, Vector list ){ + if ( key == null ) { + return; + } + // 直下のキー内を再帰的にリストアップ String[] subkeys = key.GetSubKeyNames(); foreach( String s in subkeys ){ @@ -202,8 +231,8 @@ namespace Boare.Lib.Vsq { foreach( String s in valuenames ){ RegistryValueKind kind = key.GetValueKind( s ); if ( kind == RegistryValueKind.String ){ - String str = parent_name + "\t" + s + "\t" + (String)key.GetValue( s ); - list.Add( str ); + String str = parent_name + "\t" + s + "\t" + (String)key.GetValue( s, "" ); + list.add( str ); } } } @@ -214,7 +243,7 @@ namespace Boare.Lib.Vsq { /// /// public static String getOriginalSinger1( String singer ) { - string voiceidstr = ""; + String voiceidstr = ""; SingerConfig[] singer_configs = s_singer_config_sys1.getSingerConfigs(); for ( int i = 0; i < singer_configs.Length; i++ ) { if ( singer.Equals( singer_configs[i].VOICENAME ) ) { @@ -240,7 +269,7 @@ namespace Boare.Lib.Vsq { /// /// public static String getOriginalSinger2( String singer ) { - string voiceidstr = ""; + String voiceidstr = ""; SingerConfig[] singer_configs = s_singer_config_sys2.getSingerConfigs(); for ( int i = 0; i < singer_configs.Length; i++ ) { if ( singer.Equals( singer_configs[i].VOICENAME ) ) { @@ -297,7 +326,7 @@ namespace Boare.Lib.Vsq { /// /// name of singer /// - public static VsqVoiceLanguage getLanguageFromName( string name ) { + public static VsqVoiceLanguage getLanguageFromName( String name ) { switch ( name.ToLower() ) { case "meiko": case "kaito": @@ -342,19 +371,19 @@ namespace Boare.Lib.Vsq { } public static class VocaloSysUtil_ { - private static bool s_initialized = false; + private static boolean s_initialized = false; - private static string s_dll_path2 = ""; - private static string s_editor_path2 = ""; - private static string s_voicedbdir2 = ""; - private static List s_installed_singers2 = new List(); - private static List s_singer_configs2 = new List(); + private static String s_dll_path2 = ""; + private static String s_editor_path2 = ""; + private static String s_voicedbdir2 = ""; + private static Vector s_installed_singers2 = new Vector(); + private static Vector s_singer_configs2 = new Vector(); - private static string s_dll_path1 = ""; - private static string s_editor_path1 = ""; - private static string s_voicedbdir1 = ""; - private static List s_installed_singers1 = new List(); - private static List s_singer_configs1 = new List(); + private static String s_dll_path1 = ""; + private static String s_editor_path1 = ""; + private static String s_voicedbdir1 = ""; + private static Vector s_installed_singers1 = new Vector(); + private static Vector s_singer_configs1 = new Vector(); private const int MAX_SINGERS = 0x4000; @@ -368,19 +397,19 @@ namespace Boare.Lib.Vsq { /// /// /// - public static string getOriginalSinger1( string singer ) { - string voiceidstr = ""; - for ( int i = 0; i < s_singer_configs1.Count; i++ ) { - if ( singer == s_singer_configs1[i].VOICENAME ) { - voiceidstr = s_singer_configs1[i].VOICEIDSTR; + public static String getOriginalSinger1( String singer ) { + String voiceidstr = ""; + for ( int i = 0; i < s_singer_configs1.size(); i++ ) { + if ( singer.Equals( s_singer_configs1.get( i ).VOICENAME ) ) { + voiceidstr = s_singer_configs1.get( i ).VOICEIDSTR; } } - if ( voiceidstr == "" ) { + if ( voiceidstr.Equals( "" ) ) { return ""; } - for ( int i = 0; i < s_installed_singers1.Count; i++ ) { - if ( voiceidstr == s_installed_singers1[i].VOICEIDSTR ) { - return s_installed_singers1[i].VOICENAME; + for ( int i = 0; i < s_installed_singers1.size(); i++ ) { + if ( voiceidstr.Equals( s_installed_singers1.get( i ).VOICEIDSTR ) ) { + return s_installed_singers1.get( i ).VOICENAME; } } return ""; @@ -391,19 +420,19 @@ namespace Boare.Lib.Vsq { /// /// /// - public static string getOriginalSinger2( string singer ) { - string voiceidstr = ""; - for ( int i = 0; i < s_singer_configs2.Count; i++ ) { - if ( singer == s_singer_configs2[i].VOICENAME ) { - voiceidstr = s_singer_configs2[i].VOICEIDSTR; + public static String getOriginalSinger2( String singer ) { + String voiceidstr = ""; + for ( int i = 0; i < s_singer_configs2.size(); i++ ) { + if ( singer.Equals( s_singer_configs2.get( i ).VOICENAME ) ) { + voiceidstr = s_singer_configs2.get( i ).VOICEIDSTR; } } - if ( voiceidstr == "" ) { + if ( voiceidstr.Equals( "" ) ) { return ""; } - for ( int i = 0; i < s_installed_singers2.Count; i++ ) { - if ( voiceidstr == s_installed_singers2[i].VOICEIDSTR ) { - return s_installed_singers2[i].VOICENAME; + for ( int i = 0; i < s_installed_singers2.size(); i++ ) { + if ( voiceidstr.Equals( s_installed_singers2.get( i ).VOICEIDSTR ) ) { + return s_installed_singers2.get( i ).VOICENAME; } } return ""; @@ -414,7 +443,7 @@ namespace Boare.Lib.Vsq { /// /// name of singer /// - public static VsqVoiceLanguage getLanguageFromName( string name ) { + public static VsqVoiceLanguage getLanguageFromName( String name ) { switch ( name ) { case "MEIKO": case "KAITO": @@ -435,13 +464,13 @@ namespace Boare.Lib.Vsq { return VsqVoiceLanguage.Default; } - public static VsqID getSingerID1( string singer_name ) { + public static VsqID getSingerID1( String singer_name ) { VsqID ret = new VsqID( 0 ); ret.type = VsqIDType.Singer; SingerConfig sc = null; - for ( int i = 0; i < s_singer_configs1.Count; i++ ) { - if ( s_singer_configs1[i].VOICENAME == singer_name ) { - sc = s_singer_configs1[i]; + for ( int i = 0; i < s_singer_configs1.size(); i++ ) { + if ( s_singer_configs1.get( i ).VOICENAME.Equals( singer_name ) ) { + sc = s_singer_configs1.get( i ); break; } } @@ -449,8 +478,9 @@ namespace Boare.Lib.Vsq { sc = new SingerConfig(); } int lang = 0; - foreach ( SingerConfig sc2 in s_installed_singers1 ) { - if ( sc.VOICEIDSTR == sc2.VOICEIDSTR ) { + for ( Iterator itr = s_installed_singers1.iterator(); itr.hasNext(); ){ + SingerConfig sc2 = (SingerConfig)itr.next(); + if ( sc.VOICEIDSTR.Equals( sc2.VOICEIDSTR ) ) { lang = (int)getLanguageFromName( sc.VOICENAME ); break; } @@ -467,13 +497,13 @@ namespace Boare.Lib.Vsq { return ret; } - public static VsqID getSingerID2( string singer_name ) { + public static VsqID getSingerID2( String singer_name ) { VsqID ret = new VsqID( 0 ); ret.type = VsqIDType.Singer; SingerConfig sc = null; - for ( int i = 0; i < s_singer_configs2.Count; i++ ) { - if ( s_singer_configs2[i].VOICENAME == singer_name ) { - sc = s_singer_configs2[i]; + for ( int i = 0; i < s_singer_configs2.size(); i++ ) { + if ( s_singer_configs2.get( i ).VOICENAME.Equals( singer_name ) ) { + sc = s_singer_configs2.get( i ); break; } } @@ -481,8 +511,9 @@ namespace Boare.Lib.Vsq { sc = new SingerConfig(); } int lang = 0; - foreach ( SingerConfig sc2 in s_installed_singers2 ) { - if ( sc.VOICEIDSTR == sc2.VOICEIDSTR ) { + for ( Iterator itr = s_installed_singers2.iterator(); itr.hasNext(); ){ + SingerConfig sc2 = (SingerConfig)itr.next(); + if ( sc.VOICEIDSTR.Equals( sc2.VOICEIDSTR ) ) { lang = (int)getLanguageFromName( sc.VOICENAME ); break; } @@ -500,11 +531,11 @@ namespace Boare.Lib.Vsq { } public static SingerConfig[] getSingerConfigs1() { - return s_singer_configs1.ToArray(); + return s_singer_configs1.toArray( new SingerConfig[]{} ); } public static SingerConfig[] getSingerConfigs2() { - return s_singer_configs2.ToArray(); + return s_singer_configs2.toArray( new SingerConfig[]{} ); } public static double getAmplifyCoeffFromPanLeft( int pan ) { @@ -519,19 +550,19 @@ namespace Boare.Lib.Vsq { return Math.Exp( -1.26697245e-02 + 1.18448420e-01 * feder / 10.0 ); } - public static string getEditorPath2() { + public static String getEditorPath2() { return s_editor_path2; } - public static string getEditorPath1() { + public static String getEditorPath1() { return s_editor_path1; } - public static string getDllPathVsti2() { + public static String getDllPathVsti2() { return s_dll_path2; } - public static string getDllPathVsti1() { + public static String getDllPathVsti1() { return s_dll_path1; } @@ -543,11 +574,11 @@ namespace Boare.Lib.Vsq { RegistryKey v1application = null; v1application = Registry.LocalMachine.OpenSubKey( "SOFTWARE\\VOCALOID\\APPLICATION", false ); if ( v1application != null ) { - string[] keys = v1application.GetSubKeyNames(); + String[] keys = v1application.GetSubKeyNames(); for ( int i = 0; i < keys.Length; i++ ) { RegistryKey key = v1application.OpenSubKey( keys[i], false ); if ( key != null ) { - string name = (string)key.GetValue( "PATH" ); + String name = (String)key.GetValue( "PATH" ); if ( name.ToLower().EndsWith( "\\vocaloid.dll" ) ) { s_dll_path1 = name; } else if ( name.ToLower().EndsWith( "\\vocaloid.exe" ) ) { @@ -562,40 +593,40 @@ namespace Boare.Lib.Vsq { // voicedbdir for vocaloid1 RegistryKey v1database = Registry.LocalMachine.OpenSubKey( "SOFTWARE\\VOCALOID\\DATABASE\\VOICE", false ); if ( v1database != null ) { - s_voicedbdir1 = (string)v1database.GetValue( "VOICEDIR", "" ); + s_voicedbdir1 = (String)v1database.GetValue( "VOICEDIR", "" ); #if DEBUG Console.WriteLine( "s_voicedbdir1=" + s_voicedbdir1 ); #endif // インストールされている歌手のVOICEIDSTRを列挙 - string[] singer_voiceidstrs = v1database.GetSubKeyNames(); - List vvoice_keys = new List(); - List vvoice_values = new List(); - foreach ( string voiceidstr in singer_voiceidstrs ) { + String[] singer_voiceidstrs = v1database.GetSubKeyNames(); + Vector vvoice_keys = new Vector(); + Vector vvoice_values = new Vector(); + foreach ( String voiceidstr in singer_voiceidstrs ) { RegistryKey singer = v1database.OpenSubKey( voiceidstr ); if ( singer == null ) { continue; } RegistryKey vvoice = singer.OpenSubKey( "vvoice" ); if ( vvoice != null ) { - string[] vvoices = vvoice.GetValueNames(); + String[] vvoices = vvoice.GetValueNames(); // インストールされた歌手の.vvdを読みにいく // installdir以下の、拡張子.vvdのファイルを探す - foreach ( string file in Directory.GetFiles( Path.Combine( s_voicedbdir1, voiceidstr ), "*.vvd" ) ) { + foreach ( String file in Directory.GetFiles( Path.Combine( s_voicedbdir1, voiceidstr ), "*.vvd" ) ) { SingerConfig config = SingerConfig.fromVvd( file, 0 ); //とりあえずプログラムチェンジは0 - s_installed_singers1.Add( config ); + s_installed_singers1.add( config ); } // vvoice*.vvdを読みにいく。 - foreach ( string s in vvoices ) { + foreach ( String s in vvoices ) { #if DEBUG Console.WriteLine( "s=" + s ); #endif - string file = Path.Combine( s_voicedbdir1, s + ".vvd" ); + String file = Path.Combine( s_voicedbdir1, s + ".vvd" ); if ( File.Exists( file ) ) { SingerConfig config = SingerConfig.fromVvd( file, 0 ); - vvoice_keys.Add( s ); - vvoice_values.Add( config ); + vvoice_keys.add( s ); + vvoice_values.add( config ); } } } @@ -603,7 +634,7 @@ namespace Boare.Lib.Vsq { } // voice.mapを読み込んで、s_singer_configs1のプログラムチェンジを更新する - string map = Path.Combine( s_voicedbdir1, "voice.map" ); + String map = Path.Combine( s_voicedbdir1, "voice.map" ); if ( File.Exists( map ) ) { using ( FileStream fs = new FileStream( map, FileMode.Open, FileAccess.Read ) ) { byte[] dat = new byte[8]; @@ -615,9 +646,9 @@ namespace Boare.Lib.Vsq { #if DEBUG Console.WriteLine( "value=" + value ); #endif - for ( int j = 0; j < vvoice_keys.Count; j++ ) { - if ( vvoice_keys[j] == "vvoice" + value ) { - vvoice_values[j].Program = i; + for ( int j = 0; j < vvoice_keys.size(); j++ ) { + if ( vvoice_keys.get( j ).Equals( "vvoice" + value ) ) { + vvoice_values.get( j ).Program = i; } } } @@ -626,30 +657,32 @@ namespace Boare.Lib.Vsq { } // s_installed_singers1のSingerConfigのProgramとOriginalを適当に頒番する - for ( int i = 0; i < s_installed_singers1.Count; i++ ) { - s_installed_singers1[i].Program = i; - s_installed_singers1[i].Original = i; + for ( int i = 0; i < s_installed_singers1.size(); i++ ) { + s_installed_singers1.get( i ).Program = i; + s_installed_singers1.get( i ).Original = i; } // s_singer_configs1を更新 - for ( int i = 0; i < vvoice_values.Count; i++ ) { - for ( int j = 0; j < s_installed_singers1.Count; j++ ) { - if ( vvoice_values[i].VOICEIDSTR == s_installed_singers1[j].VOICEIDSTR ) { - vvoice_values[i].Original = s_installed_singers1[j].Program; + for ( int i = 0; i < vvoice_values.size(); i++ ) { + for ( int j = 0; j < s_installed_singers1.size(); j++ ) { + if ( vvoice_values.get( i ).VOICEIDSTR.Equals( s_installed_singers1.get( j ).VOICEIDSTR ) ) { + vvoice_values.get( i ).Original = s_installed_singers1.get( j ).Program; break; } } - s_singer_configs1.Add( vvoice_values[i] ); + s_singer_configs1.add( vvoice_values.get( i ) ); } v1database.Close(); } #if DEBUG Console.WriteLine( "installed" ); - foreach ( SingerConfig sc in s_installed_singers1 ) { + for ( Iterator itr = s_installed_singers1.iterator(); itr.hasNext(); ){ + SingerConfig sc = (SingerConfig)itr.next(); Console.WriteLine( "VOICENAME=" + sc.VOICENAME + "; VOICEIDSTR=" + sc.VOICEIDSTR + "; Program=" + sc.Program + "; Original=" + sc.Original ); } Console.WriteLine( "singer configs" ); - foreach ( SingerConfig sc in s_singer_configs1 ) { + for ( Iterator itr = s_singer_configs1.iterator(); itr.hasNext(); ){ + SingerConfig sc = (SingerConfig)itr.next(); Console.WriteLine( "VOICENAME=" + sc.VOICENAME + "; VOICEIDSTR=" + sc.VOICEIDSTR + "; Program=" + sc.Program + "; Original=" + sc.Original ); } #endif @@ -665,11 +698,11 @@ namespace Boare.Lib.Vsq { v2application = Registry.LocalMachine.OpenSubKey( "SOFTWARE\\VOCALOID2_DEMO\\APPLICATION", false ); } if ( v2application != null ) { - string[] keys = v2application.GetSubKeyNames(); + String[] keys = v2application.GetSubKeyNames(); for ( int i = 0; i < keys.Length; i++ ) { RegistryKey key = v2application.OpenSubKey( keys[i], false ); if ( key != null ) { - string name = (string)key.GetValue( "PATH" ); + String name = (String)key.GetValue( "PATH" ); if ( name.ToLower().EndsWith( "\\vocaloid2.dll" ) ) { s_dll_path2 = name; } else if ( name.ToLower().EndsWith( "\\vocaloid2_demo.dll" ) ) { @@ -687,38 +720,38 @@ namespace Boare.Lib.Vsq { RegistryKey v2database = Registry.LocalMachine.OpenSubKey( "SOFTWARE\\VOCALOID2\\DATABASE\\VOICE", false ); if ( v2database != null ) { // データベース(というよりもvoice.map)が保存されているパスを取得 - s_voicedbdir2 = (string)v2database.GetValue( "VOICEDIR", "" ); + s_voicedbdir2 = (String)v2database.GetValue( "VOICEDIR", "" ); // インストールされている歌手のVOICEIDSTRを列挙 - string[] singer_voiceidstrs = v2database.GetSubKeyNames(); - List vvoice_keys = new List(); - List vvoice_values = new List(); - foreach ( string voiceidstr in singer_voiceidstrs ) { + String[] singer_voiceidstrs = v2database.GetSubKeyNames(); + Vector vvoice_keys = new Vector(); + Vector vvoice_values = new Vector(); + foreach ( String voiceidstr in singer_voiceidstrs ) { RegistryKey singer = v2database.OpenSubKey( voiceidstr ); if ( singer == null ) { continue; } - string installdir = (string)singer.GetValue( "INSTALLDIR", "" ); + String installdir = (String)singer.GetValue( "INSTALLDIR", "" ); #if DEBUG Console.WriteLine( "installdir=" + installdir ); #endif RegistryKey vvoice = singer.OpenSubKey( "vvoice" ); if ( vvoice != null ) { - string[] vvoices = vvoice.GetValueNames(); + String[] vvoices = vvoice.GetValueNames(); // インストールされた歌手の.vvdを読みにいく // installdir以下の、拡張子.vvdのファイルを探す - foreach ( string file in Directory.GetFiles( Path.Combine( installdir, voiceidstr ), "*.vvd" ) ) { + foreach ( String file in Directory.GetFiles( Path.Combine( installdir, voiceidstr ), "*.vvd" ) ) { SingerConfig config = SingerConfig.fromVvd( file, 0 ); //とりあえずプログラムチェンジは0 - s_installed_singers2.Add( config ); + s_installed_singers2.add( config ); } // vvoice*.vvdを読みにいく。場所は、installdirではなく、s_voicedbdir2 - foreach ( string s in vvoices ) { - string file = Path.Combine( s_voicedbdir2, s + ".vvd" ); + foreach ( String s in vvoices ) { + String file = Path.Combine( s_voicedbdir2, s + ".vvd" ); if ( File.Exists( file ) ) { SingerConfig config = SingerConfig.fromVvd( file, 0 ); - vvoice_keys.Add( s ); - vvoice_values.Add( config ); + vvoice_keys.add( s ); + vvoice_values.add( config ); } } } @@ -726,7 +759,7 @@ namespace Boare.Lib.Vsq { } // voice.mapを読み込んで、s_singer_configs2のプログラムチェンジを更新する - string map = Path.Combine( s_voicedbdir2, "voice.map" ); + String map = Path.Combine( s_voicedbdir2, "voice.map" ); if ( File.Exists( map ) ) { using ( FileStream fs = new FileStream( map, FileMode.Open, FileAccess.Read ) ) { byte[] dat = new byte[8]; @@ -738,9 +771,9 @@ namespace Boare.Lib.Vsq { #if DEBUG Console.WriteLine( "value=" + value ); #endif - for ( int j = 0; j < vvoice_keys.Count; j++ ) { - if ( vvoice_keys[j] == "vvoice" + value ) { - vvoice_values[j].Program = i; + for ( int j = 0; j < vvoice_keys.size(); j++ ) { + if ( vvoice_keys.get( j ).Equals( "vvoice" + value ) ) { + vvoice_values.get( j ).Program = i; } } } @@ -749,30 +782,32 @@ namespace Boare.Lib.Vsq { } // s_installed_singers2のSingerConfigのProgramとOriginalを適当に頒番する - for ( int i = 0; i < s_installed_singers2.Count; i++ ) { - s_installed_singers2[i].Program = i; - s_installed_singers2[i].Original = i; + for ( int i = 0; i < s_installed_singers2.size(); i++ ) { + s_installed_singers2.get( i ).Program = i; + s_installed_singers2.get( i ).Original = i; } // s_singer_configs2を更新 - for ( int i = 0; i < vvoice_values.Count; i++ ) { - for ( int j = 0; j < s_installed_singers2.Count; j++ ) { - if ( vvoice_values[i].VOICEIDSTR == s_installed_singers2[j].VOICEIDSTR ) { - vvoice_values[i].Original = s_installed_singers2[j].Program; + for ( int i = 0; i < vvoice_values.size(); i++ ) { + for ( int j = 0; j < s_installed_singers2.size(); j++ ) { + if ( vvoice_values.get( i ).VOICEIDSTR.Equals( s_installed_singers2.get( j ).VOICEIDSTR ) ) { + vvoice_values.get( i ).Original = s_installed_singers2.get( j ).Program; break; } } - s_singer_configs2.Add( vvoice_values[i] ); + s_singer_configs2.add( vvoice_values.get( i ) ); } v2database.Close(); } #if DEBUG Console.WriteLine( "installed" ); - foreach ( SingerConfig sc in s_installed_singers2 ) { + for ( Iterator itr = s_installed_singers2.iterator(); itr.hasNext(); ){ + SingerConfig sc = (SingerConfig)itr.next(); Console.WriteLine( "VOICENAME=" + sc.VOICENAME + "; VOICEIDSTR=" + sc.VOICEIDSTR + "; Program=" + sc.Program + "; Original=" + sc.Original ); } Console.WriteLine( "singer configs" ); - foreach ( SingerConfig sc in s_singer_configs2 ) { + for ( Iterator itr = s_singer_configs2.iterator(); itr.hasNext(); ){ + SingerConfig sc = (SingerConfig)itr.next(); Console.WriteLine( "VOICENAME=" + sc.VOICENAME + "; VOICEIDSTR=" + sc.VOICEIDSTR + "; Program=" + sc.Program + "; Original=" + sc.Original ); } #endif diff --git a/trunk/Boare.Lib.Vsq/VsqBPList.cs b/trunk/Boare.Lib.Vsq/VsqBPList.cs index b0f1df8..3a85226 100644 --- a/trunk/Boare.Lib.Vsq/VsqBPList.cs +++ b/trunk/Boare.Lib.Vsq/VsqBPList.cs @@ -16,17 +16,21 @@ using System.Collections.Generic; using System.Text; using System.IO; +using bocoree; + namespace Boare.Lib.Vsq { + using boolean = System.Boolean; + /// /// BPListのデータ部分を取り扱うためのクラス。 /// [Serializable] public class VsqBPList : ICloneable { private SortedList m_list = new SortedList(); - public int Default = 0; - public int Maximum = 127; - public int Minimum = 0; + private int m_default = 0; + private int m_maximum = 127; + private int m_minimum = 0; /// /// このリストに設定されたidの最大値.次にデータ点が追加されたときは,個の値+1がidとして利用される.削除された場合でも減らない /// @@ -41,7 +45,7 @@ namespace Boare.Lib.Vsq { m_pos = -1; } - public bool hasNext() { + public boolean hasNext() { if ( m_pos + 1 < m_list.Keys.Count ) { return true; } else { @@ -66,12 +70,45 @@ namespace Boare.Lib.Vsq { : this( 0, 0, 64 ) { } + public int Default { + get { + return getDefault(); + } + set { + setDefault( value ); + } + } + + /// + /// このBPListのデフォルト値を取得します + /// + public int getDefault() { + return m_default; + } + + public void setDefault( int value ) { + m_default = value; + } + + /// + /// データ点のIDを一度クリアし,新たに番号付けを行います. + /// IDは,Redo,Undo用コマンドが使用するため,このメソッドを呼ぶとRedo,Undo操作が破綻する.XMLからのデシリアライズ直後のみ使用するべき. + /// + public void renumberIDs() { + m_max_id = 0; + for ( Iterator itr = keyClockIterator(); itr.hasNext(); ) { + VsqBPPair item = (VsqBPPair)itr.next(); + m_max_id++; + item.id = m_max_id; + } + } + /// /// XMLシリアライズ用 /// - public string Data { + public String Data { get { - string ret = ""; + String ret = ""; int count = -1; foreach ( int key in m_list.Keys ) { count++; @@ -82,9 +119,9 @@ namespace Boare.Lib.Vsq { set { m_list.Clear(); m_max_id = 0; - string[] spl = value.Split( ',' ); + String[] spl = value.Split( ',' ); for ( int i = 0; i < spl.Length; i++ ) { - string[] spl2 = spl[i].Split( '=' ); + String[] spl2 = spl[i].Split( '=' ); if ( spl2.Length < 2 ) { continue; } @@ -105,37 +142,68 @@ namespace Boare.Lib.Vsq { /// このVsqBPListの同一コピーを作成します /// /// - public object Clone() { - VsqBPList res = new VsqBPList( Default, Minimum, Maximum ); + public Object clone() { + VsqBPList res = new VsqBPList( getDefault(), getMinimum(), getMaximum() ); foreach ( int key in m_list.Keys ) { res.m_list.Add( key, m_list[key] ); } + res.m_max_id = m_max_id; return res; } + public object Clone() { + return clone(); + } + /// /// コンストラクタ。デフォルト値はココで指定する。 /// /// public VsqBPList( int default_value, int minimum, int maximum ) { - Default = default_value; - Maximum = maximum; - Minimum = minimum; + m_default = default_value; + m_maximum = maximum; + m_minimum = minimum; m_max_id = 0; } + public int Maximum { + get { + return getMaximum(); + } + set { + setMaximum( value ); + } + } + /// /// このリストに設定された最大値を取得します。 /// public int getMaximum() { - return Maximum; + return m_maximum; + } + + public void setMaximum( int value ){ + m_maximum = value; + } + + public int Minimum { + get { + return getMinimum(); + } + set { + setMinimum( value ); + } } /// /// このリストに設定された最小値を取得します /// public int getMinimum() { - return Minimum; + return m_minimum; + } + + public void setMinimum( int value ) { + m_minimum = value; } public Iterator keyClockIterator() { @@ -148,20 +216,40 @@ namespace Boare.Lib.Vsq { } } - public bool isContainsKey( int clock ) { + public boolean isContainsKey( int clock ) { return m_list.ContainsKey( clock ); } - public int getCount() { + public int size() { return m_list.Count; } public int[] getKeys() { - List t = new List(); + Vector t = new Vector(); foreach( int key in m_list.Keys ){ - t.Add( key ); + t.add( key ); } - return t.ToArray(); + return t.toArray( new Int32[]{} ); + } + + /// + /// 時刻clockのデータを時刻new_clockに移動します。 + /// 時刻clockにデータがなければ何もしない。 + /// 時刻new_clockに既にデータがある場合、既存のデータは削除される。 + /// + /// + /// + public void move( int clock, int new_clock, int new_value ) { + if ( !m_list.ContainsKey( clock ) ) { + return; + } + VsqBPPair item = m_list[clock]; + m_list.Remove( clock ); + if ( m_list.ContainsKey( new_clock ) ) { + m_list.Remove( new_clock ); + } + item.value = new_value; + m_list.Add( new_clock, item ); } public void clear() { @@ -170,42 +258,81 @@ namespace Boare.Lib.Vsq { /// /// 新しいデータ点を追加します。 + /// 戻り値に、新しいデータ点のIDを返します /// /// /// - public void add( int clock, int value ) { + /// + public long add( int clock, int value ) { lock ( m_list ) { if ( m_list.ContainsKey( clock ) ) { VsqBPPair v = m_list[clock]; v.value = value; m_list[clock] = v; + return v.id; } else { VsqBPPair v = new VsqBPPair( value, m_max_id + 1 ); m_max_id++; +#if DEBUG + //Console.WriteLine( "VsqBPList#add; m_max_id=" + m_max_id ); +#endif m_list.Add( clock, v ); + return m_max_id; } } } public int getElement( int index ) { + return getElementA( index ); + } + + public int getElementA( int index ) { return m_list[m_list.Keys[index]].value; } + public VsqBPPair getElementB( int index ) { + return m_list[m_list.Keys[index]]; + } + public int getKeyClock( int index ) { return m_list.Keys[index]; } - public int findValueFromID( int id ) { + public int findValueFromID( long id ) { int c = m_list.Keys.Count; foreach ( int key in m_list.Keys ) { if ( m_list[key].id == id ) { return m_list[key].value; } } - return Default; + return m_default; } - public void setValueForID( int id, int value ) { + /// + /// 指定したid値を持つVsqBPPairを検索し、その結果を返します。 + /// + /// + /// + public VsqBPPairSearchContext findElement( long id ) { + VsqBPPairSearchContext context = new VsqBPPairSearchContext(); + int c = m_list.Keys.Count; + for ( int i = 0; i < c; i++ ) { + int clock = m_list.Keys[i]; + VsqBPPair item = m_list[clock]; + if ( item.id == id ) { + context.clock = clock; + context.index = i; + context.point = item; + return context; + } + } + context.clock = -1; + context.index = -1; + context.point = new VsqBPPair( m_default, -1 ); + return context; + } + + public void setValueForID( long id, int value ) { int c = m_list.Keys.Count; foreach ( int key in m_list.Keys ) { if ( m_list[key].id == id ) { @@ -219,7 +346,7 @@ namespace Boare.Lib.Vsq { public int getValue( int clock, ref int index ) { if ( m_list.Count == 0 ) { - return Default; + return m_default; } else { if ( index < 0 ) { index = 0; @@ -232,7 +359,7 @@ namespace Boare.Lib.Vsq { return m_list[m_list.Keys[i - 1]].value; } else { index = i; - return Default; + return m_default; } } } @@ -243,7 +370,7 @@ namespace Boare.Lib.Vsq { public int getValue( int clock ) { if ( m_list.Count == 0 ) { - return Default; + return m_default; } else { for ( int i = 0; i < m_list.Keys.Count; i++ ) { int keyclock = m_list.Keys[i]; @@ -251,7 +378,7 @@ namespace Boare.Lib.Vsq { if ( i > 0 ) { return m_list[m_list.Keys[i - 1]].value; } else { - return Default; + return m_default; } } } @@ -259,19 +386,12 @@ namespace Boare.Lib.Vsq { } } - /// - /// このBPListのデフォルト値を取得します - /// - public int getDefault() { - return Default; - } - /// /// このBPListの内容をテキストファイルに書き出します /// /// public void print( StreamWriter writer ) { - bool first = true; + boolean first = true; foreach ( int key in m_list.Keys ) { int val = m_list[key].value; if ( first ) { @@ -287,8 +407,8 @@ namespace Boare.Lib.Vsq { /// このBPListの内容をテキストファイルに書き出します /// /// - public void print( TextMemoryStream writer, int start, string header ) { - bool first = true; + public void print( TextMemoryStream writer, int start, String header ) { + boolean first = true; foreach ( int key in m_list.Keys ) { if ( start <= key ) { if ( first ) { @@ -306,10 +426,10 @@ namespace Boare.Lib.Vsq { /// /// /// - public string appendFromText( TextMemoryStream reader ) { - string last_line = reader.readLine(); + public String appendFromText( TextMemoryStream reader ) { + String last_line = reader.readLine(); while ( !last_line.StartsWith( "[" ) ) { - string[] spl = last_line.Split( new char[] { '=' } ); + String[] spl = last_line.Split( new char[] { '=' } ); int i1 = int.Parse( spl[0] ); int i2 = int.Parse( spl[1] ); VsqBPPair v = new VsqBPPair( i2, m_max_id + 1 ); diff --git a/trunk/Boare.Lib.Vsq/VsqBPPair.cs b/trunk/Boare.Lib.Vsq/VsqBPPair.cs index 09bb261..5b039c5 100644 --- a/trunk/Boare.Lib.Vsq/VsqBPPair.cs +++ b/trunk/Boare.Lib.Vsq/VsqBPPair.cs @@ -1,12 +1,26 @@ -using System; +/* + * VsqBPPair.cs + * Copyright (c) 2009 kbinani + * + * This file is part of Boare.Lib.Vsq. + * + * Boare.Lib.Vsq is free software; you can redistribute it and/or + * modify it under the terms of the BSD License. + * + * Boare.Lib.Vsq is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + */ +using System; namespace Boare.Lib.Vsq { + [Serializable] public struct VsqBPPair { public int value; - public int id; + public long id; - public VsqBPPair( int value_, int id_ ) { + public VsqBPPair( int value_, long id_ ) { value = value_; id = id_; } diff --git a/trunk/Boare.Lib.Vsq/VsqBPPairSearchContext.cs b/trunk/Boare.Lib.Vsq/VsqBPPairSearchContext.cs new file mode 100644 index 0000000..081401e --- /dev/null +++ b/trunk/Boare.Lib.Vsq/VsqBPPairSearchContext.cs @@ -0,0 +1,9 @@ +namespace Boare.Lib.Vsq { + + public class VsqBPPairSearchContext { + public int clock; + public int index; + public VsqBPPair point; + } + +} diff --git a/trunk/Boare.Lib.Vsq/VsqBarLineType.cs b/trunk/Boare.Lib.Vsq/VsqBarLineType.cs index a4518f8..5e33612 100644 --- a/trunk/Boare.Lib.Vsq/VsqBarLineType.cs +++ b/trunk/Boare.Lib.Vsq/VsqBarLineType.cs @@ -15,9 +15,11 @@ using System; namespace Boare.Lib.Vsq { + using boolean = System.Boolean; + public struct VsqBarLineType { private int m_clock; - private bool m_is_separator; + private boolean m_is_separator; private int m_denominator; private int m_numerator; private int m_bar_count; @@ -38,11 +40,11 @@ namespace Boare.Lib.Vsq { return m_clock; } - public bool isSeparator() { + public boolean isSeparator() { return m_is_separator; } - public VsqBarLineType( int clock, bool is_separator, int denominator, int numerator, int bar_count ) { + public VsqBarLineType( int clock, boolean is_separator, int denominator, int numerator, int bar_count ) { m_clock = clock; m_is_separator = is_separator; m_denominator = denominator; diff --git a/trunk/Boare.Lib.Vsq/VsqCommand.cs b/trunk/Boare.Lib.Vsq/VsqCommand.cs index 1938fc6..61819a2 100644 --- a/trunk/Boare.Lib.Vsq/VsqCommand.cs +++ b/trunk/Boare.Lib.Vsq/VsqCommand.cs @@ -14,8 +14,14 @@ using System; using System.Collections.Generic; +using bocoree; + namespace Boare.Lib.Vsq { + using boolean = System.Boolean; + using Integer = System.Int32; + using Long = System.Int64; + /// /// /// @@ -29,7 +35,7 @@ namespace Boare.Lib.Vsq { /// /// 後続するコマンド /// - public List Children = new List(); + public Vector Children = new Vector(); /// /// このコマンドの親 /// @@ -43,7 +49,7 @@ namespace Boare.Lib.Vsq { public static VsqCommand generateCommandRoot() { VsqCommand command = new VsqCommand(); - command.Type = VsqCommandType.Root; + command.Type = VsqCommandType.ROOT; command.Args = null; return command; } @@ -51,14 +57,14 @@ namespace Boare.Lib.Vsq { public static VsqCommand generateCommandReplace( VsqFile vsq ) { VsqCommand command = new VsqCommand(); command.Args = new object[1]; - command.Type = VsqCommandType.Replace; + command.Type = VsqCommandType.REPLACE; command.Args[0] = (VsqFile)vsq.Clone(); return command; } public static VsqCommand generateCommandTrackReplace( int track, VsqTrack item ) { VsqCommand command = new VsqCommand(); - command.Type = VsqCommandType.TrackReplace; + command.Type = VsqCommandType.TRACK_REPLACE; command.Args = new object[2]; command.Args[0] = track; command.Args[1] = (VsqTrack)item.Clone(); @@ -67,7 +73,7 @@ namespace Boare.Lib.Vsq { public static VsqCommand generateCommandUpdateTimesig( int bar_count, int new_barcount, int numerator, int denominator ) { VsqCommand command = new VsqCommand(); - command.Type = VsqCommandType.UpdateTimesig; + command.Type = VsqCommandType.UPDATE_TIMESIG; command.Args = new object[4]; command.Args[0] = bar_count; command.Args[1] = numerator; @@ -78,7 +84,7 @@ namespace Boare.Lib.Vsq { public static VsqCommand generateCommandUpdateTimesigRange( int[] bar_counts, int[] new_barcounts, int[] numerators, int[] denominators ) { VsqCommand command = new VsqCommand(); - command.Type = VsqCommandType.UpdateTimesigRange; + command.Type = VsqCommandType.UPDATE_TIMESIG_RANGE; command.Args = new object[4]; command.Args[0] = (int[])bar_counts.Clone(); command.Args[1] = (int[])numerators.Clone(); @@ -89,7 +95,7 @@ namespace Boare.Lib.Vsq { public static VsqCommand generateCommandUpdateTempoRange( int[] clocks, int[] new_clocks, int[] tempos ) { VsqCommand command = new VsqCommand(); - command.Type = VsqCommandType.UpdateTempoRange; + command.Type = VsqCommandType.UPDATE_TEMPO_RANGE; command.Args = new object[3]; command.Args[0] = (int[])clocks.Clone(); command.Args[1] = (int[])tempos.Clone(); @@ -99,7 +105,7 @@ namespace Boare.Lib.Vsq { public static VsqCommand generateCommandUpdateTempo( int clock, int new_clock, int tempo ) { VsqCommand command = new VsqCommand(); - command.Type = VsqCommandType.UpdateTempo; + command.Type = VsqCommandType.UPDATE_TEMPO; command.Args = new object[3]; command.Args[0] = clock; command.Args[1] = tempo; @@ -109,7 +115,7 @@ namespace Boare.Lib.Vsq { public static VsqCommand generateCommandChangePreMeasure( int pre_measure ) { VsqCommand command = new VsqCommand(); - command.Type = VsqCommandType.ChangePreMeasure; + command.Type = VsqCommandType.CHANGE_PRE_MEASURE; command.Args = new object[1]; command.Args[0] = pre_measure; return command; @@ -117,7 +123,7 @@ namespace Boare.Lib.Vsq { public static VsqCommand generateCommandDeleteTrack( int track ) { VsqCommand command = new VsqCommand(); - command.Type = VsqCommandType.DeleteTrack; + command.Type = VsqCommandType.TRACK_DELETE; command.Args = new object[1]; command.Args[0] = track; return command; @@ -130,7 +136,7 @@ namespace Boare.Lib.Vsq { /// public static VsqCommand generateCommandAddTrack( VsqTrack track, VsqMixerEntry mixer, int position ) { VsqCommand command = new VsqCommand(); - command.Type = VsqCommandType.AddTrack; + command.Type = VsqCommandType.TRACK_ADD; command.Args = new object[5]; command.Args[0] = track; command.Args[1] = mixer; @@ -144,9 +150,9 @@ namespace Boare.Lib.Vsq { /// /// /// - public static VsqCommand generateCommandTrackChangeName( int track, string new_name ) { + public static VsqCommand generateCommandTrackChangeName( int track, String new_name ) { VsqCommand command = new VsqCommand(); - command.Type = VsqCommandType.TrackChangeName; + command.Type = VsqCommandType.TRACK_CHANGE_NAME; command.Args = new object[2]; command.Args[0] = track; command.Args[1] = new_name; @@ -155,7 +161,7 @@ namespace Boare.Lib.Vsq { public static VsqCommand generateCommandTrackChangePlayMode( int track, int play_mode ) { VsqCommand command = new VsqCommand(); - command.Type = VsqCommandType.TrackChangePlayMode; + command.Type = VsqCommandType.TRACK_CHANGE_PLAY_MODE; command.Args = new object[2]; command.Args[0] = track; command.Args[1] = play_mode; @@ -172,7 +178,7 @@ namespace Boare.Lib.Vsq { /// public static VsqCommand generateCommandEventChangeClockAndIDContaintsRange( int track, int[] internal_ids, int[] clocks, VsqID[] values ) { VsqCommand command = new VsqCommand(); - command.Type = VsqCommandType.EventChangeClockAndIDContaintsRange; + command.Type = VsqCommandType.EVENT_CHANGE_CLOCK_AND_ID_CONTAINTS_RANGE; int count = internal_ids.Length; command.Args = new object[4]; command.Args[0] = track; @@ -192,12 +198,12 @@ namespace Boare.Lib.Vsq { /// public static VsqCommand generateCommandEventChangeClockAndIDContaints( int track, int internal_id, int clock, VsqID value ) { VsqCommand command = new VsqCommand(); - command.Type = VsqCommandType.EventChangeClockAndIDContaints; + command.Type = VsqCommandType.EVENT_CHANGE_CLOCK_AND_ID_CONTAINTS; command.Args = new object[4]; command.Args[0] = track; command.Args[1] = internal_id; command.Args[2] = clock; - command.Args[3] = (VsqID)value.Clone(); + command.Args[3] = (VsqID)value.clone(); return command; } @@ -210,13 +216,13 @@ namespace Boare.Lib.Vsq { /// public static VsqCommand generateCommandEventChangeIDContaintsRange( int track, int[] internal_ids, VsqID[] values ) { VsqCommand command = new VsqCommand(); - command.Type = VsqCommandType.EventChangeIDContaintsRange; + command.Type = VsqCommandType.EVENT_CHANGE_ID_CONTAINTS_RANGE; command.Args = new object[3]; command.Args[0] = track; command.Args[1] = (int[])internal_ids.Clone(); VsqID[] list = new VsqID[values.Length]; for ( int i = 0; i < values.Length; i++ ) { - list[i] = (VsqID)values[i].Clone(); + list[i] = (VsqID)values[i].clone(); } command.Args[2] = list; return command; @@ -231,11 +237,11 @@ namespace Boare.Lib.Vsq { /// public static VsqCommand generateCommandEventChangeIDContaints( int track, int internal_id, VsqID value ) { VsqCommand command = new VsqCommand(); - command.Type = VsqCommandType.EventChangeIDContaints; + command.Type = VsqCommandType.EVENT_CHANGE_ID_CONTAINTS; command.Args = new object[3]; command.Args[0] = track; command.Args[1] = internal_id; - command.Args[2] = (VsqID)value.Clone(); + command.Args[2] = (VsqID)value.clone(); return command; } @@ -249,7 +255,7 @@ namespace Boare.Lib.Vsq { /// public static VsqCommand generateCommandEventChangeClockAndLength( int track, int internal_id, int new_clock, int new_length ) { VsqCommand command = new VsqCommand(); - command.Type = VsqCommandType.EventChangeClockAndLength; + command.Type = VsqCommandType.EVENT_CHANGE_CLOCK_AND_LENGTH; command.Args = new object[4]; command.Args[0] = track; command.Args[1] = internal_id; @@ -267,7 +273,7 @@ namespace Boare.Lib.Vsq { /// public static VsqCommand generateCommandEventChangeLength( int track, int internal_id, int new_length ) { VsqCommand command = new VsqCommand(); - command.Type = VsqCommandType.EventChangeLength; + command.Type = VsqCommandType.EVENT_CHANGE_LENGTH; command.Args = new object[3]; command.Args[0] = track; command.Args[1] = internal_id; @@ -282,14 +288,15 @@ namespace Boare.Lib.Vsq { /// /// /// - public static VsqCommand generateCommandEventChangeVelocity( int track, List> velocity ) { + public static VsqCommand generateCommandEventChangeVelocity( int track, Vector> velocity ) { VsqCommand command = new VsqCommand(); - command.Type = VsqCommandType.EventChangeVelocity; + command.Type = VsqCommandType.EVENT_CHANGE_VELOCITY; command.Args = new object[2]; command.Args[0] = track; - List> list = new List>(); - foreach ( KeyValuePair item in velocity ) { - list.Add( new KeyValuePair( item.Key, item.Value ) ); + Vector> list = new Vector>(); + for( Iterator itr = velocity.iterator(); itr.hasNext(); ){ + KeyValuePair item = (KeyValuePair)itr.next(); + list.add( new KeyValuePair( item.Key, item.Value ) ); } command.Args[1] = list; return command; @@ -297,21 +304,21 @@ namespace Boare.Lib.Vsq { public static VsqCommand generateCommandEventReplace( int track, VsqEvent item ) { VsqCommand command = new VsqCommand(); - command.Type = VsqCommandType.EventReplace; + command.Type = VsqCommandType.EVENT_REPLACE; command.Args = new object[2]; command.Args[0] = track; - command.Args[1] = item.Clone(); + command.Args[1] = item.clone(); return command; } public static VsqCommand generateCommandEventReplaceRange( int track, VsqEvent[] items ) { VsqCommand command = new VsqCommand(); - command.Type = VsqCommandType.EventReplaceRange; + command.Type = VsqCommandType.EVENT_REPLACE_RANGE; 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(); + objs[i] = (VsqEvent)items[i].clone(); } command.Args[1] = objs; return command; @@ -324,14 +331,15 @@ namespace Boare.Lib.Vsq { /// /// /// - public static VsqCommand generateCommandEventChangeAccent( int track, List> accent_list ) { + public static VsqCommand generateCommandEventChangeAccent( int track, Vector> accent_list ) { VsqCommand command = new VsqCommand(); - command.Type = VsqCommandType.EventChangeAccent; + command.Type = VsqCommandType.EVENT_CHANGE_ACCENT; command.Args = new object[2]; command.Args[0] = track; - List> list = new List>(); - foreach ( KeyValuePair item in accent_list ) { - list.Add( new KeyValuePair( item.Key, item.Value ) ); + Vector> list = new Vector>(); + for ( Iterator itr = accent_list.iterator(); itr.hasNext(); ){ + KeyValuePair item = (KeyValuePair)itr.next(); + list.add( new KeyValuePair( item.Key, item.Value ) ); } command.Args[1] = list; return command; @@ -344,19 +352,65 @@ namespace Boare.Lib.Vsq { /// /// /// - public static VsqCommand generateCommandEventChangeDecay( int track, List> decay_list ) { + public static VsqCommand generateCommandEventChangeDecay( int track, Vector> decay_list ) { VsqCommand command = new VsqCommand(); - command.Type = VsqCommandType.EventChangeDecay; + command.Type = VsqCommandType.EVENT_CHANGE_DECAY; command.Args = new object[2]; command.Args[0] = track; - List> list = new List>(); - foreach ( KeyValuePair item in decay_list ) { - list.Add( new KeyValuePair( item.Key, item.Value ) ); + Vector> list = new Vector>(); + for ( Iterator itr = decay_list.iterator(); itr.hasNext(); ){ + KeyValuePair item = (KeyValuePair)itr.next(); + list.add( new KeyValuePair( item.Key, item.Value ) ); } command.Args[1] = list; return command; } + public static VsqCommand generateCommandTrackCurveReplaceRange( int track, String[] target_curve, VsqBPList[] bplist ) { + VsqCommand command = new VsqCommand(); + command.Type = VsqCommandType.TRACK_CURVE_REPLACE_RANGE; + command.Args = new object[3]; + command.Args[0] = track; + String[] arr = new String[target_curve.Length]; + for ( int i = 0; i < target_curve.Length; i++ ) { + arr[i] = target_curve[i]; + } + command.Args[1] = arr; + VsqBPList[] cp = new VsqBPList[bplist.Length]; + for ( int i = 0; i < bplist.Length; i++ ) { + cp[i] = (VsqBPList)bplist[i].clone(); + } + command.Args[2] = cp; + return command; + } + + public static VsqCommand generateCommandTrackCurveReplace( int track, String target_curve, VsqBPList bplist ) { + VsqCommand command = new VsqCommand(); + command.Type = VsqCommandType.TRACK_CURVE_REPLACE; + command.Args = new object[3]; + command.Args[0] = track; + command.Args[1] = target_curve; + command.Args[2] = bplist.clone(); + return command; + } + + /*public static VsqCommand generateCommandTrackRemovePoints( int track, String target, Vector ids ) { + VsqCommand command = new VsqCommand(); + command.Type = VsqCommandType.TRACK_CURVE_REMOVE_POINTS; + command.Args = new object[3]; + command.Args[0] = track; + command.Args[1] = target; + Vector cpy = new Vector(); + if ( ids != null ){ + int count = ids.size(); + for ( int i = 0; i < count; i++ ) { + cpy.add( ids.get( i ) ); + } + } + command.Args[2] = cpy; + return command; + }*/ + /// /// vsqファイルのカーブを編集するコマンドを発行します. /// @@ -364,31 +418,33 @@ namespace Boare.Lib.Vsq { /// /// /// - public static VsqCommand generateCommandTrackEditCurve( int track, string target, List edit ) { + public static VsqCommand generateCommandTrackCurveEdit( int track, String target, Vector edit ) { VsqCommand command = new VsqCommand(); - command.Type = VsqCommandType.TrackEditCurve; + command.Type = VsqCommandType.TRACK_CURVE_EDIT; command.Args = new object[5]; command.Args[0] = track; command.Args[1] = target; - List copied = new List(); - foreach ( BPPair item in edit ) { - copied.Add( item ); + Vector copied = new Vector(); + for ( Iterator itr = edit.iterator(); itr.hasNext(); ){ + BPPair item = (BPPair)itr.next(); + copied.add( item ); } command.Args[2] = copied; return command; } - public static VsqCommand generateCommandTrackEditCurveRange( int track, string[] targets, List[] edits ) { + public static VsqCommand generateCommandTrackCurveEditRange( int track, String[] targets, Vector[] edits ) { VsqCommand command = new VsqCommand(); - command.Type = VsqCommandType.TrackEditCurveRange; + command.Type = VsqCommandType.TRACK_CURVE_EDIT_RANGE; command.Args = new object[3]; command.Args[0] = track; - command.Args[1] = (string[])targets.Clone(); - List[] cpy = new List[targets.Length]; + command.Args[1] = (String[])targets.Clone(); + Vector[] cpy = new Vector[targets.Length]; for ( int i = 0; i < edits.Length; i++ ) { - List copied = new List(); - foreach ( BPPair item in edits[i] ) { - copied.Add( new BPPair( item.Clock, item.Value ) ); + Vector copied = new Vector(); + for ( Iterator itr = edits[i].iterator(); itr.hasNext(); ){ + BPPair item = (BPPair)itr.next(); + copied.add( new BPPair( item.Clock, item.Value ) ); } cpy[i] = copied; } @@ -404,9 +460,9 @@ namespace Boare.Lib.Vsq { /// /// /// - public static VsqCommand generateCommandEventChangeLyric( int track, int internal_id, string phrase, string phonetic_symbol, bool protect_symbol ) { + public static VsqCommand generateCommandEventChangeLyric( int track, int internal_id, String phrase, String phonetic_symbol, boolean protect_symbol ) { VsqCommand command = new VsqCommand(); - command.Type = VsqCommandType.EventChangeLyric; + command.Type = VsqCommandType.EVENT_CHANGE_LYRIC; command.Args = new object[5]; command.Args[0] = track; command.Args[1] = internal_id; @@ -425,7 +481,7 @@ namespace Boare.Lib.Vsq { /// public static VsqCommand generateCommandEventChangeClock( int track, int internal_id, int value ) { VsqCommand command = new VsqCommand(); - command.Type = VsqCommandType.EventChangeClock; + command.Type = VsqCommandType.EVENT_CHANGE_CLOCK; command.Args = new object[3]; command.Args[0] = track; command.Args[1] = internal_id; @@ -435,7 +491,7 @@ namespace Boare.Lib.Vsq { public static VsqCommand generateCommandEventDeleteRange( int track, int[] internal_ids ) { VsqCommand command = new VsqCommand(); - command.Type = VsqCommandType.EventDeleteRange; + command.Type = VsqCommandType.EVENT_DELETE_RANGE; command.Args = new object[2]; command.Args[0] = (int[])internal_ids.Clone(); command.Args[1] = track; @@ -449,7 +505,7 @@ namespace Boare.Lib.Vsq { /// public static VsqCommand generateCommandEventDelete( int track, int internal_id ) { VsqCommand command = new VsqCommand(); - command.Type = VsqCommandType.EventDelete; + command.Type = VsqCommandType.EVENT_DELETE; command.Args = new object[2]; command.Args[1] = track; command.Args[0] = internal_id; @@ -458,7 +514,7 @@ namespace Boare.Lib.Vsq { public static VsqCommand generateCommandEventAddRange( int track, VsqEvent[] items ) { VsqCommand command = new VsqCommand(); - command.Type = VsqCommandType.EventAddRange; + command.Type = VsqCommandType.EVENT_ADD_RANGE; command.Args = new object[2]; command.Args[0] = track; command.Args[1] = (VsqEvent[])items.Clone(); @@ -473,10 +529,10 @@ namespace Boare.Lib.Vsq { /// public static VsqCommand generateCommandEventAdd( int track, VsqEvent item ) { VsqCommand command = new VsqCommand(); - command.Type = VsqCommandType.EventAdd; + command.Type = VsqCommandType.EVENT_ADD; command.Args = new object[2]; command.Args[0] = track; - command.Args[1] = (VsqEvent)item.Clone(); + command.Args[1] = (VsqEvent)item.clone(); return command; } @@ -489,7 +545,7 @@ namespace Boare.Lib.Vsq { /// public static VsqCommand generateCommandEventChangeNote( int track, int internal_id, int note ) { VsqCommand command = new VsqCommand(); - command.Type = VsqCommandType.EventChangeNote; + command.Type = VsqCommandType.EVENT_CHANGE_NOTE; command.Args = new object[3]; command.Args[0] = track; command.Args[1] = internal_id; @@ -506,7 +562,7 @@ namespace Boare.Lib.Vsq { /// public static VsqCommand generateCommandEventChangeClockAndNote( int track, int internal_id, int clock, int note ) { VsqCommand command = new VsqCommand(); - command.Type = VsqCommandType.EventChangeClockAndNote; + command.Type = VsqCommandType.EVENT_CHANGE_CLOCK_AND_NOTE; command.Args = new object[4]; command.Args[0] = track; command.Args[1] = internal_id; diff --git a/trunk/Boare.Lib.Vsq/VsqCommandType.cs b/trunk/Boare.Lib.Vsq/VsqCommandType.cs index 2ba70e0..14c6109 100644 --- a/trunk/Boare.Lib.Vsq/VsqCommandType.cs +++ b/trunk/Boare.Lib.Vsq/VsqCommandType.cs @@ -14,39 +14,42 @@ namespace Boare.Lib.Vsq { public enum VsqCommandType { - Root, - ChangePreMeasure, - EventAdd, - EventDelete, - EventChangeClock, - EventChangeLyric, - EventChangeNote, - EventChangeClockAndNote, - TrackEditCurve, - TrackEditCurveRange, - EventChangeVelocity, - EventChangeAccent, - EventChangeDecay, - EventChangeLength, - EventChangeClockAndLength, - EventChangeIDContaints, - EventChangeClockAndIDContaints, - TrackChangeName, - AddTrack, - DeleteTrack, - EventChangeClockAndIDContaintsRange, - EventDeleteRange, - EventAddRange, - UpdateTempo, - UpdateTempoRange, - UpdateTimesig, - UpdateTimesigRange, - EventChangeIDContaintsRange, - TrackReplace, - Replace, - TrackChangePlayMode, - EventReplace, - EventReplaceRange, + ROOT, + CHANGE_PRE_MEASURE, + EVENT_ADD, + EVENT_DELETE, + EVENT_CHANGE_CLOCK, + EVENT_CHANGE_LYRIC, + EVENT_CHANGE_NOTE, + EVENT_CHANGE_CLOCK_AND_NOTE, + TRACK_CURVE_EDIT, + TRACK_CURVE_EDIT_RANGE, + //TRACK_CURVE_REMOVE_POINTS, + TRACK_CURVE_REPLACE, + TRACK_CURVE_REPLACE_RANGE, + EVENT_CHANGE_VELOCITY, + EVENT_CHANGE_ACCENT, + EVENT_CHANGE_DECAY, + EVENT_CHANGE_LENGTH, + EVENT_CHANGE_CLOCK_AND_LENGTH, + EVENT_CHANGE_ID_CONTAINTS, + EVENT_CHANGE_CLOCK_AND_ID_CONTAINTS, + TRACK_CHANGE_NAME, + TRACK_ADD, + TRACK_DELETE, + EVENT_CHANGE_CLOCK_AND_ID_CONTAINTS_RANGE, + EVENT_DELETE_RANGE, + EVENT_ADD_RANGE, + UPDATE_TEMPO, + UPDATE_TEMPO_RANGE, + UPDATE_TIMESIG, + UPDATE_TIMESIG_RANGE, + EVENT_CHANGE_ID_CONTAINTS_RANGE, + TRACK_REPLACE, + REPLACE, + TRACK_CHANGE_PLAY_MODE, + EVENT_REPLACE, + EVENT_REPLACE_RANGE, } } diff --git a/trunk/Boare.Lib.Vsq/VsqEvent.cs b/trunk/Boare.Lib.Vsq/VsqEvent.cs index a2416dc..420538e 100644 --- a/trunk/Boare.Lib.Vsq/VsqEvent.cs +++ b/trunk/Boare.Lib.Vsq/VsqEvent.cs @@ -13,6 +13,8 @@ */ using System; +using bocoree; + namespace Boare.Lib.Vsq { /// @@ -20,7 +22,7 @@ namespace Boare.Lib.Vsq { /// [Serializable] public class VsqEvent : IComparable, ICloneable { - public string Tag; + public String Tag; /// /// 内部で使用するインスタンス固有のID /// @@ -33,8 +35,8 @@ namespace Boare.Lib.Vsq { /// このオブジェクトのコピーを作成します /// /// - public object Clone() { - VsqEvent ret = new VsqEvent( Clock, (VsqID)ID.Clone() ); + public Object clone() { + VsqEvent ret = new VsqEvent( Clock, (VsqID)ID.clone() ); ret.InternalID = InternalID; if ( UstEvent != null ) { ret.UstEvent = (UstEvent)UstEvent.Clone(); @@ -43,6 +45,10 @@ namespace Boare.Lib.Vsq { return ret; } + public object Clone() { + return clone(); + } + public int CompareTo( VsqEvent item ) { int ret = this.Clock - item.Clock; if ( ret == 0 ) { @@ -56,10 +62,10 @@ namespace Boare.Lib.Vsq { } } - public VsqEvent( string line ) { - string[] spl = line.Split( new char[] { '=' } ); + public VsqEvent( String line ) { + String[] spl = line.Split( new char[] { '=' } ); Clock = int.Parse( spl[0] ); - if ( spl[1] == "EOS" ) { + if ( spl[1].Equals( "EOS" ) ) { ID = VsqID.EOS; } } diff --git a/trunk/Boare.Lib.Vsq/VsqEventList.cs b/trunk/Boare.Lib.Vsq/VsqEventList.cs index 731dcc9..35eb31a 100644 --- a/trunk/Boare.Lib.Vsq/VsqEventList.cs +++ b/trunk/Boare.Lib.Vsq/VsqEventList.cs @@ -14,6 +14,8 @@ using System; using System.Collections.Generic; +using bocoree; + namespace Boare.Lib.Vsq { /// @@ -21,19 +23,20 @@ namespace Boare.Lib.Vsq { /// [Serializable] public class VsqEventList { - public List Events; - private List m_ids; + public Vector Events; + private Vector m_ids; /// /// コンストラクタ /// public VsqEventList() { - Events = new List(); - m_ids = new List(); + Events = new Vector(); + m_ids = new Vector(); } public VsqEvent findFromID( int internal_id ) { - foreach ( VsqEvent item in Events ) { + for ( Iterator itr = Events.iterator(); itr.hasNext(); ){ + VsqEvent item = (VsqEvent)itr.next(); if ( item.InternalID == internal_id ) { return item; } @@ -42,10 +45,10 @@ namespace Boare.Lib.Vsq { } public void setForID( int internal_id, VsqEvent value ) { - int c = Events.Count; + int c = Events.size(); for ( int i = 0; i < c; i++ ) { - if ( Events[i].InternalID == internal_id ) { - Events[i] = value; + if ( Events.get( i ).InternalID == internal_id ) { + Events.set( i, value ); break; } } @@ -53,14 +56,14 @@ namespace Boare.Lib.Vsq { public void sort() { lock ( this ) { - Events.Sort(); + Collections.sort( Events ); updateIDList(); } } public void clear() { - Events.Clear(); - m_ids.Clear(); + Events.clear(); + m_ids.clear(); } public Iterator iterator() { @@ -72,59 +75,59 @@ namespace Boare.Lib.Vsq { updateIDList(); int new_id = getNextId( 0 ); item.InternalID = new_id; - Events.Add( item ); - m_ids.Add( new_id ); - Events.Sort(); - for ( int i = 0; i < Events.Count; i++ ) { - m_ids[i] = Events[i].InternalID; + Events.add( item ); + m_ids.add( new_id ); + Collections.sort( Events ); + for ( int i = 0; i < Events.size(); i++ ) { + m_ids.set( i, Events.get( i ).InternalID ); } } public void removeAt( int index ) { updateIDList(); - Events.RemoveAt( index ); - m_ids.RemoveAt( index ); + Events.removeElementAt( index ); + m_ids.removeElementAt( index ); } private int getNextId( int next ) { updateIDList(); int index = -1; - List current = new List( m_ids ); + Vector current = new Vector( m_ids ); int nfound = 0; while ( true ) { index++; - if ( !current.Contains( index ) ) { + if ( !current.contains( index ) ) { nfound++; if ( nfound == next + 1 ) { return index; } else { - current.Add( index ); + current.add( index ); } } } } public int getCount() { - return Events.Count; + return Events.size(); } public VsqEvent getElement( int index ) { - return Events[index]; + return Events.get( index ); } public void setElement( int index, VsqEvent value ) { - Events[index] = value; + Events.set( 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 ); + if ( m_ids.size() != Events.size() ) { + m_ids.clear(); + for ( int i = 0; i < Events.size(); i++ ) { + m_ids.add( Events.get( i ).InternalID ); } } else { - for ( int i = 0; i < Events.Count; i++ ) { - m_ids[i] = Events[i].InternalID; + for ( int i = 0; i < Events.size(); i++ ) { + m_ids.set( i, Events.get( i ).InternalID ); } } } diff --git a/trunk/Boare.Lib.Vsq/VsqFile.cs b/trunk/Boare.Lib.Vsq/VsqFile.cs index 8b0bb07..eb49640 100644 --- a/trunk/Boare.Lib.Vsq/VsqFile.cs +++ b/trunk/Boare.Lib.Vsq/VsqFile.cs @@ -14,9 +14,16 @@ using System; using System.Collections.Generic; using System.IO; +using System.Text; + +using bocoree; namespace Boare.Lib.Vsq { + using boolean = System.Boolean; + using Integer = Int32; + using Long = Int64; + /// /// VSQファイルの内容を保持するクラス /// @@ -25,16 +32,16 @@ namespace Boare.Lib.Vsq { /// /// トラックのリスト.最初のトラックはMasterTrackであり,通常の音符が格納されるトラックはインデックス1以降となる /// - public List Track; + public Vector Track; /// /// テンポ情報を保持したテーブル /// #if USE_TEMPO_LIST protected TempoTable m_tempo_table; #else - public List TempoTable; + public Vector TempoTable; #endif - public List TimesigTable; + public Vector TimesigTable; protected int m_tpq; /// /// 曲の長さを取得します。(クロック(4分音符は480クロック)) @@ -43,13 +50,33 @@ namespace Boare.Lib.Vsq { protected int m_base_tempo; public VsqMaster Master; // VsqMaster, VsqMixerは通常,最初の非Master Trackに記述されるが,可搬性のため, public VsqMixer Mixer; // ここではVsqFileに直属するものとして取り扱う. - //protected int m_premeasure_clocks; public object Tag; static readonly byte[] _MTRK = new byte[] { 0x4d, 0x54, 0x72, 0x6b }; static readonly byte[] _MTHD = new byte[] { 0x4d, 0x54, 0x68, 0x64 }; static readonly byte[] _MASTER_TRACK = new byte[] { 0x4D, 0x61, 0x73, 0x74, 0x65, 0x72, 0x20, 0x54, 0x72, 0x61, 0x63, 0x6B, }; - static readonly string[] _CURVES = new string[] { "VEL", "DYN", "BRE", "BRI", "CLE", "OPE", "GEN", "POR", "PIT", "PBS" }; + static readonly String[] _CURVES = new String[] { "VEL", "DYN", "BRE", "BRI", "CLE", "OPE", "GEN", "POR", "PIT", "PBS" }; + + /// + /// プリセンドタイムの妥当性を判定します + /// + /// + /// + public bool checkPreSendTimeValidity( int ms_pre_send_time ) { + int track_count = Track.size(); + for ( int i = 1; i < track_count; i++ ) { + VsqTrack track = Track.get( i ); + for ( Iterator itr = track.getNoteEventIterator(); itr.hasNext(); ) { + VsqEvent item = (VsqEvent)itr.next(); + int presend_clock = getPresendClockAt( item.Clock, ms_pre_send_time ); + if ( item.Clock - presend_clock < 0 ) { + return false; + } + break; + } + } + return true; + } /// /// テンポ値を一律order倍します。 @@ -57,9 +84,9 @@ namespace Boare.Lib.Vsq { /// public void speedingUp( double order ) { lock ( TempoTable ) { - int c = TempoTable.Count; + int c = TempoTable.size(); for ( int i = 0; i < c; i++ ) { - TempoTable[i].Tempo = (int)(TempoTable[i].Tempo / order); + TempoTable.get( i ).Tempo = (int)(TempoTable.get( i ).Tempo / order); } } updateTempoInfo(); @@ -76,7 +103,7 @@ namespace Boare.Lib.Vsq { Console.WriteLine( " type=" + command.Type ); #endif VsqCommandType type = command.Type; - if ( type == VsqCommandType.ChangePreMeasure ) { + if ( type == VsqCommandType.CHANGE_PRE_MEASURE ) { #region ChangePreMeasure VsqCommand ret = VsqCommand.generateCommandChangePreMeasure( Master.PreMeasure ); int value = (int)command.Args[0]; @@ -84,7 +111,7 @@ namespace Boare.Lib.Vsq { updateTimesigInfo(); return ret; #endregion - } else if ( type == VsqCommandType.AddTrack ) { + } else if ( type == VsqCommandType.TRACK_ADD ) { #region AddTrack #if DEBUG System.Diagnostics.Debug.WriteLine( " AddTrack" ); @@ -93,33 +120,33 @@ namespace Boare.Lib.Vsq { VsqMixerEntry mixer = (VsqMixerEntry)command.Args[1]; int position = (int)command.Args[2]; VsqCommand ret = VsqCommand.generateCommandDeleteTrack( position ); - if ( Track.Count <= 17 ) { - Track.Insert( position, (VsqTrack)track.Clone() ); - Mixer.Slave.Add( (VsqMixerEntry)mixer.Clone() ); + if ( Track.size() <= 17 ) { + Track.insertElementAt( (VsqTrack)track.Clone(), position ); + Mixer.Slave.add( (VsqMixerEntry)mixer.Clone() ); return ret; } else { return null; } #endregion - } else if ( type == VsqCommandType.DeleteTrack ) { + } else if ( type == VsqCommandType.TRACK_DELETE ) { #region DeleteTrack int track = (int)command.Args[0]; - VsqCommand ret = VsqCommand.generateCommandAddTrack( Track[track], Mixer.Slave[track - 1], track ); - Track.RemoveAt( track ); - Mixer.Slave.RemoveAt( track - 1 ); + VsqCommand ret = VsqCommand.generateCommandAddTrack( Track.get( track ), Mixer.Slave.get( track - 1 ), track ); + Track.removeElementAt( track ); + Mixer.Slave.removeElementAt( track - 1 ); updateTotalClocks(); return ret; #endregion - } else if ( type == VsqCommandType.UpdateTempo ) { + } else if ( type == VsqCommandType.UPDATE_TEMPO ) { #region UpdateTempo int clock = (int)command.Args[0]; int tempo = (int)command.Args[1]; int new_clock = (int)command.Args[2]; int index = -1; - int c = TempoTable.Count; + int c = TempoTable.size(); for ( int i = 0; i < c; i++ ) { - if ( TempoTable[i].Clock == clock ) { + if ( TempoTable.get( i ).Clock == clock ) { index = i; break; } @@ -127,32 +154,32 @@ namespace Boare.Lib.Vsq { VsqCommand ret = null; if ( index >= 0 ) { if ( tempo <= 0 ) { - ret = VsqCommand.generateCommandUpdateTempo( clock, clock, TempoTable[index].Tempo ); - TempoTable.RemoveAt( index ); + ret = VsqCommand.generateCommandUpdateTempo( clock, clock, TempoTable.get( index ).Tempo ); + TempoTable.removeElementAt( index ); } else { - ret = VsqCommand.generateCommandUpdateTempo( new_clock, clock, TempoTable[index].Tempo ); - TempoTable[index].Tempo= tempo ; - TempoTable[index].Clock= new_clock ; + ret = VsqCommand.generateCommandUpdateTempo( new_clock, clock, TempoTable.get( index ).Tempo ); + TempoTable.get( index ).Tempo= tempo ; + TempoTable.get( index ).Clock= new_clock ; } } else { ret = VsqCommand.generateCommandUpdateTempo( clock, clock, -1 ); - TempoTable.Add( new TempoTableEntry( new_clock, tempo, 0.0 ) ); + TempoTable.add( new TempoTableEntry( new_clock, tempo, 0.0 ) ); } updateTempoInfo(); updateTotalClocks(); // 編集領域を更新 int affected_clock = Math.Min( clock, new_clock ); - c = Track.Count; + c = Track.size(); for ( int i = 1; i < c; i++ ) { - if ( affected_clock < Track[i].getEditedStart() ) { - Track[i].setEditedStart( affected_clock ); + if ( affected_clock < Track.get( i ).getEditedStart() ) { + Track.get( i ).setEditedStart( affected_clock ); } - Track[i].setEditedEnd( (int)TotalClocks ); + Track.get( i ).setEditedEnd( (int)TotalClocks ); } return ret; #endregion - } else if ( type == VsqCommandType.UpdateTempoRange ) { + } else if ( type == VsqCommandType.UPDATE_TEMPO_RANGE ) { #region UpdateTempoRange int[] clocks = (int[])command.Args[0]; int[] tempos = (int[])command.Args[1]; @@ -163,47 +190,47 @@ namespace Boare.Lib.Vsq { int index = -1; affected_clock = Math.Min( affected_clock, clocks[i] ); affected_clock = Math.Min( affected_clock, new_clocks[i] ); - int tempo_table_count = TempoTable.Count; + int tempo_table_count = TempoTable.size(); for ( int j = 0; j < tempo_table_count; j++ ) { - if ( TempoTable[j].Clock == clocks[i] ) { + if ( TempoTable.get( j ).Clock == clocks[i] ) { index = j; break; } } if ( index >= 0 ) { - new_tempos[i] = TempoTable[index].Tempo; + new_tempos[i] = TempoTable.get( index ).Tempo; if ( tempos[i] <= 0 ) { - TempoTable.RemoveAt( index ); + TempoTable.removeElementAt( index ); } else { - TempoTable[index].Tempo = tempos[i]; - TempoTable[index].Clock = new_clocks[i]; + TempoTable.get( index ).Tempo = tempos[i]; + TempoTable.get( index ).Clock = new_clocks[i]; } } else { new_tempos[i] = -1; - TempoTable.Add( new TempoTableEntry( new_clocks[i], tempos[i], 0.0 ) ); + TempoTable.add( new TempoTableEntry( new_clocks[i], tempos[i], 0.0 ) ); } } updateTempoInfo(); updateTotalClocks(); - int track_count = Track.Count; + int track_count = Track.size(); for ( int i = 1; i < track_count; i++ ) { - if ( affected_clock < Track[i].getEditedStart() ) { - Track[i].setEditedStart( affected_clock ); + if ( affected_clock < Track.get( i ).getEditedStart() ) { + Track.get( i ).setEditedStart( affected_clock ); } - Track[i].setEditedEnd( (int)TotalClocks ); + Track.get( i ).setEditedEnd( (int)TotalClocks ); } return VsqCommand.generateCommandUpdateTempoRange( new_clocks, clocks, new_tempos ); #endregion - } else if ( type == VsqCommandType.UpdateTimesig ) { + } else if ( type == VsqCommandType.UPDATE_TIMESIG ) { #region UpdateTimesig int barcount = (int)command.Args[0]; int numerator = (int)command.Args[1]; int denominator = (int)command.Args[2]; int new_barcount = (int)command.Args[3]; int index = -1; - int timesig_table_count = TimesigTable.Count; + int timesig_table_count = TimesigTable.size(); for ( int i = 0; i < timesig_table_count; i++ ) { - if ( barcount == TimesigTable[i].BarCount ) { + if ( barcount == TimesigTable.get( i ).BarCount ) { index = i; break; } @@ -211,23 +238,23 @@ namespace Boare.Lib.Vsq { VsqCommand ret = null; if ( index >= 0 ) { if ( numerator <= 0 ) { - ret = VsqCommand.generateCommandUpdateTimesig( barcount, barcount, TimesigTable[index].Numerator, TimesigTable[index].Denominator ); - TimesigTable.RemoveAt( index ); + ret = VsqCommand.generateCommandUpdateTimesig( barcount, barcount, TimesigTable.get( index ).Numerator, TimesigTable.get( index ).Denominator ); + TimesigTable.removeElementAt( index ); } else { - ret = VsqCommand.generateCommandUpdateTimesig( new_barcount, barcount, TimesigTable[index].Numerator, TimesigTable[index].Denominator ); - TimesigTable[index].BarCount = new_barcount; - TimesigTable[index].Numerator = numerator; - TimesigTable[index].Denominator = denominator; + ret = VsqCommand.generateCommandUpdateTimesig( new_barcount, barcount, TimesigTable.get( index ).Numerator, TimesigTable.get( index ).Denominator ); + TimesigTable.get( index ).BarCount = new_barcount; + TimesigTable.get( index ).Numerator = numerator; + TimesigTable.get( index ).Denominator = denominator; } } else { ret = VsqCommand.generateCommandUpdateTimesig( new_barcount, new_barcount, -1, -1 ); - TimesigTable.Add( new TimeSigTableEntry( 0, numerator, denominator, new_barcount ) ); + TimesigTable.add( new TimeSigTableEntry( 0, numerator, denominator, new_barcount ) ); } updateTimesigInfo(); updateTotalClocks(); return ret; #endregion - } else if ( type == VsqCommandType.UpdateTimesigRange ) { + } else if ( type == VsqCommandType.UPDATE_TIMESIG_RANGE ) { #region UpdateTimesigRange int[] barcounts = (int[])command.Args[0]; int[] numerators = (int[])command.Args[1]; @@ -238,57 +265,57 @@ namespace Boare.Lib.Vsq { for ( int i = 0; i < barcounts.Length; i++ ) { int index = -1; // すでに拍子が登録されているかどうかを検査 - int timesig_table_count = TimesigTable.Count; + int timesig_table_count = TimesigTable.size(); for ( int j = 0; j < timesig_table_count; j++ ) { - if ( TimesigTable[j].BarCount == barcounts[i] ) { + if ( TimesigTable.get( j ).BarCount == barcounts[i] ) { index = j; break; } } if ( index >= 0 ) { // 登録されている場合 - new_numerators[i] = TimesigTable[index].Numerator; - new_denominators[i] = TimesigTable[index].Denominator; + new_numerators[i] = TimesigTable.get( index ).Numerator; + new_denominators[i] = TimesigTable.get( index ).Denominator; if ( numerators[i] <= 0 ) { - TimesigTable.RemoveAt( index ); + TimesigTable.removeElementAt( index ); } else { - TimesigTable[index].BarCount = new_barcounts[i]; - TimesigTable[index].Numerator = numerators[i]; - TimesigTable[index].Denominator = denominators[i]; + TimesigTable.get( index ).BarCount = new_barcounts[i]; + TimesigTable.get( index ).Numerator = numerators[i]; + TimesigTable.get( index ).Denominator = denominators[i]; } } else { // 登録されていない場合 new_numerators[i] = -1; new_denominators[i] = -1; - TimesigTable.Add( new TimeSigTableEntry( 0, numerators[i], denominators[i], new_barcounts[i] ) ); + TimesigTable.add( new TimeSigTableEntry( 0, numerators[i], denominators[i], new_barcounts[i] ) ); } } updateTimesigInfo(); updateTotalClocks(); return VsqCommand.generateCommandUpdateTimesigRange( new_barcounts, barcounts, new_numerators, new_denominators ); #endregion - } else if ( type == VsqCommandType.Replace ) { + } else if ( type == VsqCommandType.REPLACE ) { #region Replace VsqFile vsq = (VsqFile)command.Args[0]; VsqFile inv = (VsqFile)this.Clone(); - Track.Clear(); - int track_count = vsq.Track.Count; + Track.clear(); + int track_count = vsq.Track.size(); for ( int i = 0; i < track_count; i++ ) { - Track.Add( (VsqTrack)vsq.Track[i].Clone() ); + Track.add( (VsqTrack)vsq.Track.get( i ).Clone() ); } #if USE_TEMPO_LIST m_tempo_table = (TempoTable)vsq.m_tempo_table.Clone(); #else - TempoTable.Clear(); - int tempo_table_count = vsq.TempoTable.Count; + TempoTable.clear(); + int tempo_table_count = vsq.TempoTable.size(); for ( int i = 0; i < tempo_table_count; i++ ) { - TempoTable.Add( (TempoTableEntry)vsq.TempoTable[i].Clone() ); + TempoTable.add( (TempoTableEntry)vsq.TempoTable.get( i ).Clone() ); } #endif - TimesigTable.Clear(); - int timesig_table_count = vsq.TimesigTable.Count; + TimesigTable.clear(); + int timesig_table_count = vsq.TimesigTable.size(); for ( int i = 0; i < timesig_table_count; i++ ) { - TimesigTable.Add( (TimeSigTableEntry)vsq.TimesigTable[i].Clone() ); + TimesigTable.add( (TimeSigTableEntry)vsq.TimesigTable.get( i ).Clone() ); } m_tpq = vsq.m_tpq; TotalClocks = vsq.TotalClocks; @@ -298,65 +325,65 @@ namespace Boare.Lib.Vsq { updateTotalClocks(); return VsqCommand.generateCommandReplace( inv ); #endregion - } else if ( type == VsqCommandType.EventAdd ) { + } else if ( type == VsqCommandType.EVENT_ADD ) { #region EventAdd int track = (int)command.Args[0]; VsqEvent item = (VsqEvent)command.Args[1]; - Track[track].addEvent( item ); + Track.get( track ).addEvent( item ); VsqCommand ret = VsqCommand.generateCommandEventDelete( track, item.InternalID ); updateTotalClocks(); - if ( item.Clock < Track[track].getEditedStart() ) { - Track[track].setEditedStart( item.Clock ); + if ( item.Clock < Track.get( track ).getEditedStart() ) { + Track.get( track ).setEditedStart( item.Clock ); } - if ( Track[track].getEditedEnd() < item.Clock + item.ID.Length ) { - Track[track].setEditedEnd( item.Clock + item.ID.Length ); + if ( Track.get( track ).getEditedEnd() < item.Clock + item.ID.Length ) { + Track.get( track ).setEditedEnd( item.Clock + item.ID.Length ); } - Track[track].sortEvent(); + Track.get( track ).sortEvent(); return ret; #endregion - } else if ( type == VsqCommandType.EventAddRange ) { + } else if ( type == VsqCommandType.EVENT_ADD_RANGE ) { #region TrackAddNoteRange #if DEBUG Console.WriteLine( " TrackAddNoteRange" ); #endif int track = (int)command.Args[0]; VsqEvent[] items = (VsqEvent[])command.Args[1]; - List inv_ids = new List(); + Vector inv_ids = new Vector(); int min_clock = (int)TotalClocks; int max_clock = 0; for ( int i = 0; i < items.Length; i++ ) { - VsqEvent item = (VsqEvent)items[i].Clone(); + VsqEvent item = (VsqEvent)items[i].clone(); min_clock = Math.Min( min_clock, item.Clock ); max_clock = Math.Max( max_clock, item.Clock + item.ID.Length ); #if DEBUG Console.Write( " i=" + i + "; item.InternalID=" + item.InternalID ); #endif - Track[track].addEvent( item ); - inv_ids.Add( item.InternalID ); + Track.get( track ).addEvent( item ); + inv_ids.add( item.InternalID ); #if DEBUG Console.WriteLine( " => " + item.InternalID ); #endif } updateTotalClocks(); - if ( min_clock < Track[track].getEditedStart() ) { - Track[track].setEditedStart( min_clock ); + if ( min_clock < Track.get( track ).getEditedStart() ) { + Track.get( track ).setEditedStart( min_clock ); } - if ( Track[track].getEditedEnd() < max_clock ) { - Track[track].setEditedEnd( max_clock ); + if ( Track.get( track ).getEditedEnd() < max_clock ) { + Track.get( track ).setEditedEnd( max_clock ); } - Track[track].sortEvent(); - return VsqCommand.generateCommandEventDeleteRange( track, inv_ids.ToArray() ); + Track.get( track ).sortEvent(); + return VsqCommand.generateCommandEventDeleteRange( track, inv_ids.toArray( new Integer[]{} ) ); #endregion - } else if ( type == VsqCommandType.EventDelete ) { + } else if ( type == VsqCommandType.EVENT_DELETE ) { #region TrackDeleteNote int internal_id = (int)command.Args[0]; int track = (int)command.Args[1]; VsqEvent[] original = new VsqEvent[1]; - VsqTrack target = Track[track]; + VsqTrack target = Track.get( track ); for ( Iterator itr = target.getEventIterator(); itr.hasNext(); ) { VsqEvent item = (VsqEvent)itr.next(); if ( item.InternalID == internal_id ) { - original[0] = (VsqEvent)item.Clone(); + original[0] = (VsqEvent)item.clone(); break; } } @@ -377,19 +404,19 @@ namespace Boare.Lib.Vsq { updateTotalClocks(); return ret; #endregion - } else if ( type == VsqCommandType.EventDeleteRange ) { + } else if ( type == VsqCommandType.EVENT_DELETE_RANGE ) { #region TrackDeleteNoteRange int[] internal_ids = (int[])command.Args[0]; int track = (int)command.Args[1]; - List inv = new List(); + Vector inv = new Vector(); int min_clock = int.MaxValue; int max_clock = int.MinValue; - VsqTrack target = this.Track[track]; + VsqTrack target = this.Track.get( track ); for ( int j = 0; j < internal_ids.Length; j++ ) { for ( int i = 0; i < target.getEventCount(); i++ ) { VsqEvent item = target.getEvent( i ); if ( internal_ids[j] == item.InternalID ) { - inv.Add( (VsqEvent)item.Clone() ); + inv.add( (VsqEvent)item.clone() ); min_clock = Math.Min( min_clock, item.Clock ); max_clock = Math.Max( max_clock, item.Clock + item.ID.Length ); target.removeEvent( i ); @@ -400,14 +427,14 @@ namespace Boare.Lib.Vsq { updateTotalClocks(); target.setEditedStart( min_clock ); target.setEditedEnd( max_clock ); - return VsqCommand.generateCommandEventAddRange( track, inv.ToArray() ); + return VsqCommand.generateCommandEventAddRange( track, inv.toArray( new VsqEvent[]{} ) ); #endregion - } else if ( type == VsqCommandType.EventChangeClock ) { + } else if ( type == VsqCommandType.EVENT_CHANGE_CLOCK ) { #region TrackChangeClock int track = (int)command.Args[0]; int internal_id = (int)command.Args[1]; int value = (int)command.Args[2]; - VsqTrack target = this.Track[track]; + VsqTrack target = this.Track.get( track ); for ( Iterator itr = target.getEventIterator(); itr.hasNext(); ) { VsqEvent item = (VsqEvent)itr.next(); if ( item.InternalID == internal_id ) { @@ -423,14 +450,14 @@ namespace Boare.Lib.Vsq { } return null; #endregion - } else if ( type == VsqCommandType.EventChangeLyric ) { + } else if ( type == VsqCommandType.EVENT_CHANGE_LYRIC ) { #region TrackChangeLyric int track = (int)command.Args[0]; int internal_id = (int)command.Args[1]; - string phrase = (string)command.Args[2]; - string phonetic_symbol = (string)command.Args[3]; - bool protect_symbol = (bool)command.Args[4]; - VsqTrack target = this.Track[track]; + String phrase = (String)command.Args[2]; + String phonetic_symbol = (String)command.Args[3]; + boolean protect_symbol = (boolean)command.Args[4]; + VsqTrack target = this.Track.get( track ); for ( Iterator itr = target.getEventIterator(); itr.hasNext(); ) { VsqEvent item = (VsqEvent)itr.next(); if ( item.InternalID == internal_id ) { @@ -448,12 +475,12 @@ namespace Boare.Lib.Vsq { } return null; #endregion - } else if ( type == VsqCommandType.EventChangeNote ) { + } else if ( type == VsqCommandType.EVENT_CHANGE_NOTE ) { #region TrackChangeNote int track = (int)command.Args[0]; int internal_id = (int)command.Args[1]; int note = (int)command.Args[2]; - VsqTrack target = this.Track[track]; + VsqTrack target = this.Track.get( track ); for ( Iterator itr = target.getEventIterator(); itr.hasNext(); ) { VsqEvent item = (VsqEvent)itr.next(); if ( item.InternalID == internal_id ) { @@ -467,13 +494,13 @@ namespace Boare.Lib.Vsq { } return null; #endregion - } else if ( type == VsqCommandType.EventChangeClockAndNote ) { + } else if ( type == VsqCommandType.EVENT_CHANGE_CLOCK_AND_NOTE ) { #region TrackChangeClockAndNote int track = (int)command.Args[0]; int internal_id = (int)command.Args[1]; int clock = (int)command.Args[2]; int note = (int)command.Args[3]; - VsqTrack target = this.Track[track]; + VsqTrack target = this.Track.get( track ); for ( Iterator itr = target.getEventIterator(); itr.hasNext(); ) { VsqEvent item = (VsqEvent)itr.next(); if ( item.InternalID == internal_id ) { @@ -490,274 +517,314 @@ namespace Boare.Lib.Vsq { } return null; #endregion - } else if ( type == VsqCommandType.TrackEditCurve ) { - #region TrackEditCurve + } else if ( type == VsqCommandType.TRACK_CURVE_EDIT ) { + #region TRACK_CURVE_EDIT int track = (int)command.Args[0]; - string curve = (string)command.Args[1]; - List com = (List)command.Args[2]; + String curve = (String)command.Args[1]; + Vector com = (Vector)command.Args[2]; VsqCommand inv = null; - List edit = new List(); + Vector edit = new Vector(); + VsqBPList target_list = Track.get( track ).getCurve( curve ); if ( com != null ) { - if ( com.Count > 0 ) { - int start_clock = com[0].Clock; - int end_clock = com[0].Clock; - foreach ( BPPair item in com ) { + if ( com.size() > 0 ) { + int start_clock = com.get( 0 ).Clock; + int end_clock = com.get( 0 ).Clock; + for ( Iterator itr = com.iterator(); itr.hasNext(); ){ + BPPair item = (BPPair)itr.next(); start_clock = Math.Min( start_clock, item.Clock ); end_clock = Math.Max( end_clock, item.Clock ); } - Track[track].setEditedStart( start_clock ); - Track[track].setEditedEnd( end_clock ); - int start_value = Track[track].getCurve( curve ).getValue( start_clock ); - int end_value = Track[track].getCurve( curve ).getValue( end_clock ); - for ( Iterator i = Track[track].getCurve( curve ).keyClockIterator(); i.hasNext(); ){ + Track.get( track ).setEditedStart( start_clock ); + Track.get( track ).setEditedEnd( end_clock ); + int start_value = target_list.getValue( start_clock ); + int end_value = target_list.getValue( end_clock ); + for ( Iterator i = target_list.keyClockIterator(); i.hasNext(); ){ int clock = (int)i.next(); if ( start_clock <= clock && clock <= end_clock ) { - edit.Add( new BPPair( clock, Track[track].getCurve( curve ).getValue( clock ) ) ); + edit.add( new BPPair( clock, target_list.getValue( clock ) ) ); } } - bool start_found = false; - bool end_found = false; - for ( int i = 0; i < edit.Count; i++ ) { - if ( edit[i].Clock == start_clock ) { + boolean start_found = false; + boolean end_found = false; + int count = edit.size(); + for ( int i = 0; i < count; i++ ) { + if ( edit.get( i ).Clock == start_clock ) { start_found = true; - edit[i].Value = start_value; + edit.get( i ).Value = start_value; if ( start_found && end_found ) { break; } } - if ( edit[i].Clock == end_clock ) { + if ( edit.get( i ).Clock == end_clock ) { end_found = true; - edit[i].Value = end_value; + edit.get( i ).Value = end_value; if ( start_found && end_found ) { break; } } } if ( !start_found ) { - edit.Add( new BPPair( start_clock, start_value ) ); + edit.add( new BPPair( start_clock, start_value ) ); } if ( !end_found ) { - edit.Add( new BPPair( end_clock, end_value ) ); + edit.add( new BPPair( end_clock, end_value ) ); } // 並べ替え - edit.Sort(); - inv = VsqCommand.generateCommandTrackEditCurve( track, curve, edit ); - } else if ( com.Count == 0 ) { - inv = VsqCommand.generateCommandTrackEditCurve( track, curve, new List() ); + Collections.sort( edit ); + inv = VsqCommand.generateCommandTrackCurveEdit( track, curve, edit ); + } else if ( com.size() == 0 ) { + inv = VsqCommand.generateCommandTrackCurveEdit( track, curve, new Vector() ); } } updateTotalClocks(); - if ( com.Count == 0 ) { + if ( com.size() == 0 ) { return inv; - } else if ( com.Count == 1 ) { - bool found = false; - for ( Iterator itr = Track[track].getCurve( curve ).keyClockIterator(); itr.hasNext(); ){ + } else if ( com.size() == 1 ) { + boolean found = false; + for ( Iterator itr = target_list.keyClockIterator(); itr.hasNext(); ){ int clock = (int)itr.next(); - if ( clock == com[0].Clock ) { + if ( clock == com.get( 0 ).Clock ) { found = true; - Track[track].getCurve( curve ).add( clock, com[0].Value ); + target_list.add( clock, com.get( 0 ).Value ); break; } } if ( !found ) { - Track[track].getCurve( curve ).add( com[0].Clock, com[0].Value ); + target_list.add( com.get( 0 ).Clock, com.get( 0 ).Value ); } } else { - int start_clock = com[0].Clock; - int end_clock = com[com.Count - 1].Clock; - bool removed = true; + int start_clock = com.get( 0 ).Clock; + int end_clock = com.get( com.size() - 1 ).Clock; + boolean removed = true; while ( removed ) { removed = false; - for ( Iterator itr = Track[track].getCurve( curve ).keyClockIterator(); itr.hasNext(); ) { + for ( Iterator itr = target_list.keyClockIterator(); itr.hasNext(); ) { int clock = (int)itr.next(); if ( start_clock <= clock && clock <= end_clock ) { - Track[track].getCurve( curve ).remove( clock ); + target_list.remove( clock ); removed = true; break; } } } - foreach ( BPPair item in com ) { - Track[track].getCurve( curve ).add( item.Clock, item.Value ); + for ( Iterator itr = com.iterator(); itr.hasNext(); ){ + BPPair item = (BPPair)itr.next(); + target_list.add( item.Clock, item.Value ); } } return inv; #endregion - } else if ( type == VsqCommandType.TrackEditCurveRange ) { + } else if ( type == VsqCommandType.TRACK_CURVE_REPLACE ) { + #region TRACK_CURVE_REPLACE + int track = (int)command.Args[0]; + String target_curve = (String)command.Args[1]; + VsqBPList bplist = (VsqBPList)command.Args[2]; + VsqCommand inv = VsqCommand.generateCommandTrackCurveReplace( track, target_curve, Track.get( track ).getCurve( target_curve ) ); + Track.get( track ).setCurve( target_curve, bplist ); + return inv; + #endregion + } else if ( type == VsqCommandType.TRACK_CURVE_REPLACE_RANGE ) { + #region TRACK_CURVE_REPLACE_RANGE + int track = (int)command.Args[0]; + String[] target_curve = (String[])command.Args[1]; + VsqBPList[] bplist = (VsqBPList[])command.Args[2]; + VsqBPList[] inv_bplist = new VsqBPList[bplist.Length]; + VsqTrack work = Track.get( track ); + for ( int i = 0; i < target_curve.Length; i++ ) { + inv_bplist[i] = work.getCurve( target_curve[i] ); + } + VsqCommand inv = VsqCommand.generateCommandTrackCurveReplaceRange( track, target_curve, inv_bplist ); + for ( int i = 0; i < target_curve.Length; i++ ) { + work.setCurve( target_curve[i], bplist[i] ); + } + return inv; + #endregion + } else if ( type == VsqCommandType.TRACK_CURVE_EDIT_RANGE ) { #region TrackEditCurveRange int track = (int)command.Args[0]; - string[] curves = (string[])command.Args[1]; - List[] coms = (List[])command.Args[2]; - List[] inv_coms = new List[curves.Length]; + String[] curves = (String[])command.Args[1]; + Vector[] coms = (Vector[])command.Args[2]; + Vector[] inv_coms = new Vector[curves.Length]; VsqCommand inv = null; for ( int k = 0; k < curves.Length; k++ ) { - string curve = curves[k]; - List com = coms[k]; + String curve = curves[k]; + Vector com = coms[k]; //SortedList list = Tracks[track][curve].List; - List edit = new List(); + Vector edit = new Vector(); if ( com != null ) { - if ( com.Count > 0 ) { - int start_clock = com[0].Clock; - int end_clock = com[0].Clock; - foreach ( BPPair item in com ) { + if ( com.size() > 0 ) { + int start_clock = com.get( 0 ).Clock; + int end_clock = com.get( 0 ).Clock; + for ( Iterator itr = com.iterator(); itr.hasNext(); ){ + BPPair item = (BPPair)itr.next(); start_clock = Math.Min( start_clock, item.Clock ); end_clock = Math.Max( end_clock, item.Clock ); } - Track[track].setEditedStart( start_clock ); - Track[track].setEditedEnd( end_clock ); - int start_value = Track[track].getCurve( curve ).getValue( start_clock ); - int end_value = Track[track].getCurve( curve ).getValue( end_clock ); - for ( Iterator itr = Track[track].getCurve( curve ).keyClockIterator(); itr.hasNext(); ) { + Track.get( track ).setEditedStart( start_clock ); + Track.get( track ).setEditedEnd( end_clock ); + int start_value = Track.get( track ).getCurve( curve ).getValue( start_clock ); + int end_value = Track.get( track ).getCurve( curve ).getValue( end_clock ); + for ( Iterator itr = Track.get( track ).getCurve( curve ).keyClockIterator(); itr.hasNext(); ) { int clock = (int)itr.next(); if ( start_clock <= clock && clock <= end_clock ) { - edit.Add( new BPPair( clock, Track[track].getCurve( curve ).getValue( clock ) ) ); + edit.add( new BPPair( clock, Track.get( track ).getCurve( curve ).getValue( clock ) ) ); } } - bool start_found = false; - bool end_found = false; - for ( int i = 0; i < edit.Count; i++ ) { - if ( edit[i].Clock == start_clock ) { + boolean start_found = false; + boolean end_found = false; + for ( int i = 0; i < edit.size(); i++ ) { + if ( edit.get( i ).Clock == start_clock ) { start_found = true; - edit[i].Value = start_value; + edit.get( i ).Value = start_value; if ( start_found && end_found ) { break; } } - if ( edit[i].Clock == end_clock ) { + if ( edit.get( i ).Clock == end_clock ) { end_found = true; - edit[i].Value = end_value; + edit.get( i ).Value = end_value; if ( start_found && end_found ) { break; } } } if ( !start_found ) { - edit.Add( new BPPair( start_clock, start_value ) ); + edit.add( new BPPair( start_clock, start_value ) ); } if ( !end_found ) { - edit.Add( new BPPair( end_clock, end_value ) ); + edit.add( new BPPair( end_clock, end_value ) ); } // 並べ替え - edit.Sort(); + Collections.sort( edit ); inv_coms[k] = edit; //inv = generateCommandTrackEditCurve( track, curve, edit ); - } else if ( com.Count == 0 ) { - //inv = generateCommandTrackEditCurve( track, curve, new List() ); - inv_coms[k] = new List(); + } else if ( com.size() == 0 ) { + //inv = generateCommandTrackEditCurve( track, curve, new Vector() ); + inv_coms[k] = new Vector(); } } updateTotalClocks(); - if ( com.Count == 0 ) { + if ( com.size() == 0 ) { return inv; - } else if ( com.Count == 1 ) { - bool found = false; - for ( Iterator itr = Track[track].getCurve( curve ).keyClockIterator(); itr.hasNext(); ) { + } else if ( com.size() == 1 ) { + boolean found = false; + for ( Iterator itr = Track.get( track ).getCurve( curve ).keyClockIterator(); itr.hasNext(); ) { int clock = (int)itr.next(); - if ( clock == com[0].Clock ) { + if ( clock == com.get( 0 ).Clock ) { found = true; - Track[track].getCurve( curve ).add( clock, com[0].Value ); + Track.get( track ).getCurve( curve ).add( clock, com.get( 0 ).Value ); break; } } if ( !found ) { - Track[track].getCurve( curve ).add( com[0].Clock, com[0].Value ); + Track.get( track ).getCurve( curve ).add( com.get( 0 ).Clock, com.get( 0 ).Value ); } } else { - int start_clock = com[0].Clock; - int end_clock = com[com.Count - 1].Clock; - bool removed = true; + int start_clock = com.get( 0 ).Clock; + int end_clock = com.get( com.size() - 1 ).Clock; + boolean removed = true; while ( removed ) { removed = false; - for ( Iterator itr = Track[track].getCurve( curve ).keyClockIterator(); itr.hasNext(); ) { + for ( Iterator itr = Track.get( track ).getCurve( curve ).keyClockIterator(); itr.hasNext(); ) { int clock = (int)itr.next(); if ( start_clock <= clock && clock <= end_clock ) { - Track[track].getCurve( curve ).remove( clock ); + Track.get( track ).getCurve( curve ).remove( clock ); removed = true; break; } } } - foreach ( BPPair item in com ) { - Track[track].getCurve( curve ).add( item.Clock, item.Value ); + for ( Iterator itr = com.iterator(); itr.hasNext(); ){ + BPPair item = (BPPair)itr.next(); + Track.get( track ).getCurve( curve ).add( item.Clock, item.Value ); } } } - return VsqCommand.generateCommandTrackEditCurveRange( track, curves, inv_coms ); + return VsqCommand.generateCommandTrackCurveEditRange( track, curves, inv_coms ); #endregion - } else if ( type == VsqCommandType.EventChangeVelocity ) { + /*} else if ( type == VsqCommandType.TRACK_CURVE_REMOVE_POINTS ) { + #region TRACK_CURVE_REMOVE_POINTS + int track = (int)command.Args[0]; + String curve = (String)command.Args[1]; + Vector ids = (Vector)command.Args[2]; + #endregion*/ + } else if ( type == VsqCommandType.EVENT_CHANGE_VELOCITY ) { #region TrackChangeVelocity int track = (int)command.Args[0]; - List> veloc = (List>)command.Args[1]; - List> inv = new List>(); - for ( Iterator itr = Track[track].getEventIterator(); itr.hasNext(); ) { + Vector> veloc = (Vector>)command.Args[1]; + Vector> inv = new Vector>(); + for ( Iterator itr = Track.get( track ).getEventIterator(); itr.hasNext(); ) { VsqEvent ev = (VsqEvent)itr.next(); - foreach ( KeyValuePair add in veloc ) { + for ( Iterator itr2 = veloc.iterator(); itr2.hasNext(); ){ + KeyValuePair add = (KeyValuePair)itr2.next(); if ( ev.InternalID == add.Key ) { - inv.Add( new KeyValuePair( ev.InternalID, ev.ID.Dynamics ) ); + inv.add( new KeyValuePair( ev.InternalID, ev.ID.Dynamics ) ); ev.ID.Dynamics = add.Value; - Track[track].setEditedStart( ev.Clock ); - Track[track].setEditedEnd( ev.Clock + ev.ID.Length ); + Track.get( track ).setEditedStart( ev.Clock ); + Track.get( track ).setEditedEnd( ev.Clock + ev.ID.Length ); break; } } } return VsqCommand.generateCommandEventChangeVelocity( track, inv ); #endregion - } else if ( type == VsqCommandType.EventChangeAccent ) { + } else if ( type == VsqCommandType.EVENT_CHANGE_ACCENT ) { #region TrackChangeAccent int track = (int)command.Args[0]; - List> veloc = (List>)command.Args[1]; - List> inv = new List>(); - for ( Iterator itr = Track[track].getEventIterator(); itr.hasNext(); ) { + Vector> veloc = (Vector>)command.Args[1]; + Vector> inv = new Vector>(); + for ( Iterator itr = Track.get( track ).getEventIterator(); itr.hasNext(); ) { VsqEvent ev = (VsqEvent)itr.next(); - foreach ( KeyValuePair add in veloc ) { + for ( Iterator itr2 = veloc.iterator(); itr2.hasNext(); ){ + KeyValuePair add = (KeyValuePair)itr2.next(); if ( ev.InternalID == add.Key ) { - inv.Add( new KeyValuePair( ev.InternalID, ev.ID.DEMaccent ) ); + inv.add( new KeyValuePair( ev.InternalID, ev.ID.DEMaccent ) ); ev.ID.DEMaccent = add.Value; - Track[track].setEditedStart( ev.Clock ); - Track[track].setEditedEnd( ev.Clock + ev.ID.Length ); + Track.get( track ).setEditedStart( ev.Clock ); + Track.get( track ).setEditedEnd( ev.Clock + ev.ID.Length ); break; } } } return VsqCommand.generateCommandEventChangeAccent( track, inv ); #endregion - } else if ( type == VsqCommandType.EventChangeDecay ) { + } else if ( type == VsqCommandType.EVENT_CHANGE_DECAY ) { #region TrackChangeDecay int track = (int)command.Args[0]; - List> veloc = (List>)command.Args[1]; - List> inv = new List>(); - for ( Iterator itr = Track[track].getEventIterator(); itr.hasNext(); ) { + Vector> veloc = (Vector>)command.Args[1]; + Vector> inv = new Vector>(); + for ( Iterator itr = Track.get( track ).getEventIterator(); itr.hasNext(); ) { VsqEvent ev = (VsqEvent)itr.next(); - foreach ( KeyValuePair add in veloc ) { + for ( Iterator itr2 = veloc.iterator(); itr2.hasNext(); ){ + KeyValuePair add = (KeyValuePair)itr.next(); if ( ev.InternalID == add.Key ) { - inv.Add( new KeyValuePair( ev.InternalID, ev.ID.DEMdecGainRate ) ); + inv.add( new KeyValuePair( ev.InternalID, ev.ID.DEMdecGainRate ) ); ev.ID.DEMdecGainRate = add.Value; - Track[track].setEditedStart( ev.Clock ); - Track[track].setEditedEnd( ev.Clock + ev.ID.Length ); + Track.get( track ).setEditedStart( ev.Clock ); + Track.get( track ).setEditedEnd( ev.Clock + ev.ID.Length ); break; } } } return VsqCommand.generateCommandEventChangeDecay( track, inv ); #endregion - } else if ( type == VsqCommandType.EventChangeLength ) { + } else if ( type == VsqCommandType.EVENT_CHANGE_LENGTH ) { #region TrackChangeLength int track = (int)command.Args[0]; int internal_id = (int)command.Args[1]; int new_length = (int)command.Args[2]; - for ( Iterator itr = Track[track].getEventIterator(); itr.hasNext(); ) { + for ( Iterator itr = Track.get( track ).getEventIterator(); itr.hasNext(); ) { VsqEvent item = (VsqEvent)itr.next(); if ( item.InternalID == internal_id ) { VsqCommand ret = VsqCommand.generateCommandEventChangeLength( track, internal_id, item.ID.Length ); - Track[track].setEditedStart( item.Clock ); + Track.get( track ).setEditedStart( item.Clock ); int max = Math.Max( item.Clock + item.ID.Length, item.Clock + new_length ); - Track[track].setEditedEnd( max ); + Track.get( track ).setEditedEnd( max ); item.ID.Length = new_length; updateTotalClocks(); return ret; @@ -765,66 +832,66 @@ namespace Boare.Lib.Vsq { } return null; #endregion - } else if ( type == VsqCommandType.EventChangeClockAndLength ) { + } else if ( type == VsqCommandType.EVENT_CHANGE_CLOCK_AND_LENGTH ) { #region TrackChangeClockAndLength int track = (int)command.Args[0]; int internal_id = (int)command.Args[1]; int new_clock = (int)command.Args[2]; int new_length = (int)command.Args[3]; - for ( Iterator itr = Track[track].getEventIterator(); itr.hasNext(); ) { + for ( Iterator itr = Track.get( track ).getEventIterator(); itr.hasNext(); ) { VsqEvent item = (VsqEvent)itr.next(); if ( item.InternalID == internal_id ) { VsqCommand ret = VsqCommand.generateCommandEventChangeClockAndLength( track, internal_id, item.Clock, item.ID.Length ); int min = Math.Min( item.Clock, new_clock ); int max_length = Math.Max( item.ID.Length, new_length ); int max = Math.Max( item.Clock + max_length, new_clock + max_length ); - Track[track].setEditedStart( min ); - Track[track].setEditedEnd( max ); + Track.get( track ).setEditedStart( min ); + Track.get( track ).setEditedEnd( max ); item.ID.Length = new_length; item.Clock = new_clock; - Track[track].sortEvent(); + Track.get( track ).sortEvent(); updateTotalClocks(); return ret; } } return null; #endregion - } else if ( type == VsqCommandType.EventChangeIDContaints ) { + } else if ( type == VsqCommandType.EVENT_CHANGE_ID_CONTAINTS ) { #region TrackChangeIDContaints int track = (int)command.Args[0]; int internal_id = (int)command.Args[1]; VsqID value = (VsqID)command.Args[2]; - for ( Iterator itr = Track[track].getEventIterator(); itr.hasNext(); ) { + for ( Iterator itr = Track.get( track ).getEventIterator(); itr.hasNext(); ) { VsqEvent item = (VsqEvent)itr.next(); if ( item.InternalID == internal_id ) { VsqCommand ret = VsqCommand.generateCommandEventChangeIDContaints( track, internal_id, item.ID ); int max_length = Math.Max( item.ID.Length, value.Length ); - Track[track].setEditedStart( item.Clock ); - Track[track].setEditedEnd( item.Clock + max_length ); - item.ID = (VsqID)value.Clone(); + Track.get( track ).setEditedStart( item.Clock ); + Track.get( track ).setEditedEnd( item.Clock + max_length ); + item.ID = (VsqID)value.clone(); if ( item.ID.type == VsqIDType.Singer ) { #if DEBUG Console.WriteLine( " EventChangeIDContaints" ); #endif // 歌手変更の場合、次に現れる歌手変更の位置まで編集の影響が及ぶ - bool found = false; - for ( Iterator itr2 = Track[track].getSingerEventIterator(); itr2.hasNext(); ) { + boolean found = false; + for ( Iterator itr2 = Track.get( track ).getSingerEventIterator(); itr2.hasNext(); ) { VsqEvent item2 = (VsqEvent)itr2.next(); if ( item.Clock < item2.Clock ) { - Track[track].setEditedEnd( item2.Clock ); + Track.get( track ).setEditedEnd( item2.Clock ); found = true; break; } } if ( !found ) { // 変更対象が、該当トラック最後の歌手変更イベントだった場合 - if ( Track[track].getEventCount() >= 1 ) { - VsqEvent last_event = Track[track].getEvent( Track[track].getEventCount() - 1 ); - Track[track].setEditedEnd( last_event.Clock + last_event.ID.Length ); + if ( Track.get( track ).getEventCount() >= 1 ) { + VsqEvent last_event = Track.get( track ).getEvent( Track.get( track ).getEventCount() - 1 ); + Track.get( track ).setEditedEnd( last_event.Clock + last_event.ID.Length ); } } #if DEBUG - Console.WriteLine( " EditedStart,EditedEnd=" + Track[track].getEditedStart() + "," + Track[track].getEditedEnd() ); + Console.WriteLine( " EditedStart,EditedEnd=" + Track.get( track ).getEditedStart() + "," + Track.get( track ).getEditedEnd() ); #endif } updateTotalClocks(); @@ -833,37 +900,37 @@ namespace Boare.Lib.Vsq { } return null; #endregion - } else if ( type == VsqCommandType.EventChangeIDContaintsRange ) { + } else if ( type == VsqCommandType.EVENT_CHANGE_ID_CONTAINTS_RANGE ) { #region TrackChangeIDContaintsRange int track = (int)command.Args[0]; int[] internal_ids = (int[])command.Args[1]; VsqID[] values = (VsqID[])command.Args[2]; VsqID[] inv_values = new VsqID[values.Length]; for ( int i = 0; i < internal_ids.Length; i++ ) { - for ( Iterator itr = Track[track].getEventIterator(); itr.hasNext(); ) { + for ( Iterator itr = Track.get( track ).getEventIterator(); itr.hasNext(); ) { VsqEvent item = (VsqEvent)itr.next(); if ( item.InternalID == internal_ids[i] ) { - inv_values[i] = (VsqID)item.ID.Clone(); + inv_values[i] = (VsqID)item.ID.clone(); int max_length = Math.Max( item.ID.Length, values[i].Length ); - Track[track].setEditedStart( item.Clock ); - Track[track].setEditedEnd( item.Clock + max_length ); - item.ID = (VsqID)values[i].Clone(); + Track.get( track ).setEditedStart( item.Clock ); + Track.get( track ).setEditedEnd( item.Clock + max_length ); + item.ID = (VsqID)values[i].clone(); if ( item.ID.type == VsqIDType.Singer ) { // 歌手変更の場合、次に現れる歌手変更の位置まで編集の影響が及ぶ - bool found = false; - for ( Iterator itr2 = Track[track].getSingerEventIterator(); itr2.hasNext(); ) { + boolean found = false; + for ( Iterator itr2 = Track.get( track ).getSingerEventIterator(); itr2.hasNext(); ) { VsqEvent item2 = (VsqEvent)itr2.next(); if ( item.Clock < item2.Clock ) { - Track[track].setEditedEnd( item2.Clock ); + Track.get( track ).setEditedEnd( item2.Clock ); found = true; break; } } if ( !found ) { // 変更対象が、該当トラック最後の歌手変更イベントだった場合 - if ( Track[track].getEventCount() >= 1 ) { - VsqEvent last_event = Track[track].getEvent( Track[track].getEventCount() - 1 ); - Track[track].setEditedEnd( last_event.Clock + last_event.ID.Length ); + if ( Track.get( track ).getEventCount() >= 1 ) { + VsqEvent last_event = Track.get( track ).getEvent( Track.get( track ).getEventCount() - 1 ); + Track.get( track ).setEditedEnd( last_event.Clock + last_event.ID.Length ); } } } @@ -874,62 +941,62 @@ namespace Boare.Lib.Vsq { updateTotalClocks(); return VsqCommand.generateCommandEventChangeIDContaintsRange( track, internal_ids, inv_values ); #endregion - } else if ( type == VsqCommandType.EventChangeClockAndIDContaints ) { + } else if ( type == VsqCommandType.EVENT_CHANGE_CLOCK_AND_ID_CONTAINTS ) { #region TrackChangeClockAndIDContaints int track = (int)command.Args[0]; int internal_id = (int)command.Args[1]; int new_clock = (int)command.Args[2]; VsqID value = (VsqID)command.Args[3]; - for ( Iterator itr = Track[track].getEventIterator(); itr.hasNext(); ) { + for ( Iterator itr = Track.get( track ).getEventIterator(); itr.hasNext(); ) { VsqEvent item = (VsqEvent)itr.next(); if ( item.InternalID == internal_id ) { VsqCommand ret = VsqCommand.generateCommandEventChangeClockAndIDContaints( track, internal_id, item.Clock, item.ID ); int max_length = Math.Max( item.ID.Length, value.Length ); int min = Math.Min( item.Clock, new_clock ); int max = Math.Max( item.Clock + max_length, new_clock + max_length ); - item.ID = (VsqID)value.Clone(); + item.ID = (VsqID)value.clone(); item.Clock = new_clock; - Track[track].setEditedStart( min ); - Track[track].setEditedEnd( max ); - Track[track].sortEvent(); + Track.get( track ).setEditedStart( min ); + Track.get( track ).setEditedEnd( max ); + Track.get( track ).sortEvent(); updateTotalClocks(); return ret; } } return null; #endregion - } else if ( type == VsqCommandType.EventChangeClockAndIDContaintsRange ) { + } else if ( type == VsqCommandType.EVENT_CHANGE_CLOCK_AND_ID_CONTAINTS_RANGE ) { #region TrackChangeClockAndIDContaintsRange int track = (int)command.Args[0]; int[] internal_ids = (int[])command.Args[1]; int[] clocks = (int[])command.Args[2]; VsqID[] values = (VsqID[])command.Args[3]; - List inv_id = new List(); - List inv_clock = new List(); + Vector inv_id = new Vector(); + Vector inv_clock = new Vector(); for ( int i = 0; i < internal_ids.Length; i++ ) { - for ( Iterator itr = Track[track].getEventIterator(); itr.hasNext(); ) { + for ( Iterator itr = Track.get( track ).getEventIterator(); itr.hasNext(); ) { VsqEvent item = (VsqEvent)itr.next(); if ( item.InternalID == internal_ids[i] ) { - inv_id.Add( (VsqID)item.ID.Clone() ); - inv_clock.Add( item.Clock ); + inv_id.add( (VsqID)item.ID.clone() ); + inv_clock.add( item.Clock ); int max_length = Math.Max( item.ID.Length, values[i].Length ); int min = Math.Min( item.Clock, clocks[i] ); int max = Math.Max( item.Clock + max_length, clocks[i] + max_length ); - Track[track].setEditedStart( min ); - Track[track].setEditedEnd( max ); - item.ID = (VsqID)values[i].Clone(); + Track.get( track ).setEditedStart( min ); + Track.get( track ).setEditedEnd( max ); + item.ID = (VsqID)values[i].clone(); item.Clock = clocks[i]; break; } } } - Track[track].sortEvent(); + Track.get( track ).sortEvent(); updateTotalClocks(); return VsqCommand.generateCommandEventChangeClockAndIDContaintsRange( track, internal_ids, - inv_clock.ToArray(), - inv_id.ToArray() ); + inv_clock.toArray( new Integer[]{} ), + inv_id.toArray( new VsqID[]{} ) ); #if DEBUG Console.WriteLine( " TrackChangeClockAndIDContaintsRange" ); Console.WriteLine( " track=" + track ); @@ -938,49 +1005,49 @@ namespace Boare.Lib.Vsq { } #endif #endregion - } else if ( type == VsqCommandType.TrackChangeName ) { + } else if ( type == VsqCommandType.TRACK_CHANGE_NAME ) { #region TrackCangeName int track = (int)command.Args[0]; - string new_name = (string)command.Args[1]; - VsqCommand ret = VsqCommand.generateCommandTrackChangeName( track, Track[track].Name ); - Track[track].Name = new_name; + String new_name = (String)command.Args[1]; + VsqCommand ret = VsqCommand.generateCommandTrackChangeName( track, Track.get( track ).getName() ); + Track.get( track ).setName( new_name ); return ret; #endregion - } else if ( type == VsqCommandType.TrackReplace ) { + } else if ( type == VsqCommandType.TRACK_REPLACE ) { #region TrackReplace int track = (int)command.Args[0]; VsqTrack item = (VsqTrack)command.Args[1]; - VsqCommand ret = VsqCommand.generateCommandTrackReplace( track, Track[track] ); - Track[track] = item; + VsqCommand ret = VsqCommand.generateCommandTrackReplace( track, Track.get( track ) ); + Track.set( track, item ); updateTotalClocks(); return ret; #endregion - } else if ( type == VsqCommandType.TrackChangePlayMode ) { + } else if ( type == VsqCommandType.TRACK_CHANGE_PLAY_MODE ) { #region TrackChangePlayMode int track = (int)command.Args[0]; int play_mode = (int)command.Args[1]; - VsqCommand ret = VsqCommand.generateCommandTrackChangePlayMode( track, Track[track].getCommon().PlayMode ); - Track[track].getCommon().PlayMode = play_mode; + VsqCommand ret = VsqCommand.generateCommandTrackChangePlayMode( track, Track.get( track ).getCommon().PlayMode ); + Track.get( track ).getCommon().PlayMode = play_mode; return ret; #endregion - } else if ( type == VsqCommandType.EventReplace ) { + } else if ( type == VsqCommandType.EVENT_REPLACE ) { #region EventReplace int track = (int)command.Args[0]; VsqEvent item = (VsqEvent)command.Args[1]; VsqCommand ret = null; - for ( int i = 0; i < Track[track].getEventCount(); i++ ) { - VsqEvent ve = Track[track].getEvent( i ); + for ( int i = 0; i < Track.get( track ).getEventCount(); i++ ) { + VsqEvent ve = Track.get( track ).getEvent( i ); if ( ve.InternalID == item.InternalID ) { ret = VsqCommand.generateCommandEventReplace( track, ve ); - Track[track].setEvent( i, item ); + Track.get( track ).setEvent( i, item ); break; } } - Track[track].sortEvent(); + Track.get( track ).sortEvent(); updateTotalClocks(); return ret; #endregion - } else if ( type == VsqCommandType.EventReplaceRange ) { + } else if ( type == VsqCommandType.EVENT_REPLACE_RANGE ) { #region EventReplaceRange int track = (int)command.Args[0]; object[] items = (object[])command.Args[1]; @@ -988,16 +1055,16 @@ namespace Boare.Lib.Vsq { VsqEvent[] reverse = new VsqEvent[items.Length]; for ( int i = 0; i < items.Length; i++ ) { VsqEvent ve = (VsqEvent)items[i]; - for ( int j = 0; j < Track[track].getEventCount(); j++ ) { - VsqEvent ve2 = (VsqEvent)Track[track].getEvent( j ); + for ( int j = 0; j < Track.get( track ).getEventCount(); j++ ) { + VsqEvent ve2 = (VsqEvent)Track.get( track ).getEvent( j ); if ( ve2.InternalID == ve.InternalID ) { - reverse[i] = (VsqEvent)ve2.Clone(); - Track[track].setEvent( j, (VsqEvent)items[i] ); + reverse[i] = (VsqEvent)ve2.clone(); + Track.get( track ).setEvent( j, (VsqEvent)items[i] ); break; } } } - Track[track].sortEvent(); + Track.get( track ).sortEvent(); updateTotalClocks(); ret = VsqCommand.generateCommandEventReplaceRange( track, reverse ); return ret; @@ -1017,41 +1084,41 @@ namespace Boare.Lib.Vsq { int dclock = clock_end - clock_start; // テンポ情報の削除、シフト - bool changed = true; - List buf = new List( TempoTable ); + boolean changed = true; + Vector buf = new Vector( TempoTable ); int tempo_at_clock_start = getTempoAt( clock_start ); int tempo_at_clock_end = getTempoAt( clock_end ); - TempoTable.Clear(); - bool just_on_clock_end_added = false; - for ( int i = 0; i < buf.Count; i++ ) { - if ( buf[i].Clock < clock_start ) { - TempoTable.Add( (TempoTableEntry)buf[i].Clone() ); - } else if ( clock_end <= buf[i].Clock ) { - TempoTableEntry tte = (TempoTableEntry)buf[i].Clone(); + TempoTable.clear(); + boolean just_on_clock_end_added = false; + for ( int i = 0; i < buf.size(); i++ ) { + if ( buf.get( i ).Clock < clock_start ) { + TempoTable.add( (TempoTableEntry)buf.get( i ).Clone() ); + } else if ( clock_end <= buf.get( i ).Clock ) { + TempoTableEntry tte = (TempoTableEntry)buf.get( i ).Clone(); tte.Clock = tte.Clock - dclock; - if ( clock_end == buf[i].Clock ) { - TempoTable.Add( tte ); + if ( clock_end == buf.get( i ).Clock ) { + TempoTable.add( tte ); just_on_clock_end_added = true; } else { if ( tempo_at_clock_start != tempo_at_clock_end ) { if ( !just_on_clock_end_added ) { - TempoTable.Add( new TempoTableEntry( clock_start, tempo_at_clock_end, 0.0 ) ); + TempoTable.add( new TempoTableEntry( clock_start, tempo_at_clock_end, 0.0 ) ); just_on_clock_end_added = true; } } - TempoTable.Add( tte ); + TempoTable.add( tte ); } } } if ( tempo_at_clock_start != tempo_at_clock_end && !just_on_clock_end_added ) { - TempoTable.Add( new TempoTableEntry( clock_start, tempo_at_clock_end, 0.0 ) ); + TempoTable.add( new TempoTableEntry( clock_start, tempo_at_clock_end, 0.0 ) ); } updateTempoInfo(); - for ( int track = 1; track < Track.Count; track++ ) { + for ( int track = 1; track < Track.size(); track++ ) { // 削除する範囲に歌手変更イベントが存在するかどうかを検査。 VsqEvent t_last_singer = null; - for ( Iterator itr = Track[track].getSingerEventIterator(); itr.hasNext(); ) { + for ( Iterator itr = Track.get( track ).getSingerEventIterator(); itr.hasNext(); ) { VsqEvent ve = (VsqEvent)itr.next(); if ( clock_start <= ve.Clock && ve.Clock < clock_end ) { t_last_singer = ve; @@ -1062,7 +1129,7 @@ namespace Boare.Lib.Vsq { } VsqEvent last_singer = null; if ( t_last_singer != null ) { - last_singer = (VsqEvent)t_last_singer.Clone(); + last_singer = (VsqEvent)t_last_singer.clone(); last_singer.Clock = clock_end; } @@ -1070,9 +1137,9 @@ namespace Boare.Lib.Vsq { // イベントの削除 while ( changed ) { changed = false; - for ( int i = 0; i < Track[track].getEventCount(); i++ ) { - if ( clock_start <= Track[track].getEvent( i ).Clock && Track[track].getEvent( i ).Clock < clock_end ) { - Track[track].removeEvent( i ); + for ( int i = 0; i < Track.get( track ).getEventCount(); i++ ) { + if ( clock_start <= Track.get( track ).getEvent( i ).Clock && Track.get( track ).getEvent( i ).Clock < clock_end ) { + Track.get( track ).removeEvent( i ); changed = true; break; } @@ -1081,35 +1148,35 @@ namespace Boare.Lib.Vsq { // クロックのシフト if ( last_singer != null ) { - Track[track].addEvent( last_singer ); //歌手変更イベントを補う + Track.get( track ).addEvent( last_singer ); //歌手変更イベントを補う } - for ( int i = 0; i < Track[track].getEventCount(); i++ ) { - if ( clock_end <= Track[track].getEvent( i ).Clock ) { - Track[track].getEvent( i ).Clock -= dclock; + for ( int i = 0; i < Track.get( track ).getEventCount(); i++ ) { + if ( clock_end <= Track.get( track ).getEvent( i ).Clock ) { + Track.get( track ).getEvent( i ).Clock -= dclock; } } - foreach ( string curve in _CURVES ) { - if ( curve == "VEL" ) { + foreach ( String curve in _CURVES ) { + if ( curve.Equals( "VEL" ) ) { continue; } - VsqBPList buf_bplist = (VsqBPList)Track[track].getCurve( curve ).Clone(); - Track[track].getCurve( curve ).clear(); + VsqBPList buf_bplist = (VsqBPList)Track.get( track ).getCurve( curve ).Clone(); + Track.get( track ).getCurve( curve ).clear(); int value_at_end = buf_bplist.getValue( clock_end ); - bool at_end_added = false; + boolean at_end_added = false; for ( Iterator itr = buf_bplist.keyClockIterator(); itr.hasNext(); ) { int key = (int)itr.next(); if ( key < clock_start ) { - Track[track].getCurve( curve ).add( key, buf_bplist.getValue( key ) ); + Track.get( track ).getCurve( curve ).add( key, buf_bplist.getValue( key ) ); } else if ( clock_end <= key ) { if ( key == clock_end ) { at_end_added = true; } - Track[track].getCurve( curve ).add( key - dclock, buf_bplist.getValue( key ) ); + Track.get( track ).getCurve( curve ).add( key - dclock, buf_bplist.getValue( key ) ); } } if ( !at_end_added ) { - Track[track].getCurve( curve ).add( clock_end - dclock, value_at_end ); + Track.get( track ).getCurve( curve ).add( clock_end - dclock, value_at_end ); } } } @@ -1126,30 +1193,30 @@ namespace Boare.Lib.Vsq { return; } int dclock = (int)delta_clock; - for ( int i = 0; i < vsq.TempoTable.Count; i++ ) { - if ( vsq.TempoTable[i].Clock > 0 ) { - vsq.TempoTable[i].Clock =vsq.TempoTable[i].Clock + dclock; + for ( int i = 0; i < vsq.TempoTable.size(); i++ ) { + if ( vsq.TempoTable.get( i ).Clock > 0 ) { + vsq.TempoTable.get( i ).Clock =vsq.TempoTable.get( i ).Clock + dclock; } } vsq.updateTempoInfo(); - for ( int track = 1; track < vsq.Track.Count; track++ ) { - for ( int i = 0; i < vsq.Track[track].getEventCount(); i++ ) { - if ( vsq.Track[track].getEvent( i ).Clock > 0 ) { - vsq.Track[track].getEvent( i ).Clock += dclock; + for ( int track = 1; track < vsq.Track.size(); track++ ) { + for ( int i = 0; i < vsq.Track.get( track ).getEventCount(); i++ ) { + if ( vsq.Track.get( track ).getEvent( i ).Clock > 0 ) { + vsq.Track.get( track ).getEvent( i ).Clock += dclock; } } - foreach ( string curve in _CURVES ) { - if ( curve == "VEL" ) { + foreach ( String curve in _CURVES ) { + if ( curve.Equals( "VEL" ) ) { continue; } // 順番に+=dclockしていくとVsqBPList内部のSortedListの値がかぶる可能性がある. - VsqBPList edit = vsq.Track[track].getCurve( curve ); + VsqBPList edit = vsq.Track.get( track ).getCurve( curve ); VsqBPList new_one = new VsqBPList( edit.getDefault(), edit.getMinimum(), edit.getMaximum() ); foreach( int key in edit.getKeys() ){ new_one.add( key + dclock, edit.getValue( key ) ); } - vsq.Track[track].setCurve( curve, new_one ); + vsq.Track.get( track ).setCurve( curve, new_one ); } } vsq.updateTotalClocks(); @@ -1161,21 +1228,21 @@ namespace Boare.Lib.Vsq { /// このインスタンスのコピー public virtual object Clone() { VsqFile ret = new VsqFile(); - ret.Track = new List(); - for ( int i = 0; i < Track.Count; i++ ) { - ret.Track.Add( (VsqTrack)Track[i].Clone() ); + ret.Track = new Vector(); + for ( int i = 0; i < Track.size(); i++ ) { + ret.Track.add( (VsqTrack)Track.get( i ).Clone() ); } #if USE_TEMPO_LIST ret.m_tempo_table = (TempoTable)m_tempo_table.Clone(); #else - ret.TempoTable = new List(); - for ( int i = 0; i < TempoTable.Count; i++ ) { - ret.TempoTable.Add( (TempoTableEntry)TempoTable[i].Clone() ); + ret.TempoTable = new Vector(); + for ( int i = 0; i < TempoTable.size(); i++ ) { + ret.TempoTable.add( (TempoTableEntry)TempoTable.get( i ).Clone() ); } #endif - ret.TimesigTable = new List(); - for ( int i = 0; i < TimesigTable.Count; i++ ) { - ret.TimesigTable.Add( (TimeSigTableEntry)TimesigTable[i].Clone() ); + ret.TimesigTable = new Vector(); + for ( int i = 0; i < TimesigTable.size(); i++ ) { + ret.TimesigTable.add( (TimeSigTableEntry)TimesigTable.get( i ).Clone() ); } ret.m_tpq = m_tpq; ret.TotalClocks = TotalClocks; @@ -1190,7 +1257,7 @@ namespace Boare.Lib.Vsq { } private class BarLineIterator : Iterator { - private List m_list; + private Vector m_list; private int m_end_clock; private int i; private int clock; @@ -1201,9 +1268,9 @@ namespace Boare.Lib.Vsq { int local_clock; int bar_counter; - public BarLineIterator( List list, int end_clock ) { + public BarLineIterator( Vector list, int end_clock ) { /*lock ( list ) { - m_list = new List(); + m_list = new Vector(); for ( int j = 0; j < list.Count; j++ ) { m_list.Add( (TimeSigTableEntry)list[j].Clone() ); } @@ -1230,17 +1297,17 @@ namespace Boare.Lib.Vsq { } } - if( i < m_list.Count ) { - local_denominator = m_list[i].Denominator; - local_numerator = m_list[i].Numerator; - local_clock = m_list[i].Clock; - int local_bar_count = m_list[i].BarCount; + if( i < m_list.size() ) { + local_denominator = m_list.get( i ).Denominator; + local_numerator = m_list.get( i ).Numerator; + local_clock = m_list.get( i ).Clock; + int local_bar_count = m_list.get( i ).BarCount; clock_step = 480 * 4 / local_denominator; mod = clock_step * local_numerator; bar_counter = local_bar_count - 1; t_end = m_end_clock; - if ( i + 1 < m_list.Count ) { - t_end = m_list[i + 1].Clock; + if ( i + 1 < m_list.size() ) { + t_end = m_list.get( i + 1 ).Clock; } i++; clock = local_clock; @@ -1307,18 +1374,18 @@ namespace Boare.Lib.Vsq { /// private int calculatePreMeasureInClock() { int pre_measure = Master.PreMeasure; - int last_bar_count = TimesigTable[0].BarCount; - int last_clock = TimesigTable[0].Clock; - int last_denominator = TimesigTable[0].Denominator; - int last_numerator = TimesigTable[0].Numerator; - for ( int i = 1; i < TimesigTable.Count; i++ ) { - if ( TimesigTable[i].BarCount >= pre_measure ) { + int last_bar_count = TimesigTable.get( 0 ).BarCount; + int last_clock = TimesigTable.get( 0 ).Clock; + int last_denominator = TimesigTable.get( 0 ).Denominator; + int last_numerator = TimesigTable.get( 0 ).Numerator; + for ( int i = 1; i < TimesigTable.size(); i++ ) { + if ( TimesigTable.get( i ).BarCount >= pre_measure ) { break; } else { - last_bar_count = TimesigTable[i].BarCount; - last_clock = TimesigTable[i].Clock; - last_denominator = TimesigTable[i].Denominator; - last_numerator = TimesigTable[i].Numerator; + last_bar_count = TimesigTable.get( i ).BarCount; + last_clock = TimesigTable.get( i ).Clock; + last_denominator = TimesigTable.get( i ).Denominator; + last_numerator = TimesigTable.get( i ).Numerator; } } @@ -1332,9 +1399,9 @@ namespace Boare.Lib.Vsq { /// /// public double getSecFromClock( double clock ) { - int c = TempoTable.Count; + int c = TempoTable.size(); for ( int i = c - 1; i >= 0; i-- ) { - TempoTableEntry item = TempoTable[i]; + TempoTableEntry item = TempoTable.get( i ); if ( item.Clock < clock ) { double init = item.Time; double dclock = clock - item.Clock; @@ -1360,18 +1427,18 @@ namespace Boare.Lib.Vsq { int tempo = m_base_tempo; double base_clock = 0; double base_time = 0f; - int c = TempoTable.Count; + int c = TempoTable.size(); if ( c == 0 ) { tempo = m_base_tempo; base_clock = 0; base_time = 0f; } else if ( c == 1 ) { - tempo = TempoTable[0].Tempo; - base_clock = TempoTable[0].Clock; - base_time = TempoTable[0].Time; + tempo = TempoTable.get( 0 ).Tempo; + base_clock = TempoTable.get( 0 ).Clock; + base_time = TempoTable.get( 0 ).Time; } else { for ( int i = c - 1; i >= 0; i-- ) { - TempoTableEntry item = TempoTable[i]; + TempoTableEntry item = TempoTable.get( i ); if ( item.Time < time ) { return item.Clock + (time - item.Time) * m_tpq * 1000000.0 / item.Tempo; } @@ -1390,27 +1457,27 @@ namespace Boare.Lib.Vsq { /// public void getTimesigAt( int clock, out int numerator, out int denominator ) { int index = 0; - int c = TimesigTable.Count; + int c = TimesigTable.size(); for ( int i = c - 1; i >= 0; i-- ) { index = i; - if ( TimesigTable[i].Clock <= clock ) { + if ( TimesigTable.get( i ).Clock <= clock ) { break; } } - numerator = TimesigTable[index].Numerator; - denominator = TimesigTable[index].Denominator; + numerator = TimesigTable.get( index ).Numerator; + denominator = TimesigTable.get( index ).Denominator; } public void getTimesigAt( int clock, out int numerator, out int denominator, out int bar_count ) { int index = 0; - int c = TimesigTable.Count; + int c = TimesigTable.size(); for ( int i = c - 1; i >= 0; i-- ) { index = i; - if ( TimesigTable[i].Clock <= clock ) { + if ( TimesigTable.get( i ).Clock <= clock ) { break; } } - TimeSigTableEntry item = TimesigTable[index]; + TimeSigTableEntry item = TimesigTable.get( index ); numerator = item.Numerator; denominator = item.Denominator; int diff = clock - item.Clock; @@ -1425,14 +1492,14 @@ namespace Boare.Lib.Vsq { /// public int getTempoAt( int clock ) { int index = 0; - int c = TempoTable.Count; + int c = TempoTable.size(); for ( int i = c - 1; i >= 0; i-- ) { index = i; - if ( TempoTable[i].Clock <= clock ) { + if ( TempoTable.get( i ).Clock <= clock ) { break; } } - return TempoTable[index].Tempo; + return TempoTable.get( index ).Tempo; } /// @@ -1442,14 +1509,14 @@ namespace Boare.Lib.Vsq { /// public int getClockFromBarCount( int bar_count ) { int index = 0; - int c = TimesigTable.Count; + int c = TimesigTable.size(); for ( int i = c - 1; i >= 0; i-- ) { index = i; - if ( TimesigTable[i].BarCount <= bar_count ) { + if ( TimesigTable.get( i ).BarCount <= bar_count ) { break; } } - TimeSigTableEntry item = TimesigTable[index]; + TimeSigTableEntry item = TimesigTable.get( index ); int numerator = item.Numerator; int denominator = item.Denominator; int init_clock = item.Clock; @@ -1465,19 +1532,19 @@ namespace Boare.Lib.Vsq { /// public int getBarCountFromClock( int clock ) { int index = 0; - int c = TimesigTable.Count; + int c = TimesigTable.size(); for ( int i = c - 1; i >= 0; i-- ) { index = i; - if ( TimesigTable[i].Clock <= clock ) { + if ( TimesigTable.get( i ).Clock <= clock ) { break; } } int bar_count = 0; if ( index >= 0 ) { - int last_clock = TimesigTable[index].Clock; - int t_bar_count = TimesigTable[index].BarCount; - int numerator = TimesigTable[index].Numerator; - int denominator = TimesigTable[index].Denominator; + int last_clock = TimesigTable.get( index ).Clock; + int t_bar_count = TimesigTable.get( index ).BarCount; + int numerator = TimesigTable.get( index ).Numerator; + int denominator = TimesigTable.get( index ).Denominator; int clock_per_bar = numerator * 480 * 4 / denominator; bar_count = t_bar_count + (clock - last_clock) / clock_per_bar; } @@ -1499,7 +1566,7 @@ namespace Boare.Lib.Vsq { /*/// /// テンポの変更情報を格納したテーブルを取得します /// - public List getTempoList() { + public Vector getTempoList() { return TempoTable; }*/ #endif @@ -1507,12 +1574,12 @@ namespace Boare.Lib.Vsq { /*/// /// 拍子の変更情報を格納したテーブルを取得します /// - public List getTimeSigList() { + public Vector getTimeSigList() { return TimesigTable; }*/ /*public VsqTrack Track( int track ) { - return Track[track]; + return Track.get( track ); }*/ /*public int getTrackCount() { @@ -1526,23 +1593,23 @@ namespace Boare.Lib.Vsq { /// /// /// - public VsqFile( string singer, int pre_measure, int numerator, int denominator, int tempo ) { + public VsqFile( String singer, int pre_measure, int numerator, int denominator, int tempo ) { TotalClocks = pre_measure * 480 * 4 / denominator * numerator; m_tpq = 480; - Track = new List(); - Track.Add( new VsqTrack( tempo, numerator, denominator ) ); - Track.Add( new VsqTrack( "Voice1", singer ) ); + Track = new Vector(); + Track.add( new VsqTrack( tempo, numerator, denominator ) ); + Track.add( new VsqTrack( "Voice1", singer ) ); Master = new VsqMaster( pre_measure ); #if DEBUG Console.WriteLine( "VsqFile.ctor()" ); #endif Mixer = new VsqMixer( 0, 0, 0, 0 ); - Mixer.Slave.Add( new VsqMixerEntry( 0, 0, 0, 0 ) ); - TimesigTable = new List(); - TimesigTable.Add( new TimeSigTableEntry( 0, numerator, denominator, 0 ) ); - TempoTable = new List(); - TempoTable.Add( new TempoTableEntry( 0, tempo, 0.0 ) ); + Mixer.Slave.add( new VsqMixerEntry( 0, 0, 0, 0 ) ); + TimesigTable = new Vector(); + TimesigTable.add( new TimeSigTableEntry( 0, numerator, denominator, 0 ) ); + TempoTable = new Vector(); + TempoTable.add( new TempoTableEntry( 0, tempo, 0.0 ) ); m_base_tempo = tempo; //m_premeasure_clocks = calculatePreMeasureInClock(); } @@ -1551,35 +1618,35 @@ namespace Boare.Lib.Vsq { /// vsqファイルからのコンストラクタ /// /// - public VsqFile( string _fpath ) { - TempoTable = new List(); - TimesigTable = new List(); + public VsqFile( String _fpath, Encoding encoding ) { + TempoTable = new Vector(); + TimesigTable = new Vector(); m_tpq = 480; // SMFをコンバートしたテキストファイルを作成 //using ( TextMemoryStream tms = new TextMemoryStream( FileAccess.ReadWrite ) ) { MidiFile mf = new MidiFile( _fpath ); - Track = new List(); + Track = new Vector(); int num_track = mf.getTrackCount(); for ( int i = 0; i < num_track; i++ ) { - Track.Add( new VsqTrack( mf.getMidiEventList( i ) ) ); + Track.add( new VsqTrack( mf.getMidiEventList( i ), encoding ) ); } //} - Master = (VsqMaster)Track[1].getMaster().Clone(); - Mixer = (VsqMixer)Track[1].getMixer().Clone(); - Track[1].setMaster( null ); - Track[1].setMixer( null ); + Master = (VsqMaster)Track.get( 1 ).getMaster().Clone(); + Mixer = (VsqMixer)Track.get( 1 ).getMixer().Clone(); + Track.get( 1 ).setMaster( null ); + Track.get( 1 ).setMixer( null ); #if DEBUG System.Diagnostics.Debug.WriteLine( "VsqFile.ctor()" ); #endif int master_track = -1; - for ( int i = 0; i < Track.Count; i++ ) { + for ( int i = 0; i < Track.size(); i++ ) { #if DEBUG - System.Diagnostics.Debug.WriteLine( " m_tracks[i].Name=" + Track[i].Name ); + System.Diagnostics.Debug.WriteLine( " m_tracks[i].Name=" + Track.get( i ).getName() ); #endif - if ( Track[i].Name == "Master Track" ) { + if ( Track.get( i ).getName().Equals( "Master Track" ) ) { master_track = i; break; } @@ -1591,7 +1658,7 @@ namespace Boare.Lib.Vsq { if ( master_track >= 0 ) { #region TempoListの作成 // MIDI event リストの取得 - List midi_event = mf.getMidiEventList( master_track );//.TempoTable; + Vector midi_event = mf.getMidiEventList( master_track );//.TempoTable; // とりあえずtempo_tableに格納 m_base_tempo = 500000; prev_tempo = 500000; @@ -1599,28 +1666,28 @@ namespace Boare.Lib.Vsq { double thistime; prev_time = 0.0; int count = -1; - for ( int j = 0; j < midi_event.Count; j++ ) { - if ( midi_event[j].firstByte == 0xff && midi_event[j].data.Length >= 4 && midi_event[j].data[0] == 0x51 ) { + for ( int j = 0; j < midi_event.size(); j++ ) { + if ( midi_event.get( j ).firstByte == 0xff && midi_event.get( j ).data.Length >= 4 && midi_event.get( j ).data[0] == 0x51 ) { count++; - if ( count == 0 && midi_event[j].clock != 0 ) { - TempoTable.Add( new TempoTableEntry( 0, 500000, 0.0 ) ); + if ( count == 0 && midi_event.get( j ).clock != 0 ) { + TempoTable.add( new TempoTableEntry( 0, 500000, 0.0 ) ); m_base_tempo = 500000; prev_tempo = 500000; } - int current_tempo = midi_event[j].data[1] << 16 | midi_event[j].data[2] << 8 | midi_event[j].data[3]; - int current_index = (int)midi_event[j].clock; + int current_tempo = midi_event.get( j ).data[1] << 16 | midi_event.get( j ).data[2] << 8 | midi_event.get( j ).data[3]; + int current_index = (int)midi_event.get( j ).clock; thistime = prev_time + (double)(prev_tempo) * (double)(current_index - prev_index) / (m_tpq * 1000000.0); - TempoTable.Add( new TempoTableEntry( current_index, current_tempo, thistime ) ); + TempoTable.add( new TempoTableEntry( current_index, current_tempo, thistime ) ); prev_tempo = current_tempo; prev_index = current_index; prev_time = thistime; } } - TempoTable.Sort(); + Collections.sort( TempoTable ); #endregion #region TimeSigTableの作成 - //List time_sigs = mf.getMidiEventList( master_track );//].TimesigTable; + //Vector time_sigs = mf.getMidiEventList( master_track );//].TimesigTable; int dnomi = 4;// time_sigs[0].Data[1]; int numer = 4; /*for ( int i = 0; i < time_sigs[0].Data[2]; i++ ) { @@ -1628,12 +1695,12 @@ namespace Boare.Lib.Vsq { }*/ //m_timesig_table.Add( new TimeSigTableEntry( 0, numer, dnomi, 0 ) ); count = -1; - for ( int j = 0; j < midi_event.Count; j++ ) { - if ( midi_event[j].firstByte == 0xff && midi_event[j].data.Length >= 5 && midi_event[j].data[0] == 0x58 ) { + for ( int j = 0; j < midi_event.size(); j++ ) { + if ( midi_event.get( j ).firstByte == 0xff && midi_event.get( j ).data.Length >= 5 && midi_event.get( j ).data[0] == 0x58 ) { count++; - numer = midi_event[j].data[1]; + numer = midi_event.get( j ).data[1]; dnomi = 1; - for ( int i = 0; i < midi_event[j].data[2]; i++ ) { + for ( int i = 0; i < midi_event.get( j ).data[2]; i++ ) { dnomi = dnomi * 2; } if ( count == 0 ){ @@ -1641,21 +1708,21 @@ namespace Boare.Lib.Vsq { int denominator = 4; int clock = 0; int bar_count = 0; - if ( midi_event[j].clock == 0 ) { - TimesigTable.Add( new TimeSigTableEntry( 0, numer, dnomi, 0 ) ); + if ( midi_event.get( j ).clock == 0 ) { + TimesigTable.add( new TimeSigTableEntry( 0, numer, dnomi, 0 ) ); } else { - TimesigTable.Add( new TimeSigTableEntry( 0, 4, 4, 0 ) ); - TimesigTable.Add( new TimeSigTableEntry( 0, numer, dnomi, (int)midi_event[j].clock / (480 * 4) ) ); + TimesigTable.add( new TimeSigTableEntry( 0, 4, 4, 0 ) ); + TimesigTable.add( new TimeSigTableEntry( 0, numer, dnomi, (int)midi_event.get( j ).clock / (480 * 4) ) ); count++; } } else { - int numerator = TimesigTable[count - 1].Numerator; - int denominator = TimesigTable[count - 1].Denominator; - int clock = TimesigTable[count - 1].Clock; - int bar_count = TimesigTable[count - 1].BarCount; + int numerator = TimesigTable.get( count - 1 ).Numerator; + int denominator = TimesigTable.get( count - 1 ).Denominator; + int clock = TimesigTable.get( count - 1 ).Clock; + int bar_count = TimesigTable.get( count - 1 ).BarCount; int dif = 480 * 4 / denominator * numerator;//1小節が何クロックか? - bar_count += ((int)midi_event[j].clock - clock) / dif; - TimesigTable.Add( new TimeSigTableEntry( (int)midi_event[j].clock, numer, dnomi, bar_count ) ); + bar_count += ((int)midi_event.get( j ).clock - clock) / dif; + TimesigTable.add( new TimeSigTableEntry( (int)midi_event.get( j ).clock, numer, dnomi, bar_count ) ); } } } @@ -1679,24 +1746,24 @@ namespace Boare.Lib.Vsq { #if DEBUG Console.WriteLine( "VsqFile.UpdateTimesigInfo()" ); #endif - if ( TimesigTable[0].Clock != 0 ) { + if ( TimesigTable.get( 0 ).Clock != 0 ) { throw new ApplicationException( "initial timesig does not found" ); } - TimesigTable[0].Clock = 0; - TimesigTable.Sort(); - for ( int j = 1; j < TimesigTable.Count; j++ ) { - int numerator = TimesigTable[j - 1].Numerator; - int denominator = TimesigTable[j - 1].Denominator; - int clock = TimesigTable[j - 1].Clock; - int bar_count = TimesigTable[j - 1].BarCount; + TimesigTable.get( 0 ).Clock = 0; + Collections.sort( TimesigTable ); + for ( int j = 1; j < TimesigTable.size(); j++ ) { + int numerator = TimesigTable.get( j - 1 ).Numerator; + int denominator = TimesigTable.get( j - 1 ).Denominator; + int clock = TimesigTable.get( j - 1 ).Clock; + int bar_count = TimesigTable.get( j - 1 ).BarCount; int dif = 480 * 4 / denominator * numerator;//1小節が何クロックか? - clock += (TimesigTable[j].BarCount - bar_count) * dif; - TimesigTable[j].Clock = clock; + clock += (TimesigTable.get( j ).BarCount - bar_count) * dif; + TimesigTable.get( j ).Clock = clock; } #if DEBUG Console.WriteLine( "TimesigTable;" ); - for ( int i = 0; i < TimesigTable.Count; i++ ) { - Console.WriteLine( " " + TimesigTable[i].Clock + " " + TimesigTable[i].Numerator + "/" + TimesigTable[i].Denominator ); + for ( int i = 0; i < TimesigTable.size(); i++ ) { + Console.WriteLine( " " + TimesigTable.get( i ).Clock + " " + TimesigTable.get( i ).Numerator + "/" + TimesigTable.get( i ).Denominator ); } #endif } @@ -1705,24 +1772,24 @@ namespace Boare.Lib.Vsq { /// TempoTableの[*].Timeの部分を更新します /// public void updateTempoInfo() { - if ( TempoTable.Count == 0 ) { - TempoTable.Add( new TempoTableEntry( 0, getBaseTempo(), 0.0 ) ); + if ( TempoTable.size() == 0 ) { + TempoTable.add( new TempoTableEntry( 0, getBaseTempo(), 0.0 ) ); } - TempoTable.Sort(); - if ( TempoTable[0].Clock != 0 ) { - TempoTable[0].Time = (double)getBaseTempo() * (double)TempoTable[0].Clock / (getTickPerQuarter() * 1000000.0); + Collections.sort( TempoTable ); + if ( TempoTable.get( 0 ).Clock != 0 ) { + TempoTable.get( 0 ).Time = (double)getBaseTempo() * (double)TempoTable.get( 0 ).Clock / (getTickPerQuarter() * 1000000.0); } else { - TempoTable[0].Time = 0.0; + TempoTable.get( 0 ).Time = 0.0; } - double prev_time = TempoTable[0].Time; - int prev_clock = TempoTable[0].Clock; - int prev_tempo = TempoTable[0].Tempo; + double prev_time = TempoTable.get( 0 ).Time; + int prev_clock = TempoTable.get( 0 ).Clock; + int prev_tempo = TempoTable.get( 0 ).Tempo; double inv_tpq_sec = 1.0 / (getTickPerQuarter() * 1000000.0); - for ( int i = 1; i < TempoTable.Count; i++ ) { - TempoTable[i].Time = prev_time + (double)prev_tempo * (double)(TempoTable[i].Clock - prev_clock) * inv_tpq_sec; - prev_time = TempoTable[i].Time; - prev_tempo = TempoTable[i].Tempo; - prev_clock = TempoTable[i].Clock; + for ( int i = 1; i < TempoTable.size(); i++ ) { + TempoTable.get( i ).Time = prev_time + (double)prev_tempo * (double)(TempoTable.get( i ).Clock - prev_clock) * inv_tpq_sec; + prev_time = TempoTable.get( i ).Time; + prev_tempo = TempoTable.get( i ).Tempo; + prev_clock = TempoTable.get( i ).Clock; } } @@ -1731,19 +1798,20 @@ namespace Boare.Lib.Vsq { /// public void updateTotalClocks() { int max = getPreMeasureClocks(); - for( int i = 1; i < Track.Count; i++ ){ - VsqTrack track = Track[i]; + for( int i = 1; i < Track.size(); i++ ){ + VsqTrack track = Track.get( i ); for ( Iterator itr = track.getEventIterator(); itr.hasNext(); ) { VsqEvent ve = (VsqEvent)itr.next(); max = Math.Max( max, ve.Clock + ve.ID.Length ); } - foreach ( string vct in _CURVES ) { - if ( vct == "VEL" ) { + foreach ( String vct in _CURVES ) { + if ( vct.Equals( "VEL" ) ) { continue; } - if ( track.getCurve( vct ).getCount() > 0 ) { - int keys = track.getCurve( vct ).getCount(); - int last_key = track.getCurve( vct ).getKeys()[keys - 1]; + VsqBPList list = track.getCurve( vct ); + if ( list != null && list.size() > 0 ) { + int keys = list.size(); + int last_key = list.getKeys()[keys - 1]; max = Math.Max( max, last_key ); } } @@ -1763,116 +1831,145 @@ namespace Boare.Lib.Vsq { /// /// /// - public void printLyricTable( int track, string fpath ) { + public void printLyricTable( int track, String fpath ) { using ( StreamWriter sw = new StreamWriter( fpath ) ) { - for ( int i = 0; i < Track[track].getEventCount(); i++ ) { + for ( int i = 0; i < Track.get( track ).getEventCount(); i++ ) { int Length; // timesignal - int time_signal = Track[track].getEvent( i ).Clock; + int time_signal = Track.get( track ).getEvent( i ).Clock; // イベントで指定されたIDがLyricであった場合 - if ( Track[track].getEvent( i ).ID.type == VsqIDType.Anote ) { + if ( Track.get( track ).getEvent( i ).ID.type == VsqIDType.Anote ) { // 発音長を取得 - Length = Track[track].getEvent( i ).ID.Length; + Length = Track.get( track ).getEvent( i ).ID.Length; // tempo_tableから、発音開始時のtempoを取得 - int last = TempoTable.Count - 1; - int tempo = TempoTable[last].Tempo; - int prev_index = TempoTable[last].Clock; - double prev_time = TempoTable[last].Time; - for ( int j = 1; j < TempoTable.Count; j++ ) { - if ( TempoTable[j].Clock > time_signal ) { - tempo = TempoTable[j - 1].Tempo; - prev_index = TempoTable[j - 1].Clock; - prev_time = TempoTable[j - 1].Time; + int last = TempoTable.size() - 1; + int tempo = TempoTable.get( last ).Tempo; + int prev_index = TempoTable.get( last ).Clock; + double prev_time = TempoTable.get( last ).Time; + for ( int j = 1; j < TempoTable.size(); j++ ) { + if ( TempoTable.get( j ).Clock > time_signal ) { + tempo = TempoTable.get( j - 1 ).Tempo; + prev_index = TempoTable.get( j - 1 ).Clock; + prev_time = TempoTable.get( j - 1 ).Time; break; } } - int current_index = Track[track].getEvent( i ).Clock; + int current_index = Track.get( track ).getEvent( i ).Clock; double start_time = prev_time + (double)(current_index - prev_index) * (double)tempo / (m_tpq * 1000000.0); // TODO: 単純に + Lengthしただけではまずいはず。要検討 double end_time = start_time + ((double)Length) * ((double)tempo) / (m_tpq * 1000000.0); - sw.WriteLine( Track[track].getEvent( i ).Clock + "," + + sw.WriteLine( Track.get( track ).getEvent( i ).Clock + "," + start_time.ToString( "0.000000" ) + "," + end_time.ToString( "0.000000" ) + "," + - Track[track].getEvent( i ).ID.LyricHandle.L0.Phrase + "," + - Track[track].getEvent( i ).ID.LyricHandle.L0.getPhoneticSymbol() ); + Track.get( track ).getEvent( i ).ID.LyricHandle.L0.Phrase + "," + + Track.get( track ).getEvent( i ).ID.LyricHandle.L0.getPhoneticSymbol() ); } } } } - public List generateMetaTextEvent( int track ) { - string _NL = "" + (char)0x0a; - List ret = new List(); + public Vector generateMetaTextEvent( int track, Encoding encoding ) { + String _NL = "" + (char)0x0a; + Vector ret = new Vector(); using ( TextMemoryStream sr = new TextMemoryStream() ) { - Track[track].printMetaText( sr, TotalClocks + 120, calculatePreMeasureInClock() ); + Track.get( track ).printMetaText( sr, TotalClocks + 120, calculatePreMeasureInClock() ); sr.rewind(); int line_count = -1; - string tmp = ""; + String tmp = ""; if ( sr.peek() >= 0 ) { tmp = sr.readLine(); - char[] line_char; - string line = ""; + byte[] line_bytes; while ( sr.peek() >= 0 ) { - line = sr.readLine(); - tmp += _NL + line; - while ( (tmp + getLinePrefix( line_count + 1 )).Length >= 127 ) { + tmp += _NL + sr.readLine(); + while ( encoding.GetByteCount( tmp + getLinePrefix( line_count + 1 ) ) >= 127 ) { line_count++; tmp = getLinePrefix( line_count ) + tmp; - string work = tmp.Substring( 0, 127 ); - tmp = tmp.Substring( 127 ); - line_char = work.ToCharArray(); + String work = substring127Bytes( tmp, encoding );// tmp.Substring( 0, 127 ); +#if DEBUG + Console.WriteLine( "VsqFile#generateMetaTextEvent; tmp=" + tmp + "; work=" + work ); +#endif + tmp = tmp.Substring( work.Length ); +#if DEBUG + Console.WriteLine( "VsqFile#generateMetaTextEvent; new tmp=" + tmp ); +#endif + line_bytes = encoding.GetBytes( work ); MidiEvent add = new MidiEvent(); add.clock = 0; add.firstByte = 0xff; //ステータス メタ* - add.data = new byte[line_char.Length + 1]; + add.data = new byte[line_bytes.Length + 1]; add.data[0] = 0x01; //メタテキスト - for ( int i = 0; i < line_char.Length; i++ ) { - add.data[i + 1] = (byte)line_char[i]; + for ( int i = 0; i < line_bytes.Length; i++ ) { + add.data[i + 1] = line_bytes[i]; } - ret.Add( add ); + ret.add( add ); } } // 残りを出力 line_count++; tmp = getLinePrefix( line_count ) + tmp + _NL; - while ( tmp.Length > 127 ) { - string work = tmp.Substring( 0, 127 ); - tmp = tmp.Substring( 127 ); - line_char = work.ToCharArray(); + while ( encoding.GetByteCount( tmp ) > 127 ) { + String work = substring127Bytes( tmp, encoding ); + tmp = tmp.Substring( work.Length ); + line_bytes = encoding.GetBytes( work ); MidiEvent add = new MidiEvent(); add.clock = 0; add.firstByte = 0xff; - add.data = new byte[line_char.Length + 1]; + add.data = new byte[line_bytes.Length + 1]; add.data[0] = 0x01; - for ( int i = 0; i < line_char.Length; i++ ) { - add.data[i + 1] = (byte)line_char[i]; + for ( int i = 0; i < line_bytes.Length; i++ ) { + add.data[i + 1] = line_bytes[i]; } - ret.Add( add ); + ret.add( add ); line_count++; tmp = getLinePrefix( line_count ); } - line_char = tmp.ToCharArray(); + line_bytes = encoding.GetBytes( tmp ); MidiEvent add0 = new MidiEvent(); add0.firstByte = 0xff; - add0.data = new byte[line_char.Length + 1]; + add0.data = new byte[line_bytes.Length + 1]; add0.data[0] = 0x01; - for ( int i = 0; i < line_char.Length; i++ ) { - add0.data[i + 1] = (byte)line_char[i]; + for ( int i = 0; i < line_bytes.Length; i++ ) { + add0.data[i + 1] = line_bytes[i]; } - ret.Add( add0 ); + ret.add( add0 ); } } return ret; } - private static void printTrack( VsqFile vsq, int track, FileStream fs, int msPreSend ) { + /// + /// 文字列sの先頭から文字列を切り取るとき,切り取った文字列をencodingによりエンコードした結果が127Byte以下になるように切り取ります. + /// + /// + /// + /// + private static String substring127Bytes( String s, Encoding encoding ) { + int count = Math.Min( 127, s.Length ); + int c = encoding.GetByteCount( s.Substring( 0, count ) ); + if ( c == 127 ) { + return s.Substring( 0, count ); + } + int delta = c > 127 ? -1 : 1; + while ( (delta == -1 && c > 127) || (delta == 1 && c < 127) ) { + count += delta; + if ( delta == -1 && count == 0 ) { + break; + } else if ( delta == 1 && count == s.Length ) { + break; + } + c = encoding.GetByteCount( s.Substring( 0, count ) ); + } + return s.Substring( 0, count ); + } + + private static void printTrack( VsqFile vsq, int track, FileStream fs, int msPreSend, Encoding encoding ) { #if DEBUG Console.WriteLine( "PrintTrack" ); #endif //VsqTrack item = Tracks[track]; - string _NL = "" + (char)0x0a; + String _NL = "" + (char)0x0a; //ヘッダ fs.Write( _MTRK, 0, 4 ); //データ長。とりあえず0 @@ -1882,17 +1979,17 @@ namespace Boare.Lib.Vsq { writeFlexibleLengthUnsignedLong( fs, 0x00 );//デルタタイム fs.WriteByte( 0xff );//ステータスタイプ fs.WriteByte( 0x03 );//イベントタイプSequence/Track Name - byte[] seq_name = bocoree.cp932.convert( vsq.Track[track].Name ); + byte[] seq_name = encoding.GetBytes( vsq.Track.get( track ).getName() ); writeFlexibleLengthUnsignedLong( fs, (ulong)seq_name.Length );//seq_nameの文字数 fs.Write( seq_name, 0, seq_name.Length ); //Meta Textを準備 - List meta = vsq.generateMetaTextEvent( track ); + Vector meta = vsq.generateMetaTextEvent( track, encoding ); long lastclock = 0; - for ( int i = 0; i < meta.Count; i++ ) { - writeFlexibleLengthUnsignedLong( fs, (ulong)(meta[i].clock - lastclock) ); - meta[i].writeData( fs ); - lastclock = meta[i].clock; + for ( int i = 0; i < meta.size(); i++ ) { + writeFlexibleLengthUnsignedLong( fs, (ulong)(meta.get( i ).clock - lastclock) ); + meta.get( i ).writeData( fs ); + lastclock = meta.get( i ).clock; } int last = 0; @@ -1907,7 +2004,7 @@ namespace Boare.Lib.Vsq { } //トラックエンド - VsqEvent last_event = vsq.Track[track].getEvent( vsq.Track[track].getEventCount() - 1 ); + VsqEvent last_event = vsq.Track.get( track ).getEvent( vsq.Track.get( track ).getEventCount() - 1 ); int last_clock = last_event.Clock + last_event.ID.Length; writeFlexibleLengthUnsignedLong( fs, (ulong)last_clock ); fs.WriteByte( 0xff ); @@ -1939,9 +2036,9 @@ namespace Boare.Lib.Vsq { /// /// public static VsqNrpn[] generateExpressionNRPN( VsqFile vsq, int track, int msPreSend ) { - List ret = new List(); - VsqBPList dyn = vsq.Track[track].getCurve( "DYN" ); - int count = dyn.getCount(); + Vector ret = new Vector(); + VsqBPList dyn = vsq.Track.get( track ).getCurve( "DYN" ); + int count = dyn.size(); for ( int i = 0; i < count; i++ ) { int clock = dyn.getKeyClock( i ); int c = clock - vsq.getPresendClockAt( clock, msPreSend ); @@ -1949,16 +2046,16 @@ namespace Boare.Lib.Vsq { VsqNrpn add = new VsqNrpn( c, NRPN.CC_E_EXPRESSION, (byte)dyn.getElement( i ) ); - ret.Add( add ); + ret.add( add ); } } - return ret.ToArray(); + return ret.toArray( new VsqNrpn[]{} ); } public static VsqNrpn[] generateFx2DepthNRPN( VsqFile vsq, int track, int msPreSend ) { - List ret = new List(); - VsqBPList fx2depth = vsq.Track[track].getCurve( "fx2depth" ); - int count = fx2depth.getCount(); + Vector ret = new Vector(); + VsqBPList fx2depth = vsq.Track.get( track ).getCurve( "fx2depth" ); + int count = fx2depth.size(); for ( int i = 0; i < count; i++ ) { int clock = fx2depth.getKeyClock( i ); int c = clock - vsq.getPresendClockAt( clock, msPreSend ); @@ -1966,10 +2063,10 @@ namespace Boare.Lib.Vsq { VsqNrpn add = new VsqNrpn( c, NRPN.CC_FX2_EFFECT2_DEPTH, (byte)fx2depth.getElement( i ) ); - ret.Add( add ); + ret.add( add ); } } - return ret.ToArray(); + return ret.toArray( new VsqNrpn[]{} ); } /// @@ -2008,7 +2105,7 @@ namespace Boare.Lib.Vsq { getMsbAndLsb( duration, out duration0, out duration1 ); byte delay0, delay1; getMsbAndLsb( (ushort)msPreSend, out delay0, out delay1 ); - List ret = new List(); + Vector ret = new Vector(); int i = clock - vsq.getPresendClockAt( clock, msPreSend ); VsqNrpn add = new VsqNrpn( i, (ushort)NRPN.CC_BS_VERSION_AND_DEVICE, 0x00, 0x00 ); @@ -2025,16 +2122,16 @@ namespace Boare.Lib.Vsq { /// /// /// - public static VsqNrpn generateNoteNRPN( VsqFile vsq, int track, VsqEvent ve, int msPreSend, byte note_loc, bool add_delay_sign ) { + public static VsqNrpn generateNoteNRPN( VsqFile vsq, int track, VsqEvent ve, int msPreSend, byte note_loc, boolean add_delay_sign ) { int clock = ve.Clock; - string renderer = vsq.Track[track].getCommon().Version; + String renderer = vsq.Track.get( track ).getCommon().Version; double clock_msec = vsq.getSecFromClock( clock ) * 1000.0; int ttempo = vsq.getTempoAt( clock ); double tempo = 6e7 / ttempo; double msEnd = vsq.getSecFromClock( ve.Clock + ve.ID.Length ) * 1000.0; - ushort duration = (ushort)Math.Ceiling( msEnd - clock_msec ); + ushort duration = (ushort)(msEnd - clock_msec); byte duration0, duration1; getMsbAndLsb( duration, out duration0, out duration1 ); @@ -2063,8 +2160,8 @@ namespace Boare.Lib.Vsq { add.append( NRPN.CVM_NM_VIBRATO_DELAY, bVibratoDelay, true ); } - string[] spl = ve.ID.LyricHandle.L0.getPhoneticSymbolList(); - string s = ""; + String[] spl = ve.ID.LyricHandle.L0.getPhoneticSymbolList(); + String s = ""; for ( int j = 0; j < spl.Length; j++ ) { s += spl[j]; } @@ -2221,10 +2318,10 @@ namespace Boare.Lib.Vsq { #if DEBUG Console.WriteLine( "GenerateNRPN(VsqTrack,int,int,int,int)" ); #endif - List list = new List(); + Vector list = new Vector(); - VsqTrack target = vsq.Track[track]; - string version = target.getCommon().Version; + VsqTrack target = vsq.Track.get( track ); + String version = target.getCommon().Version; int count = target.getEventCount(); int note_start = 0; @@ -2252,16 +2349,16 @@ namespace Boare.Lib.Vsq { } } if ( singer_event >= 0 ) { //見つかった場合 - list.AddRange( generateSingerNRPN( vsq, target.getEvent( singer_event ), 0 ) ); + list.addAll( generateSingerNRPN( vsq, target.getEvent( singer_event ), 0 ) ); } else { //多分ありえないと思うが、歌手が不明の場合。 throw new ApplicationException( "first singer was not specified" ); - list.Add( new VsqNrpn( 0, NRPN.CC_BS_LANGUAGE_TYPE, 0 ) ); - list.Add( new VsqNrpn( 0, NRPN.PC_VOICE_TYPE, 0 ) ); + list.add( new VsqNrpn( 0, NRPN.CC_BS_LANGUAGE_TYPE, 0 ) ); + list.add( new VsqNrpn( 0, NRPN.PC_VOICE_TYPE, 0 ) ); } - list.AddRange( generateVoiceChangeParameterNRPN( vsq, track, msPreSend ) ); + list.addAll( generateVoiceChangeParameterNRPN( vsq, track, msPreSend ) ); if ( version.StartsWith( "DSB2" ) ) { - list.AddRange( generateFx2DepthNRPN( vsq, track, msPreSend ) ); + list.addAll( generateFx2DepthNRPN( vsq, track, msPreSend ) ); } int ms_presend = msPreSend; @@ -2275,28 +2372,28 @@ namespace Boare.Lib.Vsq { ms_presend += (int)(sec_maxlen * 1000.0); } VsqBPList dyn = target.getCurve( "dyn" ); - if ( dyn.getCount() > 0 ) { - List listdyn = new List( generateExpressionNRPN( vsq, track, ms_presend ) ); - if ( listdyn.Count > 0 ) { - list.AddRange( listdyn ); + if ( dyn.size() > 0 ) { + Vector listdyn = new Vector( generateExpressionNRPN( vsq, track, ms_presend ) ); + if ( listdyn.size() > 0 ) { + list.addAll( listdyn ); } } VsqBPList pbs = target.getCurve( "pbs" ); - if ( pbs.getCount() > 0 ) { - List listpbs = new List( generatePitchBendSensitivityNRPN( vsq, track, ms_presend ) ); - if ( listpbs.Count > 0 ) { - list.AddRange( listpbs ); + if ( pbs.size() > 0 ) { + Vector listpbs = new Vector( generatePitchBendSensitivityNRPN( vsq, track, ms_presend ) ); + if ( listpbs.size() > 0 ) { + list.addAll( listpbs ); } } VsqBPList pit = target.getCurve( "pit" ); - if ( pit.getCount() > 0 ) { - List listpit = new List( generatePitchBendNRPN( vsq, track, ms_presend ) ); - if ( listpit.Count > 0 ) { - list.AddRange( listpit ); + if ( pit.size() > 0 ) { + Vector listpit = new Vector( generatePitchBendNRPN( vsq, track, ms_presend ) ); + if ( listpit.size() > 0 ) { + list.addAll( listpit ); } } - bool first = true; + boolean first = true; int last_note_end = 0; for ( int i = note_start; i <= note_end; i++ ) { VsqEvent item = target.getEvent( i ); @@ -2318,30 +2415,30 @@ namespace Boare.Lib.Vsq { note_loc -= 0x01; } - list.Add( generateNoteNRPN( vsq, + list.add( generateNoteNRPN( vsq, track, item, msPreSend, note_loc, first ) ); first = false; - list.AddRange( generateVibratoNRPN( vsq, + list.addAll( generateVibratoNRPN( vsq, item, msPreSend ) ); last_note_end = item.Clock + item.ID.Length; } else if ( item.ID.type == VsqIDType.Singer ) { if ( i > note_start && i != singer_event ) { - list.AddRange( generateSingerNRPN( vsq, item, msPreSend ) ); + list.addAll( generateSingerNRPN( vsq, item, msPreSend ) ); } } } list = VsqNrpn.sort( list ); - List merged = new List(); - for ( int i = 0; i < list.Count; i++ ) { - merged.AddRange( list[i].expand() ); + Vector merged = new Vector(); + for ( int i = 0; i < list.size(); i++ ) { + merged.addAll( list.get( i ).expand() ); } - return merged.ToArray(); + return merged.toArray( new VsqNrpn[]{} ); } /// @@ -2352,9 +2449,9 @@ namespace Boare.Lib.Vsq { /// /// public static VsqNrpn[] generatePitchBendNRPN( VsqFile vsq, int track, int msPreSend ) { - List ret = new List(); - VsqBPList pit = vsq.Track[track].getCurve( "PIT" ); - int count = pit.getCount(); + Vector ret = new Vector(); + VsqBPList pit = vsq.Track.get( track ).getCurve( "PIT" ); + int count = pit.size(); for ( int i = 0; i < count; i++ ) { int clock = pit.getKeyClock( i ); ushort value = (ushort)(pit.getElement( i ) + 0x2000); @@ -2366,10 +2463,10 @@ namespace Boare.Lib.Vsq { NRPN.PB_PITCH_BEND, value0, value1 ); - ret.Add( add ); + ret.add( add ); } } - return ret.ToArray(); + return ret.toArray( new VsqNrpn[]{} ); } /// @@ -2380,9 +2477,9 @@ namespace Boare.Lib.Vsq { /// /// public static VsqNrpn[] generatePitchBendSensitivityNRPN( VsqFile vsq, int track, int msPreSend ) { - List ret = new List(); - VsqBPList pbs = vsq.Track[track].getCurve( "PBS" ); - int count = pbs.getCount(); + Vector ret = new Vector(); + VsqBPList pbs = vsq.Track.get( track ).getCurve( "PBS" ); + int count = pbs.size(); for ( int i = 0; i < count; i++ ) { int clock = pbs.getKeyClock( i ); int c = clock - vsq.getPresendClockAt( clock, msPreSend ); @@ -2391,10 +2488,10 @@ namespace Boare.Lib.Vsq { NRPN.CC_PBS_PITCH_BEND_SENSITIVITY, (byte)pbs.getElement( i ), 0x00 ); - ret.Add( add ); + ret.add( add ); } } - return ret.ToArray(); + return ret.toArray( new VsqNrpn[]{} ); } /// @@ -2405,7 +2502,7 @@ namespace Boare.Lib.Vsq { /// /// public static VsqNrpn[] generateVibratoNRPN( VsqFile vsq, VsqEvent ve, int msPreSend ) { - List ret = new List(); + Vector ret = new Vector(); if ( ve.ID.VibratoHandle != null ){ int vclock = ve.Clock + ve.ID.VibratoDelay; byte delay0, delay1; @@ -2417,25 +2514,25 @@ namespace Boare.Lib.Vsq { add2.append( NRPN.CC_VD_DELAY, delay0, delay1, true ); add2.append( NRPN.CC_VD_VIBRATO_DEPTH, (byte)ve.ID.VibratoHandle.StartDepth, true ); add2.append( NRPN.CC_VR_VIBRATO_RATE, (byte)ve.ID.VibratoHandle.StartRate ); - ret.Add( add2 ); + ret.add( add2 ); int vlength = ve.ID.Length - ve.ID.VibratoDelay; if ( ve.ID.VibratoHandle.RateBP.getCount() > 0 ) { for ( int i = 0; i < ve.ID.VibratoHandle.RateBP.getCount(); i++ ) { float percent = ve.ID.VibratoHandle.RateBP.getElement( i ).X; int cl = vclock + (int)(percent * vlength); - ret.Add( new VsqNrpn( cl - vsq.getPresendClockAt( cl, msPreSend ), NRPN.CC_VR_VIBRATO_RATE, (byte)ve.ID.VibratoHandle.RateBP.getElement( i ).Y ) ); + ret.add( new VsqNrpn( cl - vsq.getPresendClockAt( cl, msPreSend ), NRPN.CC_VR_VIBRATO_RATE, (byte)ve.ID.VibratoHandle.RateBP.getElement( i ).Y ) ); } } if ( ve.ID.VibratoHandle.DepthBP.getCount() > 0 ) { for ( int i = 0; i < ve.ID.VibratoHandle.DepthBP.getCount(); i++ ) { float percent = ve.ID.VibratoHandle.DepthBP.getElement( i ).X; int cl = vclock + (int)(percent * vlength); - ret.Add( new VsqNrpn( cl - vsq.getPresendClockAt( cl, msPreSend ), NRPN.CC_VD_VIBRATO_DEPTH, (byte)ve.ID.VibratoHandle.DepthBP.getElement( i ).Y ) ); + ret.add( new VsqNrpn( cl - vsq.getPresendClockAt( cl, msPreSend ), NRPN.CC_VD_VIBRATO_DEPTH, (byte)ve.ID.VibratoHandle.DepthBP.getElement( i ).Y ) ); } } } - ret.Sort(); - return ret.ToArray(); + Collections.sort( ret ); + return ret.toArray( new VsqNrpn[]{} ); } /// @@ -2447,27 +2544,27 @@ namespace Boare.Lib.Vsq { /// public static VsqNrpn[] generateVoiceChangeParameterNRPN( VsqFile vsq, int track, int msPreSend ) { int premeasure_clock = vsq.getPreMeasureClocks(); - string renderer = vsq.Track[track].getCommon().Version; - List res = new List(); + String renderer = vsq.Track.get( track ).getCommon().Version; + Vector res = new Vector(); - string[] curves; + String[] curves; if ( renderer.StartsWith( "DSB3" ) ) { - curves = new string[] { "BRE", "BRI", "CLE", "POR", "OPE", "GEN" }; + curves = new String[] { "BRE", "BRI", "CLE", "POR", "OPE", "GEN" }; } else if ( renderer.StartsWith( "DSB2" ) ) { - curves = new string[] { "BRE", "BRI", "CLE", "POR", "GEN", "harmonics", + curves = new String[] { "BRE", "BRI", "CLE", "POR", "GEN", "harmonics", "reso1amp", "reso1bw", "reso1freq", "reso2amp", "reso2bw", "reso2freq", "reso3amp", "reso3bw", "reso3freq", "reso4amp", "reso4bw", "reso4freq" }; } else { - curves = new string[] { "BRE", "BRI", "CLE", "POR", "GEN" }; + curves = new String[] { "BRE", "BRI", "CLE", "POR", "GEN" }; } for ( int i = 0; i < curves.Length; i++ ) { - VsqBPList vbpl = vsq.Track[track].getCurve( curves[i] ); - if ( vbpl.getCount() > 0 ) { + VsqBPList vbpl = vsq.Track.get( track ).getCurve( curves[i] ); + if ( vbpl.size() > 0 ) { byte lsb = NRPN.getVoiceChangeParameterID( curves[i] ); - int count = vbpl.getCount(); + int count = vbpl.size(); for ( int j = 0; j < count; j++ ) { int clock = vbpl.getKeyClock( j ); int c = clock - vsq.getPresendClockAt( clock, msPreSend ); @@ -2476,33 +2573,39 @@ namespace Boare.Lib.Vsq { NRPN.VCP_VOICE_CHANGE_PARAMETER_ID, lsb ); add.append( NRPN.VCP_VOICE_CHANGE_PARAMETER, (byte)vbpl.getElement( j ), true ); - res.Add( add ); + res.add( add ); } } } } - res.Sort(); - return res.ToArray(); + Collections.sort( res ); + return res.toArray( new VsqNrpn[]{} ); } private static void getMsbAndLsb( ushort value, out byte msb, out byte lsb ) { - msb = (byte)(value >> 7); - lsb = (byte)(value - (msb << 7)); + if ( 0x3fff < value ) { + msb = 0x7f; + lsb = 0x7f; + } else { + msb = (byte)(value >> 7); + lsb = (byte)(value - (msb << 7)); + } } - public List generateTimeSig() { - List events = new List(); - foreach ( TimeSigTableEntry entry in TimesigTable ) { - events.Add( MidiEvent.generateTimeSigEvent( entry.Clock, entry.Numerator, entry.Denominator ) ); - //last_clock = Math.Max( last_clock, entry.Clock ); + public Vector generateTimeSig() { + Vector events = new Vector(); + for ( Iterator itr = TimesigTable.iterator(); itr.hasNext(); ){ + TimeSigTableEntry entry = (TimeSigTableEntry)itr.next(); + events.add( MidiEvent.generateTimeSigEvent( entry.Clock, entry.Numerator, entry.Denominator ) ); } return events; } - public List generateTempoChange() { - List events = new List(); - foreach ( TempoTableEntry entry in TempoTable ) { - events.Add( MidiEvent.generateTempoChangeEvent( entry.Clock, entry.Tempo ) ); + public Vector generateTempoChange() { + Vector events = new Vector(); + for( Iterator itr = TempoTable.iterator(); itr.hasNext(); ){ + TempoTableEntry entry = (TempoTableEntry)itr.next(); + events.add( MidiEvent.generateTempoChangeEvent( entry.Clock, entry.Tempo ) ); //last_clock = Math.Max( last_clock, entry.Clock ); } return events; @@ -2512,8 +2615,8 @@ namespace Boare.Lib.Vsq { /// このインスタンスをファイルに出力します /// /// - public virtual void write( string file ) { - write( file, 500 ); + public virtual void write( String file ) { + write( file, 500, Encoding.GetEncoding( "Shift_JIS" ) ); } /// @@ -2521,15 +2624,15 @@ namespace Boare.Lib.Vsq { /// /// /// プリセンドタイム(msec) - public virtual void write( string file, int msPreSend ) { + public virtual void write( String file, int msPreSend, Encoding encoding ) { #if DEBUG - Console.WriteLine( "VsqFile.Write(string)" ); + Console.WriteLine( "VsqFile.Write(String)" ); #endif int last_clock = 0; - for ( int track = 1; track < Track.Count; track++ ) { - if ( Track[track].getEventCount() > 0 ) { - int index = Track[track].getEventCount() - 1; - VsqEvent last = Track[track].getEvent( index ); + for ( int track = 1; track < Track.size(); track++ ) { + if ( Track.get( track ).getEventCount() > 0 ) { + int index = Track.get( track ).getEventCount() - 1; + VsqEvent last = Track.get( track ).getEvent( index ); last_clock = Math.Max( last_clock, last.Clock + last.ID.Length ); } } @@ -2549,7 +2652,7 @@ namespace Boare.Lib.Vsq { fs.WriteByte( 0x00 ); fs.WriteByte( 0x01 ); //トラック数 - writeUnsignedShort( fs, (ushort)this.Track.Count ); + writeUnsignedShort( fs, (ushort)this.Track.size() ); //時間単位 fs.WriteByte( 0x01 ); fs.WriteByte( 0xe0 ); @@ -2568,21 +2671,24 @@ namespace Boare.Lib.Vsq { fs.WriteByte( (byte)_MASTER_TRACK.Length );//トラック名の文字数。これは固定 fs.Write( _MASTER_TRACK, 0, _MASTER_TRACK.Length ); - List events = new List(); - foreach ( TimeSigTableEntry entry in TimesigTable ) { - events.Add( MidiEvent.generateTimeSigEvent( entry.Clock, entry.Numerator, entry.Denominator ) ); + Vector events = new Vector(); + for ( Iterator itr = TimesigTable.iterator(); itr.hasNext(); ) { + TimeSigTableEntry entry = (TimeSigTableEntry)itr.next(); + events.add( MidiEvent.generateTimeSigEvent( entry.Clock, entry.Numerator, entry.Denominator ) ); last_clock = Math.Max( last_clock, entry.Clock ); } - foreach ( TempoTableEntry entry in TempoTable ) { - events.Add( MidiEvent.generateTempoChangeEvent( entry.Clock, entry.Tempo ) ); + for( Iterator itr = TempoTable.iterator(); itr.hasNext(); ){ + TempoTableEntry entry = (TempoTableEntry)itr.next(); + events.add( MidiEvent.generateTempoChangeEvent( entry.Clock, entry.Tempo ) ); last_clock = Math.Max( last_clock, entry.Clock ); } #if DEBUG - Console.WriteLine( " events.Count=" + events.Count ); + Console.WriteLine( " events.Count=" + events.size() ); #endif - events.Sort(); + Collections.sort( events ); long last = 0; - foreach ( MidiEvent me in events ) { + for ( Iterator itr = events.iterator(); itr.hasNext(); ){ + MidiEvent me = (MidiEvent)itr.next(); #if DEBUG Console.WriteLine( "me.Clock=" + me.clock ); #endif @@ -2604,11 +2710,11 @@ namespace Boare.Lib.Vsq { #region トラック VsqFile temp = (VsqFile)this.Clone(); - temp.Track[1].setMaster( (VsqMaster)Master.Clone() ); - temp.Track[1].setMixer( (VsqMixer)Mixer.Clone() ); - printTrack( temp, 1, fs, msPreSend ); - for ( int track = 2; track < Track.Count; track++ ) { - printTrack( this, track, fs, msPreSend ); + temp.Track.get( 1 ).setMaster( (VsqMaster)Master.Clone() ); + temp.Track.get( 1 ).setMixer( (VsqMixer)Mixer.Clone() ); + printTrack( temp, 1, fs, msPreSend, encoding ); + for ( int track = 2; track < Track.size(); track++ ) { + printTrack( this, track, fs, msPreSend, encoding ); } #endregion @@ -2620,10 +2726,10 @@ namespace Boare.Lib.Vsq { /// /// /// - public static string getLinePrefix( int count ) { + public static String getLinePrefix( int count ) { int digits = getHowManyDigits( count ); int c = (digits - 1) / 4 + 1; - string format = ""; + String format = ""; for ( int i = 0; i < c; i++ ) { format += "0000"; } @@ -2693,7 +2799,7 @@ namespace Boare.Lib.Vsq { /// /// public static byte[] getBytesFlexibleLengthUnsignedLong( ulong number ) { - bool[] bits = new bool[64]; + boolean[] bits = new boolean[64]; ulong val = 0x1; bits[0] = (number & val) == val; for ( int i = 1; i < 64; i++ ) { diff --git a/trunk/Boare.Lib.Vsq/VsqMetaText/Common.cs b/trunk/Boare.Lib.Vsq/VsqMetaText/Common.cs index f06caa7..1787656 100644 --- a/trunk/Boare.Lib.Vsq/VsqMetaText/Common.cs +++ b/trunk/Boare.Lib.Vsq/VsqMetaText/Common.cs @@ -17,21 +17,25 @@ using System.Text; using System.IO; using System.Drawing; +using bocoree; + namespace Boare.Lib.Vsq { + using boolean = System.Boolean; + /// /// vsqファイルのメタテキストの[Common]セクションに記録される内容を取り扱う /// [Serializable] public class VsqCommon : ICloneable { - public string Version; - public string Name; - public string Color; + public String Version; + public String Name; + public String Color; public int DynamicsMode; public int PlayMode; public object Clone() { - string[] spl = Color.Split( ",".ToCharArray(), 3 ); + String[] spl = Color.Split( ",".ToCharArray(), 3 ); int r = int.Parse( spl[0] ); int g = int.Parse( spl[1] ); int b = int.Parse( spl[2] ); @@ -48,7 +52,7 @@ namespace Boare.Lib.Vsq { /// Color値(意味は不明) /// DynamicsMode(デフォルトは1) /// PlayMode(デフォルトは1) - public VsqCommon( string name, Color color, int dynamics_mode, int play_mode ) { + public VsqCommon( String name, Color color, int dynamics_mode, int play_mode ) { this.Version = "DSB301"; this.Name = name; this.Color = color.R + "," + color.G + "," + color.B; @@ -65,14 +69,14 @@ namespace Boare.Lib.Vsq { /// /// 読み込むテキストファイル /// 読み込んだ最後の行が返される - public VsqCommon( TextMemoryStream sr, ref string last_line ) { + public VsqCommon( TextMemoryStream sr, ref String last_line ) { Version = ""; Name = ""; Color = "0,0,0"; DynamicsMode = 0; PlayMode = 0; last_line = sr.readLine(); - string[] spl; + String[] spl; while ( !last_line.StartsWith( "[" ) ) { spl = last_line.Split( new char[] { '=' } ); switch ( spl[0] ) { @@ -116,8 +120,8 @@ namespace Boare.Lib.Vsq { /// VsqCommon構造体を構築するテストを行います /// /// テストに成功すればtrue、そうでなければfalse - public static bool test() { - string fpath = Path.GetTempFileName(); + public static boolean test() { + String fpath = Path.GetTempFileName(); StreamWriter sw = new StreamWriter( fpath, false, Encoding.Unicode ); sw.WriteLine( "Version=DSB301" ); sw.WriteLine( "Name=Voice1" ); @@ -128,18 +132,18 @@ namespace Boare.Lib.Vsq { sw.Close(); VsqCommon vsqCommon; - string last_line = ""; + String last_line = ""; using ( TextMemoryStream sr = new TextMemoryStream( fpath, Encoding.Unicode ) ) { vsqCommon = new VsqCommon( sr, ref last_line ); } - bool result; - if ( vsqCommon.Version == "DSB301" && - vsqCommon.Name == "Voice1" && - vsqCommon.Color == "181,162,123" && + boolean result; + if ( vsqCommon.Version.Equals( "DSB301" ) && + vsqCommon.Name.Equals( "Voice1" ) && + vsqCommon.Color.Equals( "181,162,123" ) && vsqCommon.DynamicsMode == 1 && vsqCommon.PlayMode == 1 && - last_line == "[Master]" ) { + last_line.Equals( "[Master]" ) ) { result = true; } else { result = false; diff --git a/trunk/Boare.Lib.Vsq/VsqMetaText/Handle.cs b/trunk/Boare.Lib.Vsq/VsqMetaText/Handle.cs index 6515e21..6d24b85 100644 --- a/trunk/Boare.Lib.Vsq/VsqMetaText/Handle.cs +++ b/trunk/Boare.Lib.Vsq/VsqMetaText/Handle.cs @@ -16,13 +16,17 @@ using System.Collections.Generic; using System.Text; using System.IO; +using bocoree; + namespace Boare.Lib.Vsq { + using boolean = System.Boolean; + [Serializable] public class IconHandle : ICloneable { - public string Caption; - public string IconID; - public string IDS; + public String Caption; + public String IconID; + public String IDS; public int Index; public int Length; public int Original; @@ -72,7 +76,7 @@ namespace Boare.Lib.Vsq { /// /// 歌詞 /// 発音記号 - public LyricHandle( string phrase, string phonetic_symbol ) { + public LyricHandle( String phrase, String phonetic_symbol ) { L0 = new Lyric( phrase, phonetic_symbol ); } @@ -100,10 +104,10 @@ namespace Boare.Lib.Vsq { public int StartRate; public VibratoBPList RateBP; public int Index; - public string IconID; - public string IDS; + public String IconID; + public String IDS; public int Original; - public string Caption; + public String Caption; public int Length; public VibratoHandle(){ @@ -113,7 +117,7 @@ namespace Boare.Lib.Vsq { DepthBP = new VibratoBPList(); } - /*public static VibratoHandle[] fromVED( string ved_file, int original ){ + /*public static VibratoHandle[] fromVED( String ved_file, int original ){ }*/ @@ -152,10 +156,10 @@ namespace Boare.Lib.Vsq { [Serializable] public class NoteHeadHandle : ICloneable { public int Index; - public string IconID; - public string IDS; + public String IconID; + public String IDS; public int Original; - public string Caption; + public String Caption; public int Length; public int Duration; public int Depth; @@ -198,11 +202,11 @@ namespace Boare.Lib.Vsq { public class VsqHandle { public VsqHandleType m_type; public int Index; - public string IconID; - public string IDS; + public String IconID; + public String IDS; public Lyric L0; public int Original; - public string Caption; + public String Caption; public int Length; public int StartDepth; public VibratoBPList DepthBP; @@ -271,7 +275,7 @@ namespace Boare.Lib.Vsq { /// /// 書き込み対象 /// 2バイト文字をエンコードするか否かを指定するフラグ - public void write( TextMemoryStream sw, bool encode ) { + public void write( TextMemoryStream sw, boolean encode ) { sw.writeLine( this.ToString( encode ) ); } @@ -279,10 +283,10 @@ namespace Boare.Lib.Vsq { /// FileStreamから読み込みながらコンストラクト /// /// 読み込み対象 - public VsqHandle( TextMemoryStream sr, int value, ref string last_line ) { + public VsqHandle( TextMemoryStream sr, int value, ref String last_line ) { this.Index = value; - string[] spl; - string[] spl2; + String[] spl; + String[] spl2; // default値で梅 m_type = VsqHandleType.Vibrato; @@ -303,10 +307,10 @@ namespace Boare.Lib.Vsq { Duration = 0; Depth = 64; - string tmpDepthBPX = ""; - string tmpDepthBPY = ""; - string tmpRateBPX = ""; - string tmpRateBPY = ""; + String tmpDepthBPX = ""; + String tmpDepthBPY = ""; + String tmpRateBPX = ""; + String tmpRateBPY = ""; // "["にぶち当たるまで読込む last_line = sr.readLine(); @@ -439,8 +443,8 @@ namespace Boare.Lib.Vsq { /// /// ハンドル指定子 /// ハンドル番号 - public static int HandleIndexFromString( string _string ) { - string[] spl = _string.Split( new char[] { '#' } ); + public static int HandleIndexFromString( String _string ) { + String[] spl = _string.Split( new char[] { '#' } ); return int.Parse( spl[1] ); } @@ -449,7 +453,7 @@ namespace Boare.Lib.Vsq { /// /// 出力先 public void Print( StreamWriter sw ) { - string result = this.ToString(); + String result = this.ToString(); sw.WriteLine( result ); } @@ -457,7 +461,7 @@ namespace Boare.Lib.Vsq { /// インスタンスをコンソール画面に出力します /// private void Print() { - string result = this.ToString(); + String result = this.ToString(); Console.WriteLine( result ); } @@ -466,8 +470,8 @@ namespace Boare.Lib.Vsq { /// /// 2バイト文字をエンコードするか否かを指定するフラグ /// インスタンスを変換した文字列 - public string ToString( bool encode ) { - string result = ""; + public String ToString( boolean encode ) { + String result = ""; result += "[h#" + Index.ToString( "0000" ) + "]"; switch ( m_type ) { case VsqHandleType.Lyric: diff --git a/trunk/Boare.Lib.Vsq/VsqMetaText/ID.cs b/trunk/Boare.Lib.Vsq/VsqMetaText/ID.cs index f65327b..0bc9727 100644 --- a/trunk/Boare.Lib.Vsq/VsqMetaText/ID.cs +++ b/trunk/Boare.Lib.Vsq/VsqMetaText/ID.cs @@ -16,8 +16,12 @@ using System.Collections.Generic; using System.Text; using System.IO; +using bocoree; + namespace Boare.Lib.Vsq { + using boolean = System.Boolean; + /// /// メタテキストに埋め込まれるIDを表すクラス。 /// @@ -55,13 +59,7 @@ namespace Boare.Lib.Vsq { return m_length; } set { - if ( value < 0 ) { - m_length = 0; - } else if ( MAX_NOTE_LENGTH < value ) { - m_length = MAX_NOTE_LENGTH; - } else { - m_length = value; - } + m_length = value; } } @@ -69,7 +67,7 @@ namespace Boare.Lib.Vsq { /// このインスタンスの簡易コピーを取得します。 /// /// このインスタンスの簡易コピー - public object Clone() { + public Object clone() { VsqID result = new VsqID( this.value ); result.type = this.type; if ( this.IconHandle != null ) { @@ -100,6 +98,9 @@ namespace Boare.Lib.Vsq { return result; } + public object Clone() { + return clone(); + } /// /// IDの番号(ID#****の****)を指定したコンストラクタ。 @@ -119,8 +120,8 @@ namespace Boare.Lib.Vsq { /// 読み込み対象 /// /// 読み込んだ最後の行が返されます - public VsqID( TextMemoryStream sr, int value, ref string last_line ) { - string[] spl; + public VsqID( TextMemoryStream sr, int value, ref String last_line ) { + String[] spl; this.value = value; this.type = VsqIDType.Unknown; this.IconHandle_index = -2; @@ -143,9 +144,9 @@ namespace Boare.Lib.Vsq { spl = last_line.Split( new char[] { '=' } ); switch ( spl[0] ) { case "Type": - if ( spl[1] == "Anote" ) { + if ( spl[1].Equals( "Anote" ) ) { type = VsqIDType.Anote; - } else if ( spl[1] == "Singer" ) { + } else if ( spl[1].Equals( "Singer" ) ) { type = VsqIDType.Singer; } else { type = VsqIDType.Unknown; @@ -199,8 +200,8 @@ namespace Boare.Lib.Vsq { } } - public override string ToString() { - string ret = "{Type=" + type; + public override String ToString() { + String ret = "{Type=" + type; switch ( type ) { case VsqIDType.Anote: ret += ", Length=" + Length; @@ -266,8 +267,8 @@ namespace Boare.Lib.Vsq { /// VsqIDを構築するテストを行います。 /// /// テストに成功すればtrue、そうでなければfalseを返します - public static bool test() { - string fpath = Path.GetTempFileName(); + public static boolean test() { + String fpath = Path.GetTempFileName(); using ( StreamWriter sw = new StreamWriter( fpath, false, Encoding.Unicode ) ) { sw.WriteLine( "Type=Anote" ); sw.WriteLine( "Length=320" ); @@ -282,8 +283,8 @@ namespace Boare.Lib.Vsq { sw.WriteLine( "[ID#0104]" ); } - string last_line = ""; - bool result; + String last_line = ""; + boolean result; using ( TextMemoryStream sr = new TextMemoryStream( fpath, Encoding.Unicode ) ) { VsqID vsqID = new VsqID( sr, 103, ref last_line ); if ( vsqID.type == VsqIDType.Anote && @@ -296,7 +297,7 @@ namespace Boare.Lib.Vsq { vsqID.DEMdecGainRate == 50 && vsqID.DEMaccent == 50 && vsqID.LyricHandle_index == 111 && - last_line == "[ID#0104]" ) { + last_line.Equals( "[ID#0104]" ) ) { result = true; } else { result = false; diff --git a/trunk/Boare.Lib.Vsq/VsqMetaText/Lyric.cs b/trunk/Boare.Lib.Vsq/VsqMetaText/Lyric.cs index d345c32..c5b89dd 100644 --- a/trunk/Boare.Lib.Vsq/VsqMetaText/Lyric.cs +++ b/trunk/Boare.Lib.Vsq/VsqMetaText/Lyric.cs @@ -21,6 +21,8 @@ using bocoree; namespace Boare.Lib.Vsq { + using boolean = System.Boolean; + /// /// VsqHandleに格納される歌詞の情報を扱うクラス。 /// @@ -29,11 +31,11 @@ namespace Boare.Lib.Vsq { /// /// この歌詞のフレーズ /// - public string Phrase; - private string[] m_phonetic_symbol; + public String Phrase; + private String[] m_phonetic_symbol; public float UnknownFloat; private int[] m_consonant_adjustment; - public bool PhoneticSymbolProtected; + public boolean PhoneticSymbolProtected; public int[] getConsonantAdjustment() { return m_consonant_adjustment; @@ -46,7 +48,7 @@ namespace Boare.Lib.Vsq { public Lyric Clone() { Lyric result = new Lyric(); result.Phrase = this.Phrase; - result.m_phonetic_symbol = (string[])this.m_phonetic_symbol.Clone(); + result.m_phonetic_symbol = (String[])this.m_phonetic_symbol.Clone(); result.UnknownFloat = this.UnknownFloat; result.m_consonant_adjustment = (int[])this.m_consonant_adjustment.Clone(); result.PhoneticSymbolProtected = PhoneticSymbolProtected; @@ -58,7 +60,7 @@ namespace Boare.Lib.Vsq { /// /// 歌詞 /// 発音記号 - public Lyric( string phrase, string phonetic_symbol ) { + public Lyric( String phrase, String phonetic_symbol ) { Phrase = phrase; setPhoneticSymbol( phonetic_symbol ); UnknownFloat = 0.000000f; @@ -70,8 +72,8 @@ namespace Boare.Lib.Vsq { /// /// この歌詞の発音記号を取得します。 /// - public string getPhoneticSymbol() { - string ret = m_phonetic_symbol[0]; + public String getPhoneticSymbol() { + String ret = m_phonetic_symbol[0]; for ( int i = 1; i < m_phonetic_symbol.Length; i++ ) { ret += " " + m_phonetic_symbol[i]; } @@ -81,8 +83,8 @@ namespace Boare.Lib.Vsq { /// /// この歌詞の発音記号を設定します。 /// - public void setPhoneticSymbol( string value ) { - string s = value.Replace( " ", " " ); + public void setPhoneticSymbol( String value ) { + String s = value.Replace( " ", " " ); m_phonetic_symbol = s.Split( " ".ToCharArray(), 16 ); for ( int i = 0; i < m_phonetic_symbol.Length; i++ ) { m_phonetic_symbol[i] = m_phonetic_symbol[i].Replace( @"\\", @"\" ); @@ -100,7 +102,7 @@ namespace Boare.Lib.Vsq { /// /// XMLシリアライズ用 /// - public string PhoneticSymbol { + public String PhoneticSymbol { get { return getPhoneticSymbol(); } @@ -109,8 +111,8 @@ namespace Boare.Lib.Vsq { } } - public string[] getPhoneticSymbolList() { - string[] ret = new string[m_phonetic_symbol.Length]; + public String[] getPhoneticSymbolList() { + String[] ret = new String[m_phonetic_symbol.Length]; for ( int i = 0; i < m_phonetic_symbol.Length; i++ ) { ret[i] = m_phonetic_symbol[i]; } @@ -121,13 +123,13 @@ namespace Boare.Lib.Vsq { /// 文字列からのコンストラクタ /// /// 生成元の文字列 - public Lyric( string _line ) { + public Lyric( String _line ) { byte[] b = new byte[_line.Length]; for ( int i = 0; i < _line.Length; i++ ) { b[i] = (byte)_line[i]; } - string s = cp932.convert( b ); - string[] spl = s.Split( new char[] { ',' } ); + String s = cp932.convert( b ); + String[] spl = s.Split( new char[] { ',' } ); int c_length = spl.Length - 3; if ( spl.Length < 4 ) { Phrase = "a"; @@ -142,7 +144,7 @@ namespace Boare.Lib.Vsq { if ( Phrase.EndsWith( "\"" ) ) { Phrase = Phrase.Substring( 0, Phrase.Length - 1 ); } - string symbols = spl[1]; + String symbols = spl[1]; if ( symbols.StartsWith( "\"" ) ) { symbols = symbols.Substring( 1 ); } @@ -151,7 +153,7 @@ namespace Boare.Lib.Vsq { } setPhoneticSymbol( symbols ); UnknownFloat = float.Parse( spl[2] ); - PhoneticSymbolProtected = (spl[spl.Length - 1] == "0") ? false : true; + PhoneticSymbolProtected = (spl[spl.Length - 1].Equals( "0" )) ? false : true; } } @@ -160,10 +162,10 @@ namespace Boare.Lib.Vsq { /// /// エンコード対象 /// エンコードした文字列 - public static char[] encode( string item ) { + public static char[] encode( String item ) { //Encoding sjis = Encoding.GetEncoding( 932 ); byte[] bytea = cp932.convert( item );// sjis.GetBytes( item ); - string result = ""; + String result = ""; for ( int i = 0; i < bytea.Length; i++ ) { if ( isprint( (char)bytea[i] ) ) { result += (char)bytea[i]; @@ -180,17 +182,14 @@ namespace Boare.Lib.Vsq { /// /// 2バイト文字をエンコードするか否かを指定するフラグ /// 変換後の文字列 - public string ToString( bool a_encode ) { - string result; + public String ToString( boolean a_encode ) { + String result; if ( a_encode ) { - string njp = new string( encode( this.Phrase ) ); + String njp = new String( encode( this.Phrase ) ); result = "\"" + njp + "\",\"" + this.getPhoneticSymbol() + "\"," + UnknownFloat.ToString( "0.000000" ); } else { result = "\""; - byte[] dat = cp932.convert( this.Phrase ); - for ( int i = 0; i < dat.Length; i++ ) { - result += (char)dat[i]; - } + result += this.Phrase; result += "\",\"" + this.getPhoneticSymbol() + "\"," + UnknownFloat.ToString( "0.000000" ); result = result.Replace( @"\\", @"\" ); } @@ -210,7 +209,7 @@ namespace Boare.Lib.Vsq { /// /// /// - private static bool isprint( char ch ) { + private static boolean isprint( char ch ) { if ( 32 <= (int)ch && (int)ch <= 126 ) { return true; } else { diff --git a/trunk/Boare.Lib.Vsq/VsqMetaText/Master.cs b/trunk/Boare.Lib.Vsq/VsqMetaText/Master.cs index 657bee5..7f3a0bd 100644 --- a/trunk/Boare.Lib.Vsq/VsqMetaText/Master.cs +++ b/trunk/Boare.Lib.Vsq/VsqMetaText/Master.cs @@ -15,8 +15,12 @@ using System; using System.IO; using System.Text; +using bocoree; + namespace Boare.Lib.Vsq { + using boolean = System.Boolean; + /// /// vsqファイルのメタテキストの[Master]に記録される内容を取り扱う /// @@ -46,9 +50,9 @@ namespace Boare.Lib.Vsq { /// /// 読み込み元 /// 最後に読み込んだ行が返されます - public VsqMaster( TextMemoryStream sr, ref string last_line ) { + public VsqMaster( TextMemoryStream sr, ref String last_line ) { PreMeasure = 0; - string[] spl; + String[] spl; last_line = sr.readLine(); while ( !last_line.StartsWith( "[" ) ) { spl = last_line.Split( new char[] { '=' } ); @@ -77,19 +81,19 @@ namespace Boare.Lib.Vsq { /// VsqMasterのインスタンスを構築するテストを行います /// /// テストに成功すればtrue、そうでなければfalseを返します - public static bool test() { - string fpath = Path.GetTempFileName(); + public static boolean test() { + String fpath = Path.GetTempFileName(); using ( StreamWriter sw = new StreamWriter( fpath, false, Encoding.Unicode ) ) { sw.WriteLine( "PreMeasure=2" ); sw.WriteLine( "[Mixer]" ); } - bool result; + boolean result; using ( TextMemoryStream sr = new TextMemoryStream( fpath, Encoding.Unicode ) ) { - string last_line = ""; + String last_line = ""; VsqMaster vsqMaster = new VsqMaster( sr, ref last_line ); if ( vsqMaster.PreMeasure == 2 && - last_line == "[Mixer]" ) { + last_line.Equals( "[Mixer]" ) ) { result = true; } else { result = false; diff --git a/trunk/Boare.Lib.Vsq/VsqMetaText/Mixer.cs b/trunk/Boare.Lib.Vsq/VsqMetaText/Mixer.cs index bc64d1c..dc70232 100644 --- a/trunk/Boare.Lib.Vsq/VsqMetaText/Mixer.cs +++ b/trunk/Boare.Lib.Vsq/VsqMetaText/Mixer.cs @@ -16,8 +16,12 @@ using System.Collections.Generic; using System.IO; using System.Text; +using bocoree; + namespace Boare.Lib.Vsq { + using boolean = System.Boolean; + /// /// vsqファイルのメタテキストの[Mixer]セクションに記録される内容を取り扱う /// @@ -31,13 +35,14 @@ namespace Boare.Lib.Vsq { /// /// vsqファイルの各トラックのfader, panpot, muteおよびoutputmode値を保持します /// - public List Slave = new List(); + public Vector Slave = new Vector(); public object Clone() { VsqMixer res = new VsqMixer( MasterFeder, MasterPanpot, MasterMute, OutputMode ); - res.Slave = new List(); - foreach ( VsqMixerEntry item in Slave ) { - res.Slave.Add( (VsqMixerEntry)item.Clone() ); + res.Slave = new Vector(); + for ( Iterator itr = Slave.iterator(); itr.hasNext(); ){ + VsqMixerEntry item = (VsqMixerEntry)itr.next(); + res.Slave.add( (VsqMixerEntry)item.Clone() ); } return res; } @@ -54,7 +59,7 @@ namespace Boare.Lib.Vsq { this.MasterMute = master_mute; this.MasterPanpot = master_panpot; this.OutputMode = output_mode; - Slave = new List(); + Slave = new Vector(); } public VsqMixer() @@ -66,15 +71,15 @@ namespace Boare.Lib.Vsq { /// /// 読み込み対象 /// 最後に読み込んだ行が返されます - public VsqMixer( TextMemoryStream sr, ref string last_line ) { + public VsqMixer( TextMemoryStream sr, ref String last_line ) { MasterFeder = 0; MasterPanpot = 0; MasterMute = 0; OutputMode = 0; //Tracks = 1; int tracks = 0; - string[] spl; - string buffer = ""; + String[] spl; + String buffer = ""; last_line = sr.readLine(); while ( !last_line.StartsWith( "[" ) ) { spl = last_line.Split( new char[] { '=' } ); @@ -109,32 +114,32 @@ namespace Boare.Lib.Vsq { last_line = sr.readLine(); } - Slave = new List(); + Slave = new Vector(); for ( int i = 0; i < tracks; i++ ) { - Slave.Add( new VsqMixerEntry( 0, 0, 0, 0 ) ); + Slave.add( new VsqMixerEntry( 0, 0, 0, 0 ) ); } - spl = buffer.Split( new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries ); - string[] spl2; + spl = buffer.Split( new String[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries ); + String[] spl2; for ( int i = 0; i < spl.Length; i++ ) { - string ind = ""; + String ind = ""; int index; spl2 = spl[i].Split( new char[] { '=' } ); if ( spl2[0].StartsWith( "Feder" ) ) { ind = spl2[0].Replace( "Feder", "" ); index = int.Parse( ind ); - Slave[index].Feder = int.Parse( spl2[1] ); + Slave.get( index ).Feder = int.Parse( spl2[1] ); } else if ( spl2[0].StartsWith( "Panpot" ) ) { ind = spl2[0].Replace( "Panpot", "" ); index = int.Parse( ind ); - Slave[index].Panpot = int.Parse( spl2[1] ); + Slave.get( index ).Panpot = int.Parse( spl2[1] ); } else if ( spl2[0].StartsWith( "Mute" ) ) { ind = spl2[0].Replace( "Mute", "" ); index = int.Parse( ind ); - Slave[index].Mute = int.Parse( spl2[1] ); + Slave.get( index ).Mute = int.Parse( spl2[1] ); } else if ( spl2[0].StartsWith( "Solo" ) ) { ind = spl2[0].Replace( "Solo", "" ); index = int.Parse( ind ); - Slave[index].Solo = int.Parse( spl2[1] ); + Slave.get( index ).Solo = int.Parse( spl2[1] ); } } @@ -150,12 +155,12 @@ namespace Boare.Lib.Vsq { sw.writeLine( "MasterPanpot=" + MasterPanpot ); sw.writeLine( "MasterMute=" + MasterMute ); sw.writeLine( "OutputMode=" + OutputMode ); - sw.writeLine( "Tracks=" + Slave.Count ); - for ( int i = 0; i < Slave.Count; i++ ) { - sw.writeLine( "Feder" + i + "=" + Slave[i].Feder ); - sw.writeLine( "Panpot" + i + "=" + Slave[i].Panpot ); - sw.writeLine( "Mute" + i + "=" + Slave[i].Mute ); - sw.writeLine( "Solo" + i + "=" + Slave[i].Solo ); + sw.writeLine( "Tracks=" + Slave.size() ); + for ( int i = 0; i < Slave.size(); i++ ) { + sw.writeLine( "Feder" + i + "=" + Slave.get( i ).Feder ); + sw.writeLine( "Panpot" + i + "=" + Slave.get( i ).Panpot ); + sw.writeLine( "Mute" + i + "=" + Slave.get( i ).Mute ); + sw.writeLine( "Solo" + i + "=" + Slave.get( i ).Solo ); } } @@ -163,8 +168,8 @@ namespace Boare.Lib.Vsq { /// VsqMixerのインスタンスを構築するテストを行います /// /// テストに成功すればtrue、そうでなければfalseを返します - public static bool test() { - string fpath = Path.GetTempFileName(); + public static boolean test() { + String fpath = Path.GetTempFileName(); StreamWriter sw = new StreamWriter( fpath, false, Encoding.Unicode ); sw.WriteLine( "MasterFeder=12" ); sw.WriteLine( "MasterPanpot=13" ); @@ -207,20 +212,20 @@ namespace Boare.Lib.Vsq { sw.Close(); TextMemoryStream sr = new TextMemoryStream( fpath, Encoding.Unicode ); - string last_line = ""; + String last_line = ""; VsqMixer vsqMixer = new VsqMixer( sr, ref last_line ); if( vsqMixer.MasterFeder == 12 && vsqMixer.MasterPanpot == 13 && vsqMixer.MasterMute == 14 && vsqMixer.OutputMode == 15 && - vsqMixer.Slave.Count == 8 ){ - for( int i = 0; i < vsqMixer.Slave.Count; i++ ){ + vsqMixer.Slave.size() == 8 ){ + for( int i = 0; i < vsqMixer.Slave.size(); i++ ){ int start = 4 * i; - if ( vsqMixer.Slave[i].Feder != start + 1 || - vsqMixer.Slave[i].Panpot != start + 2 || - vsqMixer.Slave[i].Mute != start + 3 || - vsqMixer.Slave[i].Solo != start + 4 ) { + if ( vsqMixer.Slave.get( i ).Feder != start + 1 || + vsqMixer.Slave.get( i ).Panpot != start + 2 || + vsqMixer.Slave.get( i ).Mute != start + 3 || + vsqMixer.Slave.get( i ).Solo != start + 4 ) { sr.close(); File.Delete( fpath ); return false; diff --git a/trunk/Boare.Lib.Vsq/VsqMetaText/VsqMetaText.cs b/trunk/Boare.Lib.Vsq/VsqMetaText/VsqMetaText.cs index c59d1ff..58626f7 100644 --- a/trunk/Boare.Lib.Vsq/VsqMetaText/VsqMetaText.cs +++ b/trunk/Boare.Lib.Vsq/VsqMetaText/VsqMetaText.cs @@ -17,8 +17,13 @@ using System.Drawing; using System.IO; using System.Text; +using bocoree; + namespace Boare.Lib.Vsq { + using boolean = System.Boolean; + using Integer = System.Int32; + /// /// vsqのメタテキストの中身を処理するためのクラス /// @@ -99,7 +104,7 @@ namespace Boare.Lib.Vsq { if ( Events != null ) { res.Events = new VsqEventList(); for ( Iterator itr = Events.iterator(); itr.hasNext(); ) { - res.Events.add( (VsqEvent)((VsqEvent)itr.next()).Clone() ); + res.Events.add( (VsqEvent)((VsqEvent)itr.next()).clone() ); } } if ( PIT != null ) { @@ -178,7 +183,7 @@ namespace Boare.Lib.Vsq { return Events; } - internal VsqBPList getElement( string curve ) { + internal VsqBPList getElement( String curve ) { switch ( curve.Trim().ToLower() ) { case "bre": return this.BRE; @@ -215,7 +220,7 @@ namespace Boare.Lib.Vsq { case "reso2freq": return this.reso2FreqBPList; case "reso3amp": - return this.reso2AmpBPList; + return this.reso3AmpBPList; case "reso3bw": return this.reso3BWBPList; case "reso3freq": @@ -231,7 +236,7 @@ namespace Boare.Lib.Vsq { } } - internal void setElement( string curve, VsqBPList value ) { + internal void setElement( String curve, VsqBPList value ) { switch ( curve.Trim().ToLower() ) { case "bre": this.BRE = value; @@ -260,6 +265,53 @@ namespace Boare.Lib.Vsq { case "por": this.POR = value; break; + case "harmonics": + this.harmonics = value; + break; + case "fx2depth": + this.fx2depth = value; + break; + case "reso1amp": + this.reso1AmpBPList = value; + break; + case "reso1bw": + this.reso1BWBPList = value; + break; + case "reso1freq": + this.reso1FreqBPList = value; + break; + case "reso2amp": + this.reso2AmpBPList = value; + break; + case "reso2bw": + this.reso2BWBPList = value; + break; + case "reso2freq": + this.reso2FreqBPList = value; + break; + case "reso3amp": + this.reso3AmpBPList = value; + break; + case "reso3bw": + this.reso3BWBPList = value; + break; + case "reso3freq": + this.reso3FreqBPList = value; + break; + case "reso4amp": + this.reso4AmpBPList = value; + break; + case "reso4bw": + this.reso4BWBPList = value; + break; + case "reso4freq": + this.reso4FreqBPList = value; + break; + default: +#if DEBUG + Console.WriteLine( "VsqMetaText#setElement; warning:unknown curve; curve=" + curve ); +#endif + break; } } @@ -299,7 +351,7 @@ namespace Boare.Lib.Vsq { /// /// /// - public static string getCurveName( int index ) { + public static String getCurveName( int index ) { switch ( index ) { case 0: return "VEL"; @@ -329,7 +381,7 @@ namespace Boare.Lib.Vsq { /// /// Singerプロパティに指定されている /// - public string getSinger() { + public String getSinger() { for ( Iterator itr = Events.iterator(); itr.hasNext(); ) { VsqEvent item = (VsqEvent)itr.next(); if ( item.ID.type == VsqIDType.Singer ) { @@ -339,7 +391,7 @@ namespace Boare.Lib.Vsq { return ""; } - public void setSinger( string value ) { + public void setSinger( String value ) { for ( Iterator itr = Events.iterator(); itr.hasNext(); ) { VsqEvent item = (VsqEvent)itr.next(); if ( item.ID.type == VsqIDType.Singer ) { @@ -369,19 +421,19 @@ namespace Boare.Lib.Vsq { /// /// /// - void BuildIDHandleList( out List id, out List handle ) { - id = new List(); - handle = new List(); + void BuildIDHandleList( out Vector id, out Vector handle ) { + id = new Vector(); + handle = new Vector(); int current_id = -1; int current_handle = -1; - List events = new List(); + Vector events = new Vector(); for ( Iterator itr = Events.iterator(); itr.hasNext(); ) { - events.Add( (VsqEvent)itr.next() ); + events.add( (VsqEvent)itr.next() ); } - events.Sort(); - for ( int i = 0; i < events.Count; i++ ) { - VsqEvent item = events[i]; - VsqID id_item = (VsqID)item.ID.Clone(); + Collections.sort( events ); + for ( int i = 0; i < events.size(); i++ ) { + VsqEvent item = events.get( i ); + VsqID id_item = (VsqID)item.ID.clone(); current_id++; item.ID.value = current_id; id_item.value = current_id; @@ -390,7 +442,7 @@ namespace Boare.Lib.Vsq { current_handle++; VsqHandle handle_item = item.ID.IconHandle.castToVsqHandle(); handle_item.Index = current_handle; - handle.Add( handle_item ); + handle.add( handle_item ); id_item.IconHandle_index = current_handle; } // LyricHandle @@ -398,7 +450,7 @@ namespace Boare.Lib.Vsq { current_handle++; VsqHandle handle_item = item.ID.LyricHandle.castToVsqHandle(); handle_item.Index = current_handle; - handle.Add( handle_item ); + handle.add( handle_item ); id_item.LyricHandle_index = current_handle; } // VibratoHandle @@ -406,7 +458,7 @@ namespace Boare.Lib.Vsq { current_handle++; VsqHandle handle_item = item.ID.VibratoHandle.castToVsqHandle(); handle_item.Index = current_handle; - handle.Add( handle_item ); + handle.add( handle_item ); id_item.VibratoHandle_index = current_handle; } // NoteHeadHandle @@ -414,10 +466,10 @@ namespace Boare.Lib.Vsq { current_handle++; VsqHandle handle_item = item.ID.NoteHeadHandle.castToVsqHandle(); handle_item.Index = current_handle; - handle.Add( handle_item ); + handle.add( handle_item ); id_item.NoteHeadHandle_index = current_handle; } - id.Add( id_item ); + id.add( id_item ); } } @@ -426,7 +478,7 @@ namespace Boare.Lib.Vsq { /// /// /// - public void print( TextMemoryStream sw, bool encode, int eos, int start ) { + public void print( TextMemoryStream sw, boolean encode, int eos, int start ) { if ( Common != null ) { Common.write( sw ); } @@ -436,92 +488,92 @@ namespace Boare.Lib.Vsq { if ( mixer != null ) { mixer.write( sw ); } - List id; - List handle; + Vector id; + Vector handle; BuildIDHandleList( out id, out handle ); writeEventList( sw, eos ); int i; - for ( i = 0; i < id.Count; i++ ) { - id[i].write( sw ); + for ( i = 0; i < id.size(); i++ ) { + id.get( i ).write( sw ); } - for ( i = 0; i < handle.Count; i++ ) { - handle[i].write( sw, encode ); + for ( i = 0; i < handle.size(); i++ ) { + handle.get( i ).write( sw, encode ); } - string version = Common.Version; - if ( PIT.getCount() > 0 ) { + String version = Common.Version; + if ( PIT.size() > 0 ) { PIT.print( sw, start, "[PitchBendBPList]" ); } - if ( PBS.getCount() > 0 ) { + if ( PBS.size() > 0 ) { PBS.print( sw, start, "[PitchBendSensBPList]" ); } - if ( DYN.getCount() > 0 ) { + if ( DYN.size() > 0 ) { DYN.print( sw, start, "[DynamicsBPList]" ); } - if ( BRE.getCount() > 0 ) { + if ( BRE.size() > 0 ) { BRE.print( sw, start, "[EpRResidualBPList]" ); } - if ( BRI.getCount() > 0 ) { + if ( BRI.size() > 0 ) { BRI.print( sw, start, "[EpRESlopeBPList]" ); } - if ( CLE.getCount() > 0 ) { + if ( CLE.size() > 0 ) { CLE.print( sw, start, "[EpRESlopeDepthBPList]" ); } if ( version.StartsWith( "DSB2" ) ) { - if ( harmonics.getCount() > 0 ) { + if ( harmonics.size() > 0 ) { harmonics.print( sw, start, "[EpRSineBPList]" ); } - if ( fx2depth.getCount() > 0 ) { + if ( fx2depth.size() > 0 ) { fx2depth.print( sw, start, "[VibTremDepthBPList]" ); } - if ( reso1FreqBPList.getCount() > 0 ) { + if ( reso1FreqBPList.size() > 0 ) { reso1FreqBPList.print( sw, start, "[Reso1FreqBPList]" ); } - if ( reso2FreqBPList.getCount() > 0 ) { + if ( reso2FreqBPList.size() > 0 ) { reso2FreqBPList.print( sw, start, "[Reso2FreqBPList]" ); } - if ( reso3FreqBPList.getCount() > 0 ) { + if ( reso3FreqBPList.size() > 0 ) { reso3FreqBPList.print( sw, start, "[Reso3FreqBPList]" ); } - if ( reso4FreqBPList.getCount() > 0 ) { + if ( reso4FreqBPList.size() > 0 ) { reso4FreqBPList.print( sw, start, "[Reso4FreqBPList]" ); } - if ( reso1BWBPList.getCount() > 0 ) { + if ( reso1BWBPList.size() > 0 ) { reso1BWBPList.print( sw, start, "[Reso1BWBPList]" ); } - if ( reso2BWBPList.getCount() > 0 ) { + if ( reso2BWBPList.size() > 0 ) { reso2BWBPList.print( sw, start, "[Reso2BWBPList]" ); } - if ( reso3BWBPList.getCount() > 0 ) { + if ( reso3BWBPList.size() > 0 ) { reso3BWBPList.print( sw, start, "[Reso3BWBPList]" ); } - if ( reso4BWBPList.getCount() > 0 ) { + if ( reso4BWBPList.size() > 0 ) { reso4BWBPList.print( sw, start, "[Reso4BWBPList]" ); } - if ( reso1AmpBPList.getCount() > 0 ) { + if ( reso1AmpBPList.size() > 0 ) { reso1AmpBPList.print( sw, start, "[Reso1AmpBPList]" ); } - if ( reso2AmpBPList.getCount() > 0 ) { + if ( reso2AmpBPList.size() > 0 ) { reso2AmpBPList.print( sw, start, "[Reso2AmpBPList]" ); } - if ( reso3AmpBPList.getCount() > 0 ) { + if ( reso3AmpBPList.size() > 0 ) { reso3AmpBPList.print( sw, start, "[Reso3AmpBPList]" ); } - if ( reso4AmpBPList.getCount() > 0 ) { + if ( reso4AmpBPList.size() > 0 ) { reso4AmpBPList.print( sw, start, "[Reso4AmpBPList]" ); } } - if ( GEN.getCount() > 0 ) { + if ( GEN.size() > 0 ) { GEN.print( sw, start, "[GenderFactorBPList]" ); } - if ( POR.getCount() > 0 ) { + if ( POR.size() > 0 ) { POR.print( sw, start, "[PortamentoTimingBPList]" ); } if ( version.StartsWith( "DSB3" ) ) { - if ( OPE.getCount() > 0 ) { + if ( OPE.size() > 0 ) { OPE.print( sw, start, "[OpeningBPList]" ); } } @@ -529,18 +581,18 @@ namespace Boare.Lib.Vsq { private void writeEventList( TextMemoryStream sw, int eos ) { sw.writeLine( "[EventList]" ); - List temp = new List(); + Vector temp = new Vector(); for ( Iterator itr = Events.iterator(); itr.hasNext(); ) { - temp.Add( (VsqEvent)itr.next() ); + temp.add( (VsqEvent)itr.next() ); } - temp.Sort(); + Collections.sort( temp ); int i = 0; - while ( i < temp.Count ) { - VsqEvent item = temp[i]; + while ( i < temp.size() ) { + VsqEvent item = temp.get( i ); if ( !item.ID.Equals( VsqID.EOS ) ) { - string ids = "ID#" + i.ToString( "0000" ); - int clock = temp[i].Clock; - while ( i + 1 < temp.Count && clock == temp[i + 1].Clock ) { + String ids = "ID#" + i.ToString( "0000" ); + int clock = temp.get( i ).Clock; + while ( i + 1 < temp.size() && clock == temp.get( i + 1 ).Clock ) { i++; ids += ",ID#" + i.ToString( "0000" ); } @@ -560,7 +612,7 @@ namespace Boare.Lib.Vsq { /// /// 最初のトラック以外の一般のメタテキストを構築。(Masterが作られない) /// - public VsqMetaText( string name, string singer ) + public VsqMetaText( String name, String singer ) : this( name, 0, singer, false ) { } @@ -568,11 +620,11 @@ namespace Boare.Lib.Vsq { /// 最初のトラックのメタテキストを構築。(Masterが作られる) /// /// - public VsqMetaText( string name, string singer, int pre_measure ) + public VsqMetaText( String name, String singer, int pre_measure ) : this( name, pre_measure, singer, true ) { } - private VsqMetaText( string name, int pre_measure, string singer, bool is_first_track ) { + private VsqMetaText( String name, int pre_measure, String singer, boolean is_first_track ) { Common = new VsqCommon( name, Color.FromArgb( 179, 181, 123 ), 1, 1 ); PIT = new VsqBPList( 0, -8192, 8191 ); //PIT.add( 0, PIT.getDefault() ); @@ -662,9 +714,9 @@ namespace Boare.Lib.Vsq { } public VsqMetaText( TextMemoryStream sr ) { - List> t_event_list = new List>(); - Dictionary __id = new Dictionary(); - Dictionary __handle = new Dictionary(); + Vector> t_event_list = new Vector>(); + TreeMap __id = new TreeMap(); + TreeMap __handle = new TreeMap(); PIT = new VsqBPList( 0, -8192, 8191 ); PBS = new VsqBPList( 2, 0, 24 ); DYN = new VsqBPList( 64, 0, 127 ); @@ -689,7 +741,7 @@ namespace Boare.Lib.Vsq { POR = new VsqBPList( 64, 0, 127 ); OPE = new VsqBPList( 127, 0, 127 ); - string last_line = sr.readLine(); + String last_line = sr.readLine(); while ( true ) { #region "TextMemoryStreamから順次読込み" if ( last_line.Length == 0 ) { @@ -708,18 +760,18 @@ namespace Boare.Lib.Vsq { case "[EventList]": last_line = sr.readLine(); while ( !last_line.StartsWith( "[" ) ) { - string[] spl2 = last_line.Split( new char[] { '=' } ); + String[] spl2 = last_line.Split( new char[] { '=' } ); int clock = int.Parse( spl2[0] ); int id_number = -1; if ( spl2[1] != "EOS" ) { - string[] ids = spl2[1].Split( ",".ToCharArray() ); + String[] ids = spl2[1].Split( ",".ToCharArray() ); for ( int i = 0; i < ids.Length; i++ ) { - string[] spl3 = ids[i].Split( new char[] { '#' } ); + String[] spl3 = ids[i].Split( new char[] { '#' } ); id_number = int.Parse( spl3[1] ); - t_event_list.Add( new KeyValuePair( clock, id_number ) ); + t_event_list.add( new KeyValuePair( clock, id_number ) ); } } else { - t_event_list.Add( new KeyValuePair( clock, -1) ); + t_event_list.add( new KeyValuePair( clock, -1) ); } if ( sr.peek() < 0 ) { break; @@ -798,15 +850,15 @@ namespace Boare.Lib.Vsq { last_line = OPE.appendFromText( sr ); break; default: - string buffer = last_line; + String buffer = last_line; buffer = buffer.Replace( "[", "" ); buffer = buffer.Replace( "]", "" ); - string[] spl = buffer.Split( new char[] { '#' } ); + String[] spl = buffer.Split( new char[] { '#' } ); int index = int.Parse( spl[1] ); if ( last_line.StartsWith( "[ID#" ) ) { - __id.Add( index, new VsqID( sr, index, ref last_line ) ); + __id.put( index, new VsqID( sr, index, ref last_line ) ); } else if ( last_line.StartsWith( "[h#" ) ) { - __handle.Add( index, new VsqHandle( sr, index, ref last_line ) ); + __handle.put( index, new VsqHandle( sr, index, ref last_line ) ); } break; #endregion @@ -818,46 +870,46 @@ namespace Boare.Lib.Vsq { } // まずhandleをidに埋め込み - for ( int i = 0; i < __id.Count; i++ ) { - if ( __handle.ContainsKey( __id[i].IconHandle_index ) ) { - __id[i].IconHandle = __handle[__id[i].IconHandle_index].castToIconHandle(); + for ( int i = 0; i < __id.size(); i++ ) { + if ( __handle.containsKey( __id.get( i ).IconHandle_index ) ) { + __id.get( i ).IconHandle = __handle.get( __id.get( i ).IconHandle_index ).castToIconHandle(); } - if ( __handle.ContainsKey( __id[i].LyricHandle_index ) ) { - __id[i].LyricHandle = __handle[__id[i].LyricHandle_index].castToLyricHandle(); + if ( __handle.containsKey( __id.get( i ).LyricHandle_index ) ) { + __id.get( i ).LyricHandle = __handle.get( __id.get( i ).LyricHandle_index ).castToLyricHandle(); } - if ( __handle.ContainsKey( __id[i].VibratoHandle_index ) ) { - __id[i].VibratoHandle = __handle[__id[i].VibratoHandle_index].castToVibratoHandle(); + if ( __handle.containsKey( __id.get( i ).VibratoHandle_index ) ) { + __id.get( i ).VibratoHandle = __handle.get( __id.get( i ).VibratoHandle_index ).castToVibratoHandle(); } - if ( __handle.ContainsKey( __id[i].NoteHeadHandle_index ) ) { - __id[i].NoteHeadHandle = __handle[__id[i].NoteHeadHandle_index].castToNoteHeadHandle(); + if ( __handle.containsKey( __id.get( i ).NoteHeadHandle_index ) ) { + __id.get( i ).NoteHeadHandle = __handle.get( __id.get( i ).NoteHeadHandle_index ).castToNoteHeadHandle(); } } // idをeventListに埋め込み 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 ) ) { - Events.add( new VsqEvent( clock, (VsqID)__id[id_number].Clone() ) ); + for ( int i = 0; i < t_event_list.size(); i++ ) { + int clock = t_event_list.get( i ).Key; + int id_number = t_event_list.get( i ).Value; + if ( __id.containsKey( id_number ) ) { + Events.add( new VsqEvent( clock, (VsqID)__id.get( id_number ).clone() ) ); } } } - public static bool test( string fpath ) { + public static boolean test( String fpath ) { /*VsqMetaText metaText; using ( TextMemoryStream sr = new TextMemoryStream( fpath, Encoding.Unicode ) ) { metaText = new VsqMetaText( sr ); }*/ - string result = "test.txt"; + String result = "test.txt"; StreamReader honmono = new StreamReader( fpath ); TextMemoryStream copy = new TextMemoryStream(); //metaText.print( copy, true, 1000, 100 ); copy.rewind(); while ( honmono.Peek() >= 0 && copy.peek() >= 0 ) { - string hon = honmono.ReadLine(); - string cop = copy.readLine(); + String hon = honmono.ReadLine(); + String cop = copy.readLine(); if ( hon != cop ) { Console.WriteLine( "honmono,copy=" + hon + "," + cop ); honmono.Close(); diff --git a/trunk/Boare.Lib.Vsq/VsqNote.cs b/trunk/Boare.Lib.Vsq/VsqNote.cs index c49927c..75eb01c 100644 --- a/trunk/Boare.Lib.Vsq/VsqNote.cs +++ b/trunk/Boare.Lib.Vsq/VsqNote.cs @@ -15,8 +15,12 @@ using System; using System.Collections.Generic; using System.Text; +using bocoree; + namespace Boare.Lib.Vsq { + using boolean = System.Boolean; + /// /// 音階を表現するためのクラス /// @@ -26,7 +30,7 @@ namespace Boare.Lib.Vsq { /// このインスタンスが表す音階のノート値 /// public int Value; - private static readonly bool[] _KEY_TYPE = new bool[128] { + private static readonly boolean[] _KEY_TYPE = new boolean[128] { true, false, true, @@ -168,7 +172,7 @@ namespace Boare.Lib.Vsq { /// /// このインスタンスが表す音階が、ピアノの白鍵かどうかを返します /// - public bool isWhiteKey() { + public boolean isWhiteKey() { return isNoteWhiteKey( Value ); } @@ -177,7 +181,7 @@ namespace Boare.Lib.Vsq { /// /// /// - public static bool isNoteWhiteKey( int note ) { + public static boolean isNoteWhiteKey( int note ) { if ( 0 <= note && note <= 127 ) { return _KEY_TYPE[note]; } else { @@ -195,7 +199,7 @@ namespace Boare.Lib.Vsq { } } - public static string getNoteString( int note ) { + public static String getNoteString( int note ) { int odd = note % 12; int order = (note - odd) / 12 - 2; switch ( odd ) { @@ -228,7 +232,7 @@ namespace Boare.Lib.Vsq { } } - override public string ToString() { + override public String ToString() { return getNoteString( Value ); } } diff --git a/trunk/Boare.Lib.Vsq/VsqNrpn.cs b/trunk/Boare.Lib.Vsq/VsqNrpn.cs index fadac7d..b8b1b49 100644 --- a/trunk/Boare.Lib.Vsq/VsqNrpn.cs +++ b/trunk/Boare.Lib.Vsq/VsqNrpn.cs @@ -14,16 +14,20 @@ using System; using System.Collections.Generic; +using bocoree; + namespace Boare.Lib.Vsq { + using boolean = System.Boolean; + public struct VsqNrpn : IComparable { public int Clock; public ushort Nrpn; public byte DataMsb; public byte DataLsb; - public bool DataLsbSpecified; - public bool msbOmitRequired; - private List m_list; + public boolean DataLsbSpecified; + public boolean msbOmitRequired; + private Vector m_list; public VsqNrpn( int clock, ushort nrpn, byte data_msb ) { Clock = clock; @@ -32,7 +36,7 @@ namespace Boare.Lib.Vsq { DataLsb = 0x0; DataLsbSpecified = false; msbOmitRequired = false; - m_list = new List(); + m_list = new Vector(); } public VsqNrpn( int clock, ushort nrpn, byte data_msb, byte data_lsb ) { @@ -42,93 +46,93 @@ namespace Boare.Lib.Vsq { DataLsb = data_lsb; DataLsbSpecified = true; msbOmitRequired = false; - m_list = new List(); + m_list = new Vector(); } public VsqNrpn[] expand() { - List ret = new List(); + Vector ret = new Vector(); if ( DataLsbSpecified ) { VsqNrpn v = new VsqNrpn( Clock, Nrpn, DataMsb, DataLsb ); v.msbOmitRequired = msbOmitRequired; - ret.Add( v ); + ret.add( v ); } else { VsqNrpn v = new VsqNrpn( Clock, Nrpn, DataMsb ); v.msbOmitRequired = msbOmitRequired; - ret.Add( v ); + ret.add( v ); } - for ( int i = 0; i < m_list.Count; i++ ) { - ret.AddRange( m_list[i].expand() ); + for ( int i = 0; i < m_list.size(); i++ ) { + ret.addAll( m_list.get( i ).expand() ); } - return ret.ToArray(); + return ret.toArray( new VsqNrpn[]{} ); } - public static List sort( List list ) { - List ret = new List(); - list.Sort(); - if ( list.Count >= 2 ) { - List work = new List(); //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] ); + public static Vector sort( Vector list ) { + Vector ret = new Vector(); + Collections.sort( list ); + if ( list.size() >= 2 ) { + Vector work = new Vector(); //workには、clockが同じNRPNだけが入る + int last_clock = list.get( 0 ).Clock; + work.add( list.get( 0 ) ); + for ( int i = 1; i < list.size(); i++ ) { + if ( list.get( i ).Clock == last_clock ) { + work.add( list.get( i ) ); } else { // まずworkを並べ替え - last_clock = list[i].Clock; - bool changed = true; + last_clock = list.get( i ).Clock; + boolean 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); + for ( int j = 0; j < work.size() - 1; j++ ) { + byte nrpn_msb0 = (byte)((work.get( j ).Nrpn >> 8) & 0xff); + byte nrpn_msb1 = (byte)((work.get( j + 1 ).Nrpn >> 8) & 0xff); if ( nrpn_msb1 > nrpn_msb0 ) { - VsqNrpn buf = work[j]; - work[j] = work[j + 1]; - work[j + 1] = buf; + VsqNrpn buf = work.get( j ); + work.set( j, work.get( j + 1 ) ); + work.set( j + 1, buf ); changed = true; } } } - for ( int j = 0; j < work.Count; j++ ) { - ret.Add( work[j] ); + for ( int j = 0; j < work.size(); j++ ) { + ret.add( work.get( j ) ); } - work.Clear(); - work.Add( list[i] ); + work.clear(); + work.add( list.get( i ) ); } } - for ( int j = 0; j < work.Count; j++ ) { - ret.Add( work[j] ); + for ( int j = 0; j < work.size(); j++ ) { + ret.add( work.get( j ) ); } } else { - for ( int i = 0; i < list.Count; i++ ) { - ret.Add( list[i] ); + for ( int i = 0; i < list.size(); i++ ) { + ret.add( list.get( i ) ); } } return ret; } public static VsqNrpn[] merge( VsqNrpn[] src1, VsqNrpn[] src2 ) { - List ret = new List(); + Vector ret = new Vector(); for ( int i = 0; i < src1.Length; i++ ) { - ret.Add( src1[i] ); + ret.add( src1[i] ); } for ( int i = 0; i < src2.Length; i++ ) { - ret.Add( src2[i] ); + ret.add( src2[i] ); } - ret.Sort(); - return ret.ToArray(); + Collections.sort( ret ); + return ret.toArray( new VsqNrpn[]{} ); } public static NrpnData[] convert( VsqNrpn[] source ) { ushort nrpn = (ushort)source[0].Nrpn; byte msb = (byte)(nrpn >> 8); byte lsb = (byte)(nrpn - (nrpn << 8)); - List ret = new List(); - ret.Add( new NrpnData( source[0].Clock, 0x63, msb ) ); - ret.Add( new NrpnData( source[0].Clock, 0x62, lsb ) ); - ret.Add( new NrpnData( source[0].Clock, 0x06, source[0].DataMsb ) ); + Vector ret = new Vector(); + ret.add( new NrpnData( source[0].Clock, 0x63, msb ) ); + ret.add( new NrpnData( source[0].Clock, 0x62, lsb ) ); + ret.add( new NrpnData( source[0].Clock, 0x06, source[0].DataMsb ) ); if ( source[0].DataLsbSpecified ) { - ret.Add( new NrpnData( source[0].Clock, 0x26, source[0].DataLsb ) ); + ret.add( new NrpnData( source[0].Clock, 0x26, source[0].DataLsb ) ); } for ( int i = 1; i < source.Length; i++ ) { VsqNrpn item = source[i]; @@ -136,21 +140,21 @@ namespace Boare.Lib.Vsq { msb = (byte)(tnrpn >> 8); lsb = (byte)(tnrpn - (tnrpn << 8)); if ( item.msbOmitRequired ) { - ret.Add( new NrpnData( item.Clock, 0x62, lsb ) ); - ret.Add( new NrpnData( item.Clock, 0x06, item.DataMsb ) ); + ret.add( new NrpnData( item.Clock, 0x62, lsb ) ); + ret.add( new NrpnData( item.Clock, 0x06, item.DataMsb ) ); if ( item.DataLsbSpecified ) { - ret.Add( new NrpnData( item.Clock, 0x26, item.DataLsb ) ); + ret.add( new NrpnData( item.Clock, 0x26, item.DataLsb ) ); } } else { - ret.Add( new NrpnData( item.Clock, 0x63, msb ) ); - ret.Add( new NrpnData( item.Clock, 0x62, lsb ) ); - ret.Add( new NrpnData( item.Clock, 0x06, item.DataMsb ) ); + ret.add( new NrpnData( item.Clock, 0x63, msb ) ); + ret.add( new NrpnData( item.Clock, 0x62, lsb ) ); + ret.add( new NrpnData( item.Clock, 0x06, item.DataMsb ) ); if ( item.DataLsbSpecified ) { - ret.Add( new NrpnData( item.Clock, 0x26, item.DataLsb ) ); + ret.add( new NrpnData( item.Clock, 0x26, item.DataLsb ) ); } } } - return ret.ToArray(); + return ret.toArray( new NrpnData[]{} ); } public int CompareTo( VsqNrpn item ) { @@ -158,23 +162,23 @@ namespace Boare.Lib.Vsq { } public void append( ushort nrpn, byte data_msb ) { - m_list.Add( new VsqNrpn( Clock, nrpn, data_msb ) ); + m_list.add( new VsqNrpn( Clock, nrpn, data_msb ) ); } public void append( ushort nrpn, byte data_msb, byte data_lsb ) { - m_list.Add( new VsqNrpn( Clock, nrpn, data_msb, data_lsb ) ); + m_list.add( new VsqNrpn( Clock, nrpn, data_msb, data_lsb ) ); } - public void append( ushort nrpn, byte data_msb, bool msb_omit_required ) { + public void append( ushort nrpn, byte data_msb, boolean msb_omit_required ) { VsqNrpn v = new VsqNrpn( Clock, nrpn, data_msb ); v.msbOmitRequired = msb_omit_required; - m_list.Add( v ); + m_list.add( v ); } - public void append( ushort nrpn, byte data_msb, byte data_lsb, bool msb_omit_required ) { + public void append( ushort nrpn, byte data_msb, byte data_lsb, boolean msb_omit_required ) { VsqNrpn v = new VsqNrpn( Clock, nrpn, data_msb, data_lsb ); v.msbOmitRequired = msb_omit_required; - m_list.Add( v ); + m_list.add( v ); } } diff --git a/trunk/Boare.Lib.Vsq/VsqPhoneticSymbol.cs b/trunk/Boare.Lib.Vsq/VsqPhoneticSymbol.cs index 66a6d2f..2e5f237 100644 --- a/trunk/Boare.Lib.Vsq/VsqPhoneticSymbol.cs +++ b/trunk/Boare.Lib.Vsq/VsqPhoneticSymbol.cs @@ -13,17 +13,21 @@ */ using System; +using bocoree; + namespace Boare.Lib.Vsq { + using boolean = System.Boolean; + public class VsqPhoneticSymbol { - private static string[] _SYMBOL_VOWEL_JP = new string[]{ + private static String[] _SYMBOL_VOWEL_JP = new String[]{ @"a", @"i", @"M", @"e", @"o", }; - private static string[] _SYMBOL_CONSONANT_JP = new string[]{ + private static String[] _SYMBOL_CONSONANT_JP = new String[]{ @"k", @"k'", @"g", @@ -61,7 +65,7 @@ namespace Boare.Lib.Vsq { @"w", @"N\", }; - private static string[] _SYMBOL_EN = new string[]{ + private static String[] _SYMBOL_EN = new String[]{ @"@", @"V", @"e", @@ -117,32 +121,32 @@ namespace Boare.Lib.Vsq { @"h", }; - public static bool isConsonant( string symbol ) { + public static boolean isConsonant( String symbol ) { for ( int i = 0; i < _SYMBOL_CONSONANT_JP.Length; i++ ){ - string s = _SYMBOL_CONSONANT_JP[i]; - if ( s == symbol ) { + String s = _SYMBOL_CONSONANT_JP[i]; + if ( s.Equals( symbol ) ) { return true; } } return false; } - public static bool isValidSymbol( string symbol ) { + public static boolean isValidSymbol( String symbol ) { for ( int i = 0; i < _SYMBOL_VOWEL_JP.Length; i++ ){ - string s = _SYMBOL_VOWEL_JP[i]; - if ( s == symbol ) { + String s = _SYMBOL_VOWEL_JP[i]; + if ( s.Equals( symbol ) ) { return true; } } for ( int i = 0; i < _SYMBOL_CONSONANT_JP.Length; i++ ){ - string s = _SYMBOL_CONSONANT_JP[i]; - if ( s == symbol ) { + String s = _SYMBOL_CONSONANT_JP[i]; + if ( s.Equals( symbol ) ) { return true; } } for ( int i = 0; i < _SYMBOL_EN.Length; i++ ){ - string s = _SYMBOL_EN[i]; - if ( s == symbol ) { + String s = _SYMBOL_EN[i]; + if ( s.Equals( symbol ) ) { return true; } } diff --git a/trunk/Boare.Lib.Vsq/VsqTrack.cs b/trunk/Boare.Lib.Vsq/VsqTrack.cs index b3b15a3..1a99da6 100644 --- a/trunk/Boare.Lib.Vsq/VsqTrack.cs +++ b/trunk/Boare.Lib.Vsq/VsqTrack.cs @@ -14,19 +14,24 @@ using System; using System.Collections.Generic; using System.IO; +using System.Text; + +using bocoree; namespace Boare.Lib.Vsq { + using boolean = System.Boolean; + /// /// Stores the data of a vsq track. /// [Serializable] public partial class VsqTrack : ICloneable { - public string Tag; + public String Tag; /// /// トラックの名前。 /// - public string Name; + //public String Name; public VsqMetaText MetaText; private int m_edited_start = int.MaxValue; private int m_edited_end = int.MinValue; @@ -40,7 +45,7 @@ namespace Boare.Lib.Vsq { m_pos = -1; } - public bool hasNext() { + public boolean hasNext() { for ( int i = m_pos + 1; i < m_list.getCount(); i++ ) { if ( m_list.getElement( i ).ID.type == VsqIDType.Singer ) { return true; @@ -76,7 +81,7 @@ namespace Boare.Lib.Vsq { m_pos = -1; } - public bool hasNext() { + public boolean hasNext() { for ( int i = m_pos + 1; i < m_list.getCount(); i++ ) { if ( m_list.getElement( i ).ID.type == VsqIDType.Anote ) { return true; @@ -131,6 +136,30 @@ namespace Boare.Lib.Vsq { } } + public String getName() { + if ( MetaText == null ) { + return "Master Track"; + } else { + return MetaText.Common.Name; + } + } + + public void setName( String value ) { + if ( MetaText != null ) { + MetaText.Common.Name = value; + } + } + + [Obsolete] + public String Name { + get { + return getName(); + } + set { + setName( value ); + } + } + /// /// ピッチベンド。Cent単位 /// @@ -143,6 +172,23 @@ namespace Boare.Lib.Vsq { return (double)pit * (double)pbs * inv2_13 * 100.0; } + /// + /// 指定したクロック位置において、歌唱を担当している歌手のVsqEventを返します。 + /// + /// + /// + public VsqEvent getSingerEventAt( int clock ) { + VsqEvent last = null; + for ( Iterator itr = getSingerEventIterator(); itr.hasNext(); ) { + VsqEvent item = (VsqEvent)itr.next(); + if ( clock < item.Clock ) { + return last; + } + last = item; + } + return last; + } + public void sortEvent() { MetaText.Events.sort(); } @@ -182,7 +228,7 @@ namespace Boare.Lib.Vsq { /// メタテキストを,指定されたファイルに出力します /// /// - public void printMetaText( string file ) { + public void printMetaText( String file ) { TextMemoryStream tms = new TextMemoryStream(); int count = MetaText.getEventList().getCount(); int clLast = MetaText.getEventList().getElement( count - 1 ).Clock + 480; @@ -190,7 +236,7 @@ namespace Boare.Lib.Vsq { using ( StreamWriter sw = new StreamWriter( file ) ) { tms.rewind(); while ( tms.peek() >= 0 ) { - string line = tms.readLine(); + String line = tms.readLine(); sw.WriteLine( line ); } } @@ -232,9 +278,9 @@ namespace Boare.Lib.Vsq { /// /// /// - public void changeRenderer( string new_renderer, List singers ) { + public void changeRenderer( String new_renderer, Vector singers ) { VsqID default_id = null; - if ( singers.Count <= 0 ) { + if ( singers.size() <= 0 ) { default_id = new VsqID(); default_id.type = VsqIDType.Singer; default_id.IconHandle = new IconHandle(); @@ -247,21 +293,21 @@ namespace Boare.Lib.Vsq { default_id.IconHandle.Program = 0; default_id.IconHandle.Caption = ""; } else { - default_id = singers[0]; + default_id = singers.get( 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(); + boolean found = false; + for ( int i = 0; i < singers.size(); i++ ) { + if ( program == singers.get( i ).IconHandle.Program ) { + ve.ID = (VsqID)singers.get( i ).clone(); found = true; break; } } if ( !found ) { - VsqID add = (VsqID)default_id.Clone(); + VsqID add = (VsqID)default_id.clone(); add.IconHandle.Program = program; ve.ID = add; } @@ -274,11 +320,11 @@ namespace Boare.Lib.Vsq { /// /// /// - public VsqBPList getCurve( string curve ) { + public VsqBPList getCurve( String curve ) { return MetaText.getElement( curve ); } - public void setCurve( string curve, VsqBPList value ) { + public void setCurve( String curve, VsqBPList value ) { MetaText.setElement( curve, value ); } @@ -348,9 +394,9 @@ namespace Boare.Lib.Vsq { /// このインスタンスのコピーを作成します /// /// - public object Clone() { + public Object clone() { VsqTrack res = new VsqTrack(); - res.Name = Name; + res.setName( getName() ); if ( MetaText != null ) { res.MetaText = (VsqMetaText)MetaText.Clone(); } @@ -360,6 +406,10 @@ namespace Boare.Lib.Vsq { return res; } + public object Clone() { + return clone(); + } + /// /// Master Trackを構築 /// @@ -367,7 +417,8 @@ namespace Boare.Lib.Vsq { /// /// public VsqTrack( int tempo, int numerator, int denominator ) { - this.Name = "Master Track"; + //this.Name = "Master Track"; + // metatextがnullのとき,トラック名はMaster Track this.MetaText = null; } @@ -376,8 +427,7 @@ namespace Boare.Lib.Vsq { /// /// /// - public VsqTrack( string name, string singer ) { - Name = name; + public VsqTrack( String name, String singer ) { MetaText = new VsqMetaText( name, singer ); } @@ -399,28 +449,31 @@ namespace Boare.Lib.Vsq { return counter; } - public VsqTrack( List midi_event ) { - Name = ""; + public VsqTrack( Vector midi_event, Encoding encoding ) { #if DEBUG bocoree.debug.push_log( "VsqTrack..ctor" ); #endif + String track_name = ""; using ( TextMemoryStream sw = new TextMemoryStream() ) { - for ( int i = 0; i < midi_event.Count; i++ ) { - if ( midi_event[i].firstByte == 0xff && midi_event[i].data.Length > 0 ) { + for ( int i = 0; i < midi_event.size(); i++ ) { + if ( midi_event.get( i ).firstByte == 0xff && midi_event.get( i ).data.Length > 0 ) { // meta textを抽出 - byte type = midi_event[i].data[0]; + byte type = midi_event.get( i ).data[0]; if ( type == 0x01 || type == 0x03 ) { - 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]; + /*char[] ch = new char[midi_event.get( i ).data.Length - 1]; + for ( int j = 1; j < midi_event.get( i ).data.Length; j++ ) { + ch[j - 1] = (char)midi_event.get( i ).data[j]; } - string line = new string( ch ); + + String line = new String( ch );*/ + byte[] dat = midi_event.get( i ).data; + String line = encoding.GetString( dat, 1, dat.Length - 1 ); if ( type == 0x01 ) { int second_colon = line.IndexOf( ':', 3 ); line = line.Substring( second_colon + 1 ); line = line.Replace( "\\n", "\n" ); //line = line.Replace( "\n", Environment.NewLine ); - string[] lines = line.Split( '\n' ); + String[] lines = line.Split( '\n' ); int c = lines.Length; for ( int j = 0; j < c; j++ ) { if ( j < c - 1 ) { @@ -431,7 +484,7 @@ namespace Boare.Lib.Vsq { } //sw.write( line ); } else { - Name = line; + track_name = line; } } } else { @@ -440,6 +493,7 @@ namespace Boare.Lib.Vsq { } sw.rewind(); MetaText = new VsqMetaText( sw ); + setName( track_name ); } } } diff --git a/trunk/LipSync/LipSync/Editor/AviOutputArguments.cs b/trunk/LipSync/LipSync/Editor/AviOutputArguments.cs index c2b8c02..d0a17c8 100644 --- a/trunk/LipSync/LipSync/Editor/AviOutputArguments.cs +++ b/trunk/LipSync/LipSync/Editor/AviOutputArguments.cs @@ -28,6 +28,7 @@ namespace LipSync { public System.Drawing.Imaging.ImageFormat ImageFormat; public bool UseVfwEncoder = true; public bool IsRawMode = false; + public int Step = 1; } } diff --git a/trunk/LipSync/LipSync/Editor/Form1.cs b/trunk/LipSync/LipSync/Editor/Form1.cs index 6ddf2ff..5654bae 100644 --- a/trunk/LipSync/LipSync/Editor/Form1.cs +++ b/trunk/LipSync/LipSync/Editor/Form1.cs @@ -26,6 +26,7 @@ using System.Windows.Forms; using Boare.Lib.AppUtil; using Boare.Lib.Media; using Boare.Lib.Vsq; +using bocoree; using Plugin; #if DEBUG using Boare.Lib.Swf; @@ -2343,7 +2344,7 @@ namespace LipSync { if ( openVsqDialog.FilterIndex == 0 || Path.GetExtension( openVsqDialog.FileName ).ToLower() == ".vsq" ) { // VsqFileを取得 int most_lyrics_track = 0; // 一番歌詞の文字数が多かったトラックの番号 - VsqFile vsqFile = new VsqFile( openVsqDialog.FileName ); + VsqFile vsqFile = new VsqFile( openVsqDialog.FileName, Encoding.GetEncoding( "Shift_JIS" ) ); AppManager.SaveData.m_totalSec = (float)vsqFile.getTotalSec(); AppManager.SaveData.m_timesig_ex = new List( vsqFile.TimesigTable.ToArray() ); @@ -2810,6 +2811,7 @@ namespace LipSync { args.End = fsi.End; args.FileNameParser = fsi.ParserString; args.ImageFormat = fsi.ImageFormat; + args.Step = fsi.Step; bgWorkSeriesImage.RunWorkerAsync( args ); } } @@ -3643,6 +3645,7 @@ namespace LipSync { if ( menuVisualSync.Checked ) { correctPosition(); } + previewer.Invalidate(); this.Invalidate(); } @@ -3676,6 +3679,7 @@ namespace LipSync { long start_frame; AviOutputArguments args = (AviOutputArguments)e.Argument; + int step = args.Step; bool is_raw_mode = args.IsRawMode; if ( args.StartSpecified ) { start_frame = (long)(args.Start * AppManager.SaveData.FrameRate); @@ -3689,12 +3693,12 @@ namespace LipSync { } else { end_frame = (long)((AppManager.SaveData.m_totalSec) * AppManager.SaveData.FrameRate); } - long total_frames = end_frame - start_frame + 1; + long total_frames = (end_frame - start_frame) / Math.Abs( step ) + 1; #if !DEBUG try { #endif long count = -1; - for ( long frame = start_frame; frame <= end_frame; frame++ ) { + for ( long frame = start_frame; frame <= end_frame; frame+= step ) { count++; float now = (float)frame / AppManager.SaveData.FrameRate; Bitmap frm = GetPicture( now, false ); @@ -3708,7 +3712,7 @@ namespace LipSync { this.Invoke( new Form1_AviWritingChange( ChangeAviWriting ), new object[] { false } ); return; } - bgWorkSeriesImage.ReportProgress( (int)((double)(frame - start_frame) / (double)(total_frames) * 100.0), new long[] { frame - start_frame, total_frames } ); + bgWorkSeriesImage.ReportProgress( (int)((double)(frame - start_frame) / (double)(total_frames) * 100.0), new long[] { (frame - start_frame) / Math.Abs( step ), total_frames } ); if ( m_avi_cancel ) { m_avi_cancel = false; return; diff --git a/trunk/LipSync/LipSync/Editor/Form1Util.cs b/trunk/LipSync/LipSync/Editor/Form1Util.cs index 61e7b65..0005cf4 100644 --- a/trunk/LipSync/LipSync/Editor/Form1Util.cs +++ b/trunk/LipSync/LipSync/Editor/Form1Util.cs @@ -20,6 +20,7 @@ using System.IO; using System.Runtime.Serialization.Formatters.Binary; using System.Threading; using System.Windows.Forms; +using System.Text; using Boare.Lib.AppUtil; using Boare.Lib.Vsq; @@ -266,7 +267,7 @@ namespace LipSync { } AppManager.SaveData.m_totalSec = Math.Max( AppManager.SaveData.m_totalSec, (float)ust.getTotalSec() ); } else { - VsqFile vsqFile = new VsqFile( filename ); + VsqFile vsqFile = new VsqFile( filename, Encoding.GetEncoding( "Shift_JIS" ) ); int tracks = vsqFile.Track.Count; string[] track_names = new string[tracks]; for ( int track = 0; track < tracks; track++ ) { diff --git a/trunk/LipSync/LipSync/Editor/FormSeriesImage.Designer.cs b/trunk/LipSync/LipSync/Editor/FormSeriesImage.Designer.cs index 92689b2..c7494ba 100644 --- a/trunk/LipSync/LipSync/Editor/FormSeriesImage.Designer.cs +++ b/trunk/LipSync/LipSync/Editor/FormSeriesImage.Designer.cs @@ -53,6 +53,11 @@ namespace LipSync { this.comboFormat = new System.Windows.Forms.ComboBox(); this.lblParser = new System.Windows.Forms.Label(); this.txtPreview = new System.Windows.Forms.TextBox(); + this.txtStep = new System.Windows.Forms.TextBox(); + this.chkStep = new System.Windows.Forms.CheckBox(); + this.lblStart = new System.Windows.Forms.Label(); + this.lblEnd = new System.Windows.Forms.Label(); + this.lblStep = new System.Windows.Forms.Label(); this.groupStartEnd.SuspendLayout(); this.groupFileName.SuspendLayout(); this.SuspendLayout(); @@ -91,7 +96,7 @@ namespace LipSync { // this.btnCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); this.btnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; - this.btnCancel.Location = new System.Drawing.Point( 371, 283 ); + this.btnCancel.Location = new System.Drawing.Point( 371, 309 ); this.btnCancel.Name = "btnCancel"; this.btnCancel.Size = new System.Drawing.Size( 75, 23 ); this.btnCancel.TabIndex = 13; @@ -101,7 +106,7 @@ namespace LipSync { // btnOK // this.btnOK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.btnOK.Location = new System.Drawing.Point( 272, 283 ); + this.btnOK.Location = new System.Drawing.Point( 272, 309 ); this.btnOK.Name = "btnOK"; this.btnOK.Size = new System.Drawing.Size( 75, 23 ); this.btnOK.TabIndex = 12; @@ -124,13 +129,18 @@ namespace LipSync { // this.groupStartEnd.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); + this.groupStartEnd.Controls.Add( this.lblStep ); + this.groupStartEnd.Controls.Add( this.lblEnd ); + this.groupStartEnd.Controls.Add( this.lblStart ); + this.groupStartEnd.Controls.Add( this.txtStep ); + this.groupStartEnd.Controls.Add( this.chkStep ); this.groupStartEnd.Controls.Add( this.txtEnd ); this.groupStartEnd.Controls.Add( this.txtStart ); this.groupStartEnd.Controls.Add( this.chkEnd ); this.groupStartEnd.Controls.Add( this.chkStart ); this.groupStartEnd.Location = new System.Drawing.Point( 14, 41 ); this.groupStartEnd.Name = "groupStartEnd"; - this.groupStartEnd.Size = new System.Drawing.Size( 432, 89 ); + this.groupStartEnd.Size = new System.Drawing.Size( 432, 112 ); this.groupStartEnd.TabIndex = 7; this.groupStartEnd.TabStop = false; this.groupStartEnd.Text = "出力範囲を指定"; @@ -174,7 +184,7 @@ namespace LipSync { this.groupFileName.Controls.Add( this.comboFormat ); this.groupFileName.Controls.Add( this.lblParser ); this.groupFileName.Controls.Add( this.txtPreview ); - this.groupFileName.Location = new System.Drawing.Point( 14, 136 ); + this.groupFileName.Location = new System.Drawing.Point( 14, 159 ); this.groupFileName.Name = "groupFileName"; this.groupFileName.Size = new System.Drawing.Size( 432, 132 ); this.groupFileName.TabIndex = 20; @@ -241,13 +251,59 @@ namespace LipSync { this.txtPreview.Size = new System.Drawing.Size( 159, 94 ); this.txtPreview.TabIndex = 1; // + // txtStep + // + this.txtStep.Location = new System.Drawing.Point( 90, 78 ); + this.txtStep.Name = "txtStep"; + this.txtStep.Size = new System.Drawing.Size( 144, 19 ); + this.txtStep.TabIndex = 13; + this.txtStep.Text = "1"; + this.txtStep.TextChanged += new System.EventHandler( this.txtStep_TextChanged ); + // + // chkStep + // + this.chkStep.AutoSize = true; + this.chkStep.Location = new System.Drawing.Point( 19, 80 ); + this.chkStep.Name = "chkStep"; + this.chkStep.Size = new System.Drawing.Size( 48, 16 ); + this.chkStep.TabIndex = 12; + this.chkStep.Text = "増分"; + this.chkStep.UseVisualStyleBackColor = true; + // + // lblStart + // + this.lblStart.AutoSize = true; + this.lblStart.Location = new System.Drawing.Point( 240, 28 ); + this.lblStart.Name = "lblStart"; + this.lblStart.Size = new System.Drawing.Size( 23, 12 ); + this.lblStart.TabIndex = 14; + this.lblStart.Text = "sec"; + // + // lblEnd + // + this.lblEnd.AutoSize = true; + this.lblEnd.Location = new System.Drawing.Point( 240, 56 ); + this.lblEnd.Name = "lblEnd"; + this.lblEnd.Size = new System.Drawing.Size( 23, 12 ); + this.lblEnd.TabIndex = 15; + this.lblEnd.Text = "sec"; + // + // lblStep + // + this.lblStep.AutoSize = true; + this.lblStep.Location = new System.Drawing.Point( 240, 81 ); + this.lblStep.Name = "lblStep"; + this.lblStep.Size = new System.Drawing.Size( 34, 12 ); + this.lblStep.TabIndex = 16; + this.lblStep.Text = "frame"; + // // FormSeriesImage // this.AcceptButton = this.btnOK; this.AutoScaleDimensions = new System.Drawing.SizeF( 6F, 12F ); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.CancelButton = this.btnCancel; - this.ClientSize = new System.Drawing.Size( 460, 323 ); + this.ClientSize = new System.Drawing.Size( 460, 349 ); this.Controls.Add( this.groupFileName ); this.Controls.Add( this.groupStartEnd ); this.Controls.Add( this.btnCancel ); @@ -289,5 +345,10 @@ namespace LipSync { private System.Windows.Forms.Label lblParser; private System.Windows.Forms.Label lblFormat; private System.Windows.Forms.CheckBox chkAutomaticallyAddExtension; + private System.Windows.Forms.TextBox txtStep; + private System.Windows.Forms.CheckBox chkStep; + private System.Windows.Forms.Label lblStep; + private System.Windows.Forms.Label lblEnd; + private System.Windows.Forms.Label lblStart; } } diff --git a/trunk/LipSync/LipSync/Editor/FormSeriesImage.cs b/trunk/LipSync/LipSync/Editor/FormSeriesImage.cs index 7d6f38e..87f302d 100644 --- a/trunk/LipSync/LipSync/Editor/FormSeriesImage.cs +++ b/trunk/LipSync/LipSync/Editor/FormSeriesImage.cs @@ -24,6 +24,7 @@ namespace LipSync { public partial class FormSeriesImage : Form, IMultiLanguageControl { float m_start = 0f; float m_end = 0f; + int m_step = 1; public FormSeriesImage() { InitializeComponent(); @@ -60,7 +61,7 @@ namespace LipSync { public string ParserString { get { if ( chkAutomaticallyAddExtension.Checked ) { - return txtParser.Text + "." + Misc.GetExtensionFromImageFormat( ImageFormat ); + return txtParser.Text + Misc.GetExtensionFromImageFormat( ImageFormat ); } else { return txtParser.Text; } @@ -103,6 +104,7 @@ namespace LipSync { groupStartEnd.Text = _( "Specify output range" ); chkStart.Text = _( "Start" ); chkEnd.Text = _( "End" ); + chkStep.Text = _( "Step" ); groupFileName.Text = _( "File Name" ); lblParser.Text = _( "Parser String" ); chkAutomaticallyAddExtension.Text = _( "Automatically Add Extension" ); @@ -125,6 +127,12 @@ namespace LipSync { } } + public int Step { + get { + return m_step; + } + } + private void btnOK_Click( object sender, EventArgs e ) { try { m_start = float.Parse( txtStart.Text ); @@ -202,6 +210,16 @@ namespace LipSync { private void chkAutomaticallyAddExtension_CheckedChanged( object sender, EventArgs e ) { UpdateSampleFileNames(); } + + private void txtStep_TextChanged( object sender, EventArgs e ) { + int draft; + if ( !int.TryParse( txtStep.Text, out draft ) ) { + return; + } + if ( draft != 0 ) { + m_step = draft; + } + } } } diff --git a/trunk/LipSync/LipSync/LipSync.csproj b/trunk/LipSync/LipSync/LipSync.csproj index 730ccbb..32196c8 100644 --- a/trunk/LipSync/LipSync/LipSync.csproj +++ b/trunk/LipSync/LipSync/LipSync.csproj @@ -252,6 +252,9 @@ FormCurveExport.cs + + FormSeriesImage.cs + PublicResXFileCodeGenerator Resources.Designer.cs diff --git a/trunk/LipSync/LipSync/Properties/AssemblyInfo.cs b/trunk/LipSync/LipSync/Properties/AssemblyInfo.cs index 4cc4ccd..db8568f 100644 --- a/trunk/LipSync/LipSync/Properties/AssemblyInfo.cs +++ b/trunk/LipSync/LipSync/Properties/AssemblyInfo.cs @@ -30,4 +30,4 @@ using System.Runtime.InteropServices; // Revision // [assembly: AssemblyVersion( "1.0.0.0" )] -[assembly: AssemblyFileVersion( "2.4.8" )] +[assembly: AssemblyFileVersion( "2.4.9_DRAFT_07Sep2009" )] diff --git a/trunk/bocoree/Collections.cs b/trunk/bocoree/Collections.cs new file mode 100644 index 0000000..18ed6cb --- /dev/null +++ b/trunk/bocoree/Collections.cs @@ -0,0 +1,25 @@ +/* + * Collections.cs + * Copyright (c) 2009 kbinani + * + * This file is part of Boare.Cadencii. + * + * Boare.Cadencii is free software; you can redistribute it and/or + * modify it under the terms of the GPLv3 License. + * + * Boare.Cadencii is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + */ +//#define VECTOR_TEST +namespace bocoree { + + public static class Collections { + public static void sort( Vector list ) { +#if !VECTOR_TEST + list.Sort(); +#endif + } + } + +} diff --git a/trunk/bocoree/Graphics.cs b/trunk/bocoree/Graphics.cs new file mode 100644 index 0000000..db58cd8 --- /dev/null +++ b/trunk/bocoree/Graphics.cs @@ -0,0 +1,64 @@ +/* + * Graphics.cs + * Copyright (c) 2009 kbinani + * + * This file is part of Boare.Cadencii. + * + * Boare.Cadencii is free software; you can redistribute it and/or + * modify it under the terms of the GPLv3 License. + * + * Boare.Cadencii is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + */ +using System; +using System.Drawing; + +namespace bocoree { + + public class Graphics2D { + private System.Drawing.Graphics m_graphics; + private Color m_color = Color.Black; + private Pen m_pen = Pens.Black; + private SolidBrush m_brush = new SolidBrush( Color.Black ); + + public Graphics2D( System.Drawing.Graphics g ) { + m_graphics = g; + } + + public void clearRect( int x, int y, int width, int height ) { + m_graphics.FillRectangle( System.Drawing.Brushes.White, x, y, width, height ); + } + + public void drawLine( int x1, int y1, int x2, int y2 ) { + m_graphics.DrawLine( m_pen, x1, y1, x2, y2 ); + } + + public void drawRect( int x, int y, int width, int height ) { + m_graphics.DrawRectangle( m_pen, x, y, width, height ); + } + + public void fillRect( int x, int y, int width, int height ) { + m_graphics.FillRectangle( m_brush, x, y, width, height ); + } + + public void drawOval( int x, int y, int width, int height ) { + m_graphics.DrawEllipse( m_pen, x, y, width, height ); + } + + public void fillOval( int x, int y, int width, int height ) { + m_graphics.FillRectangle( m_brush, x, y, width, height ); + } + + public void setColor( System.Drawing.Color c ) { + m_color = c; + m_pen.Color = c; + m_brush.Color = c; + } + + public Color getColor() { + return m_color; + } + } + +} diff --git a/trunk/bocoree/Iterator.cs b/trunk/bocoree/Iterator.cs new file mode 100644 index 0000000..8b8798f --- /dev/null +++ b/trunk/bocoree/Iterator.cs @@ -0,0 +1,22 @@ +/* + * Iterator.cs + * Copyright (c) 2009 kbinani + * + * This file is part of Boare.Cadencii. + * + * Boare.Cadencii is free software; you can redistribute it and/or + * modify it under the terms of the GPLv3 License. + * + * Boare.Cadencii is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + */ +namespace bocoree { + + public interface Iterator { + bool hasNext(); + object next(); + void remove(); + } + +} diff --git a/trunk/bocoree/ListIterator.cs b/trunk/bocoree/ListIterator.cs new file mode 100644 index 0000000..343fb70 --- /dev/null +++ b/trunk/bocoree/ListIterator.cs @@ -0,0 +1,58 @@ +/* + * ListIterator.cs + * Copyright (c) 2009 kbinani + * + * This file is part of Boare.Cadencii. + * + * Boare.Cadencii is free software; you can redistribute it and/or + * modify it under the terms of the GPLv3 License. + * + * Boare.Cadencii is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + */ +using System; +using System.Collections.Generic; + +namespace bocoree { + + public class ListIterator : Iterator { + private List m_list; + private int m_pos; + + public ListIterator( Vector list ) { + m_list = new List(); + int c = list.size(); + for( int i = 0; i < c; i++ ){ + m_list.Add( list.get( i ) ); + } + m_pos = -1; + } + + public ListIterator( List list ) { + m_list = list; + m_pos = -1; + } + + public Boolean hasNext() { + if ( m_list != null && 0 <= m_pos + 1 && m_pos + 1 < m_list.Count ) { + return true; + } else { + return false; + } + } + + public Object next() { + if ( m_list == null ) { + return null; + } + m_pos++; + return m_list[m_pos]; + } + + public void remove() { + m_list.RemoveAt( m_pos ); + } + } + +} diff --git a/trunk/bocoree/TreeMap.cs b/trunk/bocoree/TreeMap.cs new file mode 100644 index 0000000..94bbf54 --- /dev/null +++ b/trunk/bocoree/TreeMap.cs @@ -0,0 +1,106 @@ +/* + * TreeMap.cs + * Copyright (c) 2009 kbinani + * + * This file is part of Boare.Cadencii. + * + * Boare.Cadencii is free software; you can redistribute it and/or + * modify it under the terms of the GPLv3 License. + * + * Boare.Cadencii is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + */ +//#define DICTIONARY_TEST +using System; +using System.Collections.Generic; +using System.Runtime.Serialization; + +namespace bocoree { + + [Serializable] +#if DICTIONARY_TEST + public class TreeMap { + public V remove( Object key ) { + return default( V ); + } + + public Vector keySet() { + return null; + } + + public V get( K key ) { + return default( V ); + } + + public V put( K key, V value ) { + return default( V ); + } + + public bool containsKey( Object key ) { + return false; + } + + public void clear() { + } + + public int size() { + return 0; + } + } +#else + public class TreeMap : Dictionary { + public TreeMap() + : base() { + } + + protected TreeMap( SerializationInfo info, StreamingContext context ) + : base( info, context ) { + } + + public V remove( Object key ) { + K k = (K)key; + if ( base.ContainsKey( k ) ) { + V old = base[k]; + base.Remove( k ); + return old; + } else { + base.Remove( k ); + return default( V ); + } + } + + public Vector keySet() { + return new Vector( base.Keys ); + } + + public V get( K key ){ + return base[key]; + } + + public int size(){ + return base.Count; + } + + public bool containsKey( Object key ) { + return base.ContainsKey( (K)key ); + } + + public void clear() { + base.Clear(); + } + + public V put( K key, V value ) { + if ( base.ContainsKey( key ) ){ + V old = base[key]; + base[key] = value; + return old; + } else { + base.Add( key, value ); + return default( V ); + } + } + } +#endif + +} diff --git a/trunk/bocoree/Vector.cs b/trunk/bocoree/Vector.cs new file mode 100644 index 0000000..4d6b905 --- /dev/null +++ b/trunk/bocoree/Vector.cs @@ -0,0 +1,174 @@ +/* + * Vector.cs + * Copyright (c) 2009 kbinani + * + * This file is part of Boare.Cadencii. + * + * Boare.Cadencii is free software; you can redistribute it and/or + * modify it under the terms of the GPLv3 License. + * + * Boare.Cadencii is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + */ +//#define VECTOR_TEST +using System; +using System.Collections.Generic; +using System.Runtime.Serialization; + +namespace bocoree { + + [Serializable] +#if VECTOR_TEST + public class Vector { + public Vector( int capacity ) { + } + + public Vector( Vector array ) { + } + + public Vector( T[] array ){ + } + + public Vector(){ + } + + public void addAll( T[] array ) { + } + + public void addAll( Vector array ) { + } + + public void insertElementAt( T obj, int index ) { + } + + public void removeElementAt( int index ) { + } + + public int size() { + return 0; + } + + public T get( int index ) { + return default( T ); + } + + public void set( int index, T value ) { + } + + public Object[] toArray() { + return null; + } + + public T[] toArray( T[] array ) { + return null; + } + + public Iterator iterator() { + return null; + } + + public void add( T obj ) { + } + + public void Add( T obj ) { + } + + public bool contains( T obj ) { + return false; + } + + public void clear() { + } + } +#else + public class Vector : List { + public Vector( ICollection list ) : + base( list ) { + } + + public Vector( int capacity ) + : base( capacity ) { + } + + public Vector( Vector array ) + : base( array.toArray( new T[]{} ) ){ + } + + public void addAll( T[] array ) { + base.AddRange( array ); + } + + public void addAll( Vector array ) { + base.AddRange( array ); + } + + public void insertElementAt( T obj, int index ){ + base.Insert( index, obj ); + } + + public bool removeElement( T obj ) { + return base.Remove( obj ); + } + + public void removeElementAt( int index ){ + base.RemoveAt( index ); + } + + public Vector( T[] array ) + : base( array ) { + } + + public Vector() + : base() { + } + + public void clear(){ + base.Clear(); + } + + public bool contains( T obj ){ + return base.Contains( obj ); + } + + public void add( T obj ) { + base.Add( obj ); + } + + public int size() { + return base.Count; + } + + public T get( int index ) { + return base[index]; + } + + public void set( int index, T value ) { + base[index] = value; + } + + public Object[] toArray() { + int c = size(); + Object[] ret = new Object[c]; + for( int i = 0; i < c; i++ ){ + ret[i] = base[i]; + } + return ret; + } + + public T[] toArray( T[] array ) { + int c = size(); + T[] ret = new T[c]; + for( int i = 0; i < c; i++ ){ + ret[i] = base[i]; + } + return ret; + } + + public Iterator iterator() { + return new ListIterator( this ); + } + } +#endif + +} diff --git a/trunk/bocoree/bocoree.csproj b/trunk/bocoree/bocoree.csproj index 01f9033..2d3c075 100644 --- a/trunk/bocoree/bocoree.csproj +++ b/trunk/bocoree/bocoree.csproj @@ -3,7 +3,7 @@ Debug AnyCPU - 9.0.30729 + 9.0.21022 2.0 {C8AAE632-9C6C-4372-8175-811528A66742} Library @@ -56,12 +56,18 @@ + + + + + + diff --git a/trunk/bocoree/misc.cs b/trunk/bocoree/misc.cs index b92b618..66fa7fa 100644 --- a/trunk/bocoree/misc.cs +++ b/trunk/bocoree/misc.cs @@ -19,6 +19,86 @@ using System.Collections.Generic; namespace bocoree { + public class _FOO_BAR_STRING { + public static bool operator !=( _FOO_BAR_STRING a, _FOO_BAR_STRING b ) { + return false; + } + + public static bool operator ==( _FOO_BAR_STRING a, _FOO_BAR_STRING b ) { + return true; + } + + public int Length { + get { + return 0; + } + } + + public _FOO_BAR_STRING[] Split( params char[] separator ) { + return null; + } + + public _FOO_BAR_STRING[] Split( char[] separator, int count ) { + return null; + } + + public _FOO_BAR_STRING[] Split( char[] separator, StringSplitOptions options ) { + return null; + } + + public _FOO_BAR_STRING[] Split( _FOO_BAR_STRING[] separator, StringSplitOptions options ) { + return null; + } + + public _FOO_BAR_STRING[] Split( char[] separator, int count, StringSplitOptions options ) { + return null; + } + + public _FOO_BAR_STRING[] Split( _FOO_BAR_STRING[] separator, int count, StringSplitOptions options ) { + return null; + } + + public _FOO_BAR_STRING Substring( int startIndex ) { + return null; + } + + public _FOO_BAR_STRING Substring( int startIndex, int length ) { + return null; + } + + public char[] ToCharArray() { + return null; + } + + public char[] ToCharArray( int startIndex, int length ) { + return null; + } + + public _FOO_BAR_STRING ToLower() { + return null; + } + + public _FOO_BAR_STRING ToLowerInvariant() { + return null; + } + + public override string ToString() { + return ""; + } + + public _FOO_BAR_STRING ToUpper() { + return null; + } + + public _FOO_BAR_STRING ToUpperInvariant() { + return null; + } + + public _FOO_BAR_STRING Trim() { + return null; + } + } + public static class misc { /// /// Reflectionを利用して、インスタンスのディープなクローニングを行います。 diff --git a/trunk/memo.txt b/trunk/memo.txt index ca4094f..e69de29 100644 --- a/trunk/memo.txt +++ b/trunk/memo.txt @@ -1,3 +0,0 @@ -todo: ^CC̊DF̕NbNăvC|WVύXĂCʂXVȂD -todo: ABMPo͋@\CŊgqt̂LɂƁCgq̃sIh2’ljĂ܂D -todo: CadenciiBoare.Lib.Vsq\[XR[hAD