Q:

timing two algorithms (python) using timeit or time

I am having some trouble using the time or timeit functions to determine the runtime of two algorithms within python. So far I have this
def normal(sound):
  for s in getSamples(sound):
    largest=max(0,getSampleValue(s))
    amplification = 32767.0/largest
  for s in getSamples(sound):
    louder = amplification*getSampleValue(s)
    setSampleValue(s,louder)

def onlyMax(sound):
  for s in getSamples(sound):
    value=getSampleValue(s)
    if value>0:
      setSampleValue(s,32767)
    if value<=0:
      setSampleValue(s,-32768)

import time
def timetwoalgorithms(sound):
    print time.time("normal(sound)","onlyMax(sound)")

The program should measure the time it takes to run each of the functions then output/print what the runtime of each program was.

A:

time.time gives the current time. You want timeit.timeit.
print(timeit.timeit("normal(sound)"))
print(timeit.timeit("onlyMax(sound)"))

However, you cannot pass local variables to timeit (how to pass parameters of a function when using timeit.Timer()), so you may have to simplify your function. You can either reimplement timeit:
def timeit(exec_s, globals={}, number=10000):
    t = time.time()
    for i in range(number):
        exec(exec_s, globals)
    return time.time() - t

and do
print(timeit("normal(sound)", locals()))
print(timeit("onlyMax(sound)", locals()))

or place the variables in the module namespace as per @Martijn Pieters answer.
Or, incorporating the timing loop into the main function:
def time2algorithms(sound, number=10000):
    t = time.time()
    for i in range(number):
        normal(sound)
    print(time.time() - t)
    t = time.time()
    for i in range(number):
        onlyMax(sound)
    print(time.time() - t)

