yay tracking
This commit is contained in:
commit
f5bce34728
|
|
@ -0,0 +1,55 @@
|
||||||
|
# Distribution / packaging
|
||||||
|
.Python
|
||||||
|
build
|
||||||
|
develop-eggs
|
||||||
|
dist
|
||||||
|
downloads
|
||||||
|
eggs
|
||||||
|
.eggs
|
||||||
|
lib
|
||||||
|
lib64
|
||||||
|
parts
|
||||||
|
sdist
|
||||||
|
var
|
||||||
|
wheels
|
||||||
|
share/python-wheels
|
||||||
|
*.egg-info/
|
||||||
|
.installed.cfg
|
||||||
|
*.egg
|
||||||
|
MANIFEST
|
||||||
|
|
||||||
|
# Installer logs
|
||||||
|
pip-log.txt
|
||||||
|
pip-delete-this-directory.txt
|
||||||
|
|
||||||
|
# Unit test / coverage reports
|
||||||
|
htmlcov/
|
||||||
|
.tox/
|
||||||
|
.nox/
|
||||||
|
.coverage
|
||||||
|
.coverage.*
|
||||||
|
.cache
|
||||||
|
nosetests.xml
|
||||||
|
coverage.xml
|
||||||
|
*.cover
|
||||||
|
*.py,cover
|
||||||
|
.hypothesis/
|
||||||
|
.pytest_cache/
|
||||||
|
cover/
|
||||||
|
|
||||||
|
|
||||||
|
# pyenv
|
||||||
|
# For a library or package, you might want to ignore these files since the code is
|
||||||
|
# intended to run in multiple environments; otherwise, check them in:
|
||||||
|
.python-version
|
||||||
|
|
||||||
|
# Environments
|
||||||
|
.env
|
||||||
|
.venv
|
||||||
|
env
|
||||||
|
venv
|
||||||
|
ENV
|
||||||
|
env.bak
|
||||||
|
venv.bak
|
||||||
|
pyvenv.cfg
|
||||||
|
bin
|
||||||
|
|
@ -0,0 +1,5 @@
|
||||||
|
cffi==1.16.0
|
||||||
|
colorama==0.4.6
|
||||||
|
just-playback==0.1.7
|
||||||
|
pycparser==2.21
|
||||||
|
tinytag==1.10.1
|
||||||
|
|
@ -0,0 +1,110 @@
|
||||||
|
import time, math
|
||||||
|
from colorama import Fore, Back, Style
|
||||||
|
import functools
|
||||||
|
printr = functools.partial(print, end="")
|
||||||
|
|
||||||
|
###############
|
||||||
|
FRAMERATE=30
|
||||||
|
HEIGHT=24
|
||||||
|
WIDTH=80
|
||||||
|
###############
|
||||||
|
|
||||||
|
FRAME_NO=0
|
||||||
|
def clearBuffer():
|
||||||
|
global screen_buffer,screen_buffer_color
|
||||||
|
screen_buffer = [[" "]*WIDTH for y in range(HEIGHT)]
|
||||||
|
def clearBufferColor():
|
||||||
|
global screen_buffer,screen_buffer_color
|
||||||
|
screen_buffer_color = [[Style.RESET_ALL]*WIDTH for y in range(HEIGHT)]
|
||||||
|
def clearAllBuffers():
|
||||||
|
clearBuffer()
|
||||||
|
clearBufferColor()
|
||||||
|
def clearScreen():
|
||||||
|
printr('\033[2J')
|
||||||
|
|
||||||
|
def render(clear=True):
|
||||||
|
if clear:
|
||||||
|
clearScreen()
|
||||||
|
for y in range(HEIGHT):
|
||||||
|
for x in range(WIDTH):
|
||||||
|
printr(screen_buffer_color[y][x])
|
||||||
|
printr(screen_buffer[y][x])
|
||||||
|
print() #print \n
|
||||||
|
|
||||||
|
def renderLoop():
|
||||||
|
trackers()
|
||||||
|
draw()
|
||||||
|
render()
|
||||||
|
def framerateMaker(func, perSec):
|
||||||
|
interval = 1.0 / perSec
|
||||||
|
while True:
|
||||||
|
start_time = time.time()
|
||||||
|
func()
|
||||||
|
elapsed = time.time() - start_time
|
||||||
|
if elapsed < interval:
|
||||||
|
time.sleep(interval-elapsed)
|
||||||
|
################
|
||||||
|
|
||||||
|
class RenderException(Exception):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def printBuffer(x, y, val):
|
||||||
|
global screen_buffer
|
||||||
|
string=str(val)
|
||||||
|
if len(string) > WIDTH-x:
|
||||||
|
raise RenderException("Too Long")
|
||||||
|
for i, l in enumerate(string):
|
||||||
|
screen_buffer[y][x+i]=l
|
||||||
|
|
||||||
|
def clearLine(y):
|
||||||
|
global screen_buffer
|
||||||
|
screen_buffer[y]=[" "]*WIDTH
|
||||||
|
|
||||||
|
def drawBox(x,y,width,height,char):
|
||||||
|
if x+width > WIDTH or y+height > HEIGHT:
|
||||||
|
raise RenderException("Box too BIG")
|
||||||
|
for w_x in range(width):
|
||||||
|
for w_y in range(height):
|
||||||
|
if (w_x==0 or w_x==width-1) or (w_y==0 or w_y==height-1):
|
||||||
|
screen_buffer[y+w_y][x+w_x] = char
|
||||||
|
|
||||||
|
####################
|
||||||
|
def trackers():
|
||||||
|
global FRAME_NO
|
||||||
|
FRAME_NO+=1
|
||||||
|
|
||||||
|
def main():
|
||||||
|
setup()
|
||||||
|
try:
|
||||||
|
framerateMaker(renderLoop, FRAMERATE)
|
||||||
|
pass
|
||||||
|
except KeyboardInterrupt:
|
||||||
|
pass
|
||||||
|
teardown()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
def setup():
|
||||||
|
print("Setup")
|
||||||
|
print("Clearing")
|
||||||
|
clearScreen()
|
||||||
|
clearAllBuffers()
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
def teardown():
|
||||||
|
global dat
|
||||||
|
print("Teardown")
|
||||||
|
print("Teardown Complete")
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
def draw():
|
||||||
|
global FRAME_NO,screen_buffer,screen_buffer_color
|
||||||
|
clearAllBuffers()
|
||||||
|
drawBox(0,0,WIDTH,HEIGHT,'#')
|
||||||
|
printBuffer(1,1,str(FRAMERATE)+'fps '+str(FRAME_NO))
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
||||||
|
|
@ -0,0 +1,144 @@
|
||||||
|
import time
|
||||||
|
import math
|
||||||
|
import functools
|
||||||
|
printr = functools.partial(print, end="")
|
||||||
|
|
||||||
|
from just_playback import Playback
|
||||||
|
playback = Playback()
|
||||||
|
|
||||||
|
from colorama import Fore, Back, Style
|
||||||
|
|
||||||
|
###############
|
||||||
|
BPM=112
|
||||||
|
BEAT_SUB=16
|
||||||
|
|
||||||
|
FRAMERATE=(BPM*BEAT_SUB/60)
|
||||||
|
HEIGHT=24
|
||||||
|
WIDTH=64
|
||||||
|
###############
|
||||||
|
FRAME_NO=0
|
||||||
|
MUSIC_TIME=[0 for i in range(int(math.log2(BEAT_SUB)))]
|
||||||
|
###############
|
||||||
|
|
||||||
|
def clearBuffer():
|
||||||
|
global screen_buffer,screen_buffer_color
|
||||||
|
screen_buffer = [[" "]*WIDTH for y in range(HEIGHT)]
|
||||||
|
def clearBufferColor():
|
||||||
|
global screen_buffer,screen_buffer_color
|
||||||
|
screen_buffer_color = [[Style.RESET_ALL]*WIDTH for y in range(HEIGHT)]
|
||||||
|
def clearAllBuffers():
|
||||||
|
clearBuffer()
|
||||||
|
clearBufferColor()
|
||||||
|
def clearScreen():
|
||||||
|
printr('\033[2J')
|
||||||
|
def render(clear=True):
|
||||||
|
if clear:
|
||||||
|
clearScreen()
|
||||||
|
for y in range(HEIGHT):
|
||||||
|
for x in range(WIDTH):
|
||||||
|
printr(screen_buffer_color[y][x])
|
||||||
|
printr(screen_buffer[y][x])
|
||||||
|
print() #print \n
|
||||||
|
|
||||||
|
def renderLoop():
|
||||||
|
trackers()
|
||||||
|
draw()
|
||||||
|
render()
|
||||||
|
|
||||||
|
def framerateMaker(func, perSec):
|
||||||
|
interval = 1.0 / perSec
|
||||||
|
while True:
|
||||||
|
start_time = time.time()
|
||||||
|
func()
|
||||||
|
elapsed = time.time() - start_time
|
||||||
|
if elapsed < interval:
|
||||||
|
time.sleep(interval-elapsed)
|
||||||
|
|
||||||
|
################
|
||||||
|
|
||||||
|
def printBuffer(x, y, val):
|
||||||
|
global screen_buffer
|
||||||
|
string=str(val)
|
||||||
|
if len(string) > WIDTH-x:
|
||||||
|
return
|
||||||
|
for i, l in enumerate(string):
|
||||||
|
screen_buffer[y][x+i]=l
|
||||||
|
pass
|
||||||
|
|
||||||
|
def clearLine(y):
|
||||||
|
global screen_buffer
|
||||||
|
screen_buffer[y]=[" "]*WIDTH
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
####################
|
||||||
|
def trackers():
|
||||||
|
global FRAME_NO
|
||||||
|
global MUSIC_TIME
|
||||||
|
FRAME_NO+=1
|
||||||
|
MUSIC_TIME[0]=(FRAME_NO//BEAT_SUB)//4
|
||||||
|
MUSIC_TIME[1]=(FRAME_NO//BEAT_SUB//1)%4
|
||||||
|
MUSIC_TIME[2]=(FRAME_NO//(BEAT_SUB//2))%8
|
||||||
|
MUSIC_TIME[3]=(FRAME_NO//(BEAT_SUB//4))%16
|
||||||
|
#MUSIC_TIME[1]=(FRAME_NO//(BEAT_SUB*int(math.log2(BEAT_SUB//8))))%4
|
||||||
|
# MUSIC_TIME[2]=(FRAME_NO//8)%8
|
||||||
|
# for i in range(len(MUSIC_TIME)):
|
||||||
|
# MUSIC_TIME[i]=(FRAME_NO//2**(i+1)) % 2**(i)
|
||||||
|
|
||||||
|
def main():
|
||||||
|
setup()
|
||||||
|
try:
|
||||||
|
framerateMaker(renderLoop, FRAMERATE)
|
||||||
|
pass
|
||||||
|
except KeyboardInterrupt:
|
||||||
|
pass
|
||||||
|
teardown()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
def setup():
|
||||||
|
global playback
|
||||||
|
print("Setup")
|
||||||
|
print("Clearing")
|
||||||
|
clearScreen()
|
||||||
|
clearAllBuffers()
|
||||||
|
#playback.load_file('')
|
||||||
|
#playback.play()
|
||||||
|
|
||||||
|
|
||||||
|
def teardown():
|
||||||
|
print("Teardown")
|
||||||
|
print("Stopping Playback")
|
||||||
|
#playback.stop()
|
||||||
|
print("Teardown Complete")
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
cursorX=1
|
||||||
|
cooldown=[0]*4*4
|
||||||
|
def draw():
|
||||||
|
global screen_buffer,screen_buffer_color
|
||||||
|
global MUSIC_TIME
|
||||||
|
global cursorX,cooldown
|
||||||
|
clearAllBuffers()
|
||||||
|
for y in range(HEIGHT):
|
||||||
|
for x in range(WIDTH):
|
||||||
|
if x == 0 or x == WIDTH-1:
|
||||||
|
screen_buffer[y][x]='#'
|
||||||
|
if y == 0 or y == HEIGHT-1:
|
||||||
|
screen_buffer[y][x]='#'
|
||||||
|
printBuffer(0,3,"1234567890123456789012345678901234567890123456789012345678901234")
|
||||||
|
printBuffer(0,4,"0 1 2 3 4 5 6 ")
|
||||||
|
clearLine(5)
|
||||||
|
if cursorX >= WIDTH:
|
||||||
|
cursorX=0
|
||||||
|
screen_buffer[5][cursorX] = "x"
|
||||||
|
|
||||||
|
printBuffer(1,1,FRAME_NO)
|
||||||
|
printBuffer(6,1,FRAMERATE)
|
||||||
|
printBuffer(1,2,MUSIC_TIME)
|
||||||
|
cursorX=cursorX+1
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
||||||
Loading…
Reference in New Issue