iTunes Multi-Genre Tagger now on Github

January 29th, 2011

Just a quick note to announce that iTunes Multi-Genre Tagger’s source is now on Github. In case any of you would like to fork and solve my Gem.use_paths conundrum I’d be much obliged!

Posted by bcdef
Filed in Miscellany, Ruby
No Comments »

OGG in Flash? Yes you can. Now how about WMA?

May 13th, 2009

Working with audio can be pretty limiting in the Flash Player. There’s a multitude of audio formats out there, but heretofore the only native support is for MP3 and AAC (the latter arriving only as recently as the beta releases of Flash Player 9, so long as the file has been encoded in the correct fashion.)

This leaves out a number of still-popular formats, particularly OGG, WMA, and Real. WMA is a common format for those who encode audio with Windows Media Player (as well as many streaming online radio stations). While Real is fading from view, OGG continues to grow in popularity, particularly due to the fact that it is open-source and requires no licensing fees to broadcast.

Fortunately we can add another format to the list. Adobe’s labs release of Alchemy allows us to compile C/C++ code, with a bit of tweaking, into a precompiled SWC file that can then be accessed from ActionScript. The sample library includes an OGG codec, which you can use either directly or within a wrapper class recently published by Maurice Zarzycki. This makes playing back OGG files as simple as:


oggDecoder = new OggRadio(yourUrl);
oggDecoder.play();

While playing OGG files does appear to be more CPU intensive than MP3, I’m impressed for its stability; I’ve yet to find an OGG file it couldn’t handle.

This opens the debate as to what other C++ libraries might be of use in SWF or AIR. Along the lines of audio, there is still the WMA format, which though propriety technology of Microsoft, has an open-source codec, libwma, developed by FFmpeg and further reworked into SoundCodecWMA by the Rockbox team. How difficult it would be to translate this into Flash Player functionality using Alchemy to build a SWC?

Any takers?

Posted by bcdef
Filed in Alchemy, Flash
6 Comments »

How to link SWC files to a TextMate Flex project

May 13th, 2009

I was recently asked how to compile using TextMate when you have precompiled SWC dependencies. This is a very common workflow but it’s unfortunately not as automatic as dropping them in your ’src’ directory. This is how to resolve the issue if you’re working with a folder structure built with TextMate’s Flex bundle (via File > New From Template > Flex > Project)

There’s a few ways to handle this. The quick way is to ensure that any SWC’s you use on any project are in your SDK’s frameworks/libs directory and that when mxmlc is run from the command line it runs from this SDK directory.

There’s two drawbacks to this method, however. One is that if you ever update your SDK you’ll have to migrate the SWC’s over manually (when it can often be unapparent which SWC’s are third-party and which are part of the SDK). You’d also need to have a redundant copy of SWC’s in each SDK you use (say you’re trying out both Flex 3 and Flex 4). Secondly, if you work with source control then there are code dependencies which reside outside the project folder, which is not ideal for anyone else that’s trying to collaborate with you, nor yourself if you’re trying to work on another machine. You could include your SDK in the source control, but this is not as compact a solution as sync’ing with the project folder itself.

So say we want to put all dependent SWC files in a ‘libs’ directory parallel our ’src’ directory, how do we do it?

To solve this, and potentially other future dilemmas, you really should familiarize yourself with the TextMate Bundle Editor (Bundles > Bundle Editor > Show Bundle Editor). Notice how there is no ‘Build’ option in the Flex bundle? This is because the Flex bundle also uses elements from the ActionScript 3 bundle. For example, if in the ActionScript 3 bundle you remove the keyboard shortcut for ‘Build’ and then change the ‘Build (mxmlc)’ keyboard shortcut to Cmd-B then you’ll remove a keystroke from your build process even in Flex projects. This is something I’ve personally done as I use mxmlc rather than the default Ant script to build. Remember to Bundles > Bundle Editor > Reload Bundles after making any changes.

But back to the issue at hand, open up Flex > Project > Project-config.xml. You’ll notice this is the schematic of a file which is created automatically when you create an Flex 3 project. Unfortunately, the Project-config.xml schematic in the Flex bundle lacks these two sample nodes that are in the ActionScript 3 bundle. These are:


<!-- Example library linkage -->

<!-- for swc's
  <library-path append="true">
<path-element>../lib/bin/</path-element> </library-path> -->

<!-- for src
<source-path append="true">
<path-element>../lib/src/</path-element> </source-path>
-->

This file acts as a project-level override to the general configuration file found in the SDK directory. Close the bundle editor. You’ll want to add the following to your project’s configuration xml which lives in ’src’:


<library-path append="true">
  <path-element>../libs/</path-element>      
</library-path>

Now you can create a new directory named ‘libs’ parallel to ’src’ and drop into here all SWC files that your project depends on. Save the configuration file and you should be able to build. Now anyone with the Flex SDK will be able to save your project directory locally and jump right into compiling

You can also add any other project-specific compiler instructions in here. More information on your compiler switches options are here. For example, during a recent project I had a lot of unimportant warnings being fired with each compile so I was able to silence them with:


false

HTH.

Posted by bcdef
Filed in Miscellany
4 Comments »

Euro2008.com Python Image Scraper

April 21st, 2009

Mind the cobwebs. So while cleaning house to better organize my code library today, I stumbled across a project I’d taken on during a day between jobs last year. I think I had some grand idea of writing up something more elaborate on it, but that never happened. Regardless, it might be of use to someone so I thought I’d post here.

The basic tenet was that the euro2008 website carried some engaging caricatures of the major players for the football tournament, and I had the urge to download them all.

spacer spacer

Rather than try to save them all manually, I figured it’d be instructive to learn how to build a Python script to do it for me. In short time I found a few libraries that eased the process. The code ended up being nice and tight. There might be some dependencies – I think you’ll need Beautiful Soup at the least – but I just checked it again and it still works here on Python 2.5.1.

You could tweak it toward any number of ends, not just saving images off the web but for also data mining or other purposes. Or you could just run it locally and get lots of swank portraits.

As you will, then: retrievecaricatures.py

Posted by bcdef
Filed in Data Mining, Python
2 Comments »
« Previous Entries