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?
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();
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With