AS3 computeSpectrum and FFT not working?

I was very excited to notice that you now with AS3 can retrieve amplitude and spectrum information. I been hoping for this for a long time, and now it's there :)
Problem is that it doesn't seem to work properly.

I looked at the example on www.richapps.de and tried it out.
The problem is that accessing the values of the byteArray with normal array access brackets will not give the correct values.
It will return the byte value, ie a value between 0 and 256. According to the documentation for AS3 the computeSpectrum should return a decimal value between -1.0 and 1.0.
So since the length of the byte array is 2048 and the number of values should be 2x256 the values is stored as a single-precision 32-bit value.
So that gives that each value should be stored in 4 bytes and that readFloat would be the appropriate method to retrieve the values.
So my code to read the array for the right channel looks like this:

while(i>1024){
   spectrum.position=i;
      sprites_array[Math.round(i/4)].scaleY=(spectrum.readFloat()*100);
   i=i+4;
}

That works fine when FFTMode is false.
It will display the raw wave as you can see in this example.
(requires flash player 8.5, click to start sound).

But what you usually want to do to display a spectrum is to use FTT.
That will analyse the wave and actually make it into spectral information.
So, I try with just setting FFTMode to true....but no luck :(
Here is the swf with FFT applied.
As you can see there is no spectral information. With a sine sweep like this what you should see is a thin spike travelling from right to left.

Am I doing it completely wrong, or is indeed the FFTMode not working as it should?
Someone managed to get it to display a proper spectrum graph yet, and if so how?

RIA wars

Here we go again.
What is the future dominant platform of RIA development?
The latest discussion that triggered me to reflect on the issue again is over at ajaxinfo.com

Actually I find discussions like this quite interesting and don't mind dissecting the pros and cons. I guess I just like a good argument :)
But I'm also aware of that it is impossible to judge what is the most suitable technology to use without knowing what the goals of the project is, and most of all, who's going to develop it.

The article by Alexei White on ajaxinfo does seem to reach a similar conclusion in a way. The major drawback with Flash according to the author is that it's hard to find developers skilled with the technology.
I do find the evaluation questionable though.
Sure there is more developers specializing in HTML and JS than ones specializing in actionscript.
But that doesn't mean that the HTML/JS developers usually can put together a complex RIA using their existing knowledge. To get it all to work together in a way that give reliable results seems to be a skill in it's own right.
That the developers have the "basic skill set necessary for interacting with components" for working with AJAX is not of much value if they don't have the full skill set needed to get the job done.
They could hopefully acquire it, but they could also learn a new language.
I would not think it's actually hard for someone already skilled in JS, Java and PHP to learn actionscript, and for sure Flex or Laszlo with their XML based markup can be worth the effort to learn if you want to be working with RIA development.

Sure finding a technology that matches the skill set available is beneficial, but I would say that there has to be a balance.
So you also have to consider finding developers that is capable of handling the technologies best suited for realising the goals.
What is the most efficient balance has to be carefully evaluated.
With large companies you of course have an inertia due to having invested in certain technologies and they can't sack their whole IT team every time a new and better technology come along, so hence there will be a large dose of conservatism involved.
And that's I think a big reason why AJAX is getting all the hype it has at the moment. To me it does seem like an attempt to squeeze the last drops out of a heavily invested skill set, financially by companies and intellectually by developers.

There is often much talk about all the variables one have to consider in the choice of technology. And sure many of them can be valid in very specific circumstances, but usually there is few variables that really matters and would outweigh any other benefits or disadvantages. And evaluating them properly can be hard enough without adding more to the equation.

From the perspective of the customer it's mainly two variables:

  • How much will it cost to develop?
  • How successful will it be at achieving it's goals?
  • From the developers perspective it's more of a conflict:

  • How efficient are the technologies compared to each other in achieving the objectives of the project?
  • How comfortable do i feel using one technology over the other?
  • How long can I go on what I feel comfortable with and still stay in business?
  • The user should of course not have to reflect on the technology and one has to presume all that matters is the result they are presented with and that they can get to it.

    The arguments often brought in to the discussion about Flash and FLEX being proprietary tends to be very superficial to me.
    Especially considering that the swf format is open.
    Alexei White mentions in his summary that Flash "suffer from the Vendor lock-in problem".
    I actually have problems understanding in what way it might been a problem for any project. Sure i prefer to support an open standard and open-source software based on my sentiments.
    But if we look at the standards based formats like HTML, CSS and SVG there is a lot of real problems that will have very immediate effects on any project involving such technologies.
    The "vendor lock-in problem" certainly pales in comparison to the problem of getting web standards to be standardised.

    Back button, Bookmarking and Deeplinking

    I've done a little update to my system for enabling the back button and providing deep linking/bookmarking functionality for Flash sites and applications.
    It's now using Macromedias JS integration kit for Flash to JS communication.

    Click here to download it.

    Try the system here.

    I was hoping I would solve issues with some browsers that it was not working with previously, but since there is more issues than if the browser supports the setVariable command to pass data from JS to Flash it seems like it will be very difficult to get a few browser/OS combinations to work.

    Basically I found two different methods of approach.

    One is using Rober Penners hidden frame method.
    That's still what the system does for IE, but using an iFrame instead instead of a regular frame set and removing the need to create actual HTML files to load into the frame by using document.write().
    With FF I did not have much luck with that approach.
    Just using JS to write into the hidden frame worked fine and made the back button work, but when trying to also update the hash to enable the bookmarking everything started going wrong.

    The other approach is to at regular intervals check the location.hash and if it's been updated cause a change of state in Flash.

    Both approaches have various problems on different browsers.
    For example Safari apparently will not record a history event when you use document.write() to update an iFrame.
    Opera 8 will not record a history event if you update the hash, and after experimenting a bit with writing into the iFrame I gave up on getting it to work with that method.

    It would be great with a system that works for every perceivable browser and OS, but as long as the system fails gracefully it's at least not doing any harm to implement and as it is now it will cover a vast majority of users.

    So far I tested and confirmed it working with FF 1.0.6 and 1.5 beta 1, IE6, NS8 and Opera 8.5
    Opera 8.01 does not show the hash and back button fails, but at least deep links are working.

    I would be very interested to hear from mac users in particular to find out if NS, Safari and IE still is not working.

    Big Flash

    Some nice additions to the big names making serious use of what flash can offer lately.

    The most impressive that been blogged a lot about already is the IKEA matrix kitchen.
    Clever and skill full piece of work that really uses the internet as a media in an efficient and inventive way.

    The even bigger news that even more people blogged about is Googles adaptation to using Flash to deliver video.
    It seems like a surprise to many people since it somehow seemed like they have an aversion to Flash considering the efforts they made building AJAX contents.
    Maintaining separate versions for different browsers to get your RIA applications working I guess is something you only consider if you don't consider Flash :)
    And using a proprietary video format that requires user to download and install your software can of course be seen as a similar attitude trying to avoid Flash at any cost.
    But now they have finally come to their senses it seems at least.
    Of course the service itself it's not anything revolutionary to get excited about. It's video, in flash. The big news here is the big name.
    That google uses Flash can seem like a seal of approval for serious large scale deployment of Flash content.

    Peugeot's use of flash is not all that exiting, although nicely done.
    The animation work is stylish and well carried out, but a bit bland in my opinion.
    Clicking on a key flying around to test the sliding of the doors is hardly especially fun and doesn't make me feel closer to the product really.

    It's how close you feel to the product that I love about applications like the one IKEA done.
    It shows the possibility that multimedia technologies like Flash give for taking communication to a new level.
    A video or an animation can be extremely good at delivering an experience, but when people figure out good ways to use interactive multimedia it gives you a presence previously unseen.

    A picture says more than a thousand words, but a Flash application says more than thousand pictures :)
    And in IKEA's case I guess it makes sense since it wouldn't surprise me if the application actually use about 1000 pictures.

    Nasty notepad and the invisible BOM

    First of all I'm happy to have received note that my blog have been added to MXNA today.

    They tried to add it on friday, but apparently their parser didn't like my feed.
    It contained an "feff" tag before the XML prolog I was told.

    The feed was fine according to feedvalidator, other aggregators managed to parse it and it worked fine in my feedreader.
    I double checked my PHP script that generates the feed and assured myself that there was no erroneous garbage.
    Google help me!!

    "FEFF" turns out to be a quite perculiar unicode character.
    It's used to signify the byte-order of unicode documents, and also have the meaning "ZERO WIDTH NO-BREAK SPACE"....hmmm basically meaning it means nothing.
    Using UTF-8 for my feed there is no byte order needed though, and if there ever is a need for a "ZERO WIDTH NO-BREAK SPACE" I'm curious to find out what it could be.

    So what was the byte order mark (BOM) doing in my feed?
    Apparently it's because I used notepad to make a quick edit to the document and told it to save as UTF-8.
    Many apps will add the BOM also to UTF-8 encoded documents, not to signify a byte order, but to signify that the document is unicode.
    But a parser might not be written to look for the BOM and strip it out if it's found, and hence choke since it's expecting the file to start with an XML prolog.
    And for the parser there is no need to use the BOM to find out if the document is unicode. It will look at what encoding you have specified in the prolog, and assume UTF-8 for a document without encoding specified.

    I guess that in my case the reason that the BOM ended up in the feed is that I use an include to get my db connection settings.
    If the BOM appears before the PHP declaration I guess there should be no problem and it will not be included in the feed.
    But with a BOM in the include you get a corrupted feed which not all parsers can handle.

    In the end I used my preferred editor, SciTE, and saved the files as "UTF-8 cookie" to ensure that there was no BOM, and problem was solved.

    Expression Interactive Designer

    I had look at the video presentation for MS sparkle, or as it's officially titled, Expression Interactive Designer.

    Previously when hearing about sparkle I figured it would probably not be anywhere close to living up to what it's many times refered to, a "Flash killer".
    The picture I got in my mind was somewhere close to how the sparkle vs. Flash fight is portrayed in this animation.

    Now I must say that I'm very impressed with what was shown of the application.
    It sure don't seem like a Frontpage vs. Dreamweaver scenario to me anymore, and sparkle does have some very tempting aspects to it that could make it a worthy competitor to Flash in some aspects.
    Honestly I hardly considered the option that it could be better than Flash and that I would ever contemplate to use it.
    I don't hate MS for any other reason than that all the apps I used from them have been awful, and if they start putting out good applications I will not be adverted to them based on sentiment.

    What really impressed me was the integration between code and design.
    For me at least being able to see alterations made in code reflected instantly on the stage would be a great improvement for the workflow.
    The resizable toolbars and pallets is a innovative feature, and although not that vital it's a nice improvement to the usual workspace in most graphics apps nowadays.
    I don't get all that excited about the hardware acceleration and 3D capablities since I would normally not have that much need for them, but it's of course welcome with any performance boost and the 3D stuff will come in handy in some cases.

    Of course Flash will have the edge for web applications, at least for a few years to come.
    That means that MM will have a chance to catch up in some areas where sparkle seems to be ahead.
    I doubt sparkle will ever be able to get to a state where it has the same universial deployment capabilites as Flash, which is really the prime reason that I got into Flash in the first place.

    Dissolving the borders between the web and desktop as well as between different platforms is where the future is at, and I don't really swallow the talk about sparkle being for a different purpose than Flash.
    For the user an application is an application, and if it needs to be downloaded and installed before it can be used or can't run on certain platforms it's just a drawback for that application.
    In some cases you of course need access to the system in a way that would not be suitable to permit for web based content, but it's for sure not two separate worlds anymore.
    To be able to do like with a Flash based app and decide that "hey, I need access to the file system, so let's publish this as a projector instead" is much better way of dealing with the separation needed between web based and desktop apps compared to have to use differrent tools and languages.
    And no matter if you are targeting the desktop or the browser, universial deployment is in most cases a big bonus.

    But of course MS want to tone down the "Flash killer" talk and focus on what sparkle actually might be capable of at the time of release.
    That will be to enable developers used to the MS framework and designers to work better together to deliver products tageted at the newest generations of windows desktops.
    Their long term goal is surely to be able to have a product that can rival flash as an application for merging the desktop and the web, and I'm sure they would love to have it working well on mac as well, just like with MS Word and IE.

    I'm actually happy to see that it seems like Flash is getting what seems like it might be a worthy competitor, and I can't wait to see what developers using sparkle will come up with when it is eventually released.

    Backbutton and deeplinking/bookmarking

    I was looking around for some example code for how to implement full state management in Flash with both functioning back/forward buttons and deeplinking/bookmarking, but couldn't find any.

    So I decided to put together my own and make it available in an attempt to silence the many Flash critics who, rightfully in my opinion, think that it is a major drawback with pure Flash sites.

    It's only tested and working with recent versions of firefox and IE on windows.
    Backbutton and bookmarking fails with Opera 8, but deeplinking works.
    I'm quite sure someone with decent JS skills should be able to fix that though.
    The problem is that "document[movieid].SetVariable();" does not target the swf correctly, which is a mystery to me since I have seen examples using the same syntax that does work.
    Another solution would be to rewrite the code to use localConnection instead in which case most browsers should have no problem.

    But for now at least you can easily have state management functioning for the very large percentage of users that use FF or IE, and other browsers should hopefully all fail gracefully and be able to follow deeplinks in to your flash site.
    So there is no excuse to now implement state management into your Flash site now.

    You can try the system with this little ugly example
    Please leave a comment if you are using a browser other than FF or IE on windows so I can make a list of what browsers it is working on.

    Get the download here.

    Update:
    I made a new version using Macromedia JS integration kit for communication between Flash and JS.
    Get the download here.
    It did not solve the issues with Opera 8.01 apart from getting rid of the JS error, and I doubt that Safari will work still.
    So until I get some feedback on how it works with the Browsers that been problematic I'm not sure how much of an improvement it is.
    I updated the example above, so try it out and tell me if it's not working with a particular browser.
    So far confirmed to be working is FF 1.0.6 & 1.5 beta1, IE 6, Opera 8.5 and NS8. Not working so far is Opera 8.01

    Dofus

    I haven't found time to write in the blog for a few days.
    The reason: www.dofus.com

    It's a very well made MMORPG done with Flash.
    Check it out if you like to see what Flash is capable of in the hands of good game developers.

    BlixtBlog 0.9.3

    BlixtBlog is a simple GNU GPL licensed blog system for flash that can also be used as a basic CMS system for a whole flash site.
    It uses PHP/MySQL for the backend.

    Main features:

  • Admin interface for easy adding of text, images and links and moderation of user comments.
  • Included state management enabling deeplinking, bookmarking and use of back/forward buttons in the browser.
  • Accordion style display of posts by subject and post by month as well as multiple categories of external links.
  • Generates RSS 2.0 feeds.
  • User comments with gravatar support.
  • Can be set to resize with the browser window or be used in fixed size.
  • User can resize text using ctrl mouse scroll or +/- buttons.
  • The package includes an example file of how to use the system for easy creation of a flash site manageable using your browser.
    Just configure what pages you like to have on your site and add your own graphics.

    Currently there is no HTML output generated, but that will be added in next release to enable search engines to find your content and deeplink directly into your flash page.
    Other planned additions is slideshow for photos and mp3 player.

    Get the download here.


    Click here to see an example
    of the system in use for generating a whole site.
    Also if you feel like testing making comments that is the prefered place to do it instead of posing a lot of asdsfdawasdf in here :)

    If you have any problems, discover any bugs or like to provide feedback please use the comment function on this page.

    EDIT:
    2005-09-01
    Now version 0.9.3 is up.
    It includes some very essential fixes, and you a strongly recommended to upgrade if you are running 0.9.2

    Apart from many major bugfixes a few new features was added:
    Possible to use embedded fonts.
    Display and loading of posts and comments split to pages.
    Ability to double up as a guestbook.

    Microsoft plans for a “Flash Killer”

    According to an article in eweek.com Microsoft is about to announce their developer-oriented graphics tool, code-named Sparkle.
    The name oozes desperation I must say.

    Surely being an MS product it will gain a foothold in the market, and better late than never, but I will sure not worry about the future of Flash.
    It will be interesting to see what Windows Presentation Foundation (WPF), formerly known as Avalon, will be capable of though, and some competition is always healthy.

    But I guess it will time before the solution is compatible with enough browsers out there to be worthwhile.
    Apparently there will be an update to XP so WFP technology will not only work with Vista. But for many years to come it will still be only a small share of users that will be able to view content created with WFP I guess.
    And MS client side solutions hardly have a record of taking the world by storm with their limited support outside IE.

    « Previous PageNext Page »