
# --------------------------------------------------------------------------------------------------
# Constants
# --------------------------------------------------------------------------------------------------

SIM_CLOCKS       = 8000
TESTING          = True

NUM_CHANNELS     = 8
CLK_RATE         = 16777216
SAMPLE_RATE      = 16384
SAMPLE_CYCS      = CLK_RATE // SAMPLE_RATE
CLK_PERIOD       = 1 / CLK_RATE
BAUDRATE         = 38400
SAMPLE_ADDR_BITS = 8
SAMPLE_BITS      = 4
VOL_BITS         = 4
PHASE_BITS       = 24

CHANNEL_INIT_VALUES = [
	{ 'rate': 0x008000, 'length': 0x1F, 'start': 0x00, 'vol': 0x0F }, # 0
	{ 'rate': 0x00C000, 'length': 0x1F, 'start': 0x00, 'vol': 0x0F }, # 1
	{ 'rate': 0x012000, 'length': 0x1F, 'start': 0x00, 'vol': 0x0F }, # 2
	{ 'rate': 0x024000, 'length': 0x1F, 'start': 0x00, 'vol': 0x0F }, # 3
	{ 'rate': 0x003000, 'length': 0x1F, 'start': 0x20, 'vol': 0x0F }, # 4
	{ 'rate': 0x004800, 'length': 0x1F, 'start': 0x20, 'vol': 0x0F }, # 5
	{ 'rate': 0x006C00, 'length': 0x1F, 'start': 0x20, 'vol': 0x0F }, # 6
	{ 'rate': 0x00D800, 'length': 0x1F, 'start': 0x20, 'vol': 0x0F }, # 7
]

DUMMY_RAM = [
	# sine
	0x88, 0x9A, 0xBB, 0xCD, 0xDE, 0xEF, 0xFF, 0xFF,
	0xFF, 0xFF, 0xFF, 0xEE, 0xDD, 0xCB, 0xBA, 0x98,
	0x87, 0x65, 0x44, 0x32, 0x21, 0x11, 0x00, 0x00,
	0x00, 0x00, 0x01, 0x11, 0x22, 0x34, 0x45, 0x67,

	# saw
	0x00, 0x00, 0x11, 0x11, 0x22, 0x22, 0x33, 0x33,
	0x44, 0x44, 0x55, 0x55, 0x66, 0x66, 0x77, 0x77,
	0x88, 0x88, 0x99, 0x99, 0xAA, 0xAA, 0xBB, 0xBB,
	0xCC, 0xCC, 0xDD, 0xDD, 0xEE, 0xEE, 0xFF, 0xFF,

	# tri
	0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77,
	0x88, 0x99, 0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0xFF,
	0xFF, 0xEE, 0xDD, 0xCC, 0xBB, 0xAA, 0x99, 0x88,
	0x77, 0x66, 0x55, 0x44, 0x33, 0x22, 0x11, 0x00,

	# square
	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
	0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
	0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
] + [0] * 128