Adding two sounds and removing noise from a signal
# Blend sound1 with sound2.
# In other words, add sound2 into sound1
def blend(sound1, sound2):
if getLength(sound1) >= getLength(sound2):
for position in range(1, getLength(sound2)):
s1 = getSampleValueAt(sound1, position)
s2 = getSampleValueAt(sound2, position)
setSampleValueAt(sound1, position, s1 + s2)
else:
for position in range(1, getLength(sound1)):
s1 = getSampleValueAt(sound1, position)
s2 = getSampleValueAt(sound2, position)
setSampleValueAt(sound2, position, s1 + s2)
# Clean a known noise source from an input signal.
def clean(signalPlusNoise, noise):
for position in range(1, getLength(signalPlusNoise)):
if position <= getLength(noise):
s = getSampleValueAt(signalPlusNoise, position)
n = getSampleValueAt(noise, position)
setSampleValueAt(signalPlusNoise, position, s-n)
#signalPlusNoise is now just the signal
Links to this Page