Category Archive: Library

ActionScript3/Flash10 software synthesizer SiON released

SiON title

Hello all, I’m kei mesuda aka keim japanese free-game home brewer.

I just release completely new software synthesizer named “SiON” (pronounced as “scion”), so let me introduce my work.

The SiON library works on ActionScript3/Flash10. This provides a simple sound synchronization with DisplayObject and an easy dynamic sound generation. You can generate various sounds without any mp3 files and wave data. The musical sequence is represented as simple text data “Music Macro Language”. It makes your sounding SWF file very very small.

This library’s development center is here in spark project. You can get newest version’s swc file, asdoc and svn link.


- Demonstrations

You can use SiON in Wonderfl and I posted some demonstrations.

Other works using SiON are shown in tag [SiON] in Wonderfl. I plan to post some other works with SiON at wonderfl, please check my page if you want more.

And this is another demonstration for SiON. The MMLTalks is an MML hosting service powered by SiON. Here, you can listen many musics generated only by SiON software synthsizer without any mp3 files and wave data.


- Synthesizer specifications

The SiON software synthesizer is an extention of the sound chip YM2151s emulator. Currently, SiON includes 4 types of sound modules.

    • Extended Emulators of various Frequency Modulation synthesizing sound chips; The emulation code is based on the time-proven emulators, MAME, fmgen and x68sound.dll. And the outputs of various sound chips (OPM,OPNA,OPL3,OPX,MA3) are reproducible by giving same parameters of actual equipments.
      • Simulator of PSG and wave memory sound chips; The SiONs Extended FM synth can simulate various PSG chips (AY-3-8910, DCSG, 2A03, SSG) and wave memory sound chips(SCC, C15, GameBoy).
        • Physical Modeling Guitar synthesizer; SiON also includes Guitar Physical modeling synthesizer based on Karplus strong algorism.
          • PCM sound module; The SiON handles MP3 sound (Sound Class) as a PCM sound modules source wave. This means you can control the pitch of MP3 file by musical sequence.

            The SiON can modify the output from these sound modules by low-pass filter with ADSR envelop, ring modulation, pitch/amplitude modulation.


            - Sequencer specifications

            The SiON uses Music Macro Language (MML) as a musical score data. The MML is a simple powerful language to represent musical sequence. For example, “[ccggaag2 ffeeddc2 | [ggffeed2]]” represents “the ABC song” in MML. The reference manual is here, mml editor here, and you can refer MMLs of various great musics here in MMLTalks (and click rightmost button in song title).


            - Effector specifications

            SiON includes many sound effectors like reverb, chorus, delay, wave shaper, various filters, speaker simulator and so on. These effectors can be control from MML. Please see the discriptions in the MML reference manual.

            Now detail discription is under construction, please check my blog or development center. And if you have any questions or comments, please leave comment on this post or contact me by e-mail (but sorry for my poor English..).

            Sequencer specification.
            SiON uses Music Macro Language (MML) as a musical score data. The MML is a simple powerful language to represent musical sequence. For example, “[ccggaag2 ffeeddc2 | [ggffeed2]]” represents “the ABC song” in MML. Reference manual <a href=”http://mmltalks.appspot.com/document/siopm_mml_ref_05.html”>here</a> and you can try to play mml <a href=”http://mmltalks.appspot.com/labo/mmleditor.html”>here</a>.
            This site <a href=”http://mmltalks.appspot.com/”>MMLTalks</a> is the MML hosting service powered by SiON, you can refer many MMLs to represent grate musics.

            BetweenAS3 Alpha r3022 now available

            BetweenAS3, fast, powerful and professional new tweening engine I’m developing (please see this page or this page), is still under development… But today, I announce “Alpha r3022″ version for early betweeners! :)

            I don’t give assurance about quality, but many main features may works well. Please test and send feedback (bug report, request, etc) to me.

            You can checkout BetweenAS3 Alpha r3022 via SVN from:

            or download as ZIP or SWC from:

            Did you find text “fp9″ in filename? There is good news. FlashPlayer9 version also available!!

            Yesterday, version of BetweenAS3 in Wonderfl is r2505, but today, it was updated to r3022. You can enjoy new version in Wonderfl!! You can find BetweenAS3 samples in this “BetweenAS3Tutorial” tag page.

            Changes from r2505 to r3022 is the following:

             * [r3021] Created FlashPlayer9 version based on r3019.
             * [r3018] Fix: Error occurred when stopping or playing tween in event handlers.
             * [r3017] Added property for frame tween (_frame) and utility for convert frames and time (TimeUtil).
             * [r3016] Added ITween.togglePause
             * [r3009] [r3010] Supported physical tween. (BetweenAS3.physical)
             * [r3007] Added shortcuts for BetweenAS3.tween and BetweenAS3.bezier
              * BetweenAS3.to
              * BetweenAS3.from
              * BetweenAS3.bezierTo
              * BetweenAS3.bezierFrom
             * [r3005] Fix: Function specified in BetweenAS3.func will be called many times.
             * [r2998] Supported bezier tween. (BetweenAS3.bezier)
             * [r2996] Supported parallel and serial by passing Array parameter. (BetweenAS3.parallelTweens, BetweenAS3.serialTweens)
             * Changed internal architecture and package.
              * Supported inheriting event handlers when processing tweens by this change.
              * [r2994] Created IUpdater interface.
              * [r2694] Renamed BetweenEvent class to TweenEvent.
              * [r2692] Moved ITicker interface and TickerListener class to Core package.
              * [r2688] Created Core package.
              * [r2688] Removed ITweenTarget interface, integrated it to ITween interface and created IObjectTween interface.
              * [r2688] Created ITweenContainer (now ITweenGroup) interface.
             * [r2618] Moved a delay setting to the BetweenAS3.delay method for more flexibility.
             * [r2617] Changed the timing of calculating tween parameters to the first time of start playing the tween.
                Now sequence of tween using related value works fine.
                 BetweenAS3.serial(
                   BetweenAS3.tween(mc, {$x: 100}),
                   BetweenAS3.tween(mc, {$x: 100})
                 );
             * [r2600] Fix: Sometimes ReferenceError has occured while creating a tween.

            Here is FAQ:

             Q. How to do filter tween?
             A. Do the following:
            
                 BetweenAS3.tween{mc, {_glowFilter: {blurX: 32, blurY: 32}}).play();
            
                The following properties for filter are supported.
            
                 * _bevelFilter
                 * _blurFilter
                 * _colorMatrixFilter
                 * _convolutionFilter
                 * _displacementMapFilter
                 * _dropShadowFilter
                 * _glowFilter
                 * _gradientBevelFilter
                 * _gradientGlowFilter
                 * _shaderFilter
            
             Q. How to do ColorTransform tween?
             A. Do the following:
            
                 BetweenAS3.tween(mc, {transfrom: {colorTransfrom: {redOffset: 255}}}).play();
            
             Q. How to do SoundTransform tween?
             A. Do the following:
            
                 BetweenAS3.tween(sc, {soundTransform: {volume: 0.0}}).play();
            
             Q. How to set delay?
             A. By using BetweenAS3.delay, add delay to tween.
            
                 BetweenAS3.delay(BetweenAS3.tween(mc, {x: 100}), 1.0).play(); // Delay 1.0 sec
            
             Q. How to do bezier tween?
             A. Do the following. Pass control points in argument 4. Set Array of control points for each property.
            
                 BetweenAS3.bezier(mc, {x: 385, y: 207}, null, {x: [58.05, 145.9, 246.7, 345.55], y: [61.4, 80.65, 167.05, 209.3]}).play();
            

            BeatTimer: Synchronize with the beat

            In the previous my entry, I introduced the dotFes Clock. I used some tricks to synchronize with the BGM strictly in it. One is a BeatTimer.

            It is a timer to synchronize with the beat. If you create an instance of the BeatTimer and call the start method with a tempo by BPM, it starts time counting since the current time.

            var timer:BeatTimer = new BeatTimer();
            timer.start(140);
            

            And it updates some properties based on the time lapsed since the time of the timer has started if you call the update method.

            timer.update();
            

            Then, you can get some useful values.

            • beatPosition: Indicates how many beats have been passed. For example, when three quarter notes and an eighth note are passed, the property returns 3.5.
            • phase: Indicates a position on the beat. If the new beat started, it indicates 0.0 and if the beat finished, it indicates 1.0.
            • isOnBeat: Indicates whether it has been in the new beat by the update method call this time.

            For example, you can trace a message with 4 beat kicks by the following code:

            if (timer.isOnBeat) {
                trace('Kick!');
            }
            

            In the dotFes Clock, I used it to change motion parameters synchronizing the rhythm. :)

            Introduction of QR Code Reader Library

            For people who want to use QR Codes within the Flash environment, LOGOSWARE (the company I work for) has released a QR Code Reader into the Spark Project.

            It is essentially a library that recognizes and decodes any QR Code from any image source.

            Click here to read more »

            ASReflect: Java like reflection in AS3

            flash.utils.describeType is an only way to do reflection in AS3 but it’s annoying to work with XML! So I created a library called ASReflect to manipulate the result of describeType more instinctively. ASReflect has some Java like reflection classes.

            The following is an example. If you have a class MyClass like:

            package
            {
                public class MyClass
                {
                    public var a:String;
                    public var b:Number;
            
                    public function func():void
                    {
                    }
            
                    public function add(arg1:int, arg2:int):int
                    {
                        return arg1 + arg2;
                    }
                }
            }
            

            You can get type information as an instance of Type class by ASReflect.getType method.

            var type:Type = ASReflect.getType(MyClass);
            

            Then, for example, you can output "class name", "property name and type" and "method name, parameter count and return type" by the following code:

            trace('ClassName:', type.name);
            trace('Properties:');
            for each (var prop:Property in type.properties) {
                trace(' ' + prop.name, prop.type);
            }
            trace('Methods:');
            for each (var method:Method in type.methods) {
                trace(' ' + method.name, method.parameters.length, method.returnType);
            }
            

            Output of above code:


            ClassName: MyClass
            Properties:
             a [class String]
             b [class Number]
             length [class int]
            Methods:
             add 2 [class int]
             func 0 null

            There is ASDoc only in Japanese (sorry...), but I think you can guess what does property or method provide by its name. Please ask me if you have any question.

            Source was committed to the Spark project. And also you can get a SWC package or a source code archive.

            LCDBitmap: A class version of Saburin’s LCD effect

            LCDBitmap

            The previous Saburin’s post is very impressive for me. But his code is a little difficult to use in my projects. :(

            So, I created a class LCDBitmap based on his code to use a great effect more handily. :D You can use it like:

            addChild(new LCDBitmap(bitmapData));
            

            A bitmapData is an instance of BitmapData you want to display. You can get same result by this simple code. In addition, you can customize a size or a margin of tiles displaying the RGB by passing 2nd or 3rd parameter.

            addChild(new LCDBitmap(bitmapData, 4, 2));
            

            In this case, the size is 4px and the margin is 2px.

            Source was committed to the Spark project. And a Quick Demo was posted to the Wonderfl. Please check it out!

            ForcibleLoader: Loads AVM1 SWF files into AVM2

            By default, Flash Player loads a movie as an instance of the AVM1Movie class if you load a SWF file with a version lower than 9 by the Loader class in AS3. This means you can’t touch any MovieClips in the such SWF file through the Loader. But sometimes we want to do it. I created a solution to this problem – ForcibleLoader

            var loader:Loader = Loader(addChild(new Loader()));
            var fLoader:ForcibleLoader = new ForcibleLoader(loader);
            fLoader.load(new URLRequest('swf7.swf'));
            

            This is how to use it. It loads every SWF file including files under version 9 into the Loader as a AVM2 movie. So now you can access MovieClips in the SWF file through the instance of Loader.

            Note: It will not work well if the SWF file contains ActionScript2 because ForcibleLoader doesn't convert any scripts.

            WP-Al-SWFObject was launched.

            For Flash users all over the world, I made a powerful plug-in for embedding swf on WordPress. If this plug-in is installed, swf with more detailed parameters can be displayed more easily.

            - Download
            WP-Al-SWFObject v2.0

            - How to use
            Describe the following codes at the position in which you want to embed swf.

            [embedSWF]swf, width, height, align, version, expressInstall, flashvars, params, attributes[ /embedSWF]

            Some parameters can be omitted. For example,

            [embedSWF]hoge.swf[/embedSWF]
            [embedSWF]hoge.swf, 200, 100[/embedSWF]
            [embedSWF]hoge.swf, 200, 100, right,,,{aaa:"10"}[/embedSWF]
            [embedSWF]hoge.swf, 200, 100,,,,{},{},{id:"sample", name:"sample"}[/embedSWF]
            [embedSWF]hoge.swf, 400, 360, center, 9.0.0, http://hogehoge.jp/alt.swf, {aaa:"10"}, {menu:"false", allowScriptAccess:"always"}, {id:"sample", name:"sample"}[/embedSWF]

            - Control panel
            In addition, the default value of each parameter can be set from the plug-in Control panel easily.
            The default value is applied to all swf embedded by WP-Al-SWFObject.

            - More Information
            http://blog.alumican.net/2009/05/18_005204

            This plug-in has been updated on Spark Project.

            Thanks. :-)

            1 min. Introduction of Spark project

            Spark project

            One thing I must introduce to you is the Spark project, because I founded it.

            Be happy by sharing source code and knowhow with everyone!

            …this is the slogan of the Spark project.

            The Spark project is an open source community for the Flash/ActionScript developers. It is the biggest Flash community in Japan. There are over 200 committers are joining and over 130 projects, classes and libraries were committed.

            One big project you may already know… is the FLARToolKit committed by Saqoosha, of course, one of the JActionScripters. FLARToolKit is an AS3 version of ARToolKit. I guess Saqoosha will introduce this in more detail.

            There are many other libraries committed by members of the JActionScripters including me. I hope they will introduce thier work in future posts. Of course, I’ll introduce my projects in the near future.

            You can find more information at website. Our SVN repository is here. Everyone can checkout all files committed in the repository. If you’d like to add new code, modify existing code, create branch and so on, please become a comitter. We always welcome to new comitters! ;)

            This is a short description of the Spark project. I’ll tell you more detail in the future posts. Thanks!