예제 #1
0
 public void Dispose()
 {
     if (setup != IntPtr.Zero)
     {
         InteropWrapper.pffft_destroy_setup(setup);
         setup = IntPtr.Zero;
         InteropWrapper.pffft_aligned_free(alignedBuffer1);
         InteropWrapper.pffft_aligned_free(alignedBuffer2);
     }
 }
예제 #2
0
        private void Transform(float *input, float *output, Direction direction)
        {
            // The non-ordered transform pffft_transform may be faster,
            // but all Aurio algorithms expect the canonical ordered form
            InteropWrapper.pffft_transform_ordered(setup, input, output, null, direction);

            // Scale backward transform by 1/N (according to docs)
            if (direction == Direction.Backward)
            {
                for (int x = 0; x < size; x++)
                {
                    output[x] /= size;
                }
            }
        }
예제 #3
0
        public PFFFT(int size, Transform transform)
        {
            if ((size * 4) % 16 != 0)
            {
                // For more info see pffft.h
                throw new Exception("invalid size, must be aligned to a 16-byte boundary");
            }

            this.size = size;
            setup     = InteropWrapper.pffft_new_setup(size, transform);

            if (size >= 16384)
            {
                Console.WriteLine("WARNING: size too large, might result in low performance");
                // TODO if this ever gets a problem, implement a "work" area, see pffft.h @ pffft_transform
            }

            uint bufferByteSize = (uint)size * 4;

            alignedBuffer1 = InteropWrapper.pffft_aligned_malloc(new UIntPtr(bufferByteSize));
            alignedBuffer2 = InteropWrapper.pffft_aligned_malloc(new UIntPtr(bufferByteSize));
        }