Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
        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;
        }
Ejemplo n.º 3
0
        public void Stop()
        {
            if (currentRecordingDevice != null)
            {
                Microphone.End(currentRecordingDevice.Name);

                currentRecordingDevice = null;
            }
        }
Ejemplo n.º 4
0
        public void Stop()
        {
            if ( currentRecordingDevice != null )
            {
                Microphone.End(currentRecordingDevice.Name);

                currentRecordingDevice = null;
            }
        }