SDL基准声音
SDL Benchmark Sound
我正在为我的最后一个cs项目在两个图形库(SDL、SFML)之间进行一个基准测试项目。我几乎完成了,然而,当我对播放声音的速度进行基准测试时,无论他做了多少循环,它总是返回0所花费的时间。你知道我的代码出了什么问题吗?声音确实在播放,但我可能应该做一些其他算法。
void playSound()
{
Mix_PlayChannel(-1, sound, 0);
}
void soundBenchmark(int numOfCycles)
{
int time = SDL_GetTicks(), timeRequired;
for(int i = 0; i < numOfCycles; i++) playSound();
timeRequired = SDL_GetTicks() - time;
cout << "Time required for " << numOfCycles << " cycles: " << timeRequired << " seconds.n";
}
函数Mix_PlayChannel()
不会阻止代码的执行。该函数只需将数据发送到声卡(或等效设备)并返回。
您必须记住使用Mix_PlayChannel()
的频道,然后定期使用Mix_Playing()
检查该频道是否正在播放,并查看时间。
相关文章:
- Xaudio2在更改缓冲区或循环时弹出声音
- 如何更改'a'声音?
- 使用rdtsc进行基准测试的缺点是什么
- 如何收听Windows当前正在播放的声音?
- 对 'std::thread::_M_start_thread CMake 的未定义引用进行基准测试
- 更高效地在微控制器上对C++进行基准测试
- 如何在 c++ 中循环中使用频率变化的声音?
- _mm256_load_ps调试模式下导致谷歌/基准测试的分段错误
- 如何使用 C++ gdal 库将栅格地理从 EGM96 转换为 WGS84 椭球体高度基准面
- 二叉树基准测试结果
- 如何使用谷歌基准测试对自定义界面进行基准测试
- 谷歌基准测试,如何只调用一次代码?
- 为什么我的性能基准给了我错误的结果?
- 将uintptr_t转换为布尔值会使 SSO 基准速度减慢数倍
- 如何在C++中播放声音?
- 波形音频 - waveOutWrite 发出断断续续的声音
- 如何使用 ALSA API 在应用程序中在单声道和立体声之间切换声音输出?
- 使用 std::chrono::steady_clock 对线程/异步中的代码进行基准测试
- 有没有办法毫不拖延地播放声音?
- SDL基准声音