summaryrefslogtreecommitdiff
path: root/attic/muse_qt4_evolution/muse/auxplugin.cpp
diff options
context:
space:
mode:
authorRobert Jonsson <spamatica@gmail.com>2011-03-07 19:01:11 +0000
committerRobert Jonsson <spamatica@gmail.com>2011-03-07 19:01:11 +0000
commite40fc849149dd97c248866a4a1d026dda5e57b62 (patch)
treeb12b358f3b3a0608001d30403358f8443118ec5f /attic/muse_qt4_evolution/muse/auxplugin.cpp
parent1bd4f2e8d9745cabb667b043171cad22c8577768 (diff)
clean3
Diffstat (limited to 'attic/muse_qt4_evolution/muse/auxplugin.cpp')
-rw-r--r--attic/muse_qt4_evolution/muse/auxplugin.cpp190
1 files changed, 190 insertions, 0 deletions
diff --git a/attic/muse_qt4_evolution/muse/auxplugin.cpp b/attic/muse_qt4_evolution/muse/auxplugin.cpp
new file mode 100644
index 00000000..ad203c84
--- /dev/null
+++ b/attic/muse_qt4_evolution/muse/auxplugin.cpp
@@ -0,0 +1,190 @@
+//=============================================================================
+// MusE
+// Linux Music Editor
+// $Id:$
+//
+// Copyright (C) 2006 by Werner Schweer and others
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License version 2.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+//=============================================================================
+
+#include "globaldefs.h"
+#include "auxplugin.h"
+#include "gconfig.h"
+
+AuxPlugin* auxPlugin;
+
+//---------------------------------------------------------
+// AuxPlugin
+//---------------------------------------------------------
+
+AuxPlugin::AuxPlugin()
+ : Plugin(0)
+ {
+ }
+
+//---------------------------------------------------------
+// range
+//---------------------------------------------------------
+
+void AuxPlugin::range(int idx, double* min, double* max) const
+ {
+ switch(idx) {
+ case 0: // volume
+ *min = pow(10.0f, config.minSlider * 0.05f);
+ *max = pow(10.0f, config.maxSlider * 0.05f);
+ break;
+ case 1: // pan
+ *min = -1.0;
+ *max = 1.0;
+ break;
+ default:
+ printf("AuxPlugin::bad index\n");
+ break;
+ }
+ }
+
+//---------------------------------------------------------
+// createPIF
+//---------------------------------------------------------
+
+PluginIF* AuxPlugin::createPIF(PluginI* pi)
+ {
+ AuxPluginIF* pif = new AuxPluginIF(pi);
+ pif->init(pi->plugin());
+ return pif;
+ }
+
+//---------------------------------------------------------
+// isLog
+//---------------------------------------------------------
+
+bool AuxPlugin::isLog(int idx) const
+ {
+ return idx == 0 ? true : false;
+ }
+
+//---------------------------------------------------------
+// isBool
+//---------------------------------------------------------
+
+bool AuxPlugin::isBool(int) const
+ {
+ return false;
+ }
+
+//---------------------------------------------------------
+// isInt
+//---------------------------------------------------------
+
+bool AuxPlugin::isInt(int) const
+ {
+ return false;
+ }
+
+//---------------------------------------------------------
+// defaultValue
+//---------------------------------------------------------
+
+double AuxPlugin::defaultValue(int idx) const
+ {
+ return idx == 0 ? -70.0 : 0.0;
+ }
+
+//---------------------------------------------------------
+// AuxPluginIF
+//---------------------------------------------------------
+
+AuxPluginIF::AuxPluginIF(PluginI* pi)
+ : PluginIF(pi)
+ {
+ for (int i = 0; i < MAX_CHANNELS; ++i)
+ posix_memalign((void**)(_buffer + i), 16, sizeof(float) * segmentSize);
+ }
+
+//---------------------------------------------------------
+// AuxPluginIF
+//---------------------------------------------------------
+
+AuxPluginIF::~AuxPluginIF()
+ {
+ for (int i = 0; i < MAX_CHANNELS; ++i) {
+ if (_buffer[i])
+ free(_buffer[i]);
+ }
+ }
+
+//---------------------------------------------------------
+// apply
+//---------------------------------------------------------
+
+void AuxPluginIF::apply(unsigned nframes, float** s, float** /*dst*/)
+ {
+ // TODO: optimize copy away if there is no route
+ double vol[2];
+ vol[0] = volume * (1.0 - pan);
+ vol[1] = volume * (1.0 + pan);
+
+ for (int i = 0; i < pluginI->channel(); ++i) {
+ float* dst = _buffer[i];
+ float* src = s[i];
+ double v = vol[i];
+ for (unsigned k = 0; k < nframes; ++k)
+ *dst++ = (*src++) * v;
+ }
+ }
+
+//---------------------------------------------------------
+// getParameterName
+//---------------------------------------------------------
+
+const char* AuxPluginIF::getParameterName(int i) const
+ {
+ if (i == 0)
+ return "Volume";
+ else
+ return "Pan";
+ }
+
+//---------------------------------------------------------
+// setParam
+//---------------------------------------------------------
+
+void AuxPluginIF::setParam(int i, double val)
+ {
+ if (i == 0)
+ volume = val;
+ else
+ pan = val;
+ }
+
+//---------------------------------------------------------
+// param
+//---------------------------------------------------------
+
+float AuxPluginIF::param(int i) const
+ {
+ return i == 0 ? volume : pan;
+ }
+
+//---------------------------------------------------------
+// init
+//---------------------------------------------------------
+
+bool AuxPluginIF::init(Plugin* p)
+ {
+ volume = p->defaultValue(0);
+ pan = p->defaultValue(1);
+ return true;
+ }
+