# Template file for Homework 6, CS 151, Fall 2010, ISU
# Name: (put your name here)


# Problem 1a
#
# The sampling rate of the wav file is: 
# (put your answer here)


# Problem 1b
#
# The value of the very last sample is:
# (put your answer here)


# Problem 1c
#
# The number of samples in one cycle for the wav file is:
# (put your answer here)


# Problem 1d
#
# The frequency of the tone is:
# (put your answer here)
#
# The tone is the following note:
# (put your answer here)


# Problem 2
#
# The number of bytes needed for CD quality is:
# (put your answer here)
#
# The number of bytes needed for radio quality is:
# (put your answer here)


# Problem 3
#
# The number of different C notes a typical human could here is:
# (put your answer here)


# Problem 4
#
# This is one of the extra credit problems to help boost your
# exam grade.  I am putting the definition for the function, and 
# you should fill it is like the question asks.
def stripesBW(width, height):
  print "Not doing anything yet, take this line out and put your code..."


# Problem 5
#
# This is one of the extra credit problems to help boost your
# exam grade.  I am putting the definition for the function, and 
# you should fill it is like the question asks.
def redGreenPic(pic):
  print "Not doing anything yet, take this line out and put your code..."
  repaint(pic)




# This is a function that will create a sound for 
# you that is a note of a given frequencey.  You don't
# have to understand it right now, but you can play around with it.
# hertz is the frequency of the sound you want.
# seconds is the number of seconds you want the sound to last.
# sampleRate is the sampling rate of the sound file to be created.
# You can call it like this in the command window.
# >>> snd = note(261.626, 1, 22050)
# >>> play(snd)
def note(hertz, seconds, sampleRate):
  sound = makeEmptySoundBySeconds(seconds, sampleRate)
  samplesPerCycle = (sampleRate + 0.0)/hertz
  maxAmplitude = pow(2,15)-1
  for i in range(0, seconds*sampleRate):
    t = i % samplesPerCycle
    scaledT = t * (2*pi/samplesPerCycle)
    value = sin(scaledT)*maxAmplitude
    setSampleValueAt(sound, i, value)
  return sound
