import numpy as n, pylab as p
class BasicTables:
    """Provide primary tables for lookup

    create sine, triangle, square and saw wave periods
    with size samples.
    """
    def __init__(self,size=2048):
        self.size=size
        self.makeTables(size)
    def makeTables(self,size):
        self.sine=n.sin(n.linspace(0,2*n.pi,size,endpoint=False))
        self.saw=n.linspace(-1,1,size)
        self.square=n.hstack( ( n.ones(size/2)*-1 , n.ones(size/2) )  )
        foo=n.linspace(-1,1,size/2,endpoint=False)
        self.triangle=n.hstack(  ( foo , foo*-1 )   )
    def drawTables(self):
        p.plot(self.sine,    "-")
        p.plot(self.saw,     "-")
        p.plot(self.square,  "-")
        p.plot(self.triangle,"-")
        p.xlim(-self.size*0.1,self.size*1.1)
        p.ylim(-1.1,1.1)
        p.show()


