Starting the specific endpoint device and recording its data flow MessageBox.Show( " No capture device detected and/or connected") If (nCaptureDevices = 0 & nLoopbackDevices = 0) String strLoopbackDevice = (i,ĮnumWasapiDeviceTypes.WASAPI_DEVICE_TYPE_LOOPBACK) Ĭ(strLoopbackDevice) enumerate loopback devices int nLoopbackDevices = 0 Ī (enumWasapiDeviceTypes.WASAPI_DEVICE_TYPE_LOOPBACK,įor ( int i = 0 i < nLoopbackDevices i++) String strCaptureDevice = (i,ĮnumWasapiDeviceTypes.WASAPI_DEVICE_TYPE_CAPTURE) Ĭ(strCaptureDevice) enumerate audio input devices int nCaptureDevices = 0 Ī (enumWasapiDeviceTypes.WASAPI_DEVICE_TYPE_CAPTURE,įor ( int i = 0 i < nCaptureDevices i++) Enumerating various types of audio endpoint devices (render, capture and loopback)Īfter the drivers initialization we can enumerate available audio endpoint devices through the combination of WASAPI.DeviceGetCount and WASAPI.DeviceGetDesc methods that will also allow to fill a couple of combo boxes on the user interface due to the fact that we will use this sample as a recording system, we are mainly interested in enumerating capture and loopback devices while for playback we will use the system default device: MessageBox.Show( " This sample can only work on Windows Vista or higher versions.ĪudioSoundRecorder1.InitRecordingSystem() If (nReturn = enumErrorCodes.ERR_INVALID_PLATFORM) initialize usage of WASAPI audio driversĮnumErrorCodes nReturn = audioSoundRecorder1.InitDriversType (enumDriverTypes.DRIVER_TYPE_WASAPI) Private void Form1_Load( object sender, EventArgs e) NET accesses audio devices through DirectSound and WDM drivers so, in order to leverage WASAPI, we need to specify to the component that we want to use a different kind of drivers through the InitDriversType method, then we can initialize the component through the mandatory call to the InitRecordingSystem method: Initializing the WASAPI subsystem and the component’s recording systemīy default Audio Sound Recorder for. The user interface of our sample application will look like this: In this tutorial we want to see how to start a recording session, from a capture device or from a loopback device, in order to store incoming audio data into an output sound file of a specific audio format with the possibility to playback the same file once the recording session is stopped.
0 Comments
Leave a Reply. |