import sys
import time

from gameduino import Gameduino, readarray
from GDprep import spectrum

gd = Gameduino(sys.argv[1], 115200)

gd.silence()

# gd.microcode(readarray("../j1firmware/helloworld.binle"))

for t in range(64):
    pitch = 300 + t * 16
    for (i, (f, a)) in enumerate(spectrum("thx.txt", cutoff = 64, volume = 440)):
        print f
        # tunef = 392 * (f / 392.)
        gd.voice(i, 0, int(4 * f * (pitch / 1000.)), a, a)
        # time.sleep(.05)
time.sleep(60)
