如何让 2 个波形文件读取器按顺序播放?

发布于 2024-08-17 14:52:45 字数 209 浏览 3 评论 0原文

我正在尝试播放一组通过网络发送的音频 wav 文件,以作为整体声音流播放。如何使用 NAudio 获得一组连续播放的块,并且没有声音中断或提示音?我可以播放 1 个文件,但我找不到一种方法来检测一个声音文件何时结束或如何将第二个声音文件附加到第一个声音文件上。

目前,当我尝试播放 2 个文件时,第一个音轨会立即被切断,只有最后一个音轨才能正确播放。

任何帮助将不胜感激。

I'm trying to play a set of audio wav files being sent over the network for playing as a overall sound stream. How do i get a set of these chunks to play one after the other with no sound breaks or blips using NAudio? I can have 1 file play, but I cant find a way to detect when one sound file ends or how to attach the 2nd sound file onto the 1st.

Currently when i try to play 2 files, the 1st track is cut off immediately and the only the final sound track is played properly

Any help would be greatly appreciated.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

凉薄对峙 2024-08-24 14:52:45

本 NAudio 教程展示了如何实时混合流。它似乎支持定位(因此您可以在第一个流的末尾混合第二个流)。

http://opensebj.blogspot.com/ 2009/02/naudio-tutorial-2-mixing-multiple-wave.html

This NAudio tutorial shows how to mix streams in real-time. It seems to support positioning (so you can mix the second stream right at the end of the first).

http://opensebj.blogspot.com/2009/02/naudio-tutorial-2-mixing-multiple-wave.html

纵情客 2024-08-24 14:52:45

另一种方法是创建您自己的自定义 WaveStream,其中包含两个 WaveFileReader。在Read方法中,从第一个返回数据,直到用完,然后从第二个开始返回数据。如果您需要在播放期间支持重新定位,您需要做更多的事情,但除此之外它应该非常简单

another approach is to create your own custom WaveStream that contains two WaveFileReaders. In the Read method, return data from the first until it runs out, then start returning data from the second. You'll need to do a little more if you need to support repositioning during playback, but apart from that it should be very straightforward

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文