source: tests/utils_tests.h @ 06dba46

feature/autosinkfeature/constantqfeature/pitchshiftfeature/pydocstringsfeature/timestretchpitchshiftsamplertimestretchyinfft+
Last change on this file since 06dba46 was 06dba46, checked in by Paul Brossier <piem@piem.org>, 7 years ago

wscript: small tweaks to with mingw32

Signed-off-by: Paul Brossier <piem@piem.org>

  • Property mode set to 100644
File size: 952 bytes
Line 
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
17uint_t srandom_seed = 1029;
18
19void srandom(uint_t new_seed) {
20    srandom_seed = new_seed;
21}
22
23uint_t random(void) {
24    srandom_seed = 1664525 * srandom_seed + 1013904223;
25    return srandom_seed;
26}
27#endif
28
29void utils_init_random () {
30  time_t now = time(0);
31  struct tm *tm_struct = localtime(&now);
32  int seed = tm_struct->tm_sec;
33  //PRINT_WRN("current seed: %d\n", seed);
34  srandom (seed);
35}
Note: See TracBrowser for help on using the repository browser.