public void asyncWavtool() { for (int wp = 0; wp < this.bat.toolParams.Count; wp++) { toolParam param = this.bat.toolParams[wp]; string[] args = this.getWavtoolParam(param); while (true) { if (Path.GetFileNameWithoutExtension(args[2]) != "R" && this.threadParseList[param.resamParamId] != 2 && this.synthetiseIsFinished != true) { //文件不存在就中断 this.wavtoolIsWaitting = true; this._wavtoolWaitHandle.WaitOne(); } else { break; } } string ret = wavtool(args); this.finishedGens++; this.mainForm.SetProgress2NowNum(this.finishedGens, true); } //全部合成完成后 this._mainWaitHandle.Set(); }
public string[] getWavtoolParam(toolParam param) { string[] args = new string[param.len + 1]; args[0] = "wavtool"; args[1] = param.outfile; args[2] = param.infile; args[3] = param.offset.ToString(); args[4] = param.length; if (param.len >= 5) { args[5] = param.p1.ToString(); } if (param.len >= 6) { args[6] = param.p2.ToString(); } if (param.len >= 7) { args[7] = param.p3.ToString(); } if (param.len >= 8) { args[8] = param.v1.ToString(); } if (param.len >= 9) { args[9] = param.v2.ToString(); } if (param.len >= 10) { args[10] = param.v3.ToString(); } if (param.len >= 11) { args[11] = param.v4.ToString(); } if (param.len >= 12) { args[12] = param.ovr.ToString(); } if (param.len >= 13) { args[13] = param.p4.ToString(); } if (param.len >= 14) { args[14] = param.p5.ToString(); } if (param.len >= 15) { args[15] = param.v5.ToString(); } return(args); }
private void parse() { string[] lines = this.batData.Replace("\r\n", "\n").Split('\n'); foreach (string line in lines) { string[] args = Utils.parseArgs(line); if (args.Length > 0) { string[] str; resamParam p1; toolParam p2; switch (args[0]) { case "@set": // 将cmd变量存入临时变量 string[] t = line.Substring(5).Split('='); if (t.Length == 2) { this.settings[t[0]] = t[1].Trim('"'); } break; case "@call": str = Utils.parseArgs(this.cmdFormat(string.Format("\"{0}\" \"{1}\" {2} {3} {4} {5} {6} {7} {8} {9}", args[2], settings["temp"], args[3], settings["vel"], settings["flag"], args[6], args[7], args[8], args[9], settings["params"]))); p1 = new resamParam(); p1.gen = Utils.getGen(str[0]); p1.genfile = str[0]; p1.temp = str[1]; p1.pitchPercent = str[2]; p1.velocity = Convert.ToDouble(str[3]); p1.flags = str[4]; p1.offset = Convert.ToDouble(str[5]); p1.lengthReq = Convert.ToDouble(str[6]); p1.fix = Convert.ToDouble(str[7]); p1.blank = Convert.ToDouble(str[8]); p1.volume = Convert.ToDouble(str[9]); p1.modulation = Convert.ToDouble(str[10]); p1.tempo = str[11]; if (str.Length > 12) { p1.pit = str[12]; } else { p1.pit = ""; } resamParams.Add(p1); str = Utils.parseArgs(this.cmdFormat(string.Format("\"{0}\" \"{1}\" {2} {3} {4}", settings["output"], settings["temp"], settings["stp"], args[4], settings["env"]))); p2 = new toolParam(); p2.resamParamId = resamParams.Count - 1; p2.len = str.Length; p2.outfile = str[0]; p2.infile = str[1]; p2.offset = Convert.ToDouble(str[2]); p2.length = str[3]; p2.p1 = Convert.ToDouble(str[4]); p2.p2 = Convert.ToDouble(str[5]); p2.p3 = Convert.ToDouble(str[6]); p2.v1 = Convert.ToDouble(str[7]); p2.v2 = Convert.ToDouble(str[8]); p2.v3 = Convert.ToDouble(str[9]); p2.v4 = Convert.ToDouble(str[10]); if (str.Length > 11) { p2.ovr = Convert.ToDouble(str[11]); } else { p2.ovr = 0; } if (str.Length > 12) { p2.p4 = Convert.ToDouble(str[12]); } else { p2.p4 = 0; } if (str.Length > 13) { p2.p5 = Convert.ToDouble(str[13]); } else { p2.p5 = 0; } if (str.Length > 14) { p2.v5 = Convert.ToDouble(str[14]); } else { p2.v5 = 0; } toolParams.Add(p2); break; case "@%tool%": str = Utils.parseArgs(this.cmdFormat(string.Format("\"{0}\" \"{1}\" {2} {3} {4} {5}", args[1], this.settings["oto"] + "\\R.wav", args[3], args[4], args[5], args[6]))); p2 = new toolParam(); p2.resamParamId = -1; p2.len = str.Length; p2.outfile = str[0]; p2.infile = str[1]; p2.offset = Convert.ToDouble(str[2]); p2.length = str[3]; p2.p1 = Convert.ToDouble(str[4]); p2.p2 = Convert.ToDouble(str[5]); p2.p3 = 0; p2.v1 = 0; p2.v2 = 0; p2.v3 = 0; p2.v4 = 0; p2.ovr = 0; p2.p4 = 0; p2.p5 = 0; p2.v5 = 0; toolParams.Add(p2); break; default: break; } } } }