开发者

How to let user select a audio recording device with openAL?

So we have something like:

      //...
// 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 som开发者_运维问答e 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)
{//...

but here we only use default device. How to let user select one and than use it?


when you list all the captures devices, you can display those on a combo box, let the user pick-up the device that he wants and use its name on the alcCaptureOpenDevice.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜