source: trunk/csharp/audio/NAudio/Wave/WaveInputs/WasapiLoopbackCapture.cs @ 2750

Revision 2381, 1.8 KB checked in by daniel-weck, 6 years ago (diff)

re-added folder

  • Property svn:executable set to *
Line 
1using System;
2using System.Collections.Generic;
3using System.Text;
4using NAudio.CoreAudioApi;
5
6namespace NAudio.Wave
7{
8    /// <summary>
9    /// WASAPI Loopback Capture
10    /// based on a contribution from "Pygmy" - http://naudio.codeplex.com/discussions/203605
11    /// </summary>
12    public class WasapiLoopbackCapture : WasapiCapture
13    {
14        /// <summary>
15        /// Initialises a new instance of the WASAPI capture class
16        /// </summary>
17        public WasapiLoopbackCapture() :
18            this(GetDefaultLoopbackCaptureDevice())
19        {
20        }
21
22        /// <summary>
23        /// Initialises a new instance of the WASAPI capture class
24        /// </summary>
25        /// <param name="captureDevice">Capture device to use</param>
26        public WasapiLoopbackCapture(MMDevice captureDevice) :
27            base(captureDevice)
28        {
29        }
30
31        /// <summary>
32        /// Gets the default audio loopback capture device
33        /// </summary>
34        /// <returns>The default audio loopback capture device</returns>
35        public static MMDevice GetDefaultLoopbackCaptureDevice()
36        {
37            MMDeviceEnumerator devices = new MMDeviceEnumerator();
38            return devices.GetDefaultAudioEndpoint(DataFlow.Render, Role.Multimedia);
39        }
40
41        /// <summary>
42        /// Recording wave format
43        /// </summary>
44        public override WaveFormat WaveFormat
45        {
46            get { return base.WaveFormat; }
47            set { throw new InvalidOperationException("WaveFormat cannot be set for WASAPI Loopback Capture"); }
48        }
49       
50        /// <summary>
51        /// Specify loopback
52        /// </summary>
53        protected override AudioClientStreamFlags GetAudioClientStreamFlags()
54        {
55            return AudioClientStreamFlags.Loopback;
56        }       
57    }
58}
Note: See TracBrowser for help on using the repository browser.