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; }
private async Task StartSending() { while (click) { QueueItem item = null; if (this.outgoingMessageQueue.TryTake(out item, 100)) { try { await IAT.RunIAT(VoiceReady, session_begin_params, ref sd); item.CompletionSource.TrySetResult(true); VoiceReady.Clear(); } catch (OperationCanceledException) { item.CompletionSource.TrySetCanceled(); } catch (ObjectDisposedException) { item.CompletionSource.TrySetCanceled(); } catch (Exception ex) { item.CompletionSource.TrySetException(ex); throw; } } } }