views:

93

answers:

2

I just came across a Nintendo emulator written entirely in JavaScript on the interwebs, but it doesn't have sound. It got me thinking: Is there any way to synthesize sound in the browser using JavaScript and then play it? If it's not possible in general, then are there any Safari/Opera/FireFox/IE/Etc. extensions that would make it possible?

I am not asking about techniques for synthesizing sound, just techniques for playing sounds that have been synthesized by code running in the browser.

+3  A: 

I would imagine your best bet is to have Javascript talk to Flash using ExternalInterface (http://www.adobe.com/devnet/flash/articles/external%5Finterface.html). Flash now has a way of transfering data between the sound buffers and a general purpose ByteArray classs.

http://www.adobe.com/devnet/flash/articles/dynamic%5Fsound%5Fgeneration/

You can develop Flash for free using the Flex SDK http://www.adobe.com/products/flex/.

Jotham
+2  A: 

Most developers use SoundManager 2 when they want to add sound to their application with JavaScript. It has hooks so JavaScript can interact with Flash 8 and 9 features. I am not sure if it has exposed the ability to work with Byte Data which I guess you are after, I never had to deal with that.

epascarello