Scipy FFT function and normalization not providing correct results

﹥>﹥吖頭↗ 提交于 2019-12-13 07:02:05

问题


I have a oscillator bank made in SuperCollider which receives phases and amplitudes from python via OSC. However the results don't sound correct at all. At first I thought the problem is in my SuperCollider code, but now I'm beginning to doubt my FFT function and normalization, here's my code:

def readNormalize(length, location,sample):

    samplerate, data = wavfile.read(location)

    a = data.T[0] # first track of audio
    c = fft(a[sample:], length)


    ownSum = 0;
    length = int(length/2)
    for i in range(0, length):
        ownSum += abs(c[i])
    normalizer = 1/ownSum

    phases = []
    amplitudes = []
    for i in range(0,length):
        amplitudes.append(abs(c[i])*normalizer)
        phases.append(np.angle(c[i]))

    return amplitudes, phases

So the function receives location from where to read, length of the FFT to be calculated and from which sample of the wav file to read. My normalization is done by taking the sum of the vectors of the complex numbers, dividing 1 by the sum and then multiplying the vectors with the normalizing value. I'm not sure if it is done correctly, is this the correct way to do it? Only thing I hear in the SuperCollider is this kick drum sound which is not how it should sound at all. Am I missing something important here?

来源:https://stackoverflow.com/questions/42634666/scipy-fft-function-and-normalization-not-providing-correct-results

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!