def getFFT(data,rate):
for i in range(len(self.fftx)):
# print("f=fft ",self.fftx[i],self.fft[i]);
if ( i == 0 ) :
GPIO.output(redLightsPin, GPIO.HIGH) # off
if ( i > 0 and i < b1 ) :
if self.fft[i] > max1:
GPIO.output(redLightsPin, GPIO.LOW) # on
We get the FFT of the current audio buffer
We scan the normal audible range for 6 frequency bands
at the bottom of the band we turn off our LED associated with the Band
if durring the sweep of frequencies our audio level is above a fixed threshold we turn on our LED.