Exemplo n.º 1
0
 void BuildPermutationTable()
 {
     _P = PersistentMemory.New <int2>(_N / 2);
     for (var i = 0; i < _N; i += 2)
     {
         _P[i / 2] = math.int2(Permutate(i), Permutate(i + 1));
     }
 }
Exemplo n.º 2
0
 void InitializeWindow()
 {
     _W = PersistentMemory.New <float>(_N);
     for (var i = 0; i < _N; i++)
     {
         _W[i] = (1 - math.cos(2 * math.PI * i / (_N - 1))) / 2;
     }
 }
Exemplo n.º 3
0
    public BurstFft(int width)
    {
        _N    = width;
        _logN = (int)math.log2(width);

        BuildPermutationTable();
        BuildTwiddleFactors();

        _O = PersistentMemory.New <float>(_N);
    }
Exemplo n.º 4
0
        public FftBuffer(int width)
        {
            _N    = width;
            _logN = (int)math.log2(width);

            _I = PersistentMemory.New <float>(_N);
            _O = PersistentMemory.New <float>(_N);

            InitializeWindow();
            BuildPermutationTable();
            BuildTwiddleFactors();
        }
Exemplo n.º 5
0
        public static bool Update()
        {
            bool changeState;

            changeState = CheckChangeState();

            // If update the status of the object, the data reflect of PersistentMemory.
            if (true == changeState)
            {
                PersistentMemory.Write(persistentMemoryData);
            }

            return(true);
        }
Exemplo n.º 6
0
    public BurstDft(int width)
    {
        // DFT coefficients
        var coeffs = Enumerable.Range(0, width / 2 * width).
                     Select(i => (k: i / width, n: i % width)).
                     Select(I => 2 * math.PI / width * I.k * I.n);

        var coeffs_r = coeffs.Select(x => math.cos(x));
        var coeffs_i = coeffs.Select(x => math.sin(x));

        _coeffs_r = PersistentMemory.New <float>(coeffs_r);
        _coeffs_i = PersistentMemory.New <float>(coeffs_i);

        // Output buffer
        _buffer = PersistentMemory.New <float>(width / 2);
    }
Exemplo n.º 7
0
        /// 初期化
        public static bool Init()
        {
            graphics = new GraphicsContext();
            SampleDraw.Init(graphics);

            screenWidth  = graphics.Screen.Width;
            screenHeight = graphics.Screen.Height;

            // Gets the state of the object from PersistentMemory
            persistentMemoryData = PersistentMemory.Read();

            // Set status of the object from the contents from PersistentMemory
            SetupObjects();

            return(true);
        }
Exemplo n.º 8
0
        void BuildTwiddleFactors()
        {
            _T = PersistentMemory.New <TFactor>((_logN - 1) * (_N / 4));

            var i = 0;

            for (var m = 4; m <= _N; m <<= 1)
            {
                for (var k = 0; k < _N; k += m)
                {
                    for (var j = 0; j < m / 2; j += 2)
                    {
                        _T[i++] = new TFactor
                        {
                            I = math.int2((k + j) / 2, (k + j + m / 2) / 2),
                            W = math.cos(-2 * math.PI / m * math.float2(j, j + 1))
                        }
                    }
                }
            }
            ;
        }