Friday, June 19, 2009

Looking for a job

On a more personal note: I recently was laid off from my job as part of a economy-related layoff at my employer, and so I am in the market for a job.

My work supporting large-scale Macintosh deployments has lead me into a lot of exciting areas in the last year: developing a loginwindow plugin, getting a patch accepted into Radmind, writing a multi-partition flexible imaging system, and taking over development of InstaDMG. Combined with presentations at two major conferences, MacWorld and SIGUCCS, it has been an exciting year, and I am looking for a position where I can continue this work.

I am open to both contract and full-time opportunities, and am willing to relocate for a good opportunity. If you have such a position available, or know of one that is coming available I would appreciate it if you could contact me at larkost@softhome.net. I am especially open to contracts for training or consultation on InstaDMG.

My resume can be found through these linkes, either in PDF format, or in Microsoft Word format. I am working to provide an open-source portfolio of my work, the start of which can be found at the following locations:

Saturday, June 13, 2009

Reindexing Apple Audio Loops

Reindexing Audio Loops

A number of Apple's products use Audio loops, most notably FinalCut Studio and GarageBand, but a few other applications make use of those loops as well. Those loops live in /Library/Audio/Audio Loops, and in order to be used need to be indexed (the indexes go in Library/Audio/Audio Loops Index). On most computers this is taken care of for you by the respective installers, but for computers that are imaged you usually don't run the installers on those computers. This is especially true if you use Radmind to manage the computers and have separate transcripts for the different Apps, or have selected computers that have additional loops purchased for them.

The solution for this is to use the same technique that Apple's installers use to index the loops. This article will outline a way of doing this. Note that this is similar to code that I have used in a previous job, but has not actually been tested in production use.

Grabbing the Indexing Tool

GarageBand and FinalCutStudio both have the ability to re-index the loops from within the App. From GarageBand you just drag the loops folder that you want to index into the loops area. This requires that the user be an admin, so is not a good solution for computer labs. Unfortunately this built-in ability is not scriptable (in a way that I have yet found). But there is a solution available: you can grab the tool that Apple's installers use from the latest installer. As of this point that is from the iLife '09 installer, and from the Installer DVD the application you need is:

iLife '09.mpkg/Contents/Installers/GarageBand.mpkg/Contents/Installers/GarageBand_Loops.pkg/Contents/Resources/ALPIndex.app

You will need to copy this .app bundle to a known location on all of your client computers (or keep it on a network share).

The script

We need a script to run that ALPIndex tool on all of the individual folders. If there are a lot of un-indexed loops to process the script can take some time, but if there is nothing new then it will complete within a second or so. My recommendation is to run the script on a regular basis. If you are using Radmind and have provisions for post-radmind scripts this is a good candidate for that.

Note that code assumes that you put the ALPIndexer.app in a folder at /Library/Management/ReindexAudioLoops. You should change that to match the setup on your system. If you are using the launchd option below, it assumes that you name this script reindexAudioLoops.bash and put it in this folder.

#!/bin/bash

ALP_INDEXER_PATH='/Library/Management/ReindexAudioLoops/ALPIndex.app'
ALP_PROGRAM_PATH="$ALP_INDEXER_PATH/Contents/MacOS/ALPIndex"
LOOPS_FOLDER='/Library/Audio/Apple Loops'
SUCEEDED=true

if [ `whoami` != 'root' ]; then
    echo "This tool must be run as root!" >&2
    exit 1
fi

echo "Reindexing Audio Loops: `date`"

IFS=$'\n'
for VENDOR_FOLDER in `/bin/ls "$LOOPS_FOLDER"`; do
 echo "Group: $VENDOR_FOLDER"
 for PROGRAM_FOLDER in `ls "$LOOPS_FOLDER/$VENDOR_FOLDER"`; do
  echo "  Processing: $PROGRAM_FOLDER"
  $ALP_PROGRAM_PATH "$LOOPS_FOLDER/$VENDOR_FOLDER/$PROGRAM_FOLDER" 2>/dev/null >/dev/null
  if [ $? == 0 ]; then
   echo "      Sucess"
  else
   echo "FAILED!"
   SUCEEDED=false
  fi
 done
done

echo "" # provide a space

# provide a summary of what is done
$ALP_PROGRAM_PATH -p

if [ $SUCEEDED == true ]; then
    exit 0
else
    exit 2
fi

Launchd item

If you are not using Radmind, then using launchd might be a good choice for running this script. A simple example is presented below. Placing this in /Library/LaunchDaemons with the appropriate permissions should work.

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
 <key>Label</key>
 <string>info.larkost.reindexAudioLoops</string>
 <key>Program</key>
 <string>/Library/Management/ReindexAudioLoops/reindexAudioLoops.bash</string>
 <key>RunAtLoad</key>
 <true/>
</dict>
</plist>