Monthly Archives: April 2011

Cowon J3 (Cow’n’Emu)

So I’ve recently bought the Cowon J3 32gb mp3 player. It’s a small upgrade from my Cowon S9, which was the 16gb version.

Both players has an excellent sound quality, the best I’ve ever had in an mp3 player (I’ve owned a couple of different ones, Rio, Creative, iPod, Samsung and something that starts with F that I can’t remember the name of anymore).
My only problem with the 2 Cowons is the touch-screen user interface, which has gotten a lot better with the J3. The problem is, even though the touch UI is improved, the new button(buttons on the actual device) layout is not as good as it was with the S9 (my own opinion).

But to the point of it all. Both the S9 and J3 runs on a Adobe Flash UI, and Cowon have opened up for their API, so you can make your own UI with flash and Actionscript 2 (unfortunatly the UI runs on a AVM 1 in Flash Player 7, so you can’t use AS3).
So I started out making a simple SWF to test out what the J3 was capable of, and how to use the Cowon API. And everything was really straight forward, to call their API you use the ext_fscommand2 function, and passed along some arguments letting the device know what you want to do.
The main problem is the testing phase. You need to plugin the player, transfer your SWF to it, plug it out, turn it on and then test it. The first couple of times it wasn’t an issue, but the 5th time you do it, it gets annoying, and the 10th time I did it, I stopped. It was to much of a hassle. So I searched the net for an emulator so I could test my project right away.
Now the only emulator I could find had no download link, and no one seemed to update it. So I decided to start working on my own.

So far I’ve implemented the ext_fscommand2 function and have it working as intended. But I haven’t made any actual functionality that simulates the device yet. One of the things I’m still having a hard time with is the Key events. I need to catch all the events from the UserSWF (the SWF you wish to load onto the device), and handle them in my own emulated environment instead of having Flash doing it for me.

Anyway, that was a long post just to tell you that I had started work on a Cowon S9+J3 emulator. Hopefully I’ll have a running alpha version next time I post about the subject.

CSSParser release

So… I haven’t really been doing any work at all on the CSSParser(my own CSS Tidy project for reading and compressing CSS) I started on a couple of months ago. What happened is what always happens with my own projects. After I’ve implemented the initial idea, I start to loose interest.
But I’ve made it further with this CSSParser than I usually do, so I’ve decided to release the source code for the project. Not every function will be well documented but I’ve tried to comment as much as possible.

Download it here.

I’ll do a quick explanation of how the process, just to give an idea of how it all works.

  1. The CSSParser class reads a given CSS, using a single preg_match_all call.
  2. Now then class will start to build up an array of CSSSelector classes. This class will hold all the properties and identifiers of a CSS selector from the given CSS.
  3. Each property of the CSSSelector will be held in a CSSProperty class or a class extended the CSSProperty like CSSBorder and CSSBox. This way it’s easy to add more specific output on properties, simply by extending the CSSProperty class and making your own property class.
  4. Now all the data is structured in the CSSParser class. And by calling the printCSS() function with a CSSOut class as the argument, we can get the CSS out the way we want.

When printing the CSS a very primitive templating system is used, where the template simply is PHP that has access to the list of selectors after they’ve been run through a preProcess function optimizing the data for output.
An example can be the template1.php file (found in the downloadable zip):

1
2
3
4
5
6
7
8
9
10
11
<?php
foreach ($data as $selector) {
    echo implode(",\n", $selector->identifier);
    echo " {\n";
    foreach ($selector->properties as $property) {
        foreach ($property->getProperty($settings) as $key => $value) {
            echo "\t$key: $value;\n";
        }
    }
    echo "}\n";
}?>

Read more »