示例#1
0
        // Analyze the input buffer to calculate spectrum data.
        public void Analyze()
        {
            Profiler.BeginSample("Spectrum Analyer FFT");

            using (var X = TempJobMemory.New <float4>(_N / 2))
            {
                // Bit-reversal permutation and first DFT pass
                new FirstPassJob {
                    I = _I, W = _W, P = _P, X = X
                }.Run(_N / 2);

                // 2nd and later DFT passes
                for (var i = 0; i < _logN - 1; i++)
                {
                    var T_slice = new NativeSlice <TFactor>(_T, _N / 4 * i);
                    new DftPassJob {
                        T = T_slice, X = X
                    }.Run(_N / 4);
                }

                // Postprocess (power spectrum calculation)
                var O2 = _O.Reinterpret <float2>(sizeof(float));
                new PostprocessJob {
                    X = X, O = O2, s = 2.0f / _N
                }.Run(_N / 2);
            }

            Profiler.EndSample();
        }
示例#2
0
    public void Transform(NativeArray <float> input)
    {
        var X = TempJobMemory.New <float4>(_N / 2);

        // Bit-reversal permutation and first DFT pass
        var handle = new FirstPassJob {
            I = input, P = _P, X = X
        }
        .Schedule(_N / 2, 32);

        // 2nd and later DFT passes
        for (var i = 0; i < _logN - 1; i++)
        {
            var T_slice = new NativeSlice <TFactor>(_T, _N / 4 * i);
            handle = new DftPassJob {
                T = T_slice, X = X
            }
            .Schedule(_N / 4, 32, handle);
        }

        // Postprocess (power spectrum calculation)
        var O2 = _O.Reinterpret <float2>(sizeof(float));

        handle = new PostprocessJob {
            X = X, O = O2, s = 2.0f / _N
        }
        .Schedule(_N / 2, 32, handle);

        handle.Complete();
        X.Dispose();
    }
示例#3
0
 void Start()
 {
     using (var data = TempJobMemory.New <float>(TestData))
     {
         using (var ft = new NaiveDft(Width)) _dft1 = Benchmark(ft, data);
         using (var ft = new BurstDft(Width)) _dft2 = Benchmark(ft, data);
         using (var ft = new BurstFft(Width)) _fft = Benchmark(ft, data);
     }
 }