Esempio n. 1
0
        public void StartRecording()
        {
            if (Microphone.devices.Length == 0)
            {
                return;
            }

            inputFreq = AudioUtils.GetFreqForMic();

            encoder = SpeexCodex.Create(BandMode.Wide);

            var ratio        = inputFreq / (float)AudioUtils.GetFrequency(encoder.mode);
            int sizeRequired = (int)(ratio * encoder.dataSize);

            recordingBuffer = new float[sizeRequired];
            resampleBuffer  = new float[encoder.dataSize];

            if (AudioUtils.GetFrequency(encoder.mode) == inputFreq)
            {
                recordingBuffer = resampleBuffer;
            }

            recording = Microphone.Start(null, true, 20, inputFreq);
            Plugin.log.Info("Used mic sample rate: " + inputFreq + "Hz");
        }