Ejemplo n.º 1
0
        private void BtnStart_Click(object sender, EventArgs e)
        {
            StartRecording();
            RestartRecording.Start();

            pnlSettings.Visible = false;

            btnStart.Enabled = false;
            btnStop.Enabled  = true;
        }
Ejemplo n.º 2
0
        private void StartRecording()
        {
            string outputFilePath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + $@"\ASP\Temp\temp_audio_{FileCount}.wav";

            // Redefine the capturer instance with a new instance of the LoopbackCapture class
            this.CaptureInstance = new WasapiLoopbackCapture();

            // Redefine the audio writer instance with the given configuration
            this.RecordedAudioWriter = new WaveFileWriter(outputFilePath, CaptureInstance.WaveFormat);

            // When the capturer receives audio, start writing the buffer into the mentioned file
            this.CaptureInstance.DataAvailable += (s, a) =>
            {
                this.RecordedAudioWriter.Write(a.Buffer, 0, a.BytesRecorded);
            };

            CaptureInstance.StartRecording();

            pnlRecording.Visible = true;

            pnlRecording.Visible = true;

            RestartRecording.Start();
        }