Last active
July 25, 2024 23:33
-
-
Save hcgatewood/e1f42b371ab56037eeda to your computer and use it in GitHub Desktop.
Print a random note at the passed interval, defaulting to every 4 seconds
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
#!/usr/bin/env python3 | |
""" | |
random_note.py prints a random musical note at the passed interval (seconds). | |
If no interval passed, defaults 4 seconds. | |
""" | |
import itertools | |
import random | |
import time | |
import sys | |
notes = "A B C D E F G".split() | |
acc_symbs = ["", "♯", "♭"] | |
combinations = ["".join(el) for el in itertools.product(notes, acc_symbs)] | |
try: | |
interval = int(sys.argv[1]) | |
except: | |
interval = 4 | |
while True: | |
time.sleep(interval) | |
print(random.choice(combinations)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment