static unsafe void waveIn_DataAvailable(object sender, WaveInEventArgs e) { lock (FDecoder) { byte[] downSampled = new byte[e.BytesRecorded / 2]; for (int i = 0; i < e.BytesRecorded / 2; i++) { downSampled[i] = (byte)(((int)e.Buffer[i * 2] + (int)e.Buffer[i * 2 + 1]) / 2); } FDecoder.Write(downSampled, e.BytesRecorded / 2, 0); } }
unsafe void FCapture_DataAvailable(object sender, WaveInEventArgs e) { lock (FDecoder) { byte[] downSampled = new byte[e.BytesRecorded / 2]; for (int i = 0; i < e.BytesRecorded / 2; i++) { downSampled[i] = e.Buffer[i * 2 + FChannel]; } FDecoder.Write(downSampled, e.BytesRecorded / 2, 0); } }