#!/usr/pkg/bin/python import winsound, sys # globals halfstep = pow(2, 1.0/12.0) # 12th root of two is the multiplier between halves notes = dict() note = 55 * halfstep * halfstep * halfstep # A, B-flat, B, C for octave in range(0, 5): for halfnote in range(0, 12): notes[octave, halfnote] = note note = note * halfstep def beep(frequency, duration): # duration in seconds duration = duration * 1000.0 # convert to milliseconds for winsound winsound.Beep(int(frequency), int(duration)) def main(): frequency, duration = 440, 0.5 # middle A for 1/2 second if len(sys.argv) > 1: frequency = int(sys.argv[1]) if len(sys.argv) > 2: duration = int(sys.argv[2]) beep(frequency, duration) if __name__ == "__main__": main()