Exemplo n.º 1
0
        public void asyncResampler()
        {
            int rp;

            while (true)
            {
                Monitor.Enter(this);
                for (rp = 0; rp < this.threadParseList.Length; rp++)
                {
                    if (this.threadParseList[rp] == 0)
                    {
                        //标记为正在合成
                        this.threadParseList[rp] = 1;
                        break;
                    }
                }
                Monitor.Exit(this);
                if (rp == threadParseList.Length)
                {
                    returnedThreads++;
                    if (returnedThreads == this.mainForm.config.threadNum)
                    {
                        //表示合成已经完成
                        this.synthetiseIsFinished = true;
                    }
                    if (this.wavtoolIsWaitting)
                    {
                        this._wavtoolWaitHandle.Set();
                    }
                    break;
                }
                resamParam param = this.bat.resamParams[rp];
                if (!File.Exists(param.temp))
                {
                    string[] args = getResamplerParam(param);
                    this.ResamplerEvent(Convert.ToInt32(args.Length), args, Encoding.Default.GetBytes(args[1]), Encoding.Default.GetBytes(args[2]));
                }
                //标记为已完成
                this.threadParseList[rp] = 2;
                if (this.wavtoolIsWaitting == true)
                {
                    this._wavtoolWaitHandle.Set();
                }
                Monitor.Enter(this);
                this.synthedGens++;
                this.mainForm.SetProgress1NowNum(this.synthedGens);
                Monitor.Exit(this);
                //合成部分
            }
        }
Exemplo n.º 2
0
 public string[] getResamplerParam(resamParam param)
 {
     string[] args = new string[14];
     args[0]  = "resampler";
     args[1]  = param.genfile;
     args[2]  = param.temp;
     args[3]  = param.pitchPercent;
     args[4]  = param.velocity.ToString();
     args[5]  = param.flags;
     args[6]  = param.offset.ToString();
     args[7]  = param.lengthReq.ToString();
     args[8]  = param.fix.ToString();
     args[9]  = param.blank.ToString();
     args[10] = param.volume.ToString();
     args[11] = param.modulation.ToString();
     args[12] = param.tempo;
     args[13] = param.pit;
     return(args);
 }
Exemplo n.º 3
0
        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;
                    }
                }
            }
        }