0

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?

Biffen
  • 6,249
  • 6
  • 28
  • 36
bnc
  • 57
  • 2
  • 14
  • Please mention the mathematical result that you expect. Normalizing can be simply dividing by `1/length` or `1/sqrt(length)` to fix the asymmetric or symmetric summing of the FFT routines. For audio normalization, you could want to divided by the RMS average or the maximum value of `a`. – Pierre de Buyl Mar 06 '17 at 22:21
  • I had at first that 1/sqrt(length) which I found from stackoverflow but it provided weird results. Thing I expect is that the total sum of the values for the bin amplitude wouldn't exceed 1, as I have 256 oscillators in the oscillator bank so they should all sum up to 1. I took that normalization formula from Gareth Loy's Musimathics volume 2, but I'm not sure if it is correct. – bnc Mar 06 '17 at 22:41
  • The `1/length` or `1/sqrt(length)` depends on what your function *should* return. I know Python and FFTs but not SuperCollider, so that is unknown to me. – Pierre de Buyl Mar 06 '17 at 22:51
  • The total amplitude sum of the 256 sine wave oscillators shouldn't clip -1 and 1 so that is what it should return. – bnc Mar 06 '17 at 23:14

0 Answers0