views:

460

answers:

4

Hi, is it at all possible to generate sound on-the-fly in a Silverlight app and play it? I.e. if I want to play a sine-wave, can I generate a buffer and feed it to some media API?

Cheers

Nik

+1  A: 

looks like you're in luck...

http://blogs.msdn.com/gillesk/archive/2009/03/23/playing-back-wave-files-in-silverlight.aspx

http://code.msdn.microsoft.com/wavmss/Release/ProjectReleases.aspx?ReleaseId=2417

you should be able to hack this around a bit to synthesize

spender
Thanks for the link. :-) Seems the timing of the question was great indeed. :-) So in short, generate a Stream and use WaveMediaStreamSource to play the stream?
niklassaers
+1  A: 

Pete Brown already has a working prototype: http://community.irritatedvowel.com/blogs/pete_browns_blog/archive/2009/03/23/Creating-Sound-using-MediaStreamSource-in-Silverlight-3-Beta.aspx

Mark Heath
Splendid, that's a fantastic example, including source code! Wow! :-)
niklassaers
That worked great, using his code was nice and easy.
niklassaers
A: 

Charles Petzold has the best example out there: http://www.charlespetzold.com/blog/2009/07/Simple-Electronic-Music-Sequencer-for-Silverlight.html

Mike Hodnick
A: 

You can also look at this sample created by Archetype:

Michael S. Scherotter