mirror of
https://git.femboyfinancial.jp/james/lipsync.git
synced 2024-11-28 21:11:59 -08:00
135 lines
5.5 KiB
C#
135 lines
5.5 KiB
C#
/*
|
|
* 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;
|
|
|
|
using bocoree;
|
|
|
|
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;
|
|
} else if ( line.Equals( "" ) || line.StartsWith( ";" ) ) {
|
|
continue;
|
|
}
|
|
|
|
String[] spl = line.Split( new char[] { '=' }, StringSplitOptions.RemoveEmptyEntries );
|
|
if ( spl.Length < 2 ) {
|
|
continue;
|
|
}
|
|
spl[0] = spl[0].Trim();
|
|
spl[1] = spl[1].Trim();
|
|
if ( current_entry.Equals( "[Common]" ) ) {
|
|
if ( spl[0].Equals( "Articulation" ) ) {
|
|
articulation = spl[1];
|
|
}
|
|
} else if ( current_entry.Equals( "[Parameter]" ) ) {
|
|
if ( spl[0].Equals( "Length" ) ) {
|
|
try {
|
|
this.contents.Length = int.Parse( spl[1] );
|
|
} catch { }
|
|
} else if ( spl[0].Equals( "StartDepth" ) ) {
|
|
try {
|
|
this.contents.StartDepth = int.Parse( spl[1] );
|
|
} catch { }
|
|
} else if ( spl[0].Equals( "DepthBPNum" ) ) {
|
|
try {
|
|
depth_bpnum = int.Parse( spl[1] );
|
|
} catch { }
|
|
} else if ( spl[0].Equals( "DepthBPX" ) ) {
|
|
depth_bpx = spl[1];
|
|
} else if ( spl[0].Equals( "DepthBPY" ) ) {
|
|
depth_bpy = spl[1];
|
|
} else if ( spl[0].Equals( "StartRate" ) ) {
|
|
try {
|
|
this.contents.StartRate = int.Parse( spl[1] );
|
|
} catch { }
|
|
} else if ( spl[0].Equals( "RateBPNum" ) ) {
|
|
try {
|
|
rate_bpnum = int.Parse( spl[1] );
|
|
} catch { }
|
|
} else if ( spl[0].Equals( "RateBPX" ) ) {
|
|
rate_bpx = spl[1];
|
|
} else if ( spl[0].Equals( "RateBPY" ) ) {
|
|
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 { }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|