# Template file for Homework 8, CS 151, Fall 2010, ISU
#
# Name: (put your name here)
#
# Collaborators: (put list of collaborators here, none if none).
#
# ** Note on collaboration: You should not turn in work that is not your own.
#    To make sure you are not violating this, if you work with someone, 
#    you should destroy the file once you are done working together, go 
#    your separate ways, and then you should be able to recreate the file
#    on your own, then turn that in.  If you cannot recreate the file on your
#    own, then it is not your work, and you should not turn it in.
# ** Note on sources: if you use some other source, the web or whatever, you
#    better cite it!  Not doing so is plagiarism.
#
#


# This first line has JES load all the functions from the
# cs151functions.py file so we can use them in this file too.
# So we will have this as the first line in our Python files from
# now on.
#
# Make sure to download the latest version of cs151functions.py from the 
# course webpage (make sure to right-click and "Save target as" or 
#  "Save link as" or whatever your browser calls it.)
#
# And then do the following in the command area, and select
# the folder that has cs151functions.py in it:
#
# >>> setLibPath(pickAFolder())
from cs151functions import *


# Problem 1 (10 Points)
#
# This function is supposed to compute the largest sample
# value in the sound
#
# If the function were correct, it would behave like this:
# >>> sound = note(300, 1, 20000)
# >>> largest = maxSampleValue(sound)
#  The largest sample value in the sound is 32767
# >>> sound = note(4, 1, 100)
#  The largest sample value in the sound is 32702
#
def maxSampleValue(sound):
  largest = 0
  # Fill in code here to make this work...
  print "The largest sample value in the sound is", largest
  return largest
  
  

# Problem 2 (10 Points)
#
# For this function, do anything you want to with sound.  The function
# has to at least use a for loop.  If you are using recorded sounds, you 
# should attach those when you turn in your assignment.  If you want to 
# you can change the inputs to the function so it takes some inputs.
#
def funWithSound():
  print "Not doing anything yet, put your code here"

  
   
   
# Problem 3, Extra Credit (10 Points)
#
# Since this is extra credit, I will grade it a bit more strictly than
# the regular problems.
#
# For this problem, you should create a function that computes the number
# of words in a sound file that has someone speaking.  My suggestion for 
# how to do this would be to make the following functions first:
# * nextIndexAboveVal - that takes a starting index into a sound, and finds the 
#   next index of a sample value that has absolute value above the given threshold.
#   So nextIndexAboveVal(sound, 0, 1000) might give you the index of the beginning
#   of the first word in the sound.
# * nextIndex100BelowVal - that takes a starting index into a sound, and 
#   finds the next index where 100 samples in a row have absolute value 
#   below a given threshold.  So if the 18000 is an index in the middle of a 
#   word, nextIndex100BelowVal(sound, 18000, 400) would return the index 
#   that roughly corresponds to the end of that word.
# Then I would use a while loop, which we haven't covered yet, but you could
# learn.  The while loop would use the nextIndexAboveVal and nextIndex100BelowVal
# to repeatedly find the next word in the sound until you reach the end.  Each
# time you find a word, you would increment a counter.
def nextIndexAboveVal(sound, startIndex, threshold):
  print "Nothing here yet, put your code here"

def nextIndex100BelowVal(sound, startIndex, threshold):
  print "Nothing here yet, put your code here"
  
def howManyWords(sound):
  print "Nothing here yet, put your code here"
  
