Beispiel #1
0
        public static SingerConfig readSingerConfig( string file, int original, ref string log ) {
            SingerConfig sc = new SingerConfig();
            //original = original;
            sc.ID = "VOCALOID:VIRTUAL:VOICE";
            sc.FORMAT = "2.0.0.0";
            sc.VOICEIDSTR = "";
            sc.VOICENAME = "Miku";
            sc.Breathiness = 0;
            sc.Brightness = 0;
            sc.Clearness = 0;
            sc.Opening = 0;
            sc.GenderFactor = 0;
            sc.Original = original; //original = 0;
            FileStream fs = null;
            try {
                fs = new FileStream( file, FileMode.Open, FileAccess.Read );
                int length = (int)fs.Length;
                byte[] dat = new byte[length];
                fs.Read( dat, 0, length );
                decode_vvd_bytes( ref dat );
                for ( int i = 0; i < dat.Length - 1; i++ ) {
                    if ( dat[i] == 0x17 && dat[i + 1] == 0x10 ) {
                        dat[i] = 0x0d;
                        dat[i + 1] = 0x0a;
                    }
                }
                string str = bocoree.cp932.convert( dat );
                string crlf = ((char)0x0d).ToString() + ((char)0x0a).ToString();
                string[] spl = str.Split( new string[] { crlf }, StringSplitOptions.RemoveEmptyEntries );

                foreach ( string s in spl ) {
                    int first = s.IndexOf( '"' );
                    int first_end = get_quated_string( s, first );
                    int second = s.IndexOf( '"', first_end + 1 );
                    int second_end = get_quated_string( s, second );
                    char[] chs = s.ToCharArray();
                    string id = new string( chs, first, first_end - first + 1 );
                    string value = new string( chs, second, second_end - second + 1 );
                    id = id.Substring( 1, id.Length - 2 );
                    value = value.Substring( 1, value.Length - 2 );
                    value = value.Replace( "\\\"", "\"" );
                    log += "\"" + id + "\" ";
                    if ( id == "ID" ) {
                        sc.ID = value;
                    } else if ( id == "FORMAT" ) {
                        sc.FORMAT = value;
                    } else if ( id == "VOICEIDSTR" ) {
                        sc.VOICEIDSTR = value;
                    } else if ( id == "VOICENAME" ) {
                        sc.VOICENAME = value;
                    } else if ( id == "Breathiness" ) {
                        try {
                            sc.Breathiness = int.Parse( value );
                        } catch {
                        }
                    } else if ( id == "Brightness" ) {
                        try {
                            sc.Brightness = int.Parse( value );
                        } catch {
                        }
                    } else if ( id == "Clearness" ) {
                        try {
                            sc.Clearness = int.Parse( value );
                        } catch {
                        }
                    } else if ( id == "Opening" ) {
                        try {
                            sc.Opening = int.Parse( value );
                        } catch {
                        }
                    } else if ( id == "Gender:Factor" ) {
                        try {
                            sc.GenderFactor = int.Parse( value );
                        } catch {
                        }
                    }
                }
            } catch {

            } finally {
                if ( fs != null ) {
                    fs.Close();
                }
            }
            return sc;
        }
Beispiel #2
0
 public object Clone() {
     SingerConfig ret = new SingerConfig();
     ret.ID = ID;
     ret.FORMAT = FORMAT;
     ret.VOICEIDSTR = VOICEIDSTR;
     ret.VOICENAME = VOICENAME;
     ret.Breathiness = Breathiness;
     ret.Brightness = Brightness;
     ret.Clearness = Clearness;
     ret.Opening = Opening;
     ret.GenderFactor = GenderFactor;
     ret.Original = Original;
     ret.Program = Program;
     return ret;
 }