[C #] [DxLib] I want to set the sound type to WASAPI, DirectSound, or ASIO. [WASAPI sharing support]

less than 1 minute read

Overview

This time, I will show you how to use DxLib functions to set the sound type to “WASAPI” or “DirectSound”.
I think anyone can do it easily, so let’s do it!

Thing you want to do

I want to set the sound type of the software to “WASAPI” or “DirectSound”.

element

Add the following code to the front of DX.DxLib_Init ();.

DirectSound : DX.SetEnableWASAPIFlag(DX.FALSE);

WASAPI (shared): DX.SetEnableWASAPIFlag (DX.TRUE, DX.FALSE);

WASAPI (Exclusive): DX.SetEnableWASAPIFlag (DX.TRUE, DX.TRUE);

ASIO : DX.SetEnableASIOFlag(TRUE);

Example of use

//I think it is easier to understand if you use enum, but this time we will perform branch processing with int.

//type = 0: DirectSound
//type = 1: ASIO
//type = 2: WASAPI(Exclusive)
//type = 3: WASAPI(share)
int type = 0;

switch (type)
{
	case 0:
		DX.SetEnableWASAPIFlag(DX.FALSE);
		break;
	case 1:
		DX.SetEnableASIOFlag(DX.TRUE);
		break;
	case 2:
		DX.SetEnableWASAPIFlag(DX.TRUE, DX.TRUE);
		break;
	case 3:
		DX.SetEnableWASAPIFlag(DX.TRUE, DX.FALSE);
		break;
	default:
		goto case 3;
}

Finally

This time is over.
If you have any questions, feel free to ask in the comments.

Tags:

Updated: