forked from pwsoft/synfactory_iii
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsynfactory_audioscope.m4
147 lines (123 loc) · 6.11 KB
/
synfactory_audioscope.m4
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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
module([audio output scope])
DefWindow([theAudioOutputScope], "Audio Output Scope", [audioOutputScopeHandler], 400, 400)
DefSetVar([int], [theAudioOutputScopeMode], [0])
DefSetVar([int], [theAudioOutputScopeDot], [0])
SynFileDecimal([OUTPUT_SCOPE_MODE], [theAudioOutputScopeMode]);
SynFileDecimal([OUTPUT_SCOPE_DOT], [theAudioOutputScopeDot]);
WatchVar([theAudioOutputScopeMode], [theAudioOutputScopeRefresh = true;])
WatchVar([theAudioOutputScopeDot], [theAudioOutputScopeRefresh = true;])
PrefColorSelector([OUTPUT_SCOPE_BGCOL], [Audio Output Scope Color], [theAudioOutputScopeBgColor], [COLOR_BLACK])
PrefColorSelector([OUTPUT_SCOPE_BLINE], [Audio Output Scope Base Color], [theAudioOutputScopeBaseColor], [0x00BB00])
PrefColorSelector([OUTPUT_SCOPE_TRACE], [Audio Output Scope Trace Color], [theAudioOutputScopeTraceColor], [0x00BB00])
WatchVar([theAudioOutputScopeBgColor], [theAudioOutputScopeRefresh = true;])
WatchVar([theAudioOutputScopeBaseColor], [theAudioOutputScopeRefresh = true;])
WatchVar([theAudioOutputScopeTraceColor], [theAudioOutputScopeRefresh = true;])
DefConst([static const int OUTPUT_SCOPE_BUFFER_SIZE=1024;])
DefVar([static signed short audioScopeBufferL[OUTPUT_SCOPE_BUFFER_SIZE];])
DefVar([static signed short audioScopeBufferR[OUTPUT_SCOPE_BUFFER_SIZE];])
code7([block([Audio Output Scope event handler])[
static void drawScopeTopBottom(Context_ptr_t aContext) {
int cnt;
int yRange;
SelectObject(aContext->currentHdc, GetStockObject(WHITE_BRUSH));
guiSelectFillColor(aContext, theAudioOutputScopeBgColor);
Rectangle(aContext->currentHdc, aContext->clientRect.left, aContext->clientRect.top, aContext->clientRect.right, aContext->clientRect.bottom);
yRange=((aContext->clientRect.bottom-16)/4);
if(theAudioOutputScopeDot == 0) {
guiSelectPenColor(aContext, theAudioOutputScopeTraceColor, 1);
guiDrawLineFrom(aContext, 0, yRange-(audioScopeBufferL[0]*yRange)/32768);
for(cnt=1; cnt<OUTPUT_SCOPE_BUFFER_SIZE; cnt++) {
guiDrawLineTo(aContext, (cnt*aContext->clientRect.right)/OUTPUT_SCOPE_BUFFER_SIZE, yRange-(audioScopeBufferL[cnt]*yRange)/32768);
}
guiDrawLineFrom(aContext, 0, 3*yRange+16-(audioScopeBufferR[0]*yRange)/32768);
for(cnt=1; cnt<OUTPUT_SCOPE_BUFFER_SIZE; cnt++) {
guiDrawLineTo(aContext, (cnt*aContext->clientRect.right)/OUTPUT_SCOPE_BUFFER_SIZE, 3*yRange+16-(audioScopeBufferR[cnt]*yRange)/32768);
}
} else {
guiSelectFillColor(aContext, theAudioOutputScopeTraceColor);
for(cnt = 0; cnt < OUTPUT_SCOPE_BUFFER_SIZE; cnt++) {
guiDrawPoint(aContext, (cnt*aContext->clientRect.right)/OUTPUT_SCOPE_BUFFER_SIZE, yRange-(audioScopeBufferL[cnt]*yRange)/32768);
guiDrawPoint(aContext, (cnt*aContext->clientRect.right)/OUTPUT_SCOPE_BUFFER_SIZE, 3*yRange+16-(audioScopeBufferR[cnt]*yRange)/32768);
}
guiSelectFillColor(aContext, theAudioOutputScopeBgColor);
}
// Draw base lines
guiSelectPenColor(aContext, theAudioOutputScopeBaseColor, 1);
guiDrawLine(aContext, 0, yRange, aContext->clientRect.right, yRange);
guiDrawLine(aContext, 0, 3*yRange+16, aContext->clientRect.right, 3*yRange+16);
//guiSelectTitleFont(aContext);
guiDrawTransparent(aContext);
guiSetTextAlignment(aContext, alignBottomLeft);
guiSelectPenColor(aContext, theAudioOutputScopeBaseColor, 1);
guiDrawText(aContext, 2, 0, aContext->clientRect.right, yRange, "Left");
guiDrawText(aContext, 2, 0, aContext->clientRect.right, 3*yRange+16, "Right");
//DSP_ScopePosition = 0;
}
static void drawScopeLeftRight(Context_ptr_t aContext) {
int cnt;
int yRange;
int xRange;
SelectObject(aContext->currentHdc, GetStockObject(WHITE_BRUSH));
guiSelectFillColor(aContext, theAudioOutputScopeBgColor);
Rectangle(aContext->currentHdc, aContext->clientRect.left, aContext->clientRect.top, aContext->clientRect.right, aContext->clientRect.bottom);
yRange=(aContext->clientRect.bottom/2);
xRange=((aContext->clientRect.right-16)/2);
guiSelectPenColor(aContext, theAudioOutputScopeTraceColor, 1);
if(theAudioOutputScopeDot == 0) {
guiDrawLineFrom(aContext, 0, yRange-(audioScopeBufferL[0]*yRange)/32768);
for(cnt=1; cnt<OUTPUT_SCOPE_BUFFER_SIZE; cnt++) {
guiDrawLineTo(aContext, (cnt*xRange)/OUTPUT_SCOPE_BUFFER_SIZE, yRange-(audioScopeBufferL[cnt]*yRange)/32768);
}
guiDrawLineFrom(aContext, xRange+16, yRange-(audioScopeBufferR[0]*yRange)/32768);
for(cnt=1; cnt<OUTPUT_SCOPE_BUFFER_SIZE; cnt++) {
guiDrawLineTo(aContext, (cnt*xRange)/OUTPUT_SCOPE_BUFFER_SIZE+xRange+16, yRange-(audioScopeBufferR[cnt]*yRange)/32768);
}
} else {
// guiDrawPoint requires a fill color... this is a side effect of using filled rectangles
guiSelectFillColor(aContext, theAudioOutputScopeTraceColor);
for(cnt = 0; cnt < OUTPUT_SCOPE_BUFFER_SIZE; cnt++) {
guiDrawPoint(aContext, (cnt*xRange)/OUTPUT_SCOPE_BUFFER_SIZE, yRange-(audioScopeBufferL[cnt]*yRange)/32768);
guiDrawPoint(aContext, (cnt*xRange)/OUTPUT_SCOPE_BUFFER_SIZE+xRange+16, yRange-(audioScopeBufferR[cnt]*yRange)/32768);
}
guiSelectFillColor(aContext, theAudioOutputScopeBgColor);
}
// Draw base lines
guiSelectPenColor(aContext, theAudioOutputScopeBaseColor, 1);
guiDrawLine(aContext, 0, yRange, xRange, yRange);
guiDrawLine(aContext, xRange+16, yRange, aContext->clientRect.right, yRange);
//guiSelectTitleFont(aContext);
guiDrawTransparent(aContext);
guiSetTextAlignment(aContext, alignBottomLeft);
guiSelectPenColor(aContext, theAudioOutputScopeBaseColor, 1);
guiDrawText(aContext, 2, 0, aContext->clientRect.right, yRange, "Left");
guiDrawText(aContext, xRange+18, 0, aContext->clientRect.right, yRange, "Right");
//DSP_ScopePosition = 0;
}
static void audioOutputScopeHandler(Context_ptr_t aContext) {
int yRange = 0;
switch(aContext->currentEvent) {
case GUI_EVENT_TIMER:
break;
case GUI_EVENT_REFRESH:
logprintf("audioOutputScopeHandler refresh\n");
switch(theAudioOutputScopeMode)
{
case 0: // top bottom
drawScopeTopBottom(aContext);
break;
case 1: // left right
drawScopeLeftRight(aContext);
break;
}
break;
case GUI_EVENT_MOUSE_R_DOWN:
]SetVar([theAudioOutputScopeMode], [1-theAudioOutputScopeMode])[
break;
case GUI_EVENT_MOUSE_M_DOWN:
]SetVar([theAudioOutputScopeDot], [1-theAudioOutputScopeDot])[
break;
default:
break;
}
}
]])