# Path: pym2149/buf.py
# class BufType:
# 
#     def __init__(self, _, dtype):
#         self.dtype = dtype
# 
#     def __call__(self):
#         return MasterBuf(self.dtype)
# 
# Path: pym2149/const.py

# 
# Path: pym2149/nod.py
# class BufNode(Node):
# 
#     def __init__(self, buftype, channels = 1):
#         super().__init__()
#         self.masterbuf = buftype()
#         self.channels = channels
#         self.realcallimpl = self.callimpl
#         self.callimpl = self.makeresult
# 
#     def makeresult(self):
#         self.blockbuf = self.masterbuf.ensureandcrop(self.block.framecount * self.channels)
#         resultornone = self.realcallimpl()
#         if resultornone is not None:
#             return resultornone
#         return self.blockbuf
# 
# Path: pym2149/shapes.py
# def level5toamp(level):
# def _amptolevel4(amp):
# def level4to5(level4):
#     def level4to5(cls, data4, introlen = defaultintrolen):
#     def __init__(self, g, introlen = defaultintrolen):
#     def wavelength(self):
# def _meansin(x1, x2):
# def _sinsliceamp(i, n, skew):
# def _sinuslevel4(steps, maxlevel4, skew):
# def makesample5shape(data, signed, is4bit):
# class Shape:


from .buf import BufType
from .const import i4, i8, u1, u4, u8
from .nod import BufNode
from .shapes import Shape, signaldtype, toneshape
from pyrbo import LOCAL, turbo
import itertools, numpy as np
    block = dict(framecount = u4),
    index = i4,
    shape = Shape.pyrbotype,
)

class ShapeOsc(BufNode):

    progressdtype = u4

    def __init__(self, scale, periodreg):
        super().__init__(BufType.signal)
        self.stepsize = 0 # XXX: Move to reset?
        self.scale = scale
        self.periodreg = periodreg

    def reset(self, shape):
        self.index = -1
        self.progress = np.iinfo(self.progressdtype).max
        self.shape = shape

    def callimpl(self):
        self.index, self.progress, self.stepsize = self.shapeimpl()

    @turbo(
        self = dict(
            oscnodepyrbotype,
            progress = progressdtype,
            stepsize = u4,
            scale = u4,
            periodreg = dict(value = u4),

# Path: pym2149/buf.py
# class BufType:
# 
#     def __init__(self, _, dtype):
#         self.dtype = dtype
# 
#     def __call__(self):
#         return MasterBuf(self.dtype)
# 
# Path: pym2149/const.py

# 
# Path: pym2149/nod.py
# class BufNode(Node):
# 
#     def __init__(self, buftype, channels = 1):
#         super().__init__()
#         self.masterbuf = buftype()
#         self.channels = channels
#         self.realcallimpl = self.callimpl
#         self.callimpl = self.makeresult
# 
#     def makeresult(self):
#         self.blockbuf = self.masterbuf.ensureandcrop(self.block.framecount * self.channels)
#         resultornone = self.realcallimpl()
#         if resultornone is not None:
#             return resultornone
#         return self.blockbuf
# 
# Path: pym2149/shapes.py
# def level5toamp(level):
# def _amptolevel4(amp):
# def level4to5(level4):
#     def level4to5(cls, data4, introlen = defaultintrolen):
#     def __init__(self, g, introlen = defaultintrolen):
#     def wavelength(self):
# def _meansin(x1, x2):
# def _sinsliceamp(i, n, skew):
# def _sinuslevel4(steps, maxlevel4, skew):
# def makesample5shape(data, signed, is4bit):
# class Shape:


# Path: pym2149/osc2.py
from .buf import BufType
from .const import i4, i8, u1, u4, u8
from .nod import BufNode
from .shapes import Shape, signaldtype, toneshape
from pyrbo import LOCAL, turbo
import itertools, numpy as np

    block = dict(framecount = u4),
    index = i4,
    shape = Shape.pyrbotype,
)

class ShapeOsc(BufNode):

    progressdtype = u4

    def __init__(self, scale, periodreg):
        super().__init__(BufType.signal)
        self.stepsize = 0 # XXX: Move to reset?
        self.scale = scale
        self.periodreg = periodreg

    def reset(self, shape):
        self.index = -1
        self.progress = np.iinfo(self.progressdtype).max
        self.shape = shape

    def callimpl(self):
        self.index, self.progress, self.stepsize = self.shapeimpl()

    @turbo(
        self = dict(
            oscnodepyrbotype,
            progress = progressdtype,
            stepsize = u4,
            scale = u4,
            periodreg = dict(value = u4),

            eager = u1,