-
Notifications
You must be signed in to change notification settings - Fork 0
/
winampdetectbeat.h
executable file
·97 lines (90 loc) · 2.26 KB
/
winampdetectbeat.h
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
int winampDetectBeat(struct winampVisModule *this_mod)
{
int y=0; // y=0 | 1 right | left channel;
int last=this_mod->waveformData[y][0];
int total=0;
for (int x = 1; x < 576; x ++)
{
total += abs(last - this_mod->waveformData[y][x]);
last = this_mod->waveformData[y][x];
}
total /= 576;
if (total > 127) total = 127;
return total;
}
int winampDetectBass(struct winampVisModule *this_mod,int xmin,int xmax)
{
int last=this_mod->waveformData[0][0];
int total=0;
for (int y=0;y<2;y++)
{
for (int x = xmin; x < xmax; x ++)
{
total += abs(this_mod->spectrumData[y][x]);
last = this_mod->waveformData[y][x];
}
total /= (xmax-xmin);
}
if (total > 100) total = 100;
return total;
}
int winampDetectMiddle(struct winampVisModule *this_mod)
{
int y=0; // y=0 | 1 right | left channel;
int last=this_mod->waveformData[y][0];
int total=0;
for (int x = 550; x < 555; x ++)
{
total += abs(this_mod->waveformData[y][x]);
last = this_mod->waveformData[y][x];
}
total /= 5;
if (total > 127) total = 127;
return total;
}
int winampMiddleUp(struct winampVisModule *this_mod,int i,int j)
{
int y=0; // y=0 | 1 right | left channel;
int last=this_mod->waveformData[y][i];
int total=0;
for (int x = 0; x < j; x ++)
{
total += abs(this_mod->spectrumData[y][x+i]);
last = this_mod->waveformData[y][x+i];
}
total /= j;
if (total > 127) total = 127;
return total;
}
int winampDetectTreble(struct winampVisModule *this_mod)
{
int y=0; // y=0 | 1 right | left channel;
int last=this_mod->waveformData[y][0];
int total=0;
for (int x = 250; x < 560; x ++)
{
total += abs(this_mod->spectrumData[y][x]);
last = this_mod->waveformData[y][x];
}
total /= 310;
if (total > 127) total = 127;
return total;
}
int winampBeat(struct winampVisModule *this_mod)
{
int total;
for (int y = 0; y < 2; y ++)
{
int last=this_mod->waveformData[y][0];
total=0;
//get average waveformData level
for (int x = 1; x < 576; x ++)
{
total+=abs(last-this_mod->waveformData[y][x]);
last = this_mod->waveformData[y][x];
}
total /= 576;
if (total > 100) total = 100;
}
return total;
}