1

有没有关于从麦克风获取声音的库(c++、Win32、开源)的建议?

谢谢

4

7 回答 7

3

PortAudio - 可移植的跨平台音频 API

PortAudio 提供了一个非常简单的 API,用于使用简单的回调函数录制和/或播放声音。

于 2009-06-17T20:10:50.080 回答
3

尝试查看 OpenAL[1] 可能有点过头了,但应该能够根据需要从麦克风录制。Gamedev.net[2] 上有一些非常好的文章,但恐怕没有一篇告诉你如何用麦克风录音。但是,您应该能够在文档中找到答案。:) 祝你好运,


[1] http://connect.creativelabs.com/openal/default.aspx

[2] http://www.gamedev.net/reference/articles/article2008.asp

于 2009-06-17T20:09:39.427 回答
2

我在CodeProject找到了一些代码(标准警告:请仔细检查您从 CodeProject 获取的每一段代码!它很有用,但我经常在我得到的示例中发现可怕的错误!)。这应该为您提供有关 API 以及如何开始使用它们的良好线索。从那里你可以谷歌参考和相关主题。

于 2009-06-17T20:06:25.410 回答
2
  • WaveInOpen - 这是一个打开波形输入设备的函数。
  • WaveInPrepareHeader - 使用此函数准备一个记录缓冲区。
  • WaveInAddBuffer - 添加要记录的缓冲区。
  • WaveInStart - 用于开始录制。
  • WaveInClose - 关闭波形输入设备。
于 2012-03-11T12:10:40.740 回答
1

如果您不需要跨平台,DirectShow效果很好。虽然它不是开源的,但我相信您可以分发需要 DirectShow 库的开源项目。

于 2009-06-17T20:23:23.393 回答
0

你没有说你需要跨平台支持,如果不需要跨平台支持,我会使用 Wave API 或 DirectSound - 两者都相当简单易用。

于 2009-06-18T05:33:24.403 回答
0

我过去曾使用 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);
于 2009-06-19T00:19:45.240 回答