# Path: pym2149/const.py

# 
# 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 .const import u4
from .shapes import floatdtype, signaldtype
from diapyr.util import enum
from pyrbo import generic, LOCAL, turbo, T
import numpy as np
@enum(
    ['float', floatdtype],
    ['int16', np.int16],
    ['short', np.short],
    ['signal', signaldtype],
)
class BufType:

    def __init__(self, _, dtype):
        self.dtype = dtype

    def __call__(self):
        return MasterBuf(self.dtype)

groupsets = {T: [{t.dtype for t in BufType.enum}]}

class Buf(metaclass = generic):

    def _turbo(**types):
        return turbo(types = dict(self = dict(buf = [T]), **types), groupsets = groupsets)

    def __init__(self, buf):
        self.buf = buf

    def __len__(self):
        return len(self.buf)

    def last(self):
        return self.buf[-1]


# Path: pym2149/const.py

# 
# 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/buf.py
from .const import u4
from .shapes import floatdtype, signaldtype
from diapyr.util import enum
from pyrbo import generic, LOCAL, turbo, T
import numpy as np

@enum(
    ['float', floatdtype],
    ['int16', np.int16],
    ['short', np.short],
    ['signal', signaldtype],
)
class BufType:

    def __init__(self, _, dtype):
        self.dtype = dtype

    def __call__(self):
        return MasterBuf(self.dtype)

groupsets = {T: [{t.dtype for t in BufType.enum}]}

class Buf(metaclass = generic):

    def _turbo(**types):
        return turbo(types = dict(self = dict(buf = [T]), **types), groupsets = groupsets)

    def __init__(self, buf):
        self.buf = buf

    def __len__(self):
        return len(self.buf)

    def last(self):
        return self.buf[-1]


    @_turbo(endframe = u4, that = dict(buf = [T]), i = u4)