Clock Crew

Community => General Discussion => Topic farted by: RomanClock on January 30, 2009, 01:34:23 AM

Title: Tomefoolery Spectrum [AS]
Post by: RomanClock on January 30, 2009, 01:34:23 AM
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
Title: Tomefoolery Spectrum [AS]
Post by: buttplug on January 30, 2009, 01:36:49 AM
What exactly is the spectrum analyzing?
Title: Tomefoolery Spectrum [AS]
Post by: Fireman on January 30, 2009, 01:38:07 AM
Quote from: IceeClock;1510403What exactly is the spectrum analyzing?

lots of tomfoolery of course
Title: Tomefoolery Spectrum [AS]
Post by: SnakeClock on January 30, 2009, 01:40:14 AM
I've got a decompiler and CS3. Leave it to me.
Title: Tomefoolery Spectrum [AS]
Post by: FLOUNDERMAN_CLOCK on January 30, 2009, 01:45:35 AM
Captain the tomfoolery levels are off the scale! The ship can't take much more of this!
Title: Tomefoolery Spectrum [AS]
Post by: SnakeClock on January 30, 2009, 01:55:36 AM
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;
        }
    }
}
Title: Tomefoolery Spectrum [AS]
Post by: RomanClock on January 30, 2009, 02:00:33 AM
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
Title: Tomefoolery Spectrum [AS]
Post by: RomanClock on January 30, 2009, 02:12:27 AM
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.
Title: Tomefoolery Spectrum [AS]
Post by: GodClock on January 30, 2009, 02:27:51 AM
is there supposed to be an image? all i hear is a goofy song
Title: Tomefoolery Spectrum [AS]
Post by: WiiClock on January 30, 2009, 02:30:02 AM
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
Title: Tomefoolery Spectrum [AS]
Post by: RomanClock on January 30, 2009, 02:59:22 AM
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.
Title: Tomefoolery Spectrum [AS]
Post by: Topcatyo on January 30, 2009, 06:27:43 AM
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.
Title: Tomefoolery Spectrum [AS]
Post by: SockpuppetClock on January 30, 2009, 09:40:35 AM
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?
Title: Tomefoolery Spectrum [AS]
Post by: Sombra on January 30, 2009, 09:45:17 AM
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.
Title: Tomefoolery Spectrum [AS]
Post by: zl on January 30, 2009, 10:06:59 AM
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!!
Title: Tomefoolery Spectrum [AS]
Post by: RomanClock on January 30, 2009, 03:21:14 PM
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?
Title: Tomefoolery Spectrum [AS]
Post by: Thor on January 30, 2009, 03:24:27 PM
(https://clockcrew.net/talk/proxy.php?request=http%3A%2F%2Fimg.dailymail.co.uk%2Fi%2Fpix%2F2007%2F08_04%2FCurlBeardMOS0109_468x387.jpg&hash=3fd450d12d03219b2e8a4dcaf3aefca573647d3e)
Title: Tomefoolery Spectrum [AS]
Post by: RomanClock on January 30, 2009, 03:25:43 PM
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.
Title: Tomefoolery Spectrum [AS]
Post by: EnglishClock on January 30, 2009, 03:50:24 PM
(https://clockcrew.net/talk/proxy.php?request=http%3A%2F%2Fmypetjawa.mu.nu%2Farchives%2Fhidininbeard.jpg&hash=70d9e302f1f2720f4d2669958aa68c8ff7a42e99)
Title: Tomefoolery Spectrum [AS]
Post by: The Spoiler on January 30, 2009, 04:36:08 PM
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.
Title: Tomefoolery Spectrum [AS]
Post by: Fire Extinguisher Clock on January 30, 2009, 09:19:02 PM
Oh boy! Tomfoolery spectrums are what all true warriors strive for!!