本文整理汇总了Python中OSC.OSCServer.getOSCAddressSpace方法的典型用法代码示例。如果您正苦于以下问题:Python OSCServer.getOSCAddressSpace方法的具体用法?Python OSCServer.getOSCAddressSpace怎么用?Python OSCServer.getOSCAddressSpace使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OSC.OSCServer
的用法示例。
在下文中一共展示了OSCServer.getOSCAddressSpace方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: printer
# 需要导入模块: from OSC import OSCServer [as 别名]
# 或者: from OSC.OSCServer import getOSCAddressSpace [as 别名]
def printer(addr, tags, stuff, source):
print "---"
print "received new osc msg from %s" % OSC.getUrlStr(source)
print "with addr : %s" % addr
print "typetags %s" % tags
print "data %s" % stuff
print "---"
# Hookup handlers
server.addMsgHandler("/1/elbow", elbow)
server.addMsgHandler("/1/head", head)
server.addMsgHandler("/1/btn", btn)
# Main
print "\nRegistered Callback Functions:"
for addr in server.getOSCAddressSpace():
print addr
print "\nStarting OSCServer. Use Ctrl-C to quit."
st = threading.Thread( target = server.serve_forever )
st.start()
try:
while 1:
#print "Waiting..."
sleep(5)
except KeyboardInterrupt:
print "\nClosing OSCServer."
server.close()
print "Waiting for Server thread to finish."
示例2: serve
# 需要导入模块: from OSC import OSCServer [as 别名]
# 或者: from OSC.OSCServer import getOSCAddressSpace [as 别名]
def serve(tree, wavdata, ps_correl_port, n_results, sc_synth_port, bus_num):
all_corrs = wavdata['all_corrs']
sample_times = wavdata['sample_times']
amps = wavdata['amp']
sc_synth_facing_server = OSCServer(("127.0.0.1", ps_correl_port))
sc_synth_client = sc_synth_facing_server.client
sc_synth_facing_server.addDefaultHandlers()
def transect_handler(osc_path=None, osc_tags=None, osc_args=None, osc_source=None):
node = osc_args[0]
idx = osc_args[1]
curr_amp = float(osc_args[2])
lookup = osc_args[3:] #ignores the amplitude
dists, indices = tree.query(lookup, k=n_results, return_distance=True)
dists = dists.flatten()
indices = indices.flatten()
print "hunting", lookup
times = sample_times[indices]
makeup_gains = (curr_amp/amps[indices])
# send scsynth bus messages
print "dispatching", bus_num, n_results*3, times, makeup_gains, dists
msg = OSCMessage("/c_setn", [bus_num, n_results*3])
#msg.extend()
msg.extend(times)
msg.extend(makeup_gains)
msg.extend(dists)
sc_synth_client.sendto(msg, ("127.0.0.1", sc_synth_port))
# This currently never gets called as pyOSC will ignore everything
# apart from the scsynth instance, in defiance of my understanding of UDP
# Need to set up an additional OSC server on a new port
# or somehow relay through scsynth
def quit_handler(path=None, tags=None, args=None, source=None):
print "quit", path, tags, args, source
sc_synth_facing_server.close()
def null_handler(path=None, tags=None, args=None, source=None):
pass
sc_synth_facing_server.addMsgHandler("/transect", transect_handler )
sc_synth_facing_server.addMsgHandler("/quit", quit_handler )
#sc_synth_facing_server.print_tracebacks = True
sc_synth_client.sendto(OSCMessage("/notify", 1),("127.0.0.1", sc_synth_port))
print sc_synth_facing_server.server_address, sc_synth_client.address(), sc_synth_facing_server.getOSCAddressSpace()
sc_synth_facing_server.running = True
# i = 0
# ptime = time.time()
# while True:
# i=i+1
# ntime = time.time()
# deltime = ntime - ptime
# if deltime>=1.0:
# print i, deltime
# ptime = ntime
# sc_synth_facing_server.handle_request()
# sc_lang_facing_server.handle_request()
#
# print "NOOOOOO"
# sc_synth_facing_server.close()
# sc_lang_facing_server.close()
return sc_synth_facing_server