如何让用户使用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)
{//...
但这里我们只使用默认设备。如何让用户选择一个并使用它?
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 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)
{//...
but here we only use default device. How to let user select one and than use it?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
当您列出所有捕获设备时,您可以将它们显示在组合框中,让用户选择他想要的设备并在 alcCaptureOpenDevice 上使用其名称。
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.