#!/usr/bin/env python
# -*- coding: utf-8 -*-

import unittest
import array
import sys
from math import sin, pi

import ssc
from ssc.aux import max_int, min_int, WIDTH_TYPE

MAX_8 = max_int(1)
MAX_16 = max_int(2)
MAX_32 = max_int(4)

MIN_8 = max_int(1)
MIN_16 = min_int(2)
MIN_32 = min_int(4)

# Defines Sample frecuency/bitrate and test_data subsections 
TEST_FS = 44100
TEST_T = 0.5

'''
        # test_t seconds of 440 hz sinouidal sound at 0.9 amplitude
        freq = 440.0 * 2 * pi / TEST_FS
        for i in range(samples):
            f = 0.9 * sin(freq * i)
            raw8.append(int(MAX_8 * f))
            raw16.append(int(MAX_16 * f))
            raw32.append(int(MAX_32 * f))
import array
import sys
import time
import os.path
import wave
import audioop

from intelhex import IntelHex

CHUNK = 1024        # How many samples send to player

COLUMN = 8          # Prety print of values
PAD_FILL = b'\x00'  # Padding fill of 32 byte blocks

BITS = 2
MAX = max_int(BITS)

# Try to grab pyaudio
try:
    import pyaudio
    _AUDIO = True
except ImportError:
    _AUDIO = False


class SoundsLib(object):
    """ Creates a sound lib of BTc encode sounds """

    def __init__(self, bitrate =22000, soft=21, delta=MAX//21 , codec='BTc1.0'):
        """
        Initiate a BTc SoundLib