-
Notifications
You must be signed in to change notification settings - Fork 109
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
cleanup mypy errors, address review comments, add response support to…
… UDP server
- Loading branch information
Bob Haddleton
authored and
Bob Haddleton
committed
Aug 17, 2024
1 parent
d89c241
commit 7b5d8ea
Showing
20 changed files
with
767 additions
and
367 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
"""Small example OSC client | ||
This program sends 10 random values between 0.0 and 1.0 to the /filter address, | ||
waiting for 1 seconds between each value. | ||
""" | ||
|
||
import argparse | ||
import random | ||
import time | ||
|
||
from pythonosc import udp_client | ||
|
||
if __name__ == "__main__": | ||
parser = argparse.ArgumentParser() | ||
parser.add_argument("--ip", default="127.0.0.1", help="The ip of the OSC server") | ||
parser.add_argument( | ||
"--port", type=int, default=5005, help="The port the OSC server is listening on" | ||
) | ||
args = parser.parse_args() | ||
|
||
client = udp_client.SimpleUDPClient(args.ip, args.port) | ||
|
||
for x in range(10): | ||
client.send_message("/filter", random.random()) | ||
reply = next(client.get_messages(2)) | ||
print(str(reply)) | ||
time.sleep(1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
"""Small example OSC server | ||
This program listens to several addresses, and prints some information about | ||
received packets. | ||
""" | ||
|
||
import argparse | ||
import math | ||
|
||
from pythonosc.dispatcher import Dispatcher | ||
from pythonosc import osc_server | ||
|
||
|
||
def echo_handler(client_addr, unused_addr, args): | ||
print(unused_addr, args) | ||
return (unused_addr, args) | ||
|
||
|
||
if __name__ == "__main__": | ||
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=5005, help="The port to listen on") | ||
args = parser.parse_args() | ||
|
||
dispatcher = Dispatcher() | ||
dispatcher.set_default_handler(echo_handler, True) | ||
|
||
server = osc_server.ThreadingOSCUDPServer((args.ip, args.port), dispatcher) | ||
print("Serving on {}".format(server.server_address)) | ||
server.serve_forever() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.