keijiro/Lasp

Modifying FftBuffer to output the magnitude and phase

Closed this issue · 3 comments

In the Postprocess Job you do this:

 public void Execute(int i)
      {
        var x = X[i];
        var l = math.float2(math.length(x.xy), math.length(x.zw));
        O[i] = (MathUtils.dBFS(l * DivN) - F) * DivR;
      }

I assume you're calculating the magnitude with math.length(x.xy) but what is math.length(x.zw)?
Why is each element of x float4? And why O is float2 if it's just magnitudes?

I can't remember it correctly (I wrote it 1.5 years ago), but I think it's just a SIMD optimization. I mean, calculating float4 = float4 + float4 is faster than calculating float = float + float 4 times.

Originally, X was implemented as as a float2 array, and O was just a float array. I reinterpret them as float4 and float2 to utilize SIMD.

I'm closing this issue now. Please feel free to reopen it for further problems.