utils/pianoroll-client.py
changeset 75 129281e4bc2a
parent 73 2a6590aeac15
child 85 eff9460bd4f2
equal deleted inserted replaced
74:bdcc964b3c01 75:129281e4bc2a
     3 Example of a UDP txosc sender with Twisted.
     3 Example of a UDP txosc sender with Twisted.
     4 
     4 
     5 This example is in the public domain.
     5 This example is in the public domain.
     6 """
     6 """
     7 
     7 
       
     8 import argparse
     8 import csv
     9 import csv
     9 import sys
    10 import sys
    10 import time
    11 import time
    11 
    12 
    12 from twisted.internet import reactor
    13 from twisted.internet import reactor
    44         print("Goodbye.")
    45         print("Goodbye.")
    45         reactor.callLater(0.1, reactor.stop)
    46         reactor.callLater(0.1, reactor.stop)
    46 
    47 
    47 if __name__ == "__main__":
    48 if __name__ == "__main__":
    48 
    49 
    49     with open(sys.argv[1], 'rU') as datafile:
    50     parser = argparse.ArgumentParser(description='Simulate an (osc) pianoroll client.')
       
    51     parser.add_argument('datafile', metavar='DATAFILE', help='The file containing the pianoroll data (CSV).')
       
    52     parser.add_argument('-e', '--event', dest='event', metavar='EVENT', required=True, help='the event code.')
       
    53 
       
    54     args = parser.parse_args()
       
    55 
       
    56     with open(args.datafile, 'rU') as datafile:
    50         reader = csv.reader(datafile, delimiter=' ')
    57         reader = csv.reader(datafile, delimiter=' ')
    51         app = UDPSenderApplication(9090, "127.0.0.1", '/pianoroll/mons_samedi25/', list(reader))
    58         app = UDPSenderApplication(9090, "127.0.0.1", "/pianoroll/%s/" % args.event, list(reader))
    52 
    59 
    53     reactor.run()
    60     reactor.run()