* Use two periods of the sine for testing instead of one and scale the values
[matthijs/projects/montium-fft.git] / FFT_support.cpp
index 23d07f08ca102e114e7428807701f364fcdcc566..d3b5d09d28cc0917cd68106f5db53c7b7a53d916 100644 (file)
@@ -68,7 +68,9 @@ void pre_run()
        \r
        for (i=0;i<PARAM_N_t;i++)\r
        {\r
-               int value = to_fixed(sin((float)i*2*M_PI/PARAM_N_t));\r
+               /* We take the sine from 0 to 2*2*Pi, ie two periods. We divide \r
+                * the value by PARAM_N_t to prevent overflow. */\r
+               int value = to_fixed(sin((float)i*2*2*M_PI/PARAM_N_t)/PARAM_N_t);\r
 \r
                if (i<PARAM_N_t/2)\r
                {\r