Created
October 24, 2013 21:17
-
-
Save cablehead/7145166 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| import sys | |
| import signal | |
| from vanilla import malt | |
| h = malt.Hub() | |
| ch = h.channel() | |
| def beat(name, step, offset=0): | |
| h.sleep(offset) | |
| while True: | |
| try: | |
| ch.put(name) | |
| except malt.Closed: | |
| return | |
| h.sleep(step) | |
| bpm = 120 | |
| step = (60*1000)/bpm | |
| offset = step/2 | |
| h.spawn(beat, "boom", step) | |
| h.spawn(beat, "tick", step, offset) | |
| @h.spawn | |
| def output(): | |
| for name in ch: | |
| sys.stdout.write(name + " ") | |
| sys.stdout.flush() | |
| shutdown = h.signals(signal.SIGINT, signal.SIGTERM) | |
| shutdown.get() | |
| ch.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment