如何在C#.Net中以不同的频率播放wav文件

问题描述:

如何在C#.Net中播放不同频率的wav文件。请提供一个示例代码..

How to play wav files in different frequency in C#.Net. please provide a sample code too..

即使您只是想改变整个WAV记录的速度,也不是那么简单。据我所知,.NET FCL没有提供一个随时可用的库来以任意速度播放记录。您需要使用Windows多媒体库进入较低级别。这篇CodeProject文章将帮助您了解所涉及的内容:使用Windows多媒体库播放.WAV文件 [ ^ ]。



如果你想要.NET的所有内容,你会需要包装Windows多媒体子系统(winmm.dll)。至少已经为您创建了一个这样的开源包装器: http://winmm.codeplex.com/ [ ^ ]。



详细MSDN文档,请参阅:

http://msdn.microsoft.com/en-us/library/windows/desktop/dd743883%28v=vs.85%29.aspx [ ^ ],

http://msdn.microsoft.com/en -us / library / windows / desktop / dd743606%28v = vs.85%29.aspx [ ^ ]。



全部以上是目前考虑的作为遗留API。您还可以查看更多最新的Microsoft API,但它只能在Windows 8或Windows Server 2012中使用:

http://msdn.microsoft.com/en-us/library/windows/desktop/dd370802%28v=vs。 85%29.aspx [ ^ ]。



-SA
This is not so simple, even if you just want to change the tempo of the whole WAV record. As far as I can see, .NET FCL does not provide a ready-to-use library for playing a record at arbitrary speed. You need to go to a lower level, with the Windows multimedia library. This CodeProject article will give you a good idea on what's involved: Playing .WAV files using the Windows Multi-Media Library[^].

If you want all that with .NET, you would need to wrap the Windows multimedia subsystem ("winmm.dll"). At least one such open-source wrapper is already created for you: http://winmm.codeplex.com/[^].

For detailed MSDN documentation, please see:
http://msdn.microsoft.com/en-us/library/windows/desktop/dd743883%28v=vs.85%29.aspx[^],
http://msdn.microsoft.com/en-us/library/windows/desktop/dd743606%28v=vs.85%29.aspx[^].

All of the above is currently considered as "legacy API". You can also check out more up-to-date Microsoft API, but it only can be used in Windows 8 or Windows Server 2012:
http://msdn.microsoft.com/en-us/library/windows/desktop/dd370802%28v=vs.85%29.aspx[^].

—SA