In case Flash no longer exists; a copy of this site is included in the Flashpoint archive's "ultimate" collection.

Dead Code Preservation :: Archived AS3 works from wonderfl.net

computeSpectrum

On my computer, you can call computeSpectrum to access the sound playing from other Flash movies.

Try leaving this open and watching a video on youtube or listening to grooveshark.

Sometimes the call to computeSpectrum throws a security exception as expected, but often it returns successfully.

I've also made a DTMF detector sort of thing.

Try going here and pressing some buttons.
http://www.mediacollege.com/audio/tone/dtmf.html
or watching this video
http://www.youtube.com/watch?v=KThZF8yfZrE

I'm using:
Windows 7
player version WIN 11,1,102,55
Firefox 10.0.1

Maybe this won't work for you.
Get Adobe Flash player
by wh0 12 Feb 2012

    Talk

    Hasufel at 12 Feb 2012 18:34
    That's scary. I thought browsing per tab was private/sandboxed? Works like a charm for me, Mac OS X, ff 10.0.1. So any website could theorically follow the sound of your browsing...

    Tags

    Embed
/**
 * Copyright wh0 ( http://wonderfl.net/user/wh0 )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/lV7u
 */

package {
    import flash.display.*;
    import flash.events.*;
    import flash.media.*;
    import flash.utils.*;
    public class FlashTest extends Sprite {
        
        // adjusted after experimental results
        private static const freq_low:Array = [16, 18, 20, 22];
        private static const freq_high:Array = [27, 30, 34];
        
        private var player:Object;
        private var ba:ByteArray;
        
        public function FlashTest() {
            stage.scaleMode = StageScaleMode.EXACT_FIT;
            ba = new ByteArray();
            addEventListener(Event.ENTER_FRAME, frame);
            stage.frameRate = 60;
        }
        
        private static function i2x(index:int):Number {
           return index * 465. / 256;
        }
        
        private function readSingle(index:int, _:int=0, __:Array=null):Number {
            ba.position = index * 4;
            return ba.readFloat();
        }
        
        private function frame(e:Event):void {
            try { SoundMixer.computeSpectrum(ba, true, 0); } catch (e:Error) { return; }
            graphics.clear();
            graphics.beginFill(0x000000);
            graphics.moveTo(0, 465);
            ba.position = 0;
            for (var i:int = 0; i < 256; i++) {
                graphics.lineTo(i2x(i), 465 - 465 * ba.readFloat());
            }
            graphics.lineTo(465, 465);
            graphics.endFill();
            graphics.lineStyle(0, 0xff0000, 0.5);
            for each (var fl:int in freq_low) {
                graphics.moveTo(i2x(fl), 0);
                graphics.lineTo(i2x(fl), 465);
            }
            graphics.lineStyle(0, 0x00ffff, 0.5);
            for each (var fh:int in freq_high) {
                graphics.moveTo(i2x(fh), 0);
                graphics.lineTo(i2x(fh), 465);
            }
            var low:Array = freq_low.map(readSingle);
            var high:Array = freq_high.map(readSingle);
            graphics.lineStyle(0, 0x000000);
            for (var il:int = 0; il < 4; il++) {
                for (var ih:int = 0; ih < 3; ih++) {
                    var alpha:Number = low[il] * high[ih];
                    graphics.beginFill(0xff00ff, alpha);
                    graphics.drawRect(30 * ih + 100, 30 * il, 30, 30);
                    graphics.endFill();
                }
            }
            graphics.lineStyle(NaN);
        }
        
    }
}