diff options
Diffstat (limited to 'gst/goom/goom_tools.c')
-rw-r--r-- | gst/goom/goom_tools.c | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/gst/goom/goom_tools.c b/gst/goom/goom_tools.c new file mode 100644 index 00000000..ebca69e2 --- /dev/null +++ b/gst/goom/goom_tools.c @@ -0,0 +1,32 @@ +#include "goom_tools.h" +#include <stdlib.h> + +GoomRandom * +goom_random_init (int i) +{ + GoomRandom *grandom = (GoomRandom *) malloc (sizeof (GoomRandom)); + + srand (i); + grandom->pos = 1; + goom_random_update_array (grandom, GOOM_NB_RAND); + return grandom; +} + +void +goom_random_free (GoomRandom * grandom) +{ + free (grandom); +} + +void +goom_random_update_array (GoomRandom * grandom, int numberOfValuesToChange) +{ + while (numberOfValuesToChange > 0) { +#if RAND_MAX < 0x10000 + grandom->array[grandom->pos++] = ((rand () << 16) + rand ()) / 127; +#else + grandom->array[grandom->pos++] = rand () / 127; +#endif + numberOfValuesToChange--; + } +} |