www.planet-xaml.net
[Silverlight]

Building an audio synthesizer with Silverlight 2

by Florian Krüsch May 21, 2008

The Flash community has been playing with dynamically generated audio for quite a while. For example Andre Michelle has a whole lab with fascinating audio stuff. He and other guys have gained enough momentum to convice Adobe to add advanced support for audio synthesis into the next Flash player.

I was wondering, if it is possible to build a dynamic audio synthesizer in Silverlight 2 and what it might take, so I did a little bit of investigation. To make it short, in Beta 1 you can't really do it... but it's close, so close that I hope that Microsoft might listen and add the last few extra meters.

Here's how I thought you could implement it: Silverlight PM Joe Stegman posted in his blog a way to dynamically create images in Silverlight and load them into an Image object using the SetSource method. It turns out that the MediaElement object also has a SetSource method that can be passed a video or audio stream.

Bingo, you might think. Just write a little library that creates an audio stream, pass that stream to the MediaElement and have fun. Now, here comes the bummer: MediaElement only supports WMA and MP3 audio codecs, it does not support wav or wma lossless. WAV audio would be straight forward to create and encode on the fly, but with WMA and MP3 there's no easy way, licensing and patent issues aside.

I image that adding wav support would be a piece of cake, although I'm aware that deployment size and testing have to be taken into consideration. But adding that little feature would open up a whole world for the creative community. Yep, that's right... it is important to get the creative community interested Silverlight. The enterprise will embrace it anyway.

Cheers,
Florian

 

Comments:

  • I think this hole is mostly a consequence of Silverlight 1.0 (where it wasn't practical to work with uncompressed audio/image data) and MS priorities for 2.0 being elsewhere. But did you know that in 1.1a you couldn't even pass a stream to SetSource? (for images, at least) They solved that in 2.0 beta 1, thankfully. I think they will eventually provide the other huge missing piece (acceptance of uncompressed audio/image data) - it would be incredibly stupid not to. Stegman's PNG encoder is appreciated but really, it's not a long term solution by any stretch of the imagination. Unfortunately I get the feeling we're not going to see this get solved for 2.0.

    I suspect they might have decided to skip supporting WAV/BMP and instead offer some real APIs for dealing with uncompressed audio/image data. That seems like a much better solution in many ways but it's probably a more time consuming one to implement.
    # Tom on May 23, 2008
  • Yep, my guess is too that there's something in the works for imaging, but not for 2.0... although RenderTargertBitmap is already there, but internal... maybe they will add support for WritableBitmap or other WPF imaging APIs in the future.
    With audio I'm not so sure... there's no special audio API in WPF. I have the feeling it is totally under the radar. The nice thing is, that if there was support for WAV, we could build all the rest in managed code.
    # Florian Krüsch on May 23, 2008

Language | Sprache

All[e]  |  english  |  deutsch
Tags
 

Profile

Florian Kruesch

I am working as a freelance software architect, developer and consultant in Düsseldorf, Germany.

My focus is on Microsoft technologies and .NET 3.0, especially WPF, ASP.net and SQL Server.

I've been a lead programmer on the WPF development of the OTTO Vista Store at SinnerSchrader Studios.

My client list includes DHL, LG and Ogilvy Interactive.