Index: bse/Makefile.am
===================================================================
RCS file: /cvs/gnome/beast/bse/Makefile.am,v
retrieving revision 1.133
diff -u -p -u -r1.133 Makefile.am
--- bse/Makefile.am	19 Apr 2006 22:19:42 -0000	1.133
+++ bse/Makefile.am	5 May 2006 21:59:43 -0000
@@ -55,6 +55,7 @@ bse_public_h_sources = $(strip \
 	bsenote.h		bsemidifile.h		bseblockutils.hh		\
 	bsecxxvalue.hh		bsecxxutils.hh		bsecxxbase.hh			bsecxxclosure.hh \
 	bsecxxarg.hh		bsecxxmodule.hh		bsecxxplugin.hh			bseloader.h \
+	bseresampler.hh		bsedatahandle-resample.h	\
 )
 # BSE C sources
 bse_c_sources = $(strip \
@@ -87,7 +88,7 @@ bse_c_sources = $(strip \
 	bsecxxvalue.cc		bsecxxutils.cc		bsecxxbase.cc			bsecxxclosure.cc \
 	bsecxxarg.cc		bsecxxmodule.cc		bsecxxplugin.cc			bseloader.c \
 	bseloader-aiff.c	bseloader-guspatch.cc	bseloader-oggvorbis.c		bseloader-bsewave.c \
-	bseloader-mad.c		bseloader-wav.c		\
+	bseloader-mad.c		bseloader-wav.c		bsedatahandle-resample.cc	bseresampler.cc \
 )
 # BSE C++ sources
 bse_cc_sources = $(strip 	\
Index: bse/bseblockutils.cc
===================================================================
RCS file: /cvs/gnome/beast/bse/bseblockutils.cc,v
retrieving revision 1.2
diff -u -p -u -r1.2 bseblockutils.cc
--- bse/bseblockutils.cc	20 Apr 2006 12:24:51 -0000	1.2
+++ bse/bseblockutils.cc	5 May 2006 21:59:43 -0000
@@ -17,6 +17,7 @@
  * Boston, MA 02111-1307, USA.
  */
 #include "bseblockutils.hh"
+#include "bseresampler.hh"
 
 namespace {
 class BlockImpl : virtual public Bse::Block::Impl {
@@ -60,6 +61,11 @@ class BlockImpl : virtual public Bse::Bl
     ovalues += offset;
     for (int pos = 0; pos < n; pos++)
       ovalues[pos * 2] += ivalues[pos];
+  }
+  virtual Bse::Resampler::Resampler2Factory*
+  resampler2_factory()
+  {
+    return Bse::Resampler::Resampler2Factory::default_factory();
   }
 };
 static BlockImpl default_block_impl;
Index: bse/bseblockutils.hh
===================================================================
RCS file: /cvs/gnome/beast/bse/bseblockutils.hh,v
retrieving revision 1.2
diff -u -p -u -r1.2 bseblockutils.hh
--- bse/bseblockutils.hh	20 Apr 2006 12:24:51 -0000	1.2
+++ bse/bseblockutils.hh	5 May 2006 21:59:43 -0000
@@ -62,6 +62,10 @@ G_END_DECLS
 #ifdef  __cplusplus
 namespace Bse {
 
+namespace Resampler {
+class Resampler2Factory;
+}
+
 /* --- C++ API --- */
 class Block {
 public:
@@ -92,7 +96,10 @@ public:
                                          float          *ovalues,
                                          const float    *ivalues,
                                          guint           offset)        { singleton->interleave2_add (n_ivalues, ovalues, ivalues, offset); }
-  
+
+  /* FIXME: reindent all the functions once this is blessed */
+  static inline Resampler::Resampler2Factory* resampler2_factory ()	{ return singleton->resampler2_factory(); }
+
   class Impl {
   protected:
     virtual     ~Impl                   ();
@@ -111,6 +118,8 @@ public:
                                          float          *ovalues,	/* length_ovalues = n_ivalues * 2 */
                                          const float    *ivalues,
                                          guint           offset) = 0;   /* 0=left, 1=right */
+    /* FIXME: reindent all the functions once this is blessed */
+    virtual Resampler::Resampler2Factory* resampler2_factory() = 0;
     friend class Block;
     static void substitute              (Impl           *substitute_impl);
   };
Index: bse/tests/Makefile.am
===================================================================
RCS file: /cvs/gnome/beast/bse/tests/Makefile.am,v
retrieving revision 1.16
diff -u -p -u -r1.16 Makefile.am
--- bse/tests/Makefile.am	19 Apr 2006 22:19:43 -0000	1.16
+++ bse/tests/Makefile.am	5 May 2006 21:59:44 -0000
@@ -9,21 +9,27 @@ SUBDIRS =
 INCLUDES += -I$(top_srcdir) -I$(top_builddir) $(SFI_CFLAGS)
 
 DEFS += -DG_LOG_DOMAIN=\"BSE-TEST\" # -DG_DISABLE_CONST_RETURNS
+CXXFLAGS += -O3 -funroll-loops
 
 EXTRA_DIST += arrows.gp filter-defs.gp
 
-TESTS = blocktests testfft testcxx subnormals loophandle
+TESTS = blocktests testfft testcxx testresampler subnormals loophandle resamplehandle resamplercapi
 noinst_PROGRAMS = $(TESTS)
 progs_ldadd = $(top_builddir)/bse/libbse.la
 testfft_SOURCES = testfft.c cxxdummy.cc
 testfft_LDADD = $(progs_ldadd)
 testcxx_SOURCES = testcxx.cc
 testcxx_LDADD = $(progs_ldadd)
+testresampler_SOURCES = testresampler.cc
+testresampler_LDADD = $(progs_ldadd)
 subnormals_SOURCES = subnormals.cc subnormals-aux.cc
 subnormals_LDADD = $(progs_ldadd)
 subnormals_CXXFLAGS = # -ffast-math
 loophandle_SOURCES = loophandle.c
 loophandle_LDADD = $(progs_ldadd)
-blocktests_SOURCES = blocktests.cc
+resamplehandle_SOURCES = resamplehandle.cc
+resamplehandle_LDADD = $(progs_ldadd)
+resamplercapi_SOURCES = resamplercapi.c
+resamplercapi_LDADD = $(progs_ldadd)
+bblocktests_SOURCES = blocktests.cc
 blocktests_LDADD = $(progs_ldadd)
-
Index: plugins/bseblockutils.cc
===================================================================
RCS file: /cvs/gnome/beast/plugins/bseblockutils.cc,v
retrieving revision 1.3
diff -u -p -u -r1.3 bseblockutils.cc
--- plugins/bseblockutils.cc	20 Apr 2006 18:09:27 -0000	1.3
+++ plugins/bseblockutils.cc	5 May 2006 21:59:45 -0000
@@ -18,6 +18,8 @@
  */
 #include <bse/bsecxxplugin.hh>
 #include <bse/bseblockutils.hh>
+#include <bse/bseresampler.hh>
+#include <bse/bseresampler.tcc>
 #ifndef __SSE__
 #error  SSE support is required for this plugin.
 #endif
@@ -26,6 +28,42 @@
 #define ALIGNMENT16(pointer) (0xf & (ptrdiff_t) (pointer))
 #define ALIGNED16(pointer)   (!ALIGNMENT16 (pointer))
 
+/*---- Resampler2FactorySSE implementation ----*/
+
+namespace Bse {
+namespace Resampler {
+
+class Resampler2FactorySSE : public Resampler2Factory {
+public:
+  Resampler2*
+  create_impl (Mode      mode,
+	       Precision precision)
+  {
+    /* keep in sync with Resampler2FactoryFPU */
+    /* alternatively, we could make this a template */
+    if (mode == MODE_UPSAMPLE)
+      {
+	switch (precision)
+	  {
+	  case PREC_48DB: return create_impl_with_coeffs <Upsampler2<16, true> > (halfband_fir_48db_coeffs, 16, 2.0);
+	  case PREC_96DB: return create_impl_with_coeffs <Upsampler2<32, true> > (halfband_fir_96db_coeffs, 32, 2.0);
+	  }
+      }
+    else if (mode == MODE_DOWNSAMPLE)
+      {
+	switch (precision)
+	  {
+	  case PREC_48DB: return create_impl_with_coeffs <Downsampler2<16, true> > (halfband_fir_48db_coeffs, 16, 1.0);
+	  case PREC_96DB: return create_impl_with_coeffs <Downsampler2<32, true> > (halfband_fir_96db_coeffs, 32, 1.0);
+	  }
+      }
+    return 0;
+  }
+} resampler2_factory_sse;
+
+}
+}
+
 namespace {
 class BlockImpl : virtual public Bse::Block::Impl {
   virtual void
@@ -101,6 +139,11 @@ class BlockImpl : virtual public Bse::Bl
     ovalues += offset;
     for (int pos = 0; pos < n; pos++)
       ovalues[pos * 2] += ivalues[pos];
+  }
+  virtual Bse::Resampler::Resampler2Factory*
+  resampler2_factory()
+  {
+    return &Bse::Resampler::resampler2_factory_sse;
   }
 public:
   void
