In [37]:
import numpy as np
from pygrfnn import Zparam, GrFNN
from pygrfnn.network import Model
from pygrfnn.vis import tf_detail

# test signal
sr, dur = 8000, 0.5
t = np.linspace(0, dur, sr*dur)
a = np.array([0.5, 0.7])
f = np.array([440, 320])
x = np.sum(a*np.cos(2*np.pi*np.outer(t,f)),1)

# model definition (linear regime)
params = Zparam(alpha=-0.5,
                beta1=0.5,
                beta2=-0.05,
                epsilon=1.0)
layer = GrFNN(params,
              frequency_range=(100, 2000),
              num_oscs=256)
model = Model()
model.add_layer(layer, input_channel=0)

# run the model
model.run(x, t, 1.0/sr)

# output visualizations
tf_detail(layer.Z, t, layer.f, x=x,
          t_detail=0.9*np.max(t),
          title="Oscillation Magnitude")
# tf_detail(layer.Z, t, layer.f, x=x,
#           t_detail=0.9*np.max(t),
#           title="Oscillation Phase",
#           display_op=np.angle)


# savefig('/Users/jorgeh/Documents/CCRMA/research/ismir2015/figs/simple-example1.pdf', 
#         dpi=None, facecolor='w', edgecolor='w',
#         orientation='portrait', 
#         papertype=None, format='PDF',
#         transparent=False, bbox_inches=None, pad_inches=0.1,
#         frameon=None)


4000/4000 done!
Out[37]:
(<matplotlib.figure.Figure at 0x14607ef10>,
 <matplotlib.image.AxesImage at 0x12ea5bb90>,
 [<matplotlib.lines.Line2D at 0x12e9328d0>],
 [<matplotlib.lines.Line2D at 0x12ea11950>],
 [<matplotlib.lines.Line2D at 0x12ea1c310>])

In [39]:
import numpy as np
from pygrfnn import Zparam, GrFNN
from pygrfnn.network import Model
from pygrfnn.vis import tf_detail

# test signal
sr, dur = 8000, 0.05
t = np.linspace(0, dur, sr*dur)
f = np.linspace(220, 1440, sr*dur)
phi = cumsum(f/sr)
x = np.cos(2*np.pi*phi)

# model definition (linear regime)
params = Zparam(alpha=-0.25,
                beta1=0,
                beta2=0,
                epsilon=1.0)
layer = GrFNN(params,
              frequency_range=(100, 2000),
              num_oscs=256)
model = Model()
model.add_layer(layer, input_channel=0)

# run the model
model.run(x, t, 1.0/sr)

# output visualizations
tf_detail(layer.Z, t, layer.f, x=x,
          t_detail=0.9*np.max(t),
          title="Oscillation Magnitude")
tf_detail(layer.Z, t, layer.f, x=x,
          t_detail=0.9*np.max(t),
          title="Oscillation Phase",
          display_op=np.angle)


# savefig('/Users/jorgeh/Documents/CCRMA/research/ismir2015/figs/simple-example1.pdf', 
#         dpi=None, facecolor='w', edgecolor='w',
#         orientation='portrait', 
#         papertype=None, format='PDF',
#         transparent=False, bbox_inches=None, pad_inches=0.1,
#         frameon=None)


400/400 done!
Out[39]:
(<matplotlib.figure.Figure at 0x11c6a7fd0>,
 <matplotlib.image.AxesImage at 0x124a30ed0>,
 [<matplotlib.lines.Line2D at 0x11cabafd0>],
 [<matplotlib.lines.Line2D at 0x11c668810>],
 [<matplotlib.lines.Line2D at 0x1203e5b90>])

In [ ]: