void OnDataAvailable(object sender, WaveInEventArgs e)
        {
            totalBufferLength += e.Buffer.Length;
            secondsRecorded    = (float)(totalBufferLength / 32000);

            VoiceData data = new VoiceData();

            for (int i = 0; i < 3200; i++)
            {
                data.data[i] = e.Buffer[i];
            }
            VoiceBuffer.Add(data);

            if (lastPeak < 20)
            {
                Ends = Ends - 1;
            }
            else
            {
                Ends = 5;
            }

            if (Ends == 0)
            {
                if (VoiceBuffer.Count() > 5)
                {
                    IAT.RunIAT(VoiceBuffer, session_begin_params);
                }

                VoiceBuffer.Clear();
                Ends = 5;
            }

            prgVolume.Value = lastPeak;
        }
Пример #2
0
        void OnDataAvailable(object sender, WaveInEventArgs e)
        {
            if (audioSent != null)
            {
                audioSent.Write(e.Buffer, 0, e.BytesRecorded);
            }

            if (name == "中文")
            {
                totalBufferLength += e.Buffer.Length;
                secondsRecorded    = (float)(totalBufferLength / 32000);

                VoiceData data = new VoiceData();
                for (int i = 0; i < 3200; i++)
                {
                    data.data[i] = e.Buffer[i];
                }
                VoiceBuffer.Add(data);

                if (lastPeak < 20)
                {
                    Ends = Ends - 1;
                }
                else
                {
                    Ends = 5;//梦龙:originally 5
                }
                if (Ends == 0)
                {
                    if (VoiceBuffer.Count() > 5)
                    {
                        VoiceReady.AddRange(VoiceBuffer);

                        var msg = new QueueItem(VoiceReady, session_begin_params, ref sd);
                        this.outgoingMessageQueue.Add(msg);
                    }

                    VoiceBuffer.Clear();
                    Ends = 5;//梦龙:originally 5
                }
            }

            prgVolume.Value = lastPeak;
        }