Silverlight 4 - 对来自麦克风的 PCM 数据进行编码
我编写了一个基本的 SL4 应用程序,用于使用 CaptureSource
从麦克风捕获音频数据。问题是,它是原始 PCM 输出 - 这意味着巨大且未压缩。
鉴于我需要此应用程序纯粹在 SL4 环境中运行,如何将 PCM 音频数据压缩为可以更轻松地传送到远程服务器的数据?
本质上,我需要一个可以在 Windows Phone Series 7 应用程序中部署/包含的解决方案,以及一个可以在浏览器环境中工作的解决方案 - 所以我认为只是托管代码解决方案?
在谈话中,人们建议使用 Speex 和 WMA,但我还没有找到任何不需要引用 DLL 即可工作的库或示例,而这些库或示例在 SL4 项目中不起作用。
I've written a basic SL4 application to capture audio data from the microphone using CaptureSource
. The trouble is, it's raw PCM output - which means huge and uncompressed.
Given that I need this application to run purely within a SL4 environment, how can I compress the PCM audio data into something that can be delivered to a remote server more easily?
Essentially I need a solution that I can also deploy/include in a Windows Phone Series 7 application as well as one that will work in the browser environment - so managed code solutions only, I think?
In conversation, people have suggested Speex and WMA for instance, but I haven't found any libraries or examples that work without requiring reference to DLL's that won't work in a SL4 project.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
只是对 Jason 的帖子的一小部分补充:
Speex 到 .Net 和 Silverlight 4 的另一个端口称为 NSpeex。
Just a small addition to Jason's post:
There is another port of Speex to .Net and Silverlight 4 called NSpeex.
请参阅 Silverlight 4 Rough Notes: Camera and Microphone Support 在 Mike Taulty 的博客上(比页面中间低一点,但完整的文章值得)他将 PCM 文件压缩为 WAV。
这是写入 WAV 时可以更改 Mono/Stereo 等值的另一个示例,这将直接更改 WAV 文件的大小:录音机 Silverlight 4 示例。还有一个提供了有关写入 WAV 的更多详细信息:在 Silverlight 3 Beta 中使用 MediaStreamSource 创建声音
Please see the
WavFileHelper
class in Silverlight 4 Rough Notes: Camera and Microphone Support on Mike Taulty's blog (a bit lower than the middle of the page, but the full article is worthwhile) in which he compresses the PCM file to WAV.Here's another example of when writing to WAV you can change values such as Mono/Stereo, which will directly change the size of the WAV file: Audio recorder Silverlight 4 sample. And one more that gives more details about writing to WAV: Creating Sound using MediaStreamSource in Silverlight 3 Beta
看看这个。看起来他已经将 Speex 编码器移植到 C# 来解决您想要解决的确切问题。它位于此处。 Speex 是为语音而设计的,如果您只是对语音进行编码,那么它的性能应该比 wma、mp3 或其他旨在处理音乐的音频编解码器更好,我认为这是因为您是从麦克风中抓取的。
Take a look at this. It looks like he has ported the Speex encoder to C# for the exact problem you are trying to solve. It is available here. Speex is designed for speech and should perform better than wma, mp3, or other audio codecs that are designed to handle music if you are just encoding speech, which I assume since you are grabbing from the mic.
本文 http:// alvas.net/alvas.audio,articles.aspx#how-to-save-audio-to-mp3-on-silverlight 关于在客户端上保存音频。例如,要将音频数据发送到服务器,您可以使用 WebClient。
This article http://alvas.net/alvas.audio,articles.aspx#how-to-save-audio-to-mp3-on-silverlight about save audio on client. To send audio data to a server you can use WebClient, for example.
您可以通过服务器进行编码,将所有流发送到 WCF 服务,并通过 Microsoft Expression Encoding SDK API 进行编码。
请查看我之前询问过的这个网址:
http://forums.silverlight.net/forums/t/181141.aspx
问候
You can do encoding thru the server, by send all stream to WCF service and do your encoding thru Microsoft Expression Encoding SDK API.
Please, see this url that i have asked before:
http://forums.silverlight.net/forums/t/181141.aspx
Regards