示例#1
0
 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);
 }
示例#2
0
        public void asyncWavtool()
        {
            long wavLength = 0;
            long newLength = 0;

            for (int wp = 0; wp < this.bat.toolParams.Count && !this.isStop; 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);
                if (this.realtimeSynth)
                {
                    try
                    {
                        wavLength = Utils.filesize(this.tempWaveName + ".dat");
                        byte[] tempBuffer;
                        if (!this.isOpenedWave)
                        {
                            tempBuffer = Utils.file_get_bytes(this.tempWaveName + ".whd");
                            this.streamPlayer.Push(tempBuffer);
                            tempBuffer        = null;
                            this.isOpenedWave = true;
                        }
                        if (this.PWavLength != 0)
                        {
                            newLength  = this.PWavLength - this.PPWavLength;
                            tempBuffer = Utils.file_get_bytes(this.tempWaveName + ".dat", this.PPWavLength, newLength);
                            this.streamPlayer.Push(tempBuffer);
                            //Utils.log("Push: " + tempBuffer.Length.ToString() + "/" + newLength.ToString() + "; " + wavLength.ToString());
                            tempBuffer = null;
                        }
                        this.PPWavLength = this.PWavLength;
                        this.PWavLength  = wavLength;
                    } catch (Exception e)
                    {
                        Utils.log("error: " + string.Format("{0}, {1}", e.Message, e.StackTrace));
                    }
                }
                this.finishedGens++;
                this.mainForm.SetProgress2NowNum(this.finishedGens, true);
            }
            if (this.realtimeSynth)
            {
                try
                {
                    wavLength = Utils.filesize(this.tempWaveName + ".dat");
                    byte[] tempBuffer;
                    if (this.PWavLength != 0)
                    {
                        newLength  = wavLength - this.PPWavLength;
                        tempBuffer = Utils.file_get_bytes(this.tempWaveName + ".dat", this.PPWavLength, newLength);
                        this.streamPlayer.Push(tempBuffer);
                        //Utils.log("Push: " + tempBuffer.Length.ToString() + "/" + newLength.ToString() + "; " + wavLength.ToString());
                        tempBuffer = null;
                    }
                    this.PPWavLength = this.PWavLength;
                    this.PWavLength  = wavLength;
                }
                catch (Exception e)
                {
                    Utils.log("error: " + string.Format("{0}, {1}", e.Message, e.StackTrace));
                }
            }
            //全部合成完成后
            this._mainWaitHandle.Set();
        }