Record sound from an specified application RRS feed

  • Question

  • Hello,

    i have a media player but it's very slow and so i tought what about recording my playlist an play it with anotherone. So my question is if it's possible to record sound from a specified application or thread and save it in any format. And how to do that.

    I hope sombody has an answer for me.

    Thank you in advance.

    Wednesday, October 30, 2019 5:33 PM

All replies

  • Hi BierDav,

    Thank you for posting here.

    For your question, you want to record sound from an specified application and save it.

    You can try the following code to get it.
        public partial class Form1 : Form
            // Create class-level accessible variables to store the audio recorder and capturer instance
            private WaveFileWriter RecordedAudioWriter = null;
            private WasapiLoopbackCapture CaptureInstance = null;
            public Form1()
                this.button2.Enabled = false;
            private void Button1_Click(object sender, EventArgs e)
                // Define the output wav file of the recorded audio
                string outputFilePath = @"D:\\test\system_recorded_audio.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);
                // When the Capturer Stops
                this.CaptureInstance.RecordingStopped += (s, a) =>
                    this.RecordedAudioWriter = null;
                // Enable "Stop button" and disable "Start Button"
                this.button1.Enabled = false;
                this.button2.Enabled = true;
                // Start recording !
            private void Button2_Click(object sender, EventArgs e)
                // Stop recording !
                // Enable "Start button" and disable "Stop Button"
                this.button1.Enabled = true;
                this.button2.Enabled = false;

    Hope my solution could be helpful.

    Best Regards,


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact

    Thursday, October 31, 2019 9:23 AM
  • Its not supported by Windows. You can record a specific device but not a specific application.

    If you have multiple sound output devices (you can use software ones but they may have serious lag between what you do and what people hear, a headphone is usually better) you can check if the applications have output sound card settings. If one application has output sound card settings, then you can direct audio output of the two applications to different sound cards and use WasapiLoopbackCapture to record the sound card you are interested in. 

    Visual C++ MVP

    Thursday, October 31, 2019 2:33 PM