News:

If you need instructions on how to get through the hotels, check out the enclosed instruction book.

Main Menu

Tomefoolery Spectrum [AS]

Farted by RomanClock, January 30, 2009, 01:34:23 AM

Previous topic - Next topic

0 Members and 0 Guests are viewing this topic.

RomanClock

So I tried out some AS3, in particular the spectrum analyzing functions and came up with this thing. The music is the tune from Tomato's tomfoolery thread.

Wait for load, 1.5MB
[FLASH]http://files.myfrogbag.com/bwdehj/spectrumTests2.swf width=360 height=300[/FLASH]

Edit: Thanks Snake for decompiling it
lemayo lol :soups:

buttplug

What exactly is the spectrum analyzing?

Fireman

Quote from: IceeClock;1510403What exactly is the spectrum analyzing?

lots of tomfoolery of course

SnakeClock

I've got a decompiler and CS3. Leave it to me.

FLOUNDERMAN_CLOCK

Captain the tomfoolery levels are off the scale! The ship can't take much more of this!

SnakeClock

Roman asked me to post the code for posterity:

   import flash.media.*;

package
{
    import flash.media.*;

    dynamic public class mySound extends Sound {

        public function mySound() {
            return;
        }
    }
}

   import flash.media.*;

package
{
    import flash.media.*;

    dynamic public class mySound1 extends Sound {

        public function mySound1() {
            return;
        }
    }
}

import flash.display.*;
    import flash.events.*;
    import flash.media.*;
    import flash.text.*;
    import flash.utils.*;

package spectrumTests2_fla
{
    import flash.display.*;
    import flash.events.*;
    import flash.media.*;
    import flash.text.*;
    import flash.utils.*;

    dynamic public class MainTimeline extends MovieClip {
        public var gr:Sprite;
        public var baq:ByteArray;
        public var song:SoundChannel;
        public var tran:SoundTransform;
        public var ba:ByteArray;
        public var timeq:Timer;
        public var iit:Number;
        public var s:mySound;
        public var time:Timer;
        public var wqq:TextField;
        public var wq:TextField;
        public var grq:Sprite;

        public function MainTimeline() {
            addFrameScript(0, frame1);
            return;
        }
        public function timerHandler(param1:TimerEvent) : void {
            var _loc_2:int;
            var _loc_3:Number;
            var _loc_4:uint;
            var _loc_5:Number;
            var _loc_6:Number;
            var _loc_7:Number;
            var _loc_8:Number;
            var _loc_9:Number;
            SoundMixer.computeSpectrum(ba, true, 0);
            _loc_3 = 0;
            gr.graphics.clear();
            gr.graphics.lineStyle(0, 16711680);
            gr.graphics.beginFill(16711680);
            gr.graphics.moveTo(0, 0);
            _loc_4 = 1;
            _loc_5 = 0;
            _loc_2 = 0;
            while (_loc_2 < 512){
                // label
                _loc_8 = ba.readFloat();
                if (_loc_2 < 64){
                    _loc_5 = _loc_5 + _loc_8;
                }
                _loc_9 = _loc_8 * 5;
                gr.graphics.drawCircle(Math.cos(_loc_2 / 512 / (180 / Math.PI) * 360) * 128, Math.sin(_loc_2 / 512 / (180 / Math.PI) * 360) * 128, _loc_9);
                _loc_3 = _loc_3 + _loc_8;
                _loc_2 = _loc_2 + _loc_4;
            }
            gr.rotation = gr.rotation - (_loc_3 + 0.5) / 25;
            _loc_6 = 0.3 + _loc_5 / 20;
            scaleX = scaleX + (_loc_6 - scaleX) / 10;
            scaleY = scaleX;
            _loc_7 = scaleY;
            x = -275 * _loc_7 + 275;
            y = -200 * _loc_7 + 200;
            x = Math.round(x);
            y = Math.round(y);
            return;
        }
        function frame1() {
            s = new mySound();
            song = s.play();
            song.addEventListener(Event.SOUND_COMPLETE, soundCompleteHandler);
            ba = new ByteArray();
            baq = new ByteArray();
            gr = new Sprite();
            gr.x = 275;
            gr.y = 200;
            addChild(gr);
            grq = new Sprite();
            grq.x = 275;
            grq.y = 200;
            addChild(grq);
            time = new Timer(0);
            time.addEventListener(TimerEvent.TIMER, timerHandler);
            time.start();
            tran = song.soundTransform;
            tran.volume = 2;
            song.soundTransform = tran;
            iit = 0;
            timeq = new Timer(0);
            timeq.addEventListener(TimerEvent.TIMER, timerHandlerq);
            timeq.start();
            return;
        }
        public function soundCompleteHandler(param1:Event) : void {
            var _loc_2:SoundChannel;
            _loc_2 = s.play();
            return;
        }
        public function completeHandlerq(param1:Event) : void {
            param1.target.play();
            return;
        }
        public function completeHandler(param1:Event) : void {
            param1.target.play();
            return;
        }
        public function timerHandlerq(param1:TimerEvent) : void {
            var _loc_2:Number;
            var _loc_3:uint;
            var _loc_4:Number;
            var _loc_5:Number;
            var _loc_6:Number;
            var _loc_7:Number;
            SoundMixer.computeSpectrum(baq, false, 0);
            grq.graphics.clear();
            grq.graphics.lineStyle(0, 255);
            grq.graphics.beginFill(255);
            grq.graphics.moveTo(0, 0);
            _loc_3 = 2;
            _loc_5 = 0;
            _loc_2 = 0;
            while (_loc_2 < 512){
                // label
                _loc_6 = 0;
                _loc_6 = _loc_6 + baq.readFloat();
                _loc_7 = _loc_6 * 50;
                grq.graphics.drawRect(_loc_2 / 2 - 128, 0, _loc_3 / 2, -_loc_7);
                if (_loc_2 > 256){
                    _loc_5 = _loc_5 + _loc_6;
                }
                _loc_2 = _loc_2 + _loc_3;
            }
            return;
        }
    }
}

RomanClock

The decompiler really makes the code look funny! Thats certainlly not how I program, but it looks like it has everything there! Thanks snake :D
lemayo lol :soups:

RomanClock

Btw, It would be a nice exercise for me to make more of these. If you have suggestions on how I should make the spectrum look, you should post them and I might try to make it. Or you could even provide graphics so like a dancing guy or something.
lemayo lol :soups:

GodClock

is there supposed to be an image? all i hear is a goofy song
Sw@g
Quote from: Kodiakclock;1893997godclock probably now that I think about it. We could bro it out he could learn me how to surf and then we cruise bro our way out of there into brosville

WiiClock

Quote from: GodClock;1510424is there supposed to be an image? all i hear is a goofy song

i think he changed it, there was a bouncy little wave thign that went to the music
HELLO EVERYONE.

RomanClock

Quote from: GodClock;1510424is there supposed to be an image? all i hear is a goofy song
Maybe upgrade flash player? Did you try to refresh?
Quote from: Joey;1510425i think he changed it, there was a bouncy little wave thign that went to the music

Naw, didn't change it.
lemayo lol :soups:

Topcatyo

Very cool spectrumizer.  I like the spinning red circle around the blue wavy thing.

Make a rainbowy spectrum of the song in my signature.  That'd be neat :D
Or Smell Yo Dick.

SockpuppetClock

It's nice and all, but will you ever teach/explain how you do these things, or will you leave those who are willing to learn in the dark while you extend to heights unimaginable?

Sombra

Quote from: RomanClock;1510423Btw, It would be a nice exercise for me to make more of these. If you have suggestions on how I should make the spectrum look, you should post them and I might try to make it. Or you could even provide graphics so like a dancing guy or something.

How about an eyeball, like the pupil pulses based on volume and like blood veins and shit pulse based on trebble/bass.

Maybe even have something corresponding with a change of iris color.

zl

Quote from: SockpuppetClock;1510475It's nice and all, but will you ever teach/explain how you do these things, or will you leave those who are willing to learn in the dark while you extend to heights unimaginable?

yeah, bring back the actionscript academy!!

RomanClock

Quote from: SockpuppetClock;1510475It's nice and all, but will you ever teach/explain how you do these things, or will you leave those who are willing to learn in the dark while you extend to heights unimaginable?

Well, seeing this is almost the only thing I know in AS3, I shouldn't suppose I know enough to teach it that well...
But yea, I should do an ASA, though I was disappointed in the turnout last time, and that was about sound management in AS3 (loading sound form the library, play/stop/pause, position slider, volume slider, pan slider) which is what I thought people would be interested in. It would also be difficult for me to get into more advanced types of AS since most clocks still have trouble on some of the easier aspects.
Maybe suggest a good topic to talk about?
lemayo lol :soups:

Thor

Quote from: MafiaMettaurWhat the hell is with that shit you posted? You know what, I'm joining the Locks, just to stop stuff like you!
Quote from: polyhedronclockYou're a fucking clock, what else do you have?
To be fair, you don't have anything. Clocks are just machines that tick.

RomanClock

Oh and sock puppet, if you want to learn more about AS you can just get on AIM and ask too. That's probably the best way.
lemayo lol :soups:

EnglishClock

[SIGPIC][/SIGPIC]

The Spoiler

It would be neat if you tried making some other effects with it. Maybe instead of having the spectrum thing in a line, you could make it into a ring with polar coordinates.If you did that and had it change the color constantly, and only clear the graphics every couple of seconds, It would probably look cool. I don't know how fast it would run, though.