# Path: auana/common.py
# def hann(M, sym=True):
# 	'''
# 	hanning window.
# 	'''
# 	# Docstring adapted from NumPy's hanning function
# 	if M < 1:
# 		return np.array([])
# 	if M == 1:
# 		return np.ones(1, 'd')
# 	odd = M % 2
# 	if not sym and not odd:
# 		M = M + 1
# 		n = np.arange(0, M)
# 		w = 0.5 - 0.5 * np.cos(2.0 * np.pi * n / (M - 1))
# 	if not sym and not odd:
# 		w = w[:-1]
# 	return w


import os
import numpy as np
from ctypes import *
from auana.common import hann
#Max Mel Frequency
MEL = (2596*np.log10(1+DEF_MAX_FRQ/700.0))/(DEF_FIN_BIT+1.0)


###########################################################################
# The upper and lower bounds of sub-band. 
# framerate/fft_size = 44100/4096 = 22050/2048
BandTable_1 = [[0  ,   8], [4  ,  12], [8,    17], [12 ,  22], 
			   [17 ,  27], [22 ,  32], [27 ,  38], [32 ,  44], 
			   [38 ,  51], [44 ,  58], [51 ,  65], [58 ,  73], 
			   [65 ,  81], [73 ,  89], [81 ,  99], [89 , 108], 
			   [99 , 119], [108, 130], [119, 141], [130, 153], 
			   [141, 166], [153, 180], [166, 195], [180, 210], 
			   [195, 226], [210, 244], [226, 262], [244, 282], 
			   [262, 302], [282, 324], [302, 347], [324, 372]]
# framerate/fft_size = 44100/2048
 
# framerate/fft_szie = 22050/4096
BandTable_2 = [[0 ,   16], [8  ,  25], [16 ,  34], [25 ,  44], 
			   [34 ,  54], [44 ,  65], [54 ,  76], [65 ,  89], 
			   [76 , 102], [89 , 115], [102, 130], [115, 145],
			   [130, 162], [145, 179], [162, 197], [179, 217], 
			   [197, 237], [217, 259], [237, 282], [259, 307], 
			   [282, 333], [307, 360], [333, 390], [360, 420], 
			   [390, 453], [420, 488], [453, 524], [488, 563], 
			   [524, 605], [563, 648], [605, 694], [648, 743]]

BandTable_3 = [(0, 4), (2, 6), (4, 8), (6, 11), (8, 13), (11, 16), 
				(13, 19), (16, 22), (19, 25), (22, 29), (25, 33), (29, 36), (33, 40),
				(36, 45), (40, 49), (45, 54), (49, 59), (54, 65), (59, 71), (65, 77), 

# Path: auana/common.py
# def hann(M, sym=True):
# 	'''
# 	hanning window.
# 	'''
# 	# Docstring adapted from NumPy's hanning function
# 	if M < 1:
# 		return np.array([])
# 	if M == 1:
# 		return np.ones(1, 'd')
# 	odd = M % 2
# 	if not sym and not odd:
# 		M = M + 1
# 		n = np.arange(0, M)
# 		w = 0.5 - 0.5 * np.cos(2.0 * np.pi * n / (M - 1))
# 	if not sym and not odd:
# 		w = w[:-1]
# 	return w


# Path: auana/recognize.py
import os
import numpy as np
from ctypes import *
from auana.common import hann

#Max Mel Frequency
MEL = (2596*np.log10(1+DEF_MAX_FRQ/700.0))/(DEF_FIN_BIT+1.0)


###########################################################################
# The upper and lower bounds of sub-band. 
# framerate/fft_size = 44100/4096 = 22050/2048
BandTable_1 = [[0  ,   8], [4  ,  12], [8,    17], [12 ,  22], 
			   [17 ,  27], [22 ,  32], [27 ,  38], [32 ,  44], 
			   [38 ,  51], [44 ,  58], [51 ,  65], [58 ,  73], 
			   [65 ,  81], [73 ,  89], [81 ,  99], [89 , 108], 
			   [99 , 119], [108, 130], [119, 141], [130, 153], 
			   [141, 166], [153, 180], [166, 195], [180, 210], 
			   [195, 226], [210, 244], [226, 262], [244, 282], 
			   [262, 302], [282, 324], [302, 347], [324, 372]]
# framerate/fft_size = 44100/2048
 
# framerate/fft_szie = 22050/4096
BandTable_2 = [[0 ,   16], [8  ,  25], [16 ,  34], [25 ,  44], 
			   [34 ,  54], [44 ,  65], [54 ,  76], [65 ,  89], 
			   [76 , 102], [89 , 115], [102, 130], [115, 145],
			   [130, 162], [145, 179], [162, 197], [179, 217], 
			   [197, 237], [217, 259], [237, 282], [259, 307], 
			   [282, 333], [307, 360], [333, 390], [360, 420], 
			   [390, 453], [420, 488], [453, 524], [488, 563], 
			   [524, 605], [563, 648], [605, 694], [648, 743]]

BandTable_3 = [(0, 4), (2, 6), (4, 8), (6, 11), (8, 13), (11, 16), 
				(13, 19), (16, 22), (19, 25), (22, 29), (25, 33), (29, 36), (33, 40),
				(36, 45), (40, 49), (45, 54), (49, 59), (54, 65), (59, 71), (65, 77), 

				(71, 83), (77, 90), (83, 98), (90, 105), (98, 113), (105, 122), (113, 131), 