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

Looking for the book? They have it at the Engineer's Bookstore at 748 Marietta St NW. Here is there website: http://www.engrbookstore.com/ - Monica

Hotspots: Slides and CodeTA CornerComments?AnnouncementsFAQStatic Webspace
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 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