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.
|
|
|
|
|
*/
|
2010-03-16 20:14:08 -07:00
|
|
|
|
#if JAVA
|
|
|
|
|
package org.kbinani.vsq;
|
2009-07-30 08:02:59 -07:00
|
|
|
|
|
2010-03-16 20:14:08 -07:00
|
|
|
|
import java.io.*;
|
|
|
|
|
import org.kbinani.*;
|
|
|
|
|
#else
|
|
|
|
|
using System;
|
2009-09-07 03:44:18 -07:00
|
|
|
|
using bocoree;
|
2010-03-16 20:14:08 -07:00
|
|
|
|
using bocoree.java.io;
|
2009-09-07 03:44:18 -07:00
|
|
|
|
|
2009-07-30 08:02:59 -07:00
|
|
|
|
namespace Boare.Lib.Vsq {
|
2010-03-16 20:14:08 -07:00
|
|
|
|
#endif
|
2009-07-30 08:02:59 -07:00
|
|
|
|
|
|
|
|
|
public class VibratoConfig {
|
|
|
|
|
public int number;
|
|
|
|
|
public String file;
|
|
|
|
|
public String author;
|
|
|
|
|
public String vendor;
|
|
|
|
|
public VibratoHandle contents;
|
|
|
|
|
|
2010-03-16 20:14:08 -07:00
|
|
|
|
public override String ToString() {
|
|
|
|
|
if ( contents == null ) {
|
|
|
|
|
return base.ToString();
|
|
|
|
|
} else {
|
|
|
|
|
return contents.Caption;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2009-07-30 08:02:59 -07:00
|
|
|
|
public VibratoConfig() {
|
|
|
|
|
contents = new VibratoHandle();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void parseAic( String aic_file ) {
|
2010-03-16 20:14:08 -07:00
|
|
|
|
BufferedReader sr = null;
|
|
|
|
|
try {
|
|
|
|
|
sr = new BufferedReader( new FileReader( aic_file ) );
|
2009-07-30 08:02:59 -07:00
|
|
|
|
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;
|
2010-03-16 20:14:08 -07:00
|
|
|
|
while ( (line = sr.readLine()) != null ) {
|
2009-07-30 08:02:59 -07:00
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
2010-03-16 20:14:08 -07:00
|
|
|
|
String[] spl = PortUtil.splitString( line, new char[] { '=' }, true );
|
2009-07-30 08:02:59 -07:00
|
|
|
|
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 {
|
2010-03-16 20:14:08 -07:00
|
|
|
|
this.contents.setLength( PortUtil.parseInt( spl[1] ) );
|
|
|
|
|
} catch ( Exception ex0 ) {
|
|
|
|
|
}
|
2009-09-07 03:44:18 -07:00
|
|
|
|
} else if ( spl[0].Equals( "StartDepth" ) ) {
|
2009-07-30 08:02:59 -07:00
|
|
|
|
try {
|
2010-03-16 20:14:08 -07:00
|
|
|
|
this.contents.StartDepth = PortUtil.parseInt( spl[1] );
|
|
|
|
|
} catch ( Exception ex0 ) {
|
|
|
|
|
}
|
2009-09-07 03:44:18 -07:00
|
|
|
|
} else if ( spl[0].Equals( "DepthBPNum" ) ) {
|
2009-07-30 08:02:59 -07:00
|
|
|
|
try {
|
2010-03-16 20:14:08 -07:00
|
|
|
|
depth_bpnum = PortUtil.parseInt( spl[1] );
|
|
|
|
|
} catch ( Exception ex0 ) {
|
|
|
|
|
}
|
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 {
|
2010-03-16 20:14:08 -07:00
|
|
|
|
this.contents.StartRate = PortUtil.parseInt( spl[1] );
|
|
|
|
|
} catch ( Exception ex0 ) {
|
|
|
|
|
}
|
2009-09-07 03:44:18 -07:00
|
|
|
|
} else if ( spl[0].Equals( "RateBPNum" ) ) {
|
2009-07-30 08:02:59 -07:00
|
|
|
|
try {
|
2010-03-16 20:14:08 -07:00
|
|
|
|
rate_bpnum = PortUtil.parseInt( spl[1] );
|
|
|
|
|
} catch ( Exception ex0 ) {
|
|
|
|
|
}
|
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];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2010-03-16 20:14:08 -07:00
|
|
|
|
if ( !articulation.Equals( "Vibrato" ) ) {
|
2009-07-30 08:02:59 -07:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// depth bp
|
2010-03-16 20:14:08 -07:00
|
|
|
|
if ( depth_bpnum > 0 && !depth_bpx.Equals( "" ) && !depth_bpy.Equals( "" ) ) {
|
|
|
|
|
String[] bpx = PortUtil.splitString( depth_bpx, ',' );
|
|
|
|
|
String[] bpy = PortUtil.splitString( depth_bpy, ',' );
|
2009-07-30 08:02:59 -07:00
|
|
|
|
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++ ) {
|
2010-03-16 20:14:08 -07:00
|
|
|
|
x[i] = PortUtil.parseFloat( bpx[i] );
|
|
|
|
|
y[i] = PortUtil.parseInt( bpy[i] );
|
2009-07-30 08:02:59 -07:00
|
|
|
|
}
|
|
|
|
|
this.contents.DepthBP = new VibratoBPList( x, y );
|
2010-03-16 20:14:08 -07:00
|
|
|
|
} catch ( Exception ex0 ) {
|
|
|
|
|
}
|
2009-07-30 08:02:59 -07:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// rate bp
|
2010-03-16 20:14:08 -07:00
|
|
|
|
if ( rate_bpnum > 0 && !rate_bpx.Equals( "" ) && !rate_bpy.Equals( "" ) ) {
|
|
|
|
|
String[] bpx = PortUtil.splitString( rate_bpx, ',' );
|
|
|
|
|
String[] bpy = PortUtil.splitString( rate_bpy, ',' );
|
2009-07-30 08:02:59 -07:00
|
|
|
|
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++ ) {
|
2010-03-16 20:14:08 -07:00
|
|
|
|
x[i] = PortUtil.parseFloat( bpx[i] );
|
|
|
|
|
y[i] = PortUtil.parseInt( bpy[i] );
|
2009-07-30 08:02:59 -07:00
|
|
|
|
}
|
|
|
|
|
this.contents.RateBP = new VibratoBPList( x, y );
|
2010-03-16 20:14:08 -07:00
|
|
|
|
} catch ( Exception ex0 ) {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} catch ( Exception ex ) {
|
|
|
|
|
} finally {
|
|
|
|
|
if ( sr != null ) {
|
|
|
|
|
try {
|
|
|
|
|
sr.close();
|
|
|
|
|
} catch ( Exception ex2 ) {
|
2009-07-30 08:02:59 -07:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2010-03-16 20:14:08 -07:00
|
|
|
|
#if !JAVA
|
2009-07-30 08:02:59 -07:00
|
|
|
|
}
|
2010-03-16 20:14:08 -07:00
|
|
|
|
#endif
|