2009-07-30 08:02:59 -07:00
|
|
|
|
/*
|
|
|
|
|
* ExpressionConfigSys.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.
|
|
|
|
|
*/
|
2009-09-07 03:44:18 -07:00
|
|
|
|
#if JAVA
|
|
|
|
|
package com.boare.vsq;
|
|
|
|
|
#else
|
2009-07-30 08:02:59 -07:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.IO;
|
|
|
|
|
using System.Text;
|
|
|
|
|
|
2009-09-07 03:44:18 -07:00
|
|
|
|
using bocoree;
|
|
|
|
|
|
2009-07-30 08:02:59 -07:00
|
|
|
|
namespace Boare.Lib.Vsq {
|
2009-09-07 03:44:18 -07:00
|
|
|
|
#endif
|
2009-07-30 08:02:59 -07:00
|
|
|
|
|
|
|
|
|
public class ExpressionConfigSys {
|
|
|
|
|
private const int MAX_VIBRATO = 0x400;
|
2009-09-07 03:44:18 -07:00
|
|
|
|
private Vector<VibratoConfig> m_vibrato_configs;
|
|
|
|
|
private Vector<AttackConfig> m_attack_configs;
|
2009-07-30 08:02:59 -07:00
|
|
|
|
|
|
|
|
|
public ExpressionConfigSys( String path_expdb ) {
|
2009-09-07 03:44:18 -07:00
|
|
|
|
m_vibrato_configs = new Vector<VibratoConfig>();
|
|
|
|
|
m_attack_configs = new Vector<AttackConfig>();
|
2009-07-30 08:02:59 -07:00
|
|
|
|
String expression = Path.Combine( path_expdb, "expression.map" );
|
|
|
|
|
if ( !File.Exists( expression ) ) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2009-09-07 03:44:18 -07:00
|
|
|
|
FileStream fs = null;
|
|
|
|
|
try {
|
|
|
|
|
new FileStream( expression, FileMode.Open, FileAccess.Read );
|
2009-07-30 08:02:59 -07:00
|
|
|
|
byte[] dat = new byte[8];
|
|
|
|
|
fs.Seek( 0x20, SeekOrigin.Begin );
|
|
|
|
|
for ( int i = 0; i < MAX_VIBRATO; i++ ) {
|
|
|
|
|
fs.Read( dat, 0, 8 );
|
|
|
|
|
ulong value = VocaloSysUtil.makelong_le( dat );
|
|
|
|
|
|
|
|
|
|
if ( value <= 0 ) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
String ved = Path.Combine( path_expdb, "vexp" + value + ".ved" );
|
|
|
|
|
if ( !File.Exists( ved ) ) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
String vexp_dir = Path.Combine( path_expdb, "vexp" + value );
|
|
|
|
|
if ( !Directory.Exists( vexp_dir ) ) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
2009-09-07 03:44:18 -07:00
|
|
|
|
String NL = (char)0x0D + "" + (char)0x0A;
|
|
|
|
|
FileStream fs_ved = null;
|
|
|
|
|
try {
|
|
|
|
|
fs_ved = new FileStream( ved, FileMode.Open, FileAccess.Read );
|
2009-07-30 08:02:59 -07:00
|
|
|
|
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 ) );
|
2009-09-07 03:44:18 -07:00
|
|
|
|
String[] spl = str.Split( new String[] { NL }, StringSplitOptions.RemoveEmptyEntries );
|
2009-07-30 08:02:59 -07:00
|
|
|
|
String current_entry = "";
|
|
|
|
|
for ( int j = 0; j < spl.Length; j++ ) {
|
|
|
|
|
if ( spl[j].StartsWith( "[" ) ) {
|
|
|
|
|
current_entry = spl[j];
|
|
|
|
|
continue;
|
2009-09-07 03:44:18 -07:00
|
|
|
|
} else if ( spl[j].Equals( "" ) ) {
|
2009-07-30 08:02:59 -07:00
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
if ( current_entry.Equals( "[VIBRATO]" ) ) {
|
|
|
|
|
String[] spl2 = spl[j].Split( ',' );
|
|
|
|
|
if ( spl2.Length < 6 ) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
// ex: 1,1,"normal","normal2_type1.aic","[Normal]:Type:1","Standard","YAMAHA",0
|
|
|
|
|
VibratoConfig item = new VibratoConfig();
|
|
|
|
|
item.number = int.Parse( spl2[0] );
|
|
|
|
|
item.contents.IDS = spl2[2].Replace( "\"", "" );
|
|
|
|
|
item.file = spl2[3].Replace( "\"", "" );
|
|
|
|
|
item.contents.Caption = spl2[4].Replace( ":", " " ).Replace( "\"", "" );
|
|
|
|
|
item.author = spl2[5].Replace( "\"", "" );
|
|
|
|
|
item.vendor = spl2[6].Replace( "\"", "" );
|
|
|
|
|
String aic_file = Path.Combine( vexp_dir, item.file );
|
|
|
|
|
if ( !File.Exists( aic_file ) ) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
item.parseAic( aic_file );
|
2009-09-07 03:44:18 -07:00
|
|
|
|
} if ( current_entry.Equals( "[NOTEATTACK]" ) ) {
|
2009-07-30 08:02:59 -07:00
|
|
|
|
String[] spl2 = spl[j].Split( ',' );
|
|
|
|
|
if ( spl2.Length < 6 ) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
// ex: 1,1,"normal","normal2_type1.aic","[Normal]:Type:1","Standard","YAMAHA",0
|
2009-09-07 03:44:18 -07:00
|
|
|
|
AttackConfig item = new AttackConfig();
|
2009-07-30 08:02:59 -07:00
|
|
|
|
item.number = int.Parse( spl2[0] );
|
|
|
|
|
item.contents.IDS = spl2[2].Replace( "\"", "" );
|
|
|
|
|
item.file = spl2[3].Replace( "\"", "" );
|
|
|
|
|
item.contents.Caption = spl2[4].Replace( ":", " " ).Replace( "\"", "" );
|
|
|
|
|
item.author = spl2[5].Replace( "\"", "" );
|
|
|
|
|
item.vendor = spl2[6].Replace( "\"", "" );
|
|
|
|
|
String aic_file = Path.Combine( vexp_dir, item.file );
|
|
|
|
|
if ( !File.Exists( aic_file ) ) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
item.parseAic( aic_file );
|
|
|
|
|
}
|
|
|
|
|
}
|
2009-09-07 03:44:18 -07:00
|
|
|
|
} 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 ) {
|
2009-07-30 08:02:59 -07:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|