【发布时间】:2009-06-17 19:58:24
【问题描述】:
对于从麦克风获取声音的库(c++、Win32、开源)有什么建议吗?
谢谢
【问题讨论】:
标签: c++ winapi open-source microphone
对于从麦克风获取声音的库(c++、Win32、开源)有什么建议吗?
谢谢
【问题讨论】:
标签: c++ winapi open-source microphone
尝试查看 OpenAL[1] 可能有点过头了,但应该可以根据需要从麦克风录制。 Gamedev.net[2] 上有一些非常好的文章,但恐怕没有一篇告诉你如何用麦克风录音。但是,您应该能够在文档中找到答案。 :) 祝你好运,
[1]http://connect.creativelabs.com/openal/default.aspx
[2]http://www.gamedev.net/reference/articles/article2008.asp
【讨论】:
PortAudio - portable cross-platform Audio API
PortAudio 提供了一个非常简单的 API 用于录制和/或播放声音 使用简单的回调函数。
【讨论】:
我在CodeProject 找到了一些代码(标准警告:请仔细检查您从 CodeProject 获取的每一段代码!它很有用,但我经常在我得到的示例中发现可怕的错误!)。这应该为您提供有关 API 以及如何开始使用它们的良好线索。从那里您可以通过 Google 搜索参考资料和相关主题。
【讨论】:
【讨论】:
如果您不需要跨平台,DirectShow 效果很好。虽然它不是开源的,但我相信你可以分发需要 DirectShow 库的开源项目。
【讨论】:
你没有说你需要跨平台支持,如果不需要跨平台支持,我会使用 wave API 或 DirectSound - 两者都相当简单易用。
【讨论】:
我过去曾使用 mci 功能进行记录。 抱歉,这并没有显示确保选择麦克风作为录音输入,但是一旦手动选择它,它将保持不变,除非有人更改它。这是在一个对话框中,所以这就是 windows 句柄的来源。
#define ALIAS "mci_alias"
char mci_command[100];
char ReturnString[300];
int mci_error;
// open the device
sprintf(mci_command, "open new type waveaudio alias %s", ALIAS);
mci_err = mciSendString(mci_command, ReturnString, sizeof(ReturnString), m_hWnd);
// set the time format
sprintf(mci_command,"set %s time format ms", ALIAS); // just set time format
mci_err = mciSendString(mci_command, ReturnString, sizeof(ReturnString), m_hWnd);
// start the record. specify notifications with a MM_MCINOTIFY message)
sprintf(mci_command, "record %s notify", ALIAS);
mci_err = mciSendString(mci_command, ReturnString, sizeof(ReturnString), m_hWnd);
// wait for a stop button, or an error to occur
sprintf(mci_command,"stop %s", ALIAS);
mci_err = mciSendString(mci_command, ReturnString, sizeof(ReturnString), m_hWnd);
// save the file
sprintf(mci_command, "save %s %s", ALIAS, m_filename);
mci_err = mciSendString(mci_command, ReturnString, sizeof(ReturnString), m_hWnd);
sprintf(mci_command,"stop %s", ALIAS);
mci_err = mciSendString(mci_command, ReturnString, sizeof(ReturnString), m_hWnd);
// close the device
sprintf(mci_command,"close %s", ALIAS);
mci_err = mciSendString(mci_command, ReturnString, sizeof(ReturnString), m_hWnd);
【讨论】: