from __future__ import division
from deltasigma import synthesizeNTF, simulateDSM
from deltasigma import calculateSNR, ds_hann, bilogplot
import pylab as plt
import numpy as np
f0 = 1./8
OSR = 64
order = 8
N = 8192
H = synthesizeNTF(order, OSR, 1, 1.5, f0)
fB = int(np.ceil(N/(2. * OSR)))
ftest = int(np.round(f0*N + 1./3 * fB))
u = 0.5*np.sin(2*np.pi*ftest/N*np.arange(N))
v, xn, xmax, y = simulateDSM(u, H)
spec = np.fft.fft(v*ds_hann(N))/(N/4)
X = spec[:N/2 + 1]
plt.figure()
bilogplot(X, f0*N, ftest, (.03, .3, .3), (-140, 0, 10))