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 Page (locked)Uploads to this PageHistory of this PageHomeRecent ChangesSearchHelp Guide

playMary

def playMary2():
  A = makeSound('smooth_string-a4.wav')
  B = makeSound('smooth_string-b4.wav')
  D = makeSound('smooth_string-d4.wav')
  G = makeSound('smooth_string-g4.wav')

  song = makeEmptySound(10)

  song_index = 1

  song_index = insertNote(song, song_index, B, 1)
  song_index = insertNote(song, song_index, A, .25)
  song_index = insertNote(song, song_index, G, .25)
  song_index = insertNote(song, song_index, A, .25)

  song_index = insertNote(song, song_index, B, .25)
  song_index = insertNote(song, song_index, B, .25)
  song_index = insertNote(song, song_index, B, .50)

  song_index = insertNote(song, song_index, A, .25)
  song_index = insertNote(song, song_index, A, .25)
  song_index = insertNote(song, song_index, A, .50)

  song_index = insertNote(song, song_index, B, .25)
  song_index = insertNote(song, song_index, changeOctave(D,2), .25)
  song_index = insertNote(song, song_index, changeOctave(D,2), .50)

  play(song)
######################################## Helper Functions
def insertNote(target, target_index, note, duration):
  for index in range(1, int(getSamplingRate(note)*duration)):
    value = getSampleValueAt(note, index)
    setSampleValueAt(target, target_index, value)
    target_index = target_index +1 
  return target_index

def insertRest(target, target_index, note, duration):
  for index in range(1, int(getSamplingRate(note)*duration)):
    setSampleValueAt(target, target_index, 0)
    target_index = target_index +1 
  return target_index
 
def changeOctave(source_note, factor): 
  new_note = makeEmptySound(1)
  source_note_index = 1
  for new_note_index in range(1, int(getSamplingRate(new_note))):
    value = getSampleValueAt(source_note, int(source_note_index))
    setSampleValueAt(new_note, new_note_index, value)
    source_note_index = source_note_index + factor
    if (source_note_index >= getLength(source_note)):
      source_note_index = 1
  return new_note
  
######################################## Stuff that I dont need but want to keep
def delay():
  delay = 10000
  for index in range (1, getLength(song)+1-delay):
    orig_value = getSampleValueAt(song, index)
    echo_value = 0.6*getSampleValueAt(song, index+delay)
    setSampleValueAt(song, index, orig_value + echo_value)


Link to this Page