[go: up one dir, main page]

Menu

[904618]: / util / pitchy.c  Maximize  Restore  History

Download this file

65 lines (47 with data), 868 Bytes

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#include <stdio.h>
#include <math.h>
int main(int argc, char** argv)
{
int i, v;
double Unit, Cur;
int up, low;
/* Calc unit size */
#if 1
Unit = 8192.0 / 127.0;
for (i = -128; i < 128; i++)
{
// Current unit
Cur = Unit * (double)i;
v = roundf(Cur);
// Add 8192 to normalize
v += 8192;
if (v > 16383)
v = 16383;
else if (v < 0)
v = 0;
up = (v >> 7) & 0x7F;
low = v & 0x7F;
printf("{0x%02x, 0x%02x}, ", up, low, v);
if (((i+1) % 4) == 0)
printf("\n");
}
printf("\n");
#else
Unit = 16384.0 / 256.0;
for (i = 0; i < 256; i++)
{
// Current unit
Cur = Unit * (double)i;
v = roundf(Cur);
if (v > 16383)
v = 16383;
up = (v >> 7) & 0x7F;
low = v & 0x7F;
printf("{0x%02x, 0x%02x}, ", up, low, v);
if (((i+1) % 4) == 0)
printf("\n");
}
printf("\n");
#endif
return 0;
}