7

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.

Todd Main
  • 28,951
  • 11
  • 82
  • 146
Richard
  • 1,252
  • 12
  • 23

5 Answers5

5

Just a small addition to Jason's post:

There is another port of Speex to .Net and Silverlight 4 called NSpeex.

Community
  • 1
  • 1
balistof
  • 303
  • 3
  • 10
4

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

Todd Main
  • 28,951
  • 11
  • 82
  • 146
  • Thanks, these are all articles that I've seen though. One thing to bear in mind here, is my requirement that I need to "compress the PCM audio data into something that can be delivered to a remote server more easily". Converting PCM to WAV is easy, but compressing the output isn't. WAV is undesirable because it is so bloaty, even if you encode it as mono. Mike Taulty's blog is great at showing how to use the sinks to capture PCM and convert to WAV, but I guess what we really need here is a MediaStreamSource or something similar that outputs as Speex or WMA. – Richard Mar 29 '10 at 09:40
  • @Otaku - I have accepted your answer; it was the most comprehensively sourced. A lot more still needs to be done though, and I will try to update this article at some point in the future with my actual answer. Thanks for your input. – Richard Mar 30 '10 at 13:38
  • @Richard - thank you! I hear ya on the need for something much more compact than WAV. I'll keep this front of mind as well as I run into things and if something better comes along, I'll update the answer. – Todd Main Mar 30 '10 at 14:42
  • @Richard - haven't had a chance to look at this in too much detail, but this looks of interest: http://silverlightencoder.codeplex.com – Todd Main Apr 15 '10 at 18:43
  • thanks for the pointer, I'll try and have a look at that soon! – Richard Apr 26 '10 at 16:06
1

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.

Jason B
  • 12,835
  • 2
  • 41
  • 43
0

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.

  • Thanks; what I'm after though is a purely .NET managed solution with no third party components that aren't specifically targeted at the SL4 platform. I need a solution that will work on Windows Phone Series 7, too. – Richard Mar 24 '10 at 09:14
-2

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

user342982
  • 69
  • 2
  • 7