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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
|
diff -Naur --exclude='.*' graphlcd-0.1.3.old/display.c graphlcd-0.1.3/display.c
--- graphlcd-0.1.3.old/display.c 2006-09-07 16:00:17.000000000 +0200
+++ graphlcd-0.1.3/display.c 2006-09-07 13:04:51.000000000 +0200
@@ -25,6 +25,7 @@
#include <vdr/tools.h>
#include <vdr/menu.h>
+#include <vdr/plugin.h>
#include "compat.h"
@@ -108,6 +109,8 @@
nCurrentBrightness = -1;
LastTimeBrightness = 0;
bBrightnessActive = true;
+
+ LastTimeSA.Set(0);
}
cGraphLCDDisplay::~cGraphLCDDisplay()
@@ -374,15 +377,22 @@
{
update = true;
}
-
+
+ if ( LastTimeSA.TimedOut() )
+ {
+ update = true;
+ LastTimeSA.Set(1000);
+ }
+
// update Display every second or due to an update
- if (CurrTime != LastTime || update)
+ if (CurrTime != LastTime || update )
{
// but only, if something has changed
if (replay.total / FRAMESPERSEC != replay.totalLast / FRAMESPERSEC ||
replay.current / FRAMESPERSEC != replay.currentLast / FRAMESPERSEC ||
CurrTime/60 != LastTime/60 ||
- update)
+ update
+ )
{
timerclear(&UpdateAt);
update = false;
@@ -1439,7 +1449,7 @@
it->Draw(bitmap);
}
}
-
+
// Draw Progressbar with current and total replay time
nTopY = bitmap->Height() - normalFont->TotalHeight() - FRAME_SPACE_Y - nProgressbarHeight - 2;
nMaxX = std::max(1, bitmap->Width() - 1 - 2 * FRAME_SPACE_X);
@@ -1456,6 +1466,8 @@
FRAME_SPACE_X + nMaxX,
nTopY + nProgressbarHeight,
GLCD::clrBlack, false);
+
+ DisplaySA();
if (1 < replay.total && 1 < replay.current) // Don't show full progressbar for endless streams
{
@@ -2023,4 +2035,140 @@
mutex.Unlock();
}
+void cGraphLCDDisplay::DisplaySA()
+{
+// Spectrum Analyzer visualization
+ if ( GraphLCDSetup.enableSpectrumAnalyzer )
+ {
+ if (cPluginManager::CallFirstService(SPAN_GET_BAR_HEIGHTS_ID, NULL))
+ {
+ Span_GetBarHeights_v1_0 GetBarHeights;
+
+ int bandsSA = 20;
+ int falloffSA = 8;
+ int channelsSA = 1;
+
+ unsigned int bar;
+ unsigned int *barHeights = new unsigned int[bandsSA];
+ unsigned int *barHeightsLeftChannel = new unsigned int[bandsSA];
+ unsigned int *barHeightsRightChannel = new unsigned int[bandsSA];
+ unsigned int volumeLeftChannel;
+ unsigned int volumeRightChannel;
+ unsigned int volumeBothChannels;
+ unsigned int *barPeaksBothChannels = new unsigned int[bandsSA];
+ unsigned int *barPeaksLeftChannel = new unsigned int[bandsSA];
+ unsigned int *barPeaksRightChannel = new unsigned int[bandsSA];
+
+ GetBarHeights.bands = bandsSA;
+ GetBarHeights.barHeights = barHeights;
+ GetBarHeights.barHeightsLeftChannel = barHeightsLeftChannel;
+ GetBarHeights.barHeightsRightChannel = barHeightsRightChannel;
+ GetBarHeights.volumeLeftChannel = &volumeLeftChannel;
+ GetBarHeights.volumeRightChannel = &volumeRightChannel;
+ GetBarHeights.volumeBothChannels = &volumeBothChannels;
+ GetBarHeights.name = "graphlcd";
+ GetBarHeights.falloff = falloffSA;
+ GetBarHeights.barPeaksBothChannels = barPeaksBothChannels;
+ GetBarHeights.barPeaksLeftChannel = barPeaksLeftChannel;
+ GetBarHeights.barPeaksRightChannel = barPeaksRightChannel;
+
+ if ( cPluginManager::CallFirstService(SPAN_GET_BAR_HEIGHTS_ID, &GetBarHeights ))
+ {
+ int i;
+ int barWidth = 2;
+ int saStartX = FRAME_SPACE_X;
+ int saEndX = saStartX + barWidth*bandsSA*2 + bandsSA/4 - 1;
+ int saStartY = FRAME_SPACE_Y;
+ int saEndY = FRAME_SPACE_Y + bitmap->Height()/2 - 3;
+
+ LastTimeSA.Set(100);
+
+ if ( GraphLCDSetup.SAShowVolume )
+ {
+
+ saStartX = FRAME_SPACE_X + bitmap->Width()/2 - (barWidth*bandsSA*2 + bandsSA/4)/2 - 2;
+ saEndX = saStartX + barWidth*bandsSA*2 + bandsSA/4 - 1;
+
+ // left volume
+ bitmap->DrawRectangle(FRAME_SPACE_X,
+ saStartY,
+ saStartX-1,
+ saEndY + 1,
+ GLCD::clrWhite, true);
+
+ for ( i=0; (i<logo->Width()/2-2) && (i<3*(volumeLeftChannel*saStartX)/100); i++)
+ {
+ bitmap->DrawRectangle(saStartX - i - 2,
+ saStartY + saEndY/2 - i,
+ saStartX - i - 4,
+ saStartY + saEndY/2 + i,
+ GLCD::clrBlack, true);
+ }
+
+ // right volume
+ bitmap->DrawRectangle(saEndX + 1,
+ saStartY,
+ bitmap->Width() - 1,
+ saEndY + 1,
+ GLCD::clrWhite, true);
+
+ for ( i=0; (i<logo->Width()/2-2) && (i<3*(volumeRightChannel*saStartX)/100); i++)
+ {
+ bitmap->DrawRectangle(saEndX + 2 + i,
+ saStartY + saEndY/2 - i,
+ saEndX + i + 4,
+ saStartY + saEndY/2 + i,
+ GLCD::clrBlack, true);
+ }
+ }
+ // black background
+ bitmap->DrawRectangle(saStartX,
+ saStartY,
+ saEndX,
+ saEndY + 1,
+ GLCD::clrBlack, true);
+
+ for ( i=0; i < bandsSA; i++ )
+ {
+/* if ( channelsSA == 2 )
+ {
+ bar = barHeightsLeftChannel[i];
+ bar = barHeightsRightChannel[i];
+ }*/
+ if ( channelsSA == 1)
+ {
+ // the bar
+ bar = (barHeights[i]*(saEndY-saStartY))/100;
+ bitmap->DrawRectangle(saStartX + barWidth*2*(i)+ barWidth + 1,
+ saEndY,
+ saStartX + barWidth*2*(i) + barWidth+ barWidth + 1,
+ saEndY - bar,
+ GLCD::clrWhite, true);
+
+ // the peak
+ bar = (barPeaksBothChannels[i]*(saEndY-saStartY))/100;
+ if ( bar > 0 )
+ {
+ bitmap->DrawRectangle(saStartX + barWidth*2*(i)+ barWidth + 1,
+ saEndY - bar,
+ saStartX + barWidth*2*(i) + barWidth+ barWidth + 1,
+ saEndY - bar+1,
+ GLCD::clrWhite, true);
+ }
+ }
+ }
+ }
+
+ delete [] barHeights;
+ delete [] barHeightsLeftChannel;
+ delete [] barHeightsRightChannel;
+ delete [] barPeaksBothChannels;
+ delete [] barPeaksLeftChannel;
+ delete [] barPeaksRightChannel;
+ }
+ }
+}
+
+//#############################################################################################
+
cGraphLCDDisplay Display;
diff -Naur --exclude='.*' graphlcd-0.1.3.old/display.h graphlcd-0.1.3/display.h
--- graphlcd-0.1.3.old/display.h 2006-09-07 16:00:17.000000000 +0200
+++ graphlcd-0.1.3/display.h 2006-09-07 11:08:35.000000000 +0200
@@ -44,6 +44,45 @@
#include <vdr/thread.h>
#include <vdr/player.h>
+#define SPAN_PROVIDER_CHECK_ID "Span-ProviderCheck-v1.0"
+#define SPAN_CLIENT_CHECK_ID "Span-ClientCheck-v1.0"
+#define SPAN_SET_PCM_DATA_ID "Span-SetPcmData-v1.0"
+#define SPAN_GET_BAR_HEIGHTS_ID "Span-GetBarHeights-v1.0"
+
+//Span requests to collect possible providers / clients
+struct Span_Provider_Check_1_0 {
+ bool *isActive;
+ bool *isRunning;
+};
+
+struct Span_Client_Check_1_0 {
+ bool *isActive;
+ bool *isRunning;
+};
+
+// Span data
+struct Span_SetPcmData_1_0 {
+ unsigned int length; // the length of the PCM-data
+ int *data; // the PCM-Data as 32-bit int, however only the lower 16-bit are used
+ // and you have to take care to hand in such data!
+};
+
+struct Span_GetBarHeights_v1_0 {
+ unsigned int bands; // number of bands to compute
+ unsigned int *barHeights; // the heights of the bars of the two channels combined
+ unsigned int *barHeightsLeftChannel; // the heights of the bars of the left channel
+ unsigned int *barHeightsRightChannel; // the heights of the bars of the right channel
+ unsigned int *volumeLeftChannel; // the volume of the left channels
+ unsigned int *volumeRightChannel; // the volume of the right channels
+ unsigned int *volumeBothChannels; // the combined volume of the two channels
+ const char *name; // name of the plugin that wants to get the data
+ // (must be unique for each client!)
+ unsigned int falloff; // bar falloff value
+ unsigned int *barPeaksBothChannels; // bar peaks of the two channels combined
+ unsigned int *barPeaksLeftChannel; // bar peaks of the left channel
+ unsigned int *barPeaksRightChannel; // bar peaks of the right channel
+};
+
#define LCDMAXCARDS 4
static const int kMaxTabCount = 10;
@@ -118,6 +157,7 @@
time_t LastTime;
time_t LastTimeCheckSym;
time_t LastTimeModSym;
+ cTimeMs LastTimeSA;
struct timeval CurrTimeval;
struct timeval UpdateAt;
@@ -139,6 +179,7 @@
void DisplayTextItem();
void DisplayColorButtons();
void DisplayVolume();
+ void DisplaySA();
void UpdateIn(long usec);
bool CheckAndUpdateSymbols();
diff -Naur --exclude='.*' graphlcd-0.1.3.old/i18n.c graphlcd-0.1.3/i18n.c
--- graphlcd-0.1.3.old/i18n.c 2006-09-07 16:00:17.000000000 +0200
+++ graphlcd-0.1.3/i18n.c 2006-09-07 12:23:02.000000000 +0200
@@ -966,5 +966,53 @@
# endif
#endif
},
+ {
+ "Show spectrum analyzer",
+ "Zeige Spectrum Analyzer",
+ "",// TODO Slovenski
+ "",// TODO Italiano
+ "",// TODO Nederlands
+ "",// TODO Portugu�s
+ "",// TODO Fran�ais
+ "",// TODO Norsk
+ "",// TODO Suomi
+ "",// TODO Polski
+ "",// TODO Espa�ol
+ "",// TODO Ellinika
+ "",// TODO Svenska
+ "",// TODO Rom�n�
+ "",// TODO Magyar
+ "",// TODO Catal�
+#if VDRVERSNUM > 10302
+ "",// TODO Russian
+# if VDRVERSNUM > 10307
+ "",// TODO Croatian
+# endif
+#endif
+ },
+ {
+ "Show SA volume",
+ "Zeige SA Lautst�rke",
+ "",// TODO Slovenski
+ "",// TODO Italiano
+ "",// TODO Nederlands
+ "",// TODO Portugu�s
+ "",// TODO Fran�ais
+ "",// TODO Norsk
+ "",// TODO Suomi
+ "",// TODO Polski
+ "",// TODO Espa�ol
+ "",// TODO Ellinika
+ "",// TODO Svenska
+ "",// TODO Rom�n�
+ "",// TODO Magyar
+ "",// TODO Catal�
+#if VDRVERSNUM > 10302
+ "",// TODO Russian
+# if VDRVERSNUM > 10307
+ "",// TODO Croatian
+# endif
+#endif
+ },
{ NULL }
};
diff -Naur --exclude='.*' graphlcd-0.1.3.old/menu.c graphlcd-0.1.3/menu.c
--- graphlcd-0.1.3.old/menu.c 2006-09-07 16:00:17.000000000 +0200
+++ graphlcd-0.1.3/menu.c 2006-09-07 12:21:58.000000000 +0200
@@ -75,6 +75,8 @@
Add(new cMenuEditIntItem(tr("Brightness on user activity"), &newGraphLCDSetup.BrightnessActive, 0, 100));
Add(new cMenuEditIntItem(tr("Brightness on user inactivity"), &newGraphLCDSetup.BrightnessIdle, 0, 100));
Add(new cMenuEditIntItem(tr("Brightness delay [s]"), &newGraphLCDSetup.BrightnessDelay, 0, 600));
+ Add(new cMenuEditBoolItem(tr("Show spectrum analyzer"), &newGraphLCDSetup.enableSpectrumAnalyzer));
+ Add(new cMenuEditBoolItem(tr("Show SA volume"), &newGraphLCDSetup.SAShowVolume));
}
void cGraphLCDMenuSetup::Store()
@@ -101,4 +103,6 @@
SetupStore("BrightnessActive", GraphLCDSetup.BrightnessActive = newGraphLCDSetup.BrightnessActive);
SetupStore("BrightnessIdle", GraphLCDSetup.BrightnessIdle = newGraphLCDSetup.BrightnessIdle);
SetupStore("BrightnessDelay", GraphLCDSetup.BrightnessDelay = newGraphLCDSetup.BrightnessDelay);
+ SetupStore("enableSpectrumAnalyzer", GraphLCDSetup.enableSpectrumAnalyzer = newGraphLCDSetup.enableSpectrumAnalyzer);
+ SetupStore("SAShowVolume", GraphLCDSetup.SAShowVolume = newGraphLCDSetup.SAShowVolume);
}
diff -Naur --exclude='.*' graphlcd-0.1.3.old/plugin.c graphlcd-0.1.3/plugin.c
--- graphlcd-0.1.3.old/plugin.c 2006-09-07 16:00:17.000000000 +0200
+++ graphlcd-0.1.3/plugin.c 2006-09-07 12:20:48.000000000 +0200
@@ -67,6 +67,8 @@
virtual cOsdObject * MainMenuAction();
virtual cMenuSetupPage * SetupMenu();
virtual bool SetupParse(const char * Name, const char * Value);
+
+ virtual bool Service(const char *Id, void *Data);
};
cPluginGraphLCD::cPluginGraphLCD()
@@ -235,8 +237,24 @@
else if (!strcasecmp(Name, "BrightnessActive")) GraphLCDSetup.BrightnessActive = atoi(Value);
else if (!strcasecmp(Name, "BrightnessIdle")) GraphLCDSetup.BrightnessIdle = atoi(Value);
else if (!strcasecmp(Name, "BrightnessDelay")) GraphLCDSetup.BrightnessDelay = atoi(Value);
+ else if (!strcasecmp(Name, "enableSpectrumAnalyzer")) GraphLCDSetup.enableSpectrumAnalyzer = atoi(Value);
+ else if (!strcasecmp(Name, "SAShowVolume")) GraphLCDSetup.SAShowVolume = atoi(Value);
else return false;
return true;
}
+bool cPluginGraphLCD::Service(const char *Id, void *Data)
+{
+ if (strcmp(Id, SPAN_CLIENT_CHECK_ID) == 0)
+ {
+ if ( GraphLCDSetup.enableSpectrumAnalyzer && (Data != NULL) )
+ {
+ *((Span_Client_Check_1_0*)Data)->isActive = true;
+ }
+ return true;
+ }
+
+ return false;
+}
+
VDRPLUGINCREATOR(cPluginGraphLCD); // Don't touch this!
diff -Naur --exclude='.*' graphlcd-0.1.3.old/setup.c graphlcd-0.1.3/setup.c
--- graphlcd-0.1.3.old/setup.c 2006-09-07 16:00:17.000000000 +0200
+++ graphlcd-0.1.3/setup.c 2006-09-07 12:19:22.000000000 +0200
@@ -52,7 +52,9 @@
ScrollTime(500),
BrightnessActive(100),
BrightnessIdle(100),
- BrightnessDelay(30)
+ BrightnessDelay(30),
+ enableSpectrumAnalyzer(1),
+ SAShowVolume(1)
{
}
@@ -90,4 +92,6 @@
BrightnessActive = source->BrightnessActive;
BrightnessIdle = source->BrightnessIdle;
BrightnessDelay = source->BrightnessDelay;
+ enableSpectrumAnalyzer = source->enableSpectrumAnalyzer;
+ SAShowVolume = source->SAShowVolume;
}
diff -Naur --exclude='.*' graphlcd-0.1.3.old/setup.h graphlcd-0.1.3/setup.h
--- graphlcd-0.1.3.old/setup.h 2006-09-07 16:00:17.000000000 +0200
+++ graphlcd-0.1.3/setup.h 2006-09-07 12:20:11.000000000 +0200
@@ -54,6 +54,8 @@
int BrightnessActive;
int BrightnessIdle;
int BrightnessDelay;
+ int enableSpectrumAnalyzer;
+ int SAShowVolume;
public:
cGraphLCDSetup(void);
|