/// <summary> /// 指定した歌声合成システムに登録されている指定した名前の歌手について、その派生元の歌手名を取得します。 /// </summary> /// <param name="language"></param> /// <param name="program"></param> /// <param name="type"></param> /// <returns></returns> public static string getOriginalSinger(int language, int program, SynthesizerType type) { if (!isInitialized) { serr.println("VocaloSysUtil#getOriginalSinger; not initialized yet"); return(null); } string voiceidstr = ""; if (!s_singer_config_sys.ContainsKey(type)) { return(""); } SingerConfigSys scs = s_singer_config_sys[type]; SingerConfig[] singer_configs = scs.getSingerConfigs(); for (int i = 0; i < singer_configs.Length; i++) { if (language == singer_configs[i].Language && program == singer_configs[i].Program) { voiceidstr = singer_configs[i].VOICEIDSTR; break; } } if (voiceidstr.Equals("")) { return(""); } SingerConfig[] installed_singers = scs.getInstalledSingers(); for (int i = 0; i < installed_singers.Length; i++) { if (voiceidstr.Equals(installed_singers[i].VOICEIDSTR)) { return(installed_singers[i].VOICENAME); } } return(""); }
/// <summary> /// Windowsのレジストリ・エントリを列挙した文字列のリストを指定し,初期化します /// パラメータreg_listの中身は,例えば /// "HKLM\SOFTWARE\VOCALOID2\DATABASE\EXPRESSION\\tEXPRESSIONDIR\\tC:\Program Files\VOCALOID2\expdbdir" /// のような文字列です. /// </summary> /// <param name="reg_list">レジストリ・エントリのリスト</param> /// <param name="wine_prefix">wineを使う場合,WINEPREFIXを指定する.そうでなければ空文字を指定</param> public static void init(List <string> reg_list, string wine_prefix) { #if DEBUG sout.println("VocaloSysUtil#init; wine_prefix=" + wine_prefix); #endif if (reg_list == null) { return; } if (isInitialized) { return; } // reg_listを,VOCALOIDとVOCALOID2の部分に分離する List <string> dir1 = new List <string>(); List <string> dir2 = new List <string>(); foreach (string s in reg_list) { if (s.StartsWith(header1 + "\\") || s.StartsWith(header1 + "\t")) { dir1.Add(s); } else if (s.StartsWith(header2 + "\\") || s.StartsWith(header2 + "\t")) { dir2.Add(s); } } ExpressionConfigSys exp_config_sys1 = null; try { ByRef <string> path_voicedb1 = new ByRef <string>(""); ByRef <string> path_expdb1 = new ByRef <string>(""); List <string> installed_singers1 = new List <string>(); // テキストファイルにレジストリの内容をプリントアウト bool close = false; ByRef <string> path_vsti = new ByRef <string>(""); ByRef <string> path_editor = new ByRef <string>(""); initExtract(dir1, header1, path_vsti, path_voicedb1, path_expdb1, path_editor, installed_singers1); s_path_vsti[SynthesizerType.VOCALOID1] = path_vsti.value; s_path_editor[SynthesizerType.VOCALOID1] = path_editor.value; string[] act_installed_singers1 = installed_singers1.ToArray(); string act_path_voicedb1 = path_voicedb1.value; string act_path_editor1 = path_editor.value; string act_path_expdb1 = path_expdb1.value; string act_vsti1 = path_vsti.value; if (wine_prefix.Length > 0) { for (int i = 0; i < act_installed_singers1.Length; i++) { act_installed_singers1[i] = combineWinePath(wine_prefix, act_installed_singers1[i]); } act_path_voicedb1 = combineWinePath(wine_prefix, act_path_voicedb1); act_path_editor1 = combineWinePath(wine_prefix, act_path_editor1); act_path_expdb1 = combineWinePath(wine_prefix, act_path_expdb1); act_vsti1 = combineWinePath(wine_prefix, act_vsti1); } string expression_map1 = Path.Combine(act_path_expdb1, "expression.map"); SingerConfigSys singer_config_sys = new SingerConfigSys(act_path_voicedb1, act_installed_singers1); if (System.IO.File.Exists(expression_map1)) { exp_config_sys1 = new ExpressionConfigSys(act_path_editor1, act_path_expdb1); } s_singer_config_sys[SynthesizerType.VOCALOID1] = singer_config_sys; // DSE1_1.dllがあるかどうか? if (!act_vsti1.Equals("")) { string path_dll = PortUtil.getDirectoryName(act_vsti1); string dse1_1 = Path.Combine(path_dll, "DSE1_1.dll"); dseVersion101Available = System.IO.File.Exists(dse1_1); } else { dseVersion101Available = false; } // VOCALOID.iniから、DSEVersionを取得 if (act_path_editor1 != null && !act_path_editor1.Equals("") && System.IO.File.Exists(act_path_editor1)) { string dir = PortUtil.getDirectoryName(act_path_editor1); string ini = Path.Combine(dir, "VOCALOID.ini"); if (System.IO.File.Exists(ini)) { StreamReader br = null; try { br = new StreamReader(ini, Encoding.GetEncoding("Shift_JIS")); string line; while ((line = br.ReadLine()) != null) { if (line == null) { continue; } if (line.Equals("")) { continue; } if (line.StartsWith("DSEVersion")) { string[] spl = PortUtil.splitString(line, '='); if (spl.Length >= 2) { string str_dse_version = spl[1]; try { defaultDseVersion = int.Parse(str_dse_version); } catch (Exception ex) { serr.println("VocaloSysUtil#init; ex=" + ex); defaultDseVersion = 100; } } break; } } } catch (Exception ex) { serr.println("VocaloSysUtil#init; ex=" + ex); } finally { if (br != null) { try { br.Close(); } catch (Exception ex2) { serr.println("VocaloSysUtil#init; ex2=" + ex2); } } } } } } catch (Exception ex) { serr.println("VocaloSysUtil#init; ex=" + ex); SingerConfigSys singer_config_sys = new SingerConfigSys("", new string[] { }); exp_config_sys1 = null; s_singer_config_sys[SynthesizerType.VOCALOID1] = singer_config_sys; } if (exp_config_sys1 == null) { exp_config_sys1 = ExpressionConfigSys.getVocaloid1Default(); } s_exp_config_sys[SynthesizerType.VOCALOID1] = exp_config_sys1; ExpressionConfigSys exp_config_sys2 = null; try { ByRef <string> path_voicedb2 = new ByRef <string>(""); ByRef <string> path_expdb2 = new ByRef <string>(""); List <string> installed_singers2 = new List <string>(); // レジストリの中身をファイルに出力 bool close = false; ByRef <string> path_vsti = new ByRef <string>(""); ByRef <string> path_editor = new ByRef <string>(""); initExtract(dir2, header2, path_vsti, path_voicedb2, path_expdb2, path_editor, installed_singers2); s_path_vsti[SynthesizerType.VOCALOID2] = path_vsti.value; s_path_editor[SynthesizerType.VOCALOID2] = path_editor.value; string[] act_installed_singers2 = installed_singers2.ToArray(); string act_path_expdb2 = path_expdb2.value; string act_path_voicedb2 = path_voicedb2.value; string act_path_editor2 = path_editor.value; string act_vsti2 = path_vsti.value; if (wine_prefix.Length > 0) { for (int i = 0; i < act_installed_singers2.Length; i++) { act_installed_singers2[i] = combineWinePath(wine_prefix, act_installed_singers2[i]); } act_path_expdb2 = combineWinePath(wine_prefix, act_path_expdb2); act_path_voicedb2 = combineWinePath(wine_prefix, act_path_voicedb2); act_path_editor2 = combineWinePath(wine_prefix, act_path_editor2); act_vsti2 = combineWinePath(wine_prefix, act_vsti2); } string expression_map2 = Path.Combine(act_path_expdb2, "expression.map"); SingerConfigSys singer_config_sys = new SingerConfigSys(act_path_voicedb2, act_installed_singers2); if (System.IO.File.Exists(expression_map2)) { exp_config_sys2 = new ExpressionConfigSys(act_path_editor2, act_path_expdb2); } s_singer_config_sys[SynthesizerType.VOCALOID2] = singer_config_sys; } catch (Exception ex) { serr.println("VocaloSysUtil..cctor; ex=" + ex); SingerConfigSys singer_config_sys = new SingerConfigSys("", new string[] { }); exp_config_sys2 = null; s_singer_config_sys[SynthesizerType.VOCALOID2] = singer_config_sys; } if (exp_config_sys2 == null) { #if DEBUG sout.println("VocaloSysUtil#.ctor; loading default ExpressionConfigSys..."); #endif exp_config_sys2 = ExpressionConfigSys.getVocaloid2Default(); } s_exp_config_sys[SynthesizerType.VOCALOID2] = exp_config_sys2; isInitialized = true; }