简体   繁体   English

如何在nim中播放WAV文件?

[英]How to play a WAV file in nim?

I've spent the last few hours working through many different audio libraries found on nimble.directory but they are either lacking in documentation or are years old or both. 我花了最后几个小时来研究在nimble.directory找到的许多不同的音频库,但是它们要么缺少文档,要么已经使用nimble.directory ,或者两者都有。

I'm just getting started with nim, and I'm building a super lightweight audio metronome. 我刚刚开始使用nim,并且正在构建一个超轻量级的音频节拍器。 I have the timing worked out, but I still need to be able to dump a bytestream to the audio device OR even load a .wav file and play it to an audio device. 我已经确定了时间安排,但是我仍然需要能够将字节流转储到音频设备,或者甚至加载.wav文件并将其播放到音频设备。

I have had some small success with the sdl2 library, but it feels like overkill loading a full game library for this tiny use case. 我在sdl2库方面取得了一些小成就,但感觉像在为这个很小的用例加载完整的游戏库过大了。

Can I get some guidance here? 我可以在这里得到一些指导吗?

There's nimbass which is a wrapper for the Bass library. nimbassBass库的包装器。 There's also a wrapper for Soloud here as part of the nimterop test suite that you could try. 您可以尝试在nimterop 测试套件中为Soloud包装一个包装。

Note I haven't personally used either to play a wav file but both provide facilities to do so. 注意:我个人都没有播放过wav文件,但是两者都提供了播放文件的功能。 Here's an example for Soloud which could be easily translated into Nim. 这是 Soloud的示例,可以轻松转换为Nim。

If there's a specific C audio lib you want to use, we can look into helping you wrap it, if it isn't already. 如果您要使用特定的C音频库,我们可以帮助您包装它(如果尚未包装)。

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

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