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/

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 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.


LOOPS_FOLDER='/Library/Audio/Apple Loops'

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

echo "Reindexing Audio Loops: `date`"

for VENDOR_FOLDER in `/bin/ls "$LOOPS_FOLDER"`; do
 echo "Group: $VENDOR_FOLDER"
  echo "  Processing: $PROGRAM_FOLDER"
  if [ $? == 0 ]; then
   echo "      Sucess"
   echo "FAILED!"

echo "" # provide a space

# provide a summary of what is done

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

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" "">
<plist version="1.0">

1 comment:

  1. Interesting stuff, I'll have to try this sometime. One less thing to manage in a positive. Do you remember offhand where the index is stored?