當前位置: 首頁>>代碼示例>>Python>>正文


Python osc_server.ThreadingOSCUDPServer方法代碼示例

本文整理匯總了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() 
開發者ID:neurotechuoft,項目名稱:Wall-EEG,代碼行數:25,代碼來源:osc_input.py

示例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 
開發者ID:metrasynth,項目名稱:SunVOSC,代碼行數:25,代碼來源:cli.py

示例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) 
開發者ID:pyBinSim,項目名稱:pyBinSim,代碼行數:27,代碼來源:osc_receiver.py

示例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) 
開發者ID:metrasynth,項目名稱:solar-sails,代碼行數:23,代碼來源:osc.py

示例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() 
開發者ID:treeoftenere,項目名稱:Interactivity,代碼行數:30,代碼來源:museProc_tenere.py

示例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') 
開發者ID:zeffii,項目名稱:b3d_osc_panel,代碼行數:33,代碼來源:__init__.py

示例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() 
開發者ID:cscashby,項目名稱:pi-showcontrol,代碼行數:32,代碼來源:qlab.py

示例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() 
開發者ID:cscashby,項目名稱:pi-showcontrol,代碼行數:15,代碼來源:showcontrol.py


注:本文中的pythonosc.osc_server.ThreadingOSCUDPServer方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。