#!/usr/bin/pythonw
#
# stpfindfix.py
#
# Michael Pruett <michael@68k.org>
#
# Use Soundtrack Pro to detect and repair common audio defects such as clicks
# and pops, hum, DC offset, and phase misalignment.

import appscript
import macfile
import sys, os

def usage():
	print "usage: stpfindfix.py file"
	sys.exit()

if len(sys.argv) < 2:
	usage()

infile = os.path.abspath(sys.argv[1])

stp = appscript.app('Soundtrack Pro')
stp.open(macfile.Alias(infile))
doc = stp.audio_file_documents[1]

doc.analyze()
doc.fix_issues()

doc.save()
