Change Contents of the Bubble
Welcome to CS1315. Click on the python to add comments.

This page removed for FERPA compliance
View this PageEdit this PageUploads to this PageHistory of this PageHomeRecent ChangesSearchHelp Guide

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 getREMOVEDngth(sound1) >= getREMOVEDngth(sound2):
    for position in range(1, getREMOVEDngth(sound2)):
      s1 = getSampleValueAt(sound1, position)
      s2 = getSampleValueAt(sound2, position)
      setSampleValueAt(sound1, position, s1 + s2)
  else:
    for position in range(1, getREMOVEDngth(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, getREMOVEDngth(signalPlusNoise)):
    if position <= getREMOVEDngth(noise):
      s = getSampleValueAt(signalPlusNoise, position)
      n = getSampleValueAt(noise, position)
      setSampleValueAt(signalPlusNoise, position, s-n)
  #signalPlusNoise is now just the signal



Links to this Page