diff options
author | anbr <vdr07@deltab.de> | 2010-10-31 10:25:15 +0100 |
---|---|---|
committer | anbr <vdr07@deltab.de> | 2010-10-31 10:25:15 +0100 |
commit | 05b1e47cd40f1604fbe687e86319790ad774bbf7 (patch) | |
tree | 5b66098d1b7901425c0a4a45770c4277c28f5274 | |
parent | 25177cb4765a03da7fab10c500097910e13924e6 (diff) | |
download | vdr-plugin-targavfd-05b1e47cd40f1604fbe687e86319790ad774bbf7.tar.gz vdr-plugin-targavfd-05b1e47cd40f1604fbe687e86319790ad774bbf7.tar.bz2 |
Support spectrum analyzer visualization (need span-plugin)0.0.6.1
-rw-r--r-- | span.c | 110 | ||||
-rw-r--r-- | span.h | 48 |
2 files changed, 158 insertions, 0 deletions
@@ -0,0 +1,110 @@ +/* + * targavfd plugin for VDR (C++) + * + * (C) 2010 Andreas Brachold <vdr07 AT deltab de> + * Span handling suggest by span-plugin + * + * This targavfd plugin is free software: you can redistribute it and/or + * modify it under the terms of the GNU General Public License as published + * by the Free Software Foundation, version 3 of the License. + * + * See the files README and COPYING for details. + * + */ + +#include "targavfd.h" +#include "span.h" + +/* + * Spectrum Analyzer visualization + * need as middleware span-plugin + */ +bool cVFDWatch::RenderSpectrumAnalyzer() +{ + bool bDraw = false; + /*if ( theSetup.m_bEnableSpectrumAnalyzer )*/ { + if (cPluginManager::CallFirstService(SPAN_GET_BAR_HEIGHTS_ID, NULL)) { + Span_GetBarHeights_v1_0 gbh; + + int bands = 19; + int falloff = 8; + int i,x,y; + + unsigned int *barHeights = new unsigned int[bands]; + unsigned int *barHeightsLeftChannel = new unsigned int[bands]; + unsigned int *barHeightsRightChannel = new unsigned int[bands]; + unsigned int volumeLeftChannel; + unsigned int volumeRightChannel; + unsigned int volumeBothChannels; + unsigned int *barPeaksBothChannels = new unsigned int[bands]; + unsigned int *barPeaksLeftChannel = new unsigned int[bands]; + unsigned int *barPeaksRightChannel = new unsigned int[bands]; + + gbh.bands = bands; + gbh.barHeights = barHeights; + gbh.barHeightsLeftChannel = barHeightsLeftChannel; + gbh.barHeightsRightChannel = barHeightsRightChannel; + gbh.volumeLeftChannel = &volumeLeftChannel; + gbh.volumeRightChannel = &volumeRightChannel; + gbh.volumeBothChannels = &volumeBothChannels; + gbh.name = "targavfd"; + gbh.falloff = falloff; + gbh.barPeaksBothChannels = barPeaksBothChannels; + gbh.barPeaksLeftChannel = barPeaksLeftChannel; + gbh.barPeaksRightChannel = barPeaksRightChannel; + + if ( cPluginManager::CallFirstService(SPAN_GET_BAR_HEIGHTS_ID, &gbh )) { + + int barWidth = (this->Width() - bands)/bands; + int saEndY = this->Height(); + + this->clear(); + + for ( i=0; i < bands; i++ ) { + // draw bar + y = (barHeights[i]*(saEndY))/SPAN_HEIGHT; + x = (barWidth*i) + i; + this->Rectangle(x, + saEndY, + x + barWidth - 1, + saEndY - y, + true); + + // draw peak + y = (barPeaksBothChannels[i]*(saEndY))/SPAN_HEIGHT; + if ( y > 0) { + this->Rectangle(x, + saEndY - y, + x + barWidth - 1, + saEndY - y, + true); + } + } + bDraw = true; + } + delete [] barHeights; + delete [] barHeightsLeftChannel; + delete [] barHeightsRightChannel; + delete [] barPeaksBothChannels; + delete [] barPeaksLeftChannel; + delete [] barPeaksRightChannel; + } + } + return bDraw; +} + +/* + * Report presence of Spectrum Analyzer visualization + * from span-plugin requested + */ +bool cPluginTargaVFD::Service(const char *Id, void *Data) { + if (Id && strcmp(Id, SPAN_CLIENT_CHECK_ID) == 0) { + if ( /*theSetup.m_bEnableSpectrumAnalyzer &&*/ (Data != NULL) ) { + *((Span_Client_Check_1_0*)Data)->isActive = true; + } + return true; + } + return false; +} + + @@ -0,0 +1,48 @@ +/*
+ * targavfd plugin for VDR (C++)
+ *
+ * (C) 2010 Andreas Brachold <vdr07 AT deltab de>
+ * Span handling suggest by span-plugin
+ *
+ * This targavfd plugin is free software: you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as published
+ * by the Free Software Foundation, version 3 of the License.
+ *
+ * See the files README and COPYING for details.
+ *
+ */
+
+#ifndef __SPAN_DEFINES_H
+#define __SPAN_DEFINES_H
+
+
+#define SPAN_CLIENT_CHECK_ID "Span-ClientCheck-v1.0"
+#define SPAN_GET_BAR_HEIGHTS_ID "Span-GetBarHeights-v1.0"
+
+struct Span_Client_Check_1_0 {
+ bool *isActive;
+ bool *isRunning;
+};
+
+struct Span_GetBarHeights_v1_0 {
+// all heights are normalized to 100(%)
+ 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 a "nice" (human understandable) height of the bars.
+// So each client may scale the heights with the guarantee that it is represented as a percentage of 100%.
+#define SPAN_HEIGHT 100
+
+#endif
|