[ASIO]What about latency ?

理解音频延迟
What about latency ?

The delay between a requested command, (like cue, play, bend, eq change, etc.) and the moment when the soundcard reacts on it is called latency.
Lower latencies are better for live performances but if you set the latency too low you can get sound skipping or stoping. On the other hand if you set it too high then you will hear the late sound effect of your actions. So, you have to decide the right latency value for your PC.

A soundcard has one or more drivers, like: DirectSound, MME WaveOut, ASIO.
Here are the latencies for them:
  • DirectSound : 20 - 130 ms(miliseconds)
  • MME WaveOut : 50 - 180 ms
  • ASIO : 3 - 40 ms
为了验证 Boost.Asio 库是否已正确安装并配置在开发环境中,可以通过编写一个简单的测试程序来确认。该程序将使用 Boost.Asio 的基本功能,例如异步定时器或网络通信,以确保库能够正常工作。 以下是一个使用 Boost.Asio 异步 TCP 连接的简单示例代码: ```cpp #include <boost/asio.hpp> #include <boost/array.hpp> #include <iostream> using boost::asio::ip::tcp; int main() { try { boost::asio::io_context io_context; // 解析服务器地址和端口 tcp::resolver resolver(io_context); tcp::resolver::results_type endpoints = resolver.resolve("127.0.0.1", "daytime"); // 建立连接 tcp::socket socket(io_context); boost::asio::connect(socket, endpoints); // 读取服务器返回的数据 boost::array<char, 128> buf; boost::system::error_code error; size_t len = socket.read_some(boost::asio::buffer(buf), error); if (error) { std::cerr << "Error: " << error.message() << std::endl; } else { std::cout.write(buf.data(), len); } } catch (std::exception& e) { std::cerr << "Exception: " << e.what() << std::endl; } return 0; } ``` 在编译和运行此程序之前,确保以下几点: - **Boost 库路径已正确配置**:确保在 Visual Studio 中设置好了包含目录和库目录,指向 Boost 的头文件和编译好的库文件位置。 - **Boost.Asio 依赖的库已链接**:如果使用了需要链接的组件(如 `boost_system`),则需在项目属性中添加相应的库文件路径,并在链接器输入中添加 `libboost_system-vc120-mt-x32-1_55.lib`(具体名称可能因版本和编译器不同而异)。 - **Boost 版本兼容性**:确保 Boost 库版本与 Visual Studio 2013 兼容,建议使用 Boost 1.55 或更高版本。 编译并运行程序,如果能够成功连接到本地 `daytime` 服务(或任何测试用的 TCP 服务),并且接收到数据,则表明 Boost.Asio 已正确安装和配置。 此外,也可以尝试在命令行中使用 `boost::asio::ip::host_name()` 获取本地主机名,作为另一个简单的测试方法: ```cpp #include <boost/asio.hpp> #include <iostream> int main() { try { boost::asio::io_context io_context; std::cout << "Host name: " << boost::asio::ip::host_name() << std::endl; } catch (std::exception& e) { std::cerr << "Exception: " << e.what() << std::endl; } return 0; } ``` 若程序输出主机名,则说明 Boost.Asio 的基本功能可用。
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值