summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--display.c146
-rw-r--r--display.h31
-rw-r--r--i18n.c48
-rw-r--r--menu.c4
-rw-r--r--plugin.c32
-rw-r--r--setup.c6
-rw-r--r--setup.h2
7 files changed, 263 insertions, 6 deletions
diff --git a/display.c b/display.c
index 0b437d5..9d5b9c5 100644
--- a/display.c
+++ b/display.c
@@ -28,6 +28,7 @@
#include <vdr/tools.h>
#include <vdr/menu.h>
+#include <vdr/plugin.h>
#include "compat.h"
@@ -114,6 +115,7 @@ cGraphLCDDisplay::cGraphLCDDisplay()
nCurrentBrightness = -1;
LastTimeBrightness = 0;
bBrightnessActive = true;
+ LastTimeSA.Set(0); //span
conv = new cCharSetConv(cCharSetConv::SystemCharacterTable() ? cCharSetConv::SystemCharacterTable() : "UTF-8", "ISO-8859-1");
}
@@ -384,6 +386,12 @@ void cGraphLCDDisplay::Action(void)
update = true;
}
+ if ( LastTimeSA.TimedOut() ) //span
+ {
+ update = true;
+ LastTimeSA.Set(1000);
+ }
+
// update Display every second or due to an update
if (CurrTime != LastTime || update)
{
@@ -1504,6 +1512,8 @@ void cGraphLCDDisplay::DisplayReplay(tReplayState & replay)
nTopY + nProgressbarHeight,
GLCD::clrBlack, false);
+ DisplaySA(); //span
+
if (1 < replay.total && 1 < replay.current) // Don't show full progressbar for endless streams
{
bitmap->DrawRectangle(FRAME_SPACE_X,
@@ -2030,3 +2040,139 @@ const char * cGraphLCDDisplay::Convert(const char *s)
}
+
+void cGraphLCDDisplay::DisplaySA() //span
+{
+// 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<(int)logo->Width()/2-2) && (i<3*((int)volumeLeftChannel*(int)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<(int)logo->Width()/2-2) && (i<3*((int)volumeRightChannel*(int)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;
+ }
+ }
+}
diff --git a/display.h b/display.h
index 9074f2a..5b413ee 100644
--- a/display.h
+++ b/display.h
@@ -31,10 +31,39 @@
#include <vdr/thread.h>
#include <vdr/player.h>
+#define SPAN_CLIENT_CHECK_ID "Span-ClientCheck-v1.0"
+#define SPAN_GET_BAR_HEIGHTS_ID "Span-GetBarHeights-v1.0"
#define LCDMAXCARDS 4
static const int kMaxTabCount = 10;
+struct Span_Client_Check_1_0 {
+ bool *isActive;
+ bool *isRunning;
+};
+
+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
+};
+
enum ThreadState
{
Normal,
@@ -107,6 +136,7 @@ private:
time_t LastTime;
time_t LastTimeCheckSym;
time_t LastTimeModSym;
+ cTimeMs LastTimeSA; //span
struct timeval CurrTimeval;
struct timeval UpdateAt;
@@ -128,6 +158,7 @@ private:
void DisplayTextItem();
void DisplayColorButtons();
void DisplayVolume();
+ void DisplaySA(); //span
void UpdateIn(long usec);
bool CheckAndUpdateSymbols();
diff --git a/i18n.c b/i18n.c
index 0d75e2e..821987b 100644
--- a/i18n.c
+++ b/i18n.c
@@ -966,5 +966,53 @@ const tI18nPhrase Phrases[] =
# endif
#endif
},
+ {
+ "Show spectrum analyzer",
+ "Zeige Spektrum Analyzer",
+ "",// TODO Slovenski
+ "",// TODO Italiano
+ "",// TODO Nederlands
+ "",// TODO Português
+ "",// TODO Francais
+ "",// 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 analyzer volume",
+ "Zeige Analyzer Lautstärke",
+ "",// TODO Slovenski
+ "",// TODO Italiano
+ "",// TODO Nederlands
+ "",// TODO Português
+ "",// TODO Francais
+ "",// 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 --git a/menu.c b/menu.c
index b3b6e07..0d2f208 100644
--- a/menu.c
+++ b/menu.c
@@ -75,6 +75,8 @@ cGraphLCDMenuSetup::cGraphLCDMenuSetup()
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 analyzer volume"), &newGraphLCDSetup.SAShowVolume));
}
void cGraphLCDMenuSetup::Store()
@@ -101,4 +103,6 @@ void cGraphLCDMenuSetup::Store()
SetupStore("BrightnessActive", GraphLCDSetup.BrightnessActive = newGraphLCDSetup.BrightnessActive);
SetupStore("BrightnessIdle", GraphLCDSetup.BrightnessIdle = newGraphLCDSetup.BrightnessIdle);
SetupStore("BrightnessDelay", GraphLCDSetup.BrightnessDelay = newGraphLCDSetup.BrightnessDelay);
+ SetupStore("enableSpectrumAnalyzer", GraphLCDSetup.enableSpectrumAnalyzer = newGraphLCDSetup.enableSpectrumAnalyzer); //span
+ SetupStore("SAShowVolume", GraphLCDSetup.SAShowVolume = newGraphLCDSetup.SAShowVolume);
}
diff --git a/plugin.c b/plugin.c
index 2a06a1d..0710c81 100644
--- a/plugin.c
+++ b/plugin.c
@@ -22,7 +22,7 @@
#include <vdr/plugin.h>
-static const char *VERSION = "0.1.9-pre (git 20110101)";
+static const char *VERSION = "0.1.9-pre (git 20110123)";
static const char *DESCRIPTION = "Output to graphic LCD";
static const char *MAINMENUENTRY = NULL;
@@ -54,6 +54,7 @@ public:
virtual bool SetupParse(const char * Name, const char * Value);
virtual const char **SVDRPHelpPages(void);
virtual cString SVDRPCommand(const char *Command, const char *Option, int &ReplyCode);
+ virtual bool Service(const char *Id, void *Data); // for span
};
cPluginGraphLCD::cPluginGraphLCD()
@@ -238,6 +239,8 @@ bool cPluginGraphLCD::SetupParse(const char * Name, const char * Value)
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;
}
@@ -245,10 +248,14 @@ bool cPluginGraphLCD::SetupParse(const char * Name, const char * Value)
const char **cPluginGraphLCD::SVDRPHelpPages(void)
{
static const char *HelpPages[] = {
- "CLS Clear Display.",
- "UPD Update Display.",
- "OFF Switch Plugin off.",
- "ON Switch Plugin on.",
+ "CLS\n"
+ " Clear Display.",
+ "UPD\n"
+ " Update Display.",
+ "OFF\n"
+ " Switch Plugin off.",
+ "ON \n"
+ " Switch Plugin on.",
NULL
};
return HelpPages;
@@ -284,4 +291,19 @@ cString cPluginGraphLCD::SVDRPCommand(const char *Command, const char *Option, i
return NULL;
}
+ 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 --git a/setup.c b/setup.c
index 6f3e57c..d45fdfb 100644
--- a/setup.c
+++ b/setup.c
@@ -52,7 +52,9 @@ cGraphLCDSetup::cGraphLCDSetup(void)
ScrollTime(500),
BrightnessActive(100),
BrightnessIdle(100),
- BrightnessDelay(30)
+ BrightnessDelay(30),
+ enableSpectrumAnalyzer(1), //span
+ SAShowVolume(1)
{
}
@@ -90,4 +92,6 @@ void cGraphLCDSetup::CopyFrom(const cGraphLCDSetup * source)
BrightnessActive = source->BrightnessActive;
BrightnessIdle = source->BrightnessIdle;
BrightnessDelay = source->BrightnessDelay;
+ enableSpectrumAnalyzer = source->enableSpectrumAnalyzer;
+ SAShowVolume = source->SAShowVolume;
}
diff --git a/setup.h b/setup.h
index 184aa02..2796856 100644
--- a/setup.h
+++ b/setup.h
@@ -54,6 +54,8 @@ public:
int BrightnessActive;
int BrightnessIdle;
int BrightnessDelay;
+ int enableSpectrumAnalyzer; //span
+ int SAShowVolume;
public:
cGraphLCDSetup(void);