简体   繁体   English

Linux上的OpenAL C ++

[英]OpenAL C++ on Linux

I just need a simple program which allows me to play and stop an audio file. 我只需要一个简单的程序,即可播放和停止音频文件。 I'm guessing OpenAL is the way to go? 我猜OpenAL是路要走吗? All I need is this functionality - start audio file with spacebar and stop audio file with a second press of the spacebar. 我需要的只是此功能-用空格键启动音频文件,再按一下空格键即可停止音频文件。 I notice the OpenAL documentation is quite involved. 我注意到OpenAL文档非常复杂。 Can someone point me to something really simple in order to just get the start/stop functionality of a .wav file? 有人可以给我指出一个非常简单的东西,以便仅获取.wav文件的启动/停止功能吗?

OpenAL may not be the simplest choice. OpenAL可能不是最简单的选择。 If you use a gui-framework like QT, check for what their ecosystems provide for playing sound (eg qsound ). 如果您使用QT等GUI框架,请检查其生态系统提供了哪些播放声音的功能(例如qsound )。 Another choice may be Allegro which may feel more straightforward. 另一个选择可能是Allegro,这可能会让您感觉更简单。

For OpenAL, there is a working example to play a wav in the example repositories . 对于OpenAL, 在示例存储库中有一个工作示例可以播放wav。 Playback can be paused using alSourcePause . 可以使用alSourcePause暂停播放。

Edit: 编辑:

For choosing libraries I like to consult Awesome-cpp . 对于选择库,我喜欢咨询Awesome-cpp The simple_playback.c example of mini_al looks extremely straightforward. mini_al的simple_playback.c示例看起来非常简单。 Simply use mal_device_stop(&device) to pause the running playback and mal_device_start(&device) to continue. 简单地使用mal_device_stop(&device)以暂停运行播放和mal_device_start(&device)以继续。 Works perfectly on my machine and seems very portable. 在我的机器上可以完美运行,并且看起来非常便携。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM