I miss writing classes w/ 50 or so lines of code and here is one. This is a take off of Lee Brimelow's Example of Dynamic Sound Generation. I'm using the BitmapData to create a tone.
Actionscript:
-
package
-
{
-
import flash.display.*;
-
import flash.events.*;
-
import flash.media.*;
-
import flash.net.URLRequest;
-
import flash.system.Capabilities;
-
import flash.text.TextField;
-
-
public class DynamicSound extends Sprite
-
{
-
private var sound:Sound;
-
private var noise:Number = 0;
-
private var _loader:Loader;
-
private var _bm:Bitmap;
-
private var _verText:TextField;
-
public function DynamicSound():void
-
{
-
stage.align = StageAlign.TOP_LEFT;
-
stage.scaleMode = StageScaleMode.NO_SCALE;
-
_verText = new TextField();
-
_verText.text = Capabilities.playerType + " (" + Capabilities.version + ")";
-
_loader = new Loader();
-
_loader.contentLoaderInfo.addEventListener(Event.COMPLETE, onComplete, false, 0, true);
-
_loader.load(new URLRequest("http://www.scarlet.nl/~ivo/photo_ASTRO3.JPEG"));
-
-
}
-
-
private function onComplete(evt:Event):void
-
{
-
_bm = Bitmap(_loader.content);
-
addChild(_bm);
-
addChild(_verText);
-
sound = new Sound();
-
sound.addEventListener(Event.SAMPLES_CALLBACK, onCallback);
-
sound.play();
-
}
-
private function onCallback(e:SamplesCallbackEvent):void
-
{
-
for(var i:uint=0; i<512; i++)
-
{
-
noise += _bm.bitmapData.getPixel(mouseX, mouseY)/ 44100;
-
var sample:Number = noise * Math.PI * 2;
-
sound.samplesCallbackData.writeFloat(Math.sin(sample));
-
-
sound.samplesCallbackData.writeFloat(Math.sin(sample));
-
}
-
}
-
}
-
}
Quick and Dirty!
Last 5 posts in actionscript
- Using Flash Player 10 to produce Dynamic Musical Notes - May 20th, 2008
- How to compile and examples for Flash Player 10 or ASTRO BETA - May 16th, 2008
- How to use Bitmap and BitmapData in ActionScript 3 - v2 - April 23rd, 2008
- How to use Bitmap and BitmapData in ActionScript 3 - v1 - April 21st, 2008
- How to add and remove Mediators in a actionscript-3 puremvc app - March 30th, 2008
Last 5 posts in as3
- Using Flash Player 10 to produce Dynamic Musical Notes - May 20th, 2008
- How to load Pixel Bender in Flash Player 10 - May 19th, 2008
- How to compile and examples for Flash Player 10 or ASTRO BETA - May 16th, 2008
- How to use Bitmap and BitmapData in ActionScript 3 - v3 - April 29th, 2008
- How to use Bitmap and BitmapData in ActionScript 3 - v2 - April 23rd, 2008
Last 5 posts in Bitmap/BitmapData
- How to use Bitmap and BitmapData in ActionScript 3 - v3 - April 29th, 2008
- How to use Bitmap and BitmapData in ActionScript 3 - v2 - April 23rd, 2008
- How to use Bitmap and BitmapData in ActionScript 3 - v1 - April 21st, 2008
Last 5 posts in flash
- Using Flash Player 10 to produce Dynamic Musical Notes - May 20th, 2008
- How to load Pixel Bender in Flash Player 10 - May 19th, 2008
- How to compile and examples for Flash Player 10 or ASTRO BETA - May 16th, 2008
- How to use Bitmap and BitmapData in ActionScript 3 - v3 - April 29th, 2008
- How to use Bitmap and BitmapData in ActionScript 3 - v2 - April 23rd, 2008
Josh Weatherspoon, A self-proclaimed millionaire who for some reason has to work as a Flash Developer, at Travelocity in Dallas(Southlake), TX.


1 person has left a comment
Thats something cool indeed. Gonna try it. Let me know if you gonna have anything else sound-related.
Cheers,
Evi.