如何将 DynamicSoundEffectInstance 或 SoundEffectInstance 保存到文件或数组?
我有一个 Windows Phone Silverlight 应用程序。我这样做是为了减慢声音并改变麦克风流的音调:
sound = new SoundEffect(bStream, microphone.SampleRate, AudioChannels.Mono);
SoundEffectInstance soundInstance = sound.CreateInstance();
soundInstance.Pitch -= 1;
soundInstance.Play();
这里“bStream”是一个字节数组。问题是我无法保存更改音高的数据(尽管我可以播放它)。有没有办法在音调更改后保存我的字节数组?我也尝试了 DynamicSoundEffectInstance ,结果相同。当我将 bStream 保存为 wav 文件时,所有效果都消失了。
感谢您的帮助和见解。
I have a Windows Phone Silverlight Application. I do this to slow down the voice and change the pitch from microphone stream:
sound = new SoundEffect(bStream, microphone.SampleRate, AudioChannels.Mono);
SoundEffectInstance soundInstance = sound.CreateInstance();
soundInstance.Pitch -= 1;
soundInstance.Play();
here "bStream" is a byte array. The problem is I cannot save the data with the changed pitch (although I can play it). Is there a way to save my byte array after the pitch has been changed ? I tried DynamicSoundEffectInstance as well with same result. When I save bStream as a wav file, all the effects are gone.
Thanks for your help and insight.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您真的需要在调整音高的情况下保存它吗?为什么不直接将音调调整量与文件一起保存,并在加载文件后重新应用它(就像您已经在做的那样)。
如果您确实需要调整数据的音调,那么您实际上需要对其进行重新采样。这涉及对值进行插值和/或平均以及时拉伸或压缩它们。我相信 NAudio 包含用于执行此操作的 C# 代码: http://naudio.codeplex.com/
Do you really need to save it with the pitch adjusted? Why not just save the pitch adjustment amount with the file and re-apply it again (just like you are doing already) after you load the file up.
If you really do need to adjust the pitch of the data, you'll essentially be resampling it. This involves interpolating and/or averaging the values to stretch or compress them in time. I believe NAudio contains C# code for doing this: http://naudio.codeplex.com/