本文整理汇总了Python中pythonosc.osc_server.ThreadingOSCUDPServer方法的典型用法代码示例。如果您正苦于以下问题:Python osc_server.ThreadingOSCUDPServer方法的具体用法?Python osc_server.ThreadingOSCUDPServer怎么用?Python osc_server.ThreadingOSCUDPServer使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pythonosc.osc_server
的用法示例。
在下文中一共展示了osc_server.ThreadingOSCUDPServer方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: connect_to_tcp
# 需要导入模块: from pythonosc import osc_server [as 别名]
# 或者: from pythonosc.osc_server import ThreadingOSCUDPServer [as 别名]
def connect_to_tcp():
print("starting")
# Connect to TCP Port
parser = argparse.ArgumentParser()
parser.add_argument("--ip",
default="127.0.0.1",
help="The ip to listen on")
parser.add_argument("--port",
type=int,
default=5000,
help="The port to listen on")
args = parser.parse_args()
new_dispatcher = dispatcher.Dispatcher()
new_dispatcher.map("/debug", print)
new_dispatcher.map("/muse/eeg", eeg_handler, "EEG")
server = osc_server.ThreadingOSCUDPServer(
(args.ip, args.port), new_dispatcher)
print("Serving on {}".format(server.server_address))
# Collect from port
server.serve_forever()
示例2: main
# 需要导入模块: from pythonosc import osc_server [as 别名]
# 或者: from pythonosc.osc_server import ThreadingOSCUDPServer [as 别名]
def main(
interface: 'Interface to listen on' = 'localhost',
port: 'Port to listen to' = 9000,
freq: 'Audio output frequency (frames/sec)' = 44100,
channels: 'Audio channels (1 or 2)' = 2,
):
"""
Bidirectional OSC bridge for SunVox DLL.
"""
process = sunvox.dll
process.init(None, freq, channels, 0)
dispatcher = SunVoscDispatcher(process)
watch_thread = threading.Thread(target=dispatcher.watch_playback)
watch_thread.start()
server = osc_server.ThreadingOSCUDPServer((interface, port), dispatcher)
logging.info('Serving on %s:%s', *server.server_address)
try:
server.serve_forever()
except KeyboardInterrupt:
print()
logging.info('Exiting')
process.deinit()
return 0
示例3: __init__
# 需要导入模块: from pythonosc import osc_server [as 别名]
# 或者: from pythonosc.osc_server import ThreadingOSCUDPServer [as 别名]
def __init__(self):
self.log = logging.getLogger("pybinsim.OscReceiver")
self.log.info("oscReceiver: init")
# Basic settings
self.ip = '127.0.0.1'
self.port = 10000
self.maxChannels = 100
# Default values; Stores filter keys for all channles/convolvers
self.filters_updated = [True] * self.maxChannels
self.defaultValue = (0, 0, 0, 0, 0, 0)
self.valueList = [self.defaultValue] * self.maxChannels
# self.valueList = [()] * self.maxChannels
self.soundFileList = ''
self.soundFileNew = False
osc_dispatcher = dispatcher.Dispatcher()
osc_dispatcher.map("/pyBinSim", self.handle_filter_input)
osc_dispatcher.map("/pyBinSimFile", self.handle_file_input)
self.server = osc_server.ThreadingOSCUDPServer(
(self.ip, self.port), osc_dispatcher)
示例4: __init__
# 需要导入模块: from pythonosc import osc_server [as 别名]
# 或者: from pythonosc.osc_server import ThreadingOSCUDPServer [as 别名]
def __init__(self, interface='localhost', port=9001,
sunvosc_host='localhost', sunvosc_port=9000):
self.interface = interface
self.port = port
self.sunvosc_host = sunvosc_host
self.sunvosc_port = sunvosc_port
self.client = udp_client.UDPClient(sunvosc_host, sunvosc_port)
self.dispatcher = PeerDispatcher()
server = osc_server.ThreadingOSCUDPServer(
(interface, port), self.dispatcher)
logging.info('Peer serving on %s:%s', *server.server_address)
self.server_thread = threading.Thread(target=server.serve_forever)
self.server_thread.start()
self.engine = None
self.generators = OrderedDict()
self.default_velocity = 128
b = OscMessageBuilder('/slot0/inform/start')
b.add_arg(interface, 's')
b.add_arg(port, 'i')
msg = b.build()
self.client.send(msg)
示例5: start
# 需要导入模块: from pythonosc import osc_server [as 别名]
# 或者: from pythonosc.osc_server import ThreadingOSCUDPServer [as 别名]
def start(self):
"""Start receiving and processing EEG data.
"""
self.started = True
if isinstance(self.incoming, str): # LSL inlet
self.eeg_thread = Thread(target=self._update_eeg_lsl)
self.eeg_thread.daemon = True
self.eeg_thread.start()
else: # OSC input stream
if USE_LIBLO:
self._osc_server.add_method('/muse/eeg', None,
self._update_eeg_liblo_osc)
self._osc_server.add_method('/muse/acc', None,
self._update_acc_liblo_osc)
self._osc_server.add_method('/muse/gyro', None,
self._update_gyro_liblo_osc)
self._osc_server.start()
else:
self._dispatcher.map('Person2/eeg',
self._update_eeg_python_osc, 'EEG')
self._osc_server = osc_server.ThreadingOSCUDPServer(
('127.0.0.1', self.incoming['port']), self._dispatcher)
print('OSC server initialized at port {}.'.format(
self.incoming['port']))
self._server_thread = Thread(
target=self._osc_server.serve_forever)
self._server_thread.start()
示例6: start_server_comms
# 需要导入模块: from pythonosc import osc_server [as 别名]
# 或者: from pythonosc.osc_server import ThreadingOSCUDPServer [as 别名]
def start_server_comms(ip, port, paths):
# paths = ['random_integer', 'circle']
parser = argparse.ArgumentParser()
parser.add_argument("--ip", default=ip, help="The ip to listen on")
parser.add_argument("--port", type=int, default=port, help="The port to listen on")
args = parser.parse_args()
osc_statemachine['args'] = args
dispatch = dispatcher.Dispatcher()
for path in paths:
dispatch.map("/" + path, general_handler)
osc_statemachine['dispatcher'] = dispatch
try:
server = osc_server.ThreadingOSCUDPServer((args.ip, args.port), dispatch)
print("Serving on {}".format(server.server_address))
# makes it non blocking, and serves on another thread, how exactly the dispatch
# commands are able to callback into the current thread is kinda magical. This
# seems to work, but something tells me this is brittle af.
server_thread = threading.Thread(target=server.serve_forever)
server_thread.start()
osc_statemachine['server_thread'] = server_thread
osc_statemachine['server'] = server
except:
print('already active')
示例7: run
# 需要导入模块: from pythonosc import osc_server [as 别名]
# 或者: from pythonosc.osc_server import ThreadingOSCUDPServer [as 别名]
def run(self):
# Start listening server
ip = self.myConfig["settings"]["listenIP"]
port = self.myConfig["settings"]["port"]
d = dispatcher.Dispatcher()
# Catch workspace updates which tell us we have a new cue position
d.map("/update/workspace/*/cueList/*/playbackPosition", self.updatePlaybackPosition)
d.map("/reply/cue_id/*/displayName", self.updateNextCueName)
d.map("/reply/workspace/*/runningCues", self.updateCurrentCue)
d.map("/reply/workspace/*/runningOrPausedCues", self.updateCurrentCue)
d.map("/reply/workspace/*/cueList", self.updateCurrentCue)
d.map("/reply/cue_id/*/isPaused", self.updateCurrentCueStatus)
d.map("/reply/cue_id/*/isRunning", self.updateCurrentCueStatus)
for action in self.myConfig["actions"]:
for actionName in action.keys():
if isinstance(action[actionName], dict):
if re.match("OSC-", actionName, re.I):
n = re.sub("OSC-", "", actionName, flags=re.I)
self.logger.debug("Registering action for {}".format(n))
d.map(n, self.receiveOSCMessage, actionName)
self.logger.debug("Starting OSC server on {} port {}".format(ip, port))
server = osc_server.ThreadingOSCUDPServer((ip, port), d)
self.server_thread = threading.Thread(target = server.serve_forever)
self.server_thread.start()
while self.running:
pass
self.logger.debug("Stopping server")
server.shutdown()
示例8: start_server
# 需要导入模块: from pythonosc import osc_server [as 别名]
# 或者: from pythonosc.osc_server import ThreadingOSCUDPServer [as 别名]
def start_server(serverName):
listenIP = config()['settings']['listenIP']
listenPort = config()['oscServers'][serverName]['responsePort']
d = dispatcher.Dispatcher()
for string, fn in config()['oscServers'][serverName]['responseCallback'].items():
d.map(string, get_function(fn))
global servers
servers = {}
print("Starting server on {}, port {}".format(listenIP, listenPort))
server = osc_server.ThreadingOSCUDPServer((listenIP, listenPort), d)
servers[serverName] = server
server_thread = threading.Thread(target=server.serve_forever)
server_thread.start()