views:

845

answers:

4

I'm looking into making a music theory lab application, where you can see the graphical relation between music theory concepts. I would like this to be available online, so Flash and Silverlight come to mind.

But I would like to dynamically generate tones and chords etc from user input. This is something I know is a very underdeveloped area in the Flash Player. So my question is what is the current state of features for dynamic audio generation on both the Flash and Silverlight players?

A: 

There are ways to do it which involves a fair bit of hacking. I don't remember the exact mechanics, but you could have a look at (or use) existing streaming libraries like StandingWave: http://code.google.com/p/standingwave/ or the stuff at Popforge: http://code.google.com/p/popforge/

It can hopefully give more information than I can right here. :)

Dentoid
@Dentoid Thanks for the links I'll give them a look and see what they can do for me
Brian Heylin
+1  A: 

From Flash Player 10 and onwards you don't need to do any hacky type stuff. There is an API to generate sound dynamically.

This blog post has a quick introduction. His code reads samples from an mp3 but you can write samples any way you want to.

As always the docs have lots of info too, along with this code sample which should get you going pretty quickly.

var mySound:Sound = new Sound();
function sineWaveGenerator(event:SampleDataEvent):void {
    for ( var c:int=0; c<8192; c++ ) {
        event.data.writeFloat(Math.sin((Number(c+event.position)/Math.PI/2))*0.25);
        event.data.writeFloat(Math.sin((Number(c+event.position)/Math.PI/2))*0.25);
    }
}

mySound.addEventListener(SampleDataEvent.SAMPLE_DATA,sineWaveGenerator);
mySound.play();
grapefrukt
You can also find a lot of interesting source codes and samples at http://lab.andre-michelle.com/
speps
A: 

You may try out The Synthesis ToolKit in AS3 which is ported from C++ by me :)

It's different from standingwave and popforge, STK in AS3 provides real-life instruments like flute and clarinet for you to use which the first two don't.

Andy Li
A: 

So it seems that out of Silverlight and Flash, that Flash beats Silverlight on dynamic audio generation features, (which surprised me considering how basic audio support is in Flash). It seems Silverlight cannot generate dynamic audio at all, and Flash can only do so officially since version 10 of the player.

I can find very little information on the future of dynamic audio on both platforms, but Flash has the most active discussions at the moment.

Brian Heylin