需要下载较新版的 cmake 以及 Visual Studio 20xx。
该库的链接:http://www.music.mcgill.ca/~gary/rtaudio/index.html
该库的github:https://github.com/thestk/rtaudio
windows 10 安装方法(或者直接看下面方法):https://github.com/thestk/rtaudio/blob/master/install.txt
打开 git 输入:
git clone https://github.com/thestk/rtaudio mkdir build cd build cmake .. -DAUDIO_WINDOWS_WASAPI=ON
然后vs 打开 rtaudio.sln 项目,我使用的是 64 位构建,ALL_BUILD 构建两次(大概第一次会有一个失败,第二次构建就没了)。
然后找到 dll 以及 lib 路径,dll 放到Windows/System32 中或者,自己项目的exe文件目录下即可。
然后检测是否成功:
#include <iostream> #include "RtAudio.h" #pragma comment(lib, "C:/rtaudio/build/Debug/rtaudio.lib") int main(int argc, char * argv[]) { RtAudio audio; // Determine the number of devices available unsigned int devices = audio.getDeviceCount(); // Scan through devices for various capabilities RtAudio::DeviceInfo info; for (unsigned int i = 0; i < devices; i++) { info = audio.getDeviceInfo(i); if (info.probed == true) { // Print, for example, the maximum number of output channels for each device std::cout << "device = " << i; std::cout << ": maximum output channels = " << info.outputChannels << " "; } } return 0; }