Ejemplo n.º 1
0
def main():
    #@TODO: make names for all these magic numbers...
    
    screen = makeWindow(winsize=(200, 400))
    grad = makeGradient()
    
    black = pygame.Surface((80,10))
    black.fill((0,0,0))

    # the windowing array quiets down the edges of the sample
    # to prevent "clicking" at the edges:
    windowing = MLab.blackman(64)
    
    session = fakeSession()
    t = 0
    
    center= 81 # same as in creating the graph @TODO: consolidate these

    while keepLooping():

        # simulate aquiring data for 1/4th of a second (64 samples):
        time.sleep(0.25) 

        data = session[t:t+64] * windowing
        graph = makeSpectrogram(data)

        t += 64
        if t >= len(session):
            t = 0

        # draw the gradient, then cover part of it up:
        for i in range(32):
            screen.blit(grad, (20,         20+i*10))
            # left is blank for now:
            #screen.blit(black,(20 +(0       ), 20+i*10))
            # right side shows the data:
            screen.blit(black,(20+center+(graph[i]*10), 20+i*10))