In [ ]:
import numpy
from scipy import signal
import matplotlib.pyplot as plt
%matplotlib inline
import IPython.display as ipd

In [32]:
sr = 22050 # sample rate
T = 2.0    # seconds
f = 220    # 220 Hz
# time variable
t = numpy.linspace(0, T, int(T*sr), endpoint=False)
#wave = 0.5*numpy.sin(2 * numpy.pi * f * t)
wave1 = signal.sawtooth(2 * numpy.pi * f * t)
wave2 = signal.sawtooth(2 * numpy.pi * f * t - (numpy.pi*0.25))
wave = numpy.add(wave1, wave2)

In [33]:
plt.figure(figsize=(100, 40))
plt.plot(wave[:500])
plt.show()



In [35]:
ipd.Audio(wave, rate=sr) # load a NumPy array


Out[35]:

In [ ]: