import numpy as np
import matplotlib.pyplot as plt
import IPython.display as ipd
## Step 1: Make one second of random noise
sr = 44100
x = np.random.randn(sr)
## Step 2: Create the pulse train
T = 100
num_pulses = 10
pulses = np.zeros(T*num_pulses)
pulses[0::T] = 1 # Every T samples is a 1. The rest are 0
plt.figure(figsize=(10, 3))
plt.plot(pulses)
[<matplotlib.lines.Line2D at 0x7eff7a7f3880>]
## Step 3: Convolve the pulse train with the noise to create
## a pitched sound
y = np.convolve(x, pulses)
ipd.Audio(y, rate=sr)