Merge branch 'develop' of aubio.org:/git/aubio/aubio into develop
[aubio.git] / tests / utils_tests.h
1 #include <time.h>
2 #include <stdlib.h>
3 #include <stdio.h>
4 #include <math.h>
5 #include <assert.h>
6 #include "config.h"
7
8 #define PRINT_ERR(format, args...)   fprintf(stderr, "AUBIO-TESTS ERROR: " format , ##args)
9 #define PRINT_MSG(format, args...)   fprintf(stdout, format , ##args)
10 #define PRINT_DBG(format, args...)   fprintf(stderr, format , ##args)
11 #define PRINT_WRN(format, args...)   fprintf(stderr, "AUBIO-TESTS WARNING: " format, ##args)
12
13 #ifdef HAVE_WIN_HACKS
14 // http://en.wikipedia.org/wiki/Linear_congruential_generator
15 // no srandom/random on win32
16
17 uint_t srandom_seed = 1029;
18
19 void srandom(uint_t new_seed) {
20     srandom_seed = new_seed;
21 }
22
23 uint_t random(void) {
24     srandom_seed = 1664525 * srandom_seed + 1013904223;
25     return srandom_seed;
26 }
27 #endif
28
29 void utils_init_random (void);
30
31 void utils_init_random (void) {
32   time_t now = time(0);
33   struct tm *tm_struct = localtime(&now);
34   int seed = tm_struct->tm_sec;
35   //PRINT_WRN("current seed: %d\n", seed);
36   srandom (seed);
37 }