/// <summary> /// Notifies client about new block of frames. /// </summary> /// /// <param name="frame">New frame's audio.</param> /// protected void OnNewFrame(Array frame) { framesReceived++; if (NewFrame != null) { NewFrame(this, new NewFrameEventArgs(Signal.FromArray(frame, channels, sampleRate, SampleFormat.Format16Bit))); } }
/// <summary> /// Worker thread. /// </summary> /// private unsafe void WorkerThread() { try { needToStop = false; // Rearm the auto reset events for (int i = 0; i < inputReady.Length; i++) { inputReady[i].Reset(); } short[] buffer = new short[frameSize * channels]; Signal signal = Signal.FromArray(buffer, channels, sampleRate, SampleFormat.Format16Bit); // Multiple sources while (!needToStop) { mix(buffer, signal); } } catch (Exception ex) { if (AudioSourceError != null) { AudioSourceError(this, new AudioSourceErrorEventArgs(ex.Message)); } else { throw; } } finally { } }