Skip to content

Commit 9c44a09

Browse files
committed
add convolve operator to Noise class
1 parent 30c569a commit 9c44a09

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

sound.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -183,11 +183,14 @@ def draw_phase(self):
183183
plt.phase_spectrum(self.data)
184184
plt.show()
185185

186-
def convolve(self, hn):
187-
return Noise(name='{} * {}'.format(self.name, hn.name), data=np.convolve(self.data, hn.data), path='')
186+
def convolve(self, other):
187+
return Noise(name='{} * {}'.format(self.name, other.name), data=np.convolve(self.data, other.data), path='')
188188

189189
def hear_noise(self):
190190
return Audio(data=self.data, rate=self.sample_rate)
191191

192+
def __mul__(self, other):
193+
return self.convolve(other)
194+
192195
def __str__(self):
193196
return self.data

0 commit comments

Comments
 (0)