如何让 2 个波形文件读取器按顺序播放?
我正在尝试播放一组通过网络发送的音频 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
本 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
另一种方法是创建您自己的自定义 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