# Path: pym2149/const.py



from .const import u4
from minBlepy.shapes import floatdtype
import math, numpy as np
# pym2149 is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# pym2149 is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with pym2149.  If not, see <http://www.gnu.org/licenses/>.


signaldtype = np.uint8 # Slightly faster than plain old int.
floatdtype = floatdtype
log2 = math.log(2)

def level5toamp(level):
    return 2 ** ((level - 31) / 4)

def _amptolevel4(amp):
    return max(0, int(round(15 + 2 * math.log(amp) / log2)))

def level4to5(level4):
    return level4 * 2 + 1 # Observe 4-bit 0 is 5-bit 1.

class Shape:

    defaultintrolen = 0

# Path: pym2149/const.py



# Path: pym2149/shapes.py
from .const import u4
from minBlepy.shapes import floatdtype
import math, numpy as np

# pym2149 is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# pym2149 is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with pym2149.  If not, see <http://www.gnu.org/licenses/>.


signaldtype = np.uint8 # Slightly faster than plain old int.
floatdtype = floatdtype
log2 = math.log(2)

def level5toamp(level):
    return 2 ** ((level - 31) / 4)

def _amptolevel4(amp):
    return max(0, int(round(15 + 2 * math.log(amp) / log2)))

def level4to5(level4):
    return level4 * 2 + 1 # Observe 4-bit 0 is 5-bit 1.

class Shape:

    defaultintrolen = 0

    pyrbotype = dict(buf = [signaldtype], size = u4, introlen = u4)