# Bruce Maxwell # January 2012 # Program that generates note entries for a simple instrument # These are randomly selected samples played at uniformly random times import sys import random # Generates N granules, all the same length, at uniformly random times # Each granule is a random sample from the source table # The length of each granule is a given # The total number of granules is a given # The playback ratio is a given # The overall amplitude is a given def main(argv): if len(argv) < 8: print 'Usage: python %s <# notes> ' % (argv[0]) exit() instr = int(argv[1]) # instrument N = int(argv[2]) # number of notes time = float(argv[3]) # total time duration = float(argv[4]) minoctave = int(argv[5]) maxoctave = int(argv[6]) iamp = float( argv[7] ) iamp = iamp / ( duration * N / time ) # loop over the number of notes for i in range(N): t = random.random()*(time - duration) # uniformly pick start time pitch = '%d.%02d' % (random.randint( minoctave, maxoctave ), random.randint( 0, 12 ) ) s = 'i %6d %6.2f %6.2f %10.2f %s' % (instr, t, duration, iamp, pitch) print s if __name__ == "__main__": main(sys.argv)