audio_processor.py 文件源码

python
阅读 25 收藏 0 点赞 0 评论 0

项目:audio-visualizer-screenlet 作者: ninlith 项目源码 文件源码
def __init__(self, configs, chunks, chunksize, channels, rate):
        self.configs = configs
        self.channels = channels
        self.chunksize = chunksize
        self.channel_len = chunks*chunksize
        self.fft_len = self.channel_len//2 + 1  # See numpy.fft.rfft
        self.fft_freqs_in_hertz = np.fft.rfftfreq(self.channel_len, d=1.0/rate)
        endpoint_notes = configs.settings.getmultistr('fft', 'endpoint_notes')
        self.notespace = process.generic.notespace(
            endpoint_notes[0], endpoint_notes[1],
            step=1.0/6)  # XXX
        self.window = np.hanning(self.channel_len)
        self.sensitivity = configs.settings.getfloat('fft', 'sensitivity')
        self.compute_weights(self.sensitivity)

        logger.debug("FFT length: {}".format(self.fft_len))

        # Create a pyfftw.FFTW object
        a = pyfftw.empty_aligned(
            self.channel_len, dtype='int16', n=pyfftw.simd_alignment)
        self.fft = pyfftw.builders.rfft(
            a, overwrite_input=True, threads=multiprocessing.cpu_count())
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号