In [27]:
import numpy
from scipy import signal
import matplotlib.pyplot as plt
%matplotlib inline
import math
In [28]:
t = numpy.linspace(0.0, 1.0, 100, endpoint=True)
In [31]:
def ad_env(pos, ad):
env = 0.0
if pos < ad: # 1st segment: attack
env = pos / ad
else: # 2nd segment : decay
env = (1 - pos) / (1.0 - ad)
#return env*env
#return math.sqrt(env)
return env
v_ad_env = numpy.vectorize(ad_env, excluded=['ad'])
env_05 = v_ad_env(t, ad=0.05)
env_25 = v_ad_env(t, ad=0.25)
env_50 = v_ad_env(t, ad=0.5)
env_75 = v_ad_env(t, ad=0.75)
env_95 = v_ad_env(t, ad=0.95)
In [32]:
plt.figure(figsize=(100, 40))
plt.plot(t)
plt.plot(env_05)
plt.plot(env_25)
plt.plot(env_50)
plt.plot(env_75)
plt.plot(env_95)
plt.show()
In [ ]: