# 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 math
import numpy as np
from auana.common import hann

	ZCR_FALG  = False
	SIGNAL_START_FLAG = False

	EXPECT_ZCR = int(DEF_FFT_SIZE/framerate*base_frq*2)

	#data length
	data_len = len(wdata)
	num = int(data_len/DEF_FFT_SIZE)
	frames_num = t*framerate/DEF_FFT_SIZE
	print frames_num
	if frames_num>num:
		frames_num = num

	#frequency domain scale
	scale = (framerate/2.0)/(DEF_FFT_SIZE/2.0+1.0)

	max_freq = int(framerate/(2*scale))
	#
	NN = max_freq/(2*2000)

	thd = 0
	count = 0
	zcr_last = 0


	f_upper = int((base_frq+50)/scale)
	f_lower = int((base_frq-50)/scale)

	#hanning window

# 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/frequency.py
import math
import numpy as np
from auana.common import hann


	ZCR_FALG  = False
	SIGNAL_START_FLAG = False

	EXPECT_ZCR = int(DEF_FFT_SIZE/framerate*base_frq*2)

	#data length
	data_len = len(wdata)
	num = int(data_len/DEF_FFT_SIZE)
	frames_num = t*framerate/DEF_FFT_SIZE
	print frames_num
	if frames_num>num:
		frames_num = num

	#frequency domain scale
	scale = (framerate/2.0)/(DEF_FFT_SIZE/2.0+1.0)

	max_freq = int(framerate/(2*scale))
	#
	NN = max_freq/(2*2000)

	thd = 0
	count = 0
	zcr_last = 0


	f_upper = int((base_frq+50)/scale)
	f_lower = int((base_frq-50)/scale)

	#hanning window

	hanning = hann(DEF_FFT_SIZE, sym=0)