lipsync/trunk/Boare.Lib.Vsq/AttackConfig.cs

74 lines
2.6 KiB
C#

/*
* AttackConfig.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;
namespace Boare.Lib.Vsq {
public class AttackConfig {
public int number;
public String file;
public String author;
public String vendor;
public NoteHeadHandle contents;
public AttackConfig() {
contents = new NoteHeadHandle();
}
public void parseAic( String aic_file ) {
using ( StreamReader sr = new StreamReader( aic_file ) ) {
String line;
String current_entry = "";
String articulation = "";
while ( (line = sr.ReadLine()) != null ) {
if ( line.StartsWith( "[" ) ) {
current_entry = line;
continue;
} else if ( line == "" || 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 == "[Common]" ) {
if ( spl[0] == "Articulation" ) {
articulation = spl[1];
}
} else if ( current_entry == "[Parameter]" ) {
if ( spl[0] == "Length" ) {
try {
this.contents.Length = int.Parse( spl[1] );
} catch { }
} else if ( spl[0] == "Duration" ) {
try {
this.contents.Duration = int.Parse( spl[1] );
} catch { }
} else if ( spl[0] == "Depth" ) {
try {
this.contents.Depth = int.Parse( spl[1] );
} catch { }
}
}
}
}
}
}
}