Richard
Richard

Reputation: 1252

Silverlight 4 - encoding PCM data from the microphone

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.

Upvotes: 7

Views: 5014

Answers (5)

balistof
balistof

Reputation: 303

Just a small addition to Jason's post:

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

Upvotes: 5

user342982
user342982

Reputation: 69

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

Upvotes: -2

Todd Main
Todd Main

Reputation: 29155

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

Upvotes: 4

Jason B
Jason B

Reputation: 12975

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.

Upvotes: 1

user595809
user595809

Reputation:

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.

Upvotes: 0

Related Questions