# Increasing the length of the input stream will yield a more detailed graph.
+ # Input is S16, so scale by 2**16 to get output coordinates in [0,1]
+ y = fft(mono[:64] / float(2**16))
# Calculate the frequencies according to the FFT coefficients. They aren't being displayed
#freqstep = self.source.samplerate / n
#freq = array(range(n/2)) * freqstep
- # Calculate the power as the absolute of the FFT coefficients scaled by 2**16 (arbitrarily).
- power = sqrt(abs(y[1:(n/2)]) / float(2**16))
+ # The first half of the output array contains the fourier coefficients for our frequencies,
+ # abs() calcs sqrt(i² + j²) to un-complex-numberfy them.
+ # the sqrt() call then makes the graph look a bit nicer, because changes at a lower volume
+ # make more of a difference than changes at higher volumes.
+ self.points = sqrt(abs(y[1:(n/2)]))