Skip to content

Instantly share code, notes, and snippets.

@catboy1357
Last active August 1, 2023 00:35
Show Gist options
  • Save catboy1357/39047a8ce5cd6e60ccbb9d3cad082f06 to your computer and use it in GitHub Desktop.
Save catboy1357/39047a8ce5cd6e60ccbb9d3cad082f06 to your computer and use it in GitHub Desktop.
# requires the python-osc library. If you need to install the modual use:
# "pip install python-osc"
from pythonosc.udp_client import SimpleUDPClient
from datetime import datetime as d
from time import sleep
# sets up an osc sender
client = SimpleUDPClient("127.0.0.1", 9000)
# main
while True:
# Gets the time
time = d.now()
# Sends hour min sec
client.send_message(f'/avatar/parameters/sec', time.second)
client.send_message(f'/avatar/parameters/min', time.minute)
client.send_message(f'/avatar/parameters/hour', time.hour % 12)
print(f'\r{time.hour % 12}:{time.minute}:{time.second}', end='')
# update rate
sleep(1)
@hakanai
Copy link

hakanai commented Mar 10, 2023

Shortcut:

>>> time = d.now()
>>> time.hour
12
>>> time.minute
24
>>> time.second
54

@catboy1357
Copy link
Author

Thank you for the simplification; I was not aware of this shortcut.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment