使用生成的波形数据在.NET中播放声音 [英] Play Sound in .NET using generated Waveform data

查看:169
本文介绍了使用生成的波形数据在.NET中播放声音的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我怎么能起到基础上,我的.NET程序从用户的输入和数学函数产生波形数据的声音?通过波形数据我的意思是SPL(声pressure水平)在固定间隔时间序列(可能是44.1千赫)值。我presume,这需要某种形式的流媒体缓冲安排。

How can I play a sound based on waveform data that my .NET program is generating from user input and mathematical functions? By "waveform data" I mean SPL (sound pressure level) values in a fixed interval time-series (probably 44.1 kHz). I presume that this requires some kind of streaming buffer arrangement.

请注意,这必须是活/实时性,所以只创建一个.wav文件,然后播放,这将是不够的。 VB.NET是preferred,但是C#是可以接受的。

Note, that this has to be live/real-time, so just creating a .wav file and then playing that will not be sufficient. VB.NET is preferred, but C# is acceptable also.

只是为了澄清:我所寻找的是一个简单的工作code例如

Just to clarify: What I am looking for is a simple working code example.

推荐答案

您可以使用做到这一点 n音讯。您创建一个流源自的WaveStream,并在其被覆盖的阅读方法,你回到你的样品,你可以在飞行中产生。您可以在使用的声卡,让你掌控延迟缓冲区的大小控制。

You can do this using NAudio. You create a stream that derives from WaveStream and in its overriden Read method, you return your samples which you can generate on the fly. You have control over the size of the buffers used by the soundcard which gives you control over the latency.

这篇关于使用生成的波形数据在.NET中播放声音的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆