r4080 - trunk/plugins



Author: timj
Date: 2006-11-14 18:29:06 -0500 (Tue, 14 Nov 2006)
New Revision: 4080

Added:
   trunk/plugins/bsequantizer.cc
   trunk/plugins/bsequantizer.idl
Modified:
   trunk/plugins/ChangeLog
   trunk/plugins/Makefile.am
   trunk/plugins/Makefile.plugins
Log:
Wed Nov 15 00:27:55 2006  Tim Janik  <timj gtk org>                                                                                                           
                                                                                                                                                              
        * bsequantizer.idl, bsequantizer.cc: added bit-quantization module.                                                                                   
                                                                                                                                                              



Modified: trunk/plugins/ChangeLog
===================================================================
--- trunk/plugins/ChangeLog	2006-11-14 23:25:48 UTC (rev 4079)
+++ trunk/plugins/ChangeLog	2006-11-14 23:29:06 UTC (rev 4080)
@@ -1,3 +1,7 @@
+Wed Nov 15 00:27:55 2006  Tim Janik  <timj gtk org>
+
+	* bsequantizer.idl, bsequantizer.cc: added bit-quantization module.
+
 Tue Oct 24 23:55:45 2006  Tim Janik  <timj gtk org>
 
 	* bseblockutils.cc: provide "SSE" as impl_name.

Modified: trunk/plugins/Makefile.am
===================================================================
--- trunk/plugins/Makefile.am	2006-11-14 23:25:48 UTC (rev 4079)
+++ trunk/plugins/Makefile.am	2006-11-14 23:29:06 UTC (rev 4080)
@@ -18,6 +18,7 @@
 	bsebalance.idl			\
 	bsecontribsampleandhold.idl	\
 	bsenoise.idl			\
+	bsequantizer.idl		\
 	bsesummation.idl		\
 	davbassfilter.idl		\
 	davchorus.idl			\

Modified: trunk/plugins/Makefile.plugins
===================================================================
--- trunk/plugins/Makefile.plugins	2006-11-14 23:25:48 UTC (rev 4079)
+++ trunk/plugins/Makefile.plugins	2006-11-14 23:29:06 UTC (rev 4080)
@@ -70,6 +70,20 @@
 bsenoise_SSE_la_LIBADD    = $(bsenoise_FPU_la_LIBADD)
 bsenoise_SSE_la_CXXFLAGS  = $(SSE_PLUGIN_CXXFLAGS)
 
+## C++ Plugin bsequantizer
+$(srcdir)/bsequantizer.cc: bsequantizer.genidl.hh
+plugins_built_sources   += bsequantizer.genidl.hh
+plugin_FPU_ltlibs    += bsequantizer.FPU.la
+bsequantizer_FPU_la_SOURCES = bsequantizer.cc
+bsequantizer_FPU_la_LDFLAGS = -module $(plugins_ldflags)
+bsequantizer_FPU_la_LIBADD  = $(plugins_libs)
+bsequantizer_FPU_la_CXXFLAGS  = $(FPU_PLUGIN_CXXFLAGS)
+plugin_SSE_ltlibs      += bsequantizer.SSE.la
+bsequantizer_SSE_la_SOURCES   = $(bsequantizer_FPU_la_SOURCES)
+bsequantizer_SSE_la_LDFLAGS   = $(bsequantizer_FPU_la_LDFLAGS)
+bsequantizer_SSE_la_LIBADD    = $(bsequantizer_FPU_la_LIBADD)
+bsequantizer_SSE_la_CXXFLAGS  = $(SSE_PLUGIN_CXXFLAGS)
+
 ## C++ Plugin bsesummation
 $(srcdir)/bsesummation.cc: bsesummation.genidl.hh
 plugins_built_sources   += bsesummation.genidl.hh

Added: trunk/plugins/bsequantizer.cc
===================================================================
--- trunk/plugins/bsequantizer.cc	2006-11-14 23:25:48 UTC (rev 4079)
+++ trunk/plugins/bsequantizer.cc	2006-11-14 23:29:06 UTC (rev 4080)
@@ -0,0 +1,95 @@
+/* BSE - Bedevilled Sound Engine                        -*-mode: c++;-*-
+ * Copyright (C) 2006 Tim Janik
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General
+ * Public License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+#include "bsequantizer.genidl.hh"
+#include <bse/bseengine.h>
+#include <bse/bsemathsignal.h>
+
+namespace Bse { namespace Standard {
+
+class Quantizer : public QuantizerBase {
+  class Module: public SynthesisModule {
+    /* params */
+    double qfactor;
+  public:
+    void
+    config (QuantizerProperties *params)
+    {
+      qfactor = params->qsteps;
+    }
+    void
+    reset ()
+    {}
+    void
+    process (unsigned int n_values)
+    {
+      const double ifactor = 1.0 / qfactor;
+      if (ostream (OCHANNEL_AUDIO_OUT1).connected)
+        {
+          if (istream (ICHANNEL_AUDIO_IN1).connected)
+            {
+              float *ovalues = ostream (OCHANNEL_AUDIO_OUT1).values;
+              const float *ivalues = istream (ICHANNEL_AUDIO_IN1).values;
+              for (uint i = 0; i < n_values; i++)
+                ovalues[i] = ifactor * floor (ivalues[i] * qfactor);
+            }
+          else
+            ostream_set (OCHANNEL_AUDIO_OUT1, const_values (0));
+        }
+      if (ostream (OCHANNEL_AUDIO_OUT2).connected)
+        {
+          if (istream (ICHANNEL_AUDIO_IN2).connected)
+            {
+              float *ovalues = ostream (OCHANNEL_AUDIO_OUT2).values;
+              const float *ivalues = istream (ICHANNEL_AUDIO_IN2).values;
+              for (uint i = 0; i < n_values; i++)
+                ovalues[i] = ifactor * floor (ivalues[i] * qfactor);
+            }
+          else
+            ostream_set (OCHANNEL_AUDIO_OUT2, const_values (0));
+        }
+    }
+  };
+public:
+  bool
+  property_changed (QuantizerPropertyID prop_id)
+  {
+    switch (prop_id)
+      {
+      case PROP_QSTEPS:
+        qstep_powers = log (qsteps) / BSE_LN2;
+        notify ("qstep_powers");
+        break;
+      case PROP_QSTEP_POWERS: /* GUI only property */
+        qsteps = pow (2, qstep_powers);
+        qstep_powers = log (qsteps) / BSE_LN2; /* re-quantise */
+        notify ("qsteps");
+        break;
+      default: ;
+      }
+    return false;
+  }
+public:
+  /* implement creation and config methods for synthesis Module */
+  BSE_EFFECT_INTEGRATE_MODULE (Quantizer, Module, QuantizerProperties);
+};
+
+BSE_CXX_DEFINE_EXPORTS();
+BSE_CXX_REGISTER_ALL_TYPES_FROM_BSEQUANTIZER_IDL();
+
+} } // Bse::Standard

Added: trunk/plugins/bsequantizer.idl
===================================================================
--- trunk/plugins/bsequantizer.idl	2006-11-14 23:25:48 UTC (rev 4079)
+++ trunk/plugins/bsequantizer.idl	2006-11-14 23:29:06 UTC (rev 4080)
@@ -0,0 +1,38 @@
+/* BSE - Bedevilled Sound Engine                        -*-mode: c++;-*-
+ * Copyright (C) 2006 Tim Janik
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General
+ * Public License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+#include <bse/bse.idl>
+
+namespace Bse { namespace Standard {
+
+class Quantizer : Bse::Effect {
+  Info    category   = "/Distortion/Quantizer";
+  // Info    icon      = "icons/quantize.png";
+  Info    authors    = "Tim Janik";
+  Info    blurb      = _("This plugin quantizes the input signals according to a configurable step setting.");
+  group _("Quantization") {
+    Num  qsteps       = Num  (_("Quantization Steps"), _("The number of different steps the output signal is quantized to."), 256, 1, 4294967296, 256, STANDARD);
+    Real qstep_powers = Real (_("Bit Depth"),          _("The number of bits the quantization steps correspond to."), 8, 0, 32, 1, GUI);
+  };
+  IStream audio_in1  = ("Audio In1",  "Audio Input 1");
+  IStream audio_in2  = ("Audio In2",  "Audio Input 2");
+  OStream audio_out1 = ("Audio Out1", "Audio Output 1");
+  OStream audio_out2 = ("Audio Out2", "Audio Output 2");
+};
+
+} } // Bse::Standard




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]