Interpolator defined out until I can bring in libsoxr.
authorbruceperens <bruceperens@01035d8c-6547-0410-b346-abe4f91aad63>
Fri, 30 May 2014 18:40:25 +0000 (18:40 +0000)
committerbruceperens <bruceperens@01035d8c-6547-0410-b346-abe4f91aad63>
Fri, 30 May 2014 18:40:25 +0000 (18:40 +0000)
git-svn-id: https://svn.code.sf.net/p/freetel/code@1619 01035d8c-6547-0410-b346-abe4f91aad63

freedv-server/CMakeLists.txt
freedv-server/source/drivers.h
freedv-server/source/interpolate.cpp [deleted file]
freedv-server/source/interpolator.cpp [new file with mode: 0644]

index b302a61e0b2ed634e62420450cb22a8e095d906e..bb4c572590a6bdfcec64df68ffa1a0e3d44ba3ed 100644 (file)
@@ -136,6 +136,7 @@ set(Compile.sources
   source/framer_noop.cpp
   source/global.cpp
   source/interfaces.cpp
+  source/interpolator.cpp
   source/io_device.cpp
   source/keying.cpp
   source/keying_sink.cpp
index 12ee40a4ccbdfaea16fc539c632900af18af411b..fa39e1215513e6639549e21668c520a5725f5e22 100644 (file)
@@ -8,6 +8,9 @@
 #include <cstdint>
 #include <ostream>
 #include <assert.h>
+#if 0
+#include <soxr.h>
+#endif
 #include "platform.h"
 
 /// Portable way to use the [[unused]] C++11 attribute before all compilers
@@ -1027,4 +1030,33 @@ operator << (std::ostream & stream, const DriverManager & d) {
 /// Global reference to the driver manager.
 ///
 extern DriverManager * driver_manager();
+
+#if 0
+/// Interpolate between two sample rates.
+class Interpolator16 {
+private:
+  const std::size_t            in_rate;
+  const std::size_t            out_rate;
+  const unsigned int           number_of_channels;
+  const soxr_io_spec_t io_spec;
+  const soxr_quality_spec_t    quality_spec;
+  const soxr_runtime_spec_t    runtime_spec;
+
+  // Prohibit the copy constructor and operator =().
+               Interpolator16(const Interpolator16 &);
+  Interpolator16 &
+               operator = (const Interpolator &);
+
+public
+               Interpolator16(std::size_t _in_rate, std::size_t _out_rate);
+               ~Interpolator16();
+
+  void         process(
+                const std::int16_t *   in,
+                std::int16_t *         out, 
+                std::size_t            in_length,
+                std::size_t            out_length);
+}
+#endif
+
 }
diff --git a/freedv-server/source/interpolate.cpp b/freedv-server/source/interpolate.cpp
deleted file mode 100644 (file)
index 0c10128..0000000
+++ /dev/null
@@ -1,42 +0,0 @@
-#if 0
-#include <soxr.h>
-#include "drivers.h"
-
-namespace FreeDV {
-  void
-  Interpolate16(
-   const std::int16_t *        in,
-   std::int16_t *      out, 
-   std::size_t         in_rate,
-   std::size_t         out_rate, 
-   std::size_t         in_length,
-   std::size_t         out_length)
-  {
-    std::size_t                        in_done = 0;
-    std::size_t                        out_done = 0;
-    const unsigned int         number_of_channels = 1;
-    const soxr_io_spec_t       io_spec = soxr_io_spec(SOXR_INT16_S, SOXR_INT16_S);
-    const soxr_quality_spec_t  quality_spec = soxr_quality_spec(
-                                SOXR_QQ, SOXR_NO_DITHER);
-    const soxr_runtime_spec_t  runtime_spec = soxr_runtime_spec(1);
-
-    /// The "Gibbs effect" may be seen because I don't save data from the
-    /// previous block. Fix this by making the resampler a class,
-    /// instantiate it to save state, and use the iterative rather than the
-    /// one-shot version.
-    const soxr_error_t error = soxr_oneshot(
-     in_rate,
-     out_rate,
-     number_of_channels, // Number of channels.
-     in,
-     in_length,
-     &in_done,
-     out,
-     out_length,
-     &out_done,
-     io_spec,
-     quality_spec,
-     runtime_spec);  
-  }
-};
-#endif
diff --git a/freedv-server/source/interpolator.cpp b/freedv-server/source/interpolator.cpp
new file mode 100644 (file)
index 0000000..15e5afc
--- /dev/null
@@ -0,0 +1,45 @@
+#include "drivers.h"
+
+#if 0
+namespace FreeDV {
+  Interpolator16::Interpolator16(std::size_t _in_rate, std::size_t _out_rate)
+  : in_rate(_in_rate), out_rate(_out_rate), number_of_channels(1),
+    io_spec(soxr_io_spec(SOXR_INT16_S, SOXR_INT16_S),
+    quality_spec(SOXR_QQ, SOXR_NO_DITHER),
+    runtime_spec(soxr_runtime_spec(1))
+  {
+  }
+
+  Interpolator16::~Interpolator16()
+  {
+  };
+
+  void
+  Interpolator16::process(
+   const std::int16_t *        in,
+   std::int16_t *      out, 
+   std::size_t         in_length,
+   std::size_t         out_length)
+  {
+    std::size_t        in_done = 0;
+    std::size_t        out_done = 0;
+
+    // FIX: Use the state-saving version instead of the one-shot version,
+    // to prevent ringing. Is there a pipeline delay?
+
+    const soxr_error_t error = soxr_oneshot(
+     in_rate,
+     out_rate,
+     number_of_channels, // Number of channels.
+     in,
+     in_length,
+     &in_done,
+     out,
+     out_length,
+     &out_done,
+     io_spec,
+     quality_spec,
+     runtime_spec);  
+  }
+};
+#endif