C# 中的 PCM 数据音高变化
我有一个程序,可以从 Web 服务器下载 PCM 数据,稍后使用该数据通过标准 PCM 播放器进行播放。 我希望能够允许用户在播放 PCM 数据时更改其音调。
有谁知道如何做到这一点?
I have a program that downloads PCM data from a Web Server, which it uses later to play through a standard PCM player. I want to be able to allow users to change the pitch of the PCM data while its being played.
Does anyone know how to do this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
最简单的解决方案是以比录制时更高的采样率播放声音 - 以 44 kHz 播放 22 kHz 文件将使音调加倍。 您可以通过丢弃声音中的一些样本(质量差)或重新采样声音(如果使用正弦插值等良好算法,则质量好)来实现相同的效果。
但有一个依赖性 - 通过以不同的采样率播放来改变音调不仅会改变音调,还会改变声音的长度。 可以独立改变持续时间和音高,但这并不容易,并且需要大量的信号处理才能获得良好的质量。 通常使用快速傅立叶变换在频域中完成。
The simplest solution is to play back the sound at a higher sampling rate than it was recorded - playing a 22 kHz file at 44 kHz will double the pitch. You can achieve the same by just throwing away some samples from the sound (bad quality) or resampling the sound (good quality if a good algorithm like sinc interpolation is used).
But there is a dependency - changing the pitch by playing back at different sampling rates will not only change the pitch, but the length of the sound, too. It is possible to change the duration and pitch independently, but that is not that easy and involves a fair amount of singnal processing to achieve good quality. It is usually done in the frequency domain using Fast Fourier Transformations.
我不知道任何 C# 数字信号处理库,但这似乎是 .net 中音调转换的完整源示例。:
http://sites.google.com/site/mikescoderama/pitch-shifting
I don't know any digital signal processing library for C#, but this seems to be a complete source sample for pitch shifting in .net.:
http://sites.google.com/site/mikescoderama/pitch-shifting