public int Start(AudioInputDeviceDescription device, Action <float[], int> bufferCallback) { if (device == null) { throw new ArgumentNullException("device"); } if (bufferCallback == null) { throw new ArgumentNullException("bufferCallback"); } Stop(); currentRecordingDevice = device; this.bufferCallback = bufferCallback; // Select sample frequency: sampleFrequency = device.MaxFrequency > 0 ? device.MaxFrequency : defaultSampleFrequency; bufferLengthInSamples = sampleFrequency * BufferLengthInSeconds; currentSamplePosition = 0; readBuffer = new float[bufferLengthInSamples]; recordingBuffer = Microphone.Start(currentRecordingDevice.Name, false, BufferLengthInSeconds, sampleFrequency); return(sampleFrequency); }
public int Start(AudioInputDeviceDescription device,Action<float[],int> bufferCallback ) { if ( device == null ) { throw new ArgumentNullException("device"); } if ( bufferCallback == null ) { throw new ArgumentNullException("bufferCallback"); } Stop(); currentRecordingDevice = device; this.bufferCallback = bufferCallback; // Select sample frequency: sampleFrequency = device.MaxFrequency > 0 ? device.MaxFrequency : defaultSampleFrequency; bufferLengthInSamples = sampleFrequency*BufferLengthInSeconds; currentSamplePosition = 0; readBuffer = new float[bufferLengthInSamples]; recordingBuffer = Microphone.Start(currentRecordingDevice.Name, false, BufferLengthInSeconds, sampleFrequency); return sampleFrequency; }
public void Stop() { if (currentRecordingDevice != null) { Microphone.End(currentRecordingDevice.Name); currentRecordingDevice = null; } }
public void Stop() { if ( currentRecordingDevice != null ) { Microphone.End(currentRecordingDevice.Name); currentRecordingDevice = null; } }