# HG changeset patch # User Neil Muller # Date 1328959856 -7200 # Node ID 15713dfe555d8dc4e5c8b66411c9bd6b4bdb6327 # Parent 38fb04728ac58b8f43b5ba57a72071e0403c45f4 The new, friendlier gen_sound helper diff -r 38fb04728ac5 -r 15713dfe555d tools/gen_sound.py --- a/tools/gen_sound.py Sat Feb 11 13:24:00 2012 +0200 +++ b/tools/gen_sound.py Sat Feb 11 13:30:56 2012 +0200 @@ -27,12 +27,31 @@ for x in range(int(freq * secs)): output.write(''.join(data)) output.close() + return filename +def usage(): + print 'Unexpected input' + print 'Usage: gen_sound.py []' + print ' where is the frequency in Hz (integer)' + print ' and [] is the time is seconds (float)' + if __name__ == "__main__": - freq = int(sys.argv[1]) + try: + freq = int(sys.argv[1]) + except Exception, exc: + usage() + print 'Error was: %s' % exc + sys.exit(1) + if len(sys.argv) > 2: - secs = float(sys.argv[2]) + try: + secs = float(sys.argv[2]) + except Exception, exc: + usage() + print 'Error was: %s' % exc + sys.exit(1) else: secs = 0.25 - gen_sine(freq, secs) + output = gen_sine(freq, secs) + print 'Wrote sample to %s' % output