Automatic genre identification and ‘similar track’ matching Automatic genre identification and ‘similar track’ matching
  • Home
  • Posts
  • Home
  • Posts

Geekspeak

Automatic genre identification and ‘similar track’ matching

200804101846.jpgI’ve got a bit of new music lately, and I’ve noticed that the genre is always a bit off. Genre is a pretty tricky thing to figure out for most modern music, as there’s so much ‘cross-pollination’ going on in the music world. Additionally, over a single album, several genres may be visited (eg. folk, acoustic, pop).

There’s no way anyone’s going to go through every track independently and assign a genre (unless they’re seriously O.C.D). So, automatic genre setting (a new AutoRate feature?).

It looks like there has been some work done in the field, although it looks like it’s all still at the early-research stage; I haven’t found any available software. So there’s another possible project.

Another use could be to build a database of tracks in the local music library, and offer similar tracks when playing, constructing an automatic playlist. The same could be done with an online database, similar to Pandora.

Read More

Automatically eject all disks on sleep, reconnect on wake

sleep-macbook.png

Using a laptop with permanent external drives can be a bit annoying when you leave the desk – you have to manually eject all your devices, otherwise you get that dreaded ‘Device Removal’ dialog. With a little bit of Terminal magic, you can automatically eject disks when you sleep the laptop, meaning you can just put the lid down and go. Disk are also reconnected automatically on wake, for when you’re just sleeping the computer without going places.

It’s all thanks to a little utility by Bernhard Baehr called SleepWatcher, which runs in the background and is triggered by sleep and wake events, calling scripts to perform required actions.

Download and install SleepWatcher and its StartupItem.
Next, you’re going to create ~/.sleep and ~/.wakeup files which SleepWatcher will call upon. Pull up your favourite text editor and paste the following in (should be just two lines):

#!/bin/sh
osascript -e 'tell application "Finder" to eject (disks where free space ≠ 0)'

Save the file – call it “sleep.txt”, and save it to the Desktop; make sure it’s plain text! Then put the following in another file, called “wakeup.txt”, saved to Desktop too (also just two lines):

#!/bin/sh
/usr/sbin/diskutil list | grep -e ' +[0-9]+: +[^ ]+ [^ ]+' | sed 's/.(disk[0-9].)/1/' | xargs -I{} /usr/sbin/diskutil mount {}

Next, open the Terminal (Applications, Utilities, Terminal), and type the following:

mv Desktop/sleep.txt .sleep
chmod a+x .sleep
mv Desktop/wakeup.txt .wakeup
chmod a+x .wakeup

Now, whenever you sleep your machine, the external drives will be ejected automatically; when the machine wakes again, all connected external drives will be reconnected.

Read More

Memory tricks: Linking it in

23112370.jpg

I tend to have an appalling memory for performing tasks, unaided by beeping alarms – I get lost in the moment and it just goes out of my head. A trick I found many years ago works surprisingly well, though, when I actually remember to use it (of course, that’s the real trick).

Memory recall in people (or at least me!) seems to work a bit like it does in a computer. If you don’t have anything to link that memory region to something, it’s probably lost forever. In computers, you keep track of addresses of things in memory (we call them ‘pointers’, numbers that point to memory). If you don’t keep a pointer, there’s no way to access that region in memory, because you don’t have its address.

This is more-or-less what I do when I don’t put special effort into remembering to perform a task. Usually, we just acknowledge that there’s something that needs doing, at some vague time in the future. This is like storing something in memory, but throwing away the pointer. What’s the point in that? (What are you looking at me like that for? Oh, point…)

So, keep the pointer: link the memory in to something. When you have things to do, assign a time to perform them, and picture what you will be doing around that time. For example, I’ve been having trouble remembering to buy these Daniel Kitson tickets. I pictured myself walking through the door to the study, and then remembering. Sure enough, in the morning, I walked in, and suddenly it was in my mind. I only hope we manage to get tickets that aren’t marked “RESTRICTED VIEW INFORM PATRON”…

Next is using magnetic pulses to counteract the effects of sleep deprivation on working memory…

Read More

PHP debugging

php-debug.jpgManaging PHP debugging can be tricky as, by default, errors and test ‘echo’ statements can be lost along with all the other output. This problem is compounded when using AJAX, and errors can turn up in XML streams, causing all sorts of problems.

A better solution is to redirect all of that output into an external file, and use a tool like tail to monitor the log.

For printing debug statements, a debug function that shows where each statement came from (file and line number), and is capable of printing complex objects is useful too.

The following is the debugging code that’s included in SiteComponents.

if ( defined("DEBUG_ENABLED") )
{
   ini_set("error_log", $_SERVER["DOCUMENT_ROOT"]."/debug.log");
   ini_set("error_reporting", E_ALL);
   ini_set("display_errors", false);
   ini_set("log_errors", true);
}

/**
 * Define debugging routine
 */
function SCDEBUG($content="")
{
    if ( !defined("DEBUG_ENABLED") ) return;

    if ( !array_key_exists("__SCDEBUG_fd", $GLOBALS) )
    {
       $GLOBALS["__SCDEBUG_fd"] = fopen($_SERVER["DOCUMENT_ROOT"]."/debug.log", "a");
        if ( !$GLOBALS["__SCDEBUG_fd"] ) return;
    }

    $bt = debug_backtrace();

    if ( is_array($content) || is_object($content) )
    {
       $content = print_r($content, true);
    }

    fwrite($GLOBALS["__SCDEBUG_fd"], 
          ($bt[0]["file"] ? (substr($bt[0]["file"], 
                strlen($_SERVER["DOCUMENT_ROOT"])+1).":".$bt[0]["line"]." (") : "").
            $bt[1]["function"]."()".
          ($bt[0]["file"]?")":"").
            ": ".$content."n");
}
Read More

TVSync syncs your TV episodes with iTunes and your iPod or iPhone

TVSync-logo.png I’ve just created a glorified bash script that will intelligently (hopefully) synchronise downloaded or recorded episodes from TV shows with an iTunes library.

From the website:

This utility will automatically transfer video files of TV series (such as those downloaded from Bittorrent or recorded from TV) into iTunes for transfer onto an iPod/iPhone. It can import shows into a local iTunes library, or a remote iTunes library, over SSH.

Whenever the utility is run (automatically, every half hour), episodes from the configured shows will be converted to an iPod-compatible format, and imported into iTunes. The utility will do its best to set the correct metadata, including setting the items as type ‘TV Show’, and downloading episode titles from IMDB if it can’t be found from the filename.

Install it with the provided package, and it automatically is registered with crontab, to run every half hour. It can be configured to run locally (syncing with a local iTunes installation), or remotely, over SSH.

It works with almost anything downloaded, and with EyeTV.

Check it out at the TVSync page.

Read More

Intelligent image resize

There are times when you need a certain resolution in an image (like if you want to use it as a desktop wallpaper), but all you have is a small version – which means if you try and enlarge it, you get either a blurred or pixellated version.

There’s actually another way, which doesn’t seem to have caught on yet, probably because it’s a bit tricky still. You can trace the image, making a vector version, then resize it to anything you like. Provided you’re starting with enough resolution, the effects can be quite good.

It’s all thanks to the genius of Peter Selinger’s Potrace library. It’s built into Inkscape, which runs on most platforms.

Start up Inkscape (If you’re running Leopard, I think you have to start up X11 first, manually), and open the image you want to enlarge. Select the image, then go Path, Trace Bitmap.

200802021841

Configure it to use colours, not smooth, and choose a good number of scans (the more, the more colours and better representation of the original image)

200802021842

Click OK and wait while it does it (this may take a little while). Once it’s done it’ll tell you in the status bar, and the ‘OK’ button will re-enable. Close the ‘Trace Bitmap’ dialog (with the window controls at the top, not by clicking ‘OK’, which will just do it again).

Now, to save the result, click File, Export Bitmap, choose ‘Selection’, and choose whatever size you want to export as.

200802021844

Done!

If you’re adventurous, you can also export as postscript or PDF, by going File, Print, and putting “> filename” to print to the file. For PDF conversion under OS X, put in “> ~/Desktop/file.ps”, then double-click on it in finder, which will open Preview to convert to a PDF (you can then save in Preview).

Before and after:

<

p style=”text-align:center”>
200802021854200802021854-1

Read More

My iTunes iPhone playlist setup

 Files 2007 06 Iphone 34I used to manually choose the tracks to sync to my iPod Nano, but now I have 7-something gig to play with on the iPhone, it’s a bit too much. Instead, I use smart playlists to select which tracks to carry with me.

Two standard playlists, ‘iPhone Selections’ and ‘iPhone Exclusions’ allow me to specifically choose or disallow tracks to go onto the iPhone. Then, a smart playlist called ‘iPhone Inclusions’ looks like:

 

200712210847

Watch that ‘any’ selection in the top drop-down – a bug in iTunes resets it to ‘all’ every time you bring up the dialog, so you gotta reset it every time.

Finally, a smart playlist called ‘iPhone’, which is the one that is selected to be sync’d, looks like:

200712210848

That makes sure that tracks I manually choose are copied over, and the rest is automatically selected by rating and the date added (ideally).

Ratings, of course, are automatically set using AutoRate.

The one caveat is that because you can’t select more than one sorting criteria when limiting to a certain filesize in the smart playlist, you can just choose either to sort by add date – which means you’re guaranteed to get that great new album copied over – or by rating, so that you’re gunna get the best tracks. Not both, unfortunately, unless you limit the ‘iPhone Inclusions’ smart playlist too (but that means you won’t necessarily fill up the iPhone if you have lots of exclusions that would otherwise be included).

Other than that, it works quite well – I haven’t yet had a moment when I’ve missed anything on the iPhone.

Read More

AutoRate in Japan’s Mac Fan Magazine

 Mg 5912AutoRate got a mention in the Japanese Mac Fan magazine! Anyone speak Japanese?

<

p style=”text-align:center”>
 Mg 5913

Read More

Hi! I'm Michael Tyson, and I run A Tasty Pixel from our home in the hills of Melbourne, Australia. I occasionally write on a variety of technology and software development topics. I've also spent 3.5-years travelling around Europe in a motorhome.

I make Loopy, the live-looper for iOS, Audiobus, the app-to-app audio platform, and Samplebot, a sampler and sequencer app for iOS.

Follow me on Twitter.

Posts pagination

« 1 … 24 25 26 … 29 »
© 2021 A Tasty Pixel.