Created
September 6, 2024 19:23
-
-
Save attilam/c27344dfeca42d9f8132c6238026253e to your computer and use it in GitHub Desktop.
Four on the Floor
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
# install: `pip install mido python-rtmidi` | |
import mido | |
counter = 0 | |
step = 1 | |
beat = 1 | |
bar = 1 | |
viz = "+---+---+---+---" | |
print("\033[H\033[2J") | |
with mido.open_input() as inport: | |
for message in inport: | |
if message.type == 'start': | |
counter = 0 | |
step = 1 | |
beat = 1 | |
bar = 1 | |
print("\033[H\033[2JSTART") | |
if message.type == 'clock': | |
counter += 1 | |
v = int(counter / 6) | |
step = v % 4 + 1 | |
beat = int(v / 4) % 4 + 1 | |
bar = int(v / 16) + 1 | |
disp = viz[:(v % 16)] + ("O" if step == 1 else "o") + viz[(v % 16 + 1):] | |
print(f"\033[F|{disp}| - {bar}:{beat}:{step}") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment