def process(self, frames, eod, spec_range=<NUM_LIT>):
samples = frames[:, <NUM_LIT:0>]<EOL>nsamples = len(frames[:, <NUM_LIT:0>])<EOL>if nsamples != self.blocksize:<EOL><INDENT>self.window = self.window_function(nsamples)<EOL><DEDENT>samples *= self.window<EOL>while nsamples > self.fft_size:<EOL><INDENT>self.fft_size = <NUM_LIT:2> * self.fft_size<EOL><DEDENT>zeros_p = numpy.zeros(self.fft_size / <NUM_LIT:2> - int(nsamples / <NUM_LIT:2>))<EOL>if nsamples % <NUM_LIT:2>:<EOL><INDENT>zeros_n = numpy.zeros(self.fft_size / <NUM_LIT:2> - int(nsamples / <NUM_LIT:2>) - <NUM_LIT:1>)<EOL><DEDENT>else:<EOL><INDENT>zeros_n = numpy.zeros(self.fft_size / <NUM_LIT:2> - int(nsamples / <NUM_LIT:2>))<EOL><DEDENT>samples = numpy.concatenate((zeros_p, samples, zeros_n), axis=<NUM_LIT:0>)<EOL>fft = numpy.fft.fft(samples)<EOL>spectrum = numpy.abs(fft[:fft.shape[<NUM_LIT:0>] / <NUM_LIT:2> + <NUM_LIT:1>]) / float(nsamples)<EOL>length = numpy.float64(spectrum.shape[<NUM_LIT:0>])<EOL>db_spectrum = ((<NUM_LIT:20> * (numpy.log10(spectrum + <NUM_LIT>)))<EOL>.clip(-spec_range, <NUM_LIT:0.0>) + spec_range) / spec_range<EOL>energy = spectrum.sum()<EOL>spectral_centroid = <NUM_LIT:0><EOL>if energy > <NUM_LIT>:<EOL><INDENT>if self.spectrum_range is None:<EOL><INDENT>self.spectrum_range = numpy.arange(length)<EOL><DEDENT>spectral_centroid = (spectrum * self.spectrum_range).sum() /(energy * (length - <NUM_LIT:1>)) *self.samplerate * <NUM_LIT:0.5><EOL>spectral_centroid = (math.log10(self.clip(spectral_centroid,<EOL>self.lower,<EOL>self.higher)) -<EOL>self.lower_log) / (self.higher_log -<EOL>self.lower_log)<EOL><DEDENT>return (spectral_centroid, db_spectrum)<EOL>
Returns a tuple containing the spectral centroid and
        the spectrum (dB scales) of the input audio frames.
        FFT window sizes are adatable to the input frame size.