2009-07-30 08:02:59 -07:00
|
|
|
|
/*
|
|
|
|
|
* VibratoConfig.cs
|
|
|
|
|
* Copyright (c) 2009 kbinani
|
|
|
|
|
*
|
|
|
|
|
* This file is part of Boare.Lib.Vsq.
|
|
|
|
|
*
|
|
|
|
|
* Boare.Lib.Vsq is free software; you can redistribute it and/or
|
|
|
|
|
* modify it under the terms of the BSD License.
|
|
|
|
|
*
|
|
|
|
|
* Boare.Lib.Vsq is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
|
*/
|
|
|
|
|
using System;
|
|
|
|
|
using System.IO;
|
|
|
|
|
|
2009-09-07 03:44:18 -07:00
|
|
|
|
using bocoree;
|
|
|
|
|
|
2009-07-30 08:02:59 -07:00
|
|
|
|
namespace Boare.Lib.Vsq {
|
|
|
|
|
|
|
|
|
|
public class VibratoConfig {
|
|
|
|
|
public int number;
|
|
|
|
|
public String file;
|
|
|
|
|
public String author;
|
|
|
|
|
public String vendor;
|
|
|
|
|
public VibratoHandle contents;
|
|
|
|
|
|
|
|
|
|
public VibratoConfig() {
|
|
|
|
|
contents = new VibratoHandle();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void parseAic( String aic_file ) {
|
|
|
|
|
using ( StreamReader sr = new StreamReader( aic_file ) ) {
|
|
|
|
|
String line;
|
|
|
|
|
String current_entry = "";
|
|
|
|
|
String articulation = "";
|
|
|
|
|
String depth_bpx = "";
|
|
|
|
|
String depth_bpy = "";
|
|
|
|
|
String rate_bpx = "";
|
|
|
|
|
String rate_bpy = "";
|
|
|
|
|
int depth_bpnum = 0;
|
|
|
|
|
int rate_bpnum = 0;
|
|
|
|
|
while ( (line = sr.ReadLine()) != null ) {
|
|
|
|
|
if ( line.StartsWith( "[" ) ) {
|
|
|
|
|
current_entry = line;
|
|
|
|
|
continue;
|
2009-09-07 03:44:18 -07:00
|
|
|
|
} else if ( line.Equals( "" ) || line.StartsWith( ";" ) ) {
|
2009-07-30 08:02:59 -07:00
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
String[] spl = line.Split( new char[] { '=' }, StringSplitOptions.RemoveEmptyEntries );
|
|
|
|
|
if ( spl.Length < 2 ) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
spl[0] = spl[0].Trim();
|
|
|
|
|
spl[1] = spl[1].Trim();
|
2009-09-07 03:44:18 -07:00
|
|
|
|
if ( current_entry.Equals( "[Common]" ) ) {
|
|
|
|
|
if ( spl[0].Equals( "Articulation" ) ) {
|
2009-07-30 08:02:59 -07:00
|
|
|
|
articulation = spl[1];
|
|
|
|
|
}
|
2009-09-07 03:44:18 -07:00
|
|
|
|
} else if ( current_entry.Equals( "[Parameter]" ) ) {
|
|
|
|
|
if ( spl[0].Equals( "Length" ) ) {
|
2009-07-30 08:02:59 -07:00
|
|
|
|
try {
|
|
|
|
|
this.contents.Length = int.Parse( spl[1] );
|
|
|
|
|
} catch { }
|
2009-09-07 03:44:18 -07:00
|
|
|
|
} else if ( spl[0].Equals( "StartDepth" ) ) {
|
2009-07-30 08:02:59 -07:00
|
|
|
|
try {
|
|
|
|
|
this.contents.StartDepth = int.Parse( spl[1] );
|
|
|
|
|
} catch { }
|
2009-09-07 03:44:18 -07:00
|
|
|
|
} else if ( spl[0].Equals( "DepthBPNum" ) ) {
|
2009-07-30 08:02:59 -07:00
|
|
|
|
try {
|
|
|
|
|
depth_bpnum = int.Parse( spl[1] );
|
|
|
|
|
} catch { }
|
2009-09-07 03:44:18 -07:00
|
|
|
|
} else if ( spl[0].Equals( "DepthBPX" ) ) {
|
2009-07-30 08:02:59 -07:00
|
|
|
|
depth_bpx = spl[1];
|
2009-09-07 03:44:18 -07:00
|
|
|
|
} else if ( spl[0].Equals( "DepthBPY" ) ) {
|
2009-07-30 08:02:59 -07:00
|
|
|
|
depth_bpy = spl[1];
|
2009-09-07 03:44:18 -07:00
|
|
|
|
} else if ( spl[0].Equals( "StartRate" ) ) {
|
2009-07-30 08:02:59 -07:00
|
|
|
|
try {
|
|
|
|
|
this.contents.StartRate = int.Parse( spl[1] );
|
|
|
|
|
} catch { }
|
2009-09-07 03:44:18 -07:00
|
|
|
|
} else if ( spl[0].Equals( "RateBPNum" ) ) {
|
2009-07-30 08:02:59 -07:00
|
|
|
|
try {
|
|
|
|
|
rate_bpnum = int.Parse( spl[1] );
|
|
|
|
|
} catch { }
|
2009-09-07 03:44:18 -07:00
|
|
|
|
} else if ( spl[0].Equals( "RateBPX" ) ) {
|
2009-07-30 08:02:59 -07:00
|
|
|
|
rate_bpx = spl[1];
|
2009-09-07 03:44:18 -07:00
|
|
|
|
} else if ( spl[0].Equals( "RateBPY" ) ) {
|
2009-07-30 08:02:59 -07:00
|
|
|
|
rate_bpy = spl[1];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if ( articulation != "Vibrato" ) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// depth bp
|
|
|
|
|
if ( depth_bpnum > 0 && depth_bpx != "" && depth_bpy != "" ) {
|
|
|
|
|
String[] bpx = depth_bpx.Split( ',' );
|
|
|
|
|
String[] bpy = depth_bpy.Split( ',' );
|
|
|
|
|
if ( depth_bpnum == bpx.Length && depth_bpnum == bpy.Length ) {
|
|
|
|
|
float[] x = new float[depth_bpnum];
|
|
|
|
|
int[] y = new int[depth_bpnum];
|
|
|
|
|
try {
|
|
|
|
|
for ( int i = 0; i < depth_bpnum; i++ ) {
|
|
|
|
|
x[i] = float.Parse( bpx[i] );
|
|
|
|
|
y[i] = int.Parse( bpy[i] );
|
|
|
|
|
}
|
|
|
|
|
this.contents.DepthBP = new VibratoBPList( x, y );
|
|
|
|
|
} catch { }
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// rate bp
|
|
|
|
|
if ( rate_bpnum > 0 && rate_bpx != "" && rate_bpy != "" ) {
|
|
|
|
|
String[] bpx = rate_bpx.Split( ',' );
|
|
|
|
|
String[] bpy = rate_bpy.Split( ',' );
|
|
|
|
|
if ( rate_bpnum == bpx.Length && rate_bpnum == bpy.Length ) {
|
|
|
|
|
float[] x = new float[rate_bpnum];
|
|
|
|
|
int[] y = new int[rate_bpnum];
|
|
|
|
|
try {
|
|
|
|
|
for ( int i = 0; i < rate_bpnum; i++ ) {
|
|
|
|
|
x[i] = float.Parse( bpx[i] );
|
|
|
|
|
y[i] = int.Parse( bpy[i] );
|
|
|
|
|
}
|
|
|
|
|
this.contents.RateBP = new VibratoBPList( x, y );
|
|
|
|
|
} catch { }
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|