如何让用户选择openAL的录音设备?

时间:2010-11-25 21:46:19

标签: c++ c list device openal

所以我们有类似的东西:

      //...
// Get list of available Capture Devices
const ALchar *pDeviceList = alcGetString(NULL, ALC_CAPTURE_DEVICE_SPECIFIER);
if (pDeviceList)
{
    ALFWprintf("\nAvailable Capture Devices are:-\n");

    while (*pDeviceList)
    {
        ALFWprintf("%s\n", pDeviceList);
        pDeviceList += strlen(pDeviceList) + 1;
    }
}

// Get the name of the 'default' capture device
szDefaultCaptureDevice = alcGetString(NULL, ALC_CAPTURE_DEFAULT_DEVICE_SPECIFIER);
ALFWprintf("\nDefault Capture Device is '%s'\n\n", szDefaultCaptureDevice);

alGenSources(1, &source);
alGenBuffers(3, buffers);

/* Setup some initial silent data to play out of the source */
alBufferData(buffers[0], AL_FORMAT_MONO16, data, sizeof(data), 22050);
alBufferData(buffers[1], AL_FORMAT_MONO16, data, sizeof(data), 22050);
alBufferData(buffers[2], AL_FORMAT_MONO16, data, sizeof(data), 22050);
alSourceQueueBuffers(source, 3, buffers);

/* If you don't need 3D spatialization, this should help processing time */
alDistanceModel(AL_NONE); 


// Open the default Capture device to record a 22050Hz 16bit Mono Stream using an internal buffer
// of BUFFERSIZE Samples (== BUFFERSIZE * 2 bytes)
pCaptureDevice = alcCaptureOpenDevice(szDefaultCaptureDevice, 22050, AL_FORMAT_MONO16, BUFFERSIZE);
if (pCaptureDevice)
{//...

但这里我们只使用默认设备。如何让用户选择一个而不是使用它?

1 个答案:

答案 0 :(得分:1)

当您列出所有捕获设备时,您可以在组合框中显示这些设备,让用户拿起他想要的设备并在alcCaptureOpenDevice上使用其名称。