import numpy as np
timeLength = 6
def chirp(t, f_func, f0, k):
return np.sin(2*np.pi*f_func(t, f0, k)*t)
def f_linear_chirp(t, f0, k):
return f0 + k*t
def f_exp_chirp(t, f0, k):
return f0*k**t
duration = 1 fs = 2**13 t = np.arange(0, timeLength, 1.0/fs)
f0 = 2 f1 = 20
k_test_lin = (f1-f0)/timeLength
k_test_exp = (f1/f0)**(1/timeLength)
print(f'k_lin = {k_test_lin}, k_exp = {k_test_exp}')
linear_chirp_example = [chirp(x, f_linear_chirp, f0, k_test_lin) for x in t]
exp_chirp_example = [chirp(x, f_exp_chirp, f0, k_test_exp) for x in t]
import matplotlib.pyplot as plt
plt.plot(t, linear_chirp_example)
plt.show()
plt.plot(t, exp_chirp_example)
plt.show()