-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathIVVectorScope.cpp
More file actions
45 lines (34 loc) · 961 Bytes
/
IVVectorScope.cpp
File metadata and controls
45 lines (34 loc) · 961 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
#include "IVVectorScope.h"
inline double gainToDb(double gain) {
return 20.0 * log10(gain);
}
inline double dbToGain(double decibels) {
return pow(10.0, decibels / 20.0);
}
void IVVectorScope::Draw(IGraphics& g)
{
StereoRingBuffer srb = RingBufferSolidify(mBuffer);
float cx = mRECT.MW();
float cy = mRECT.MH();
for (int i = 0; i < points; i++) {
float left = 0, right = 0;
for (int s = 0; s < step; s++) {
int pos = i * step + s;
left += srb.left[pos];
right += srb.right[pos];
}
left = left * normalize;
right = right * normalize;
float x = mRECT.W() * 0.5f * left;
float y = mRECT.H() * 0.5f * right;
float xnew = cx + ( x * c - y * s );
float ynew = cy + ( x * s + y * c );
g.DrawCircle(color, xnew, ynew, 1);
g.DrawLine(color, lastX, lastY, xnew, ynew, 0, 1.5f);
lastX = xnew;
lastY = ynew;
}
free(srb.left);
free(srb.right);
SetDirty(false);
}