01: #include <stdio.h>
02: #include <stdlib.h>
03: #include <math.h>
04: #include <inttypes.h>
05:
06: int32_t mystere(uint32_t n)
07: {
08: n &= 0xFF;
09: if (!n) return -21;
10: if ((n & 0xC0) == 0x40) n &= 0xBF;
11: if ((n & 0x1F) > 16) return mystere((n ^ 0x1F) + 1);
12: if (n & 0x1C) return mystere(n - 4) + 12;
13: if ((n & 0xC3) == 0xC0) return mystere(n & 0xBF) - 1;
14: if ((n & 3) == 1) return mystere(n - 1) + 2 + ((n >> 7) * (((n & 0x40) >> 6) + 1));
15: if ((n & 3) == 2) return mystere(n - 1) + 3 + ((((n & 0xC0) == 0x80) << 1) - ((!(n & 0xC0)) * (((n & 0x20) >> 5) + 1)));
16: if ((n & 3) == 3) return mystere(n - 1) + 4 - ((!(n & 0xE0)) + (((n & 0xC0) == 0x80) << 1));
17: return mystere(0) - 3 + (((n & 0xE0) == 0xA0) << 1);
18: }
19:
20: int main(void)
21: {
22: uint32_t i;
23: int16_t *buf = malloc(10584320);
24: int16_t *p = buf;
25: FILE *f = fopen("mystere.bin", "wb");
26: for (i = 0; i < 320; i++)
27: {
28: uint32_t j;
29: for (j = 0; j < 8269; j++)
30: {
31: double n = sin((double)(j) * 0.062689 * pow(2, (double)mystere(i) / 12.0)) * 16384.0;
32: double s[2];
33: n *= exp((double)j * -5E-5);
34: if (i & 0x100) n *= exp(-(double)(i & 0xFF) * 0.1);
35: if (j < 441) n *= (double)(j) * 0.002268;
36: if (j > 7828) n *= (double)(8269 - j) * 0.002268;
37: s[0] = s[1] = n;
38: if ((p - buf) > 1999) { s[0] += (double)p[-2000] * 0.3; s[1] += (double)p[-2000] * 0.3; }
39: if (i > 1) { s[0] += (double)p[-33076] * 0.125; s[1] += (double)p[-33076] * 0.375; }
40: if (i > 2) { s[0] += (double)p[-49614] * 0.1875; s[1] += (double)p[-49614] * 0.0625; }
41: *p++ = (int16_t)s[0]; *p++ = (int16_t)s[1];
42: }
43: }
44: fwrite(buf, 1, 10584320, f);
45: return 0;
46: }