r3987 - in trunk/bse: . tests



Author: stw
Date: 2006-10-18 16:04:18 -0400 (Wed, 18 Oct 2006)
New Revision: 3987

Modified:
   trunk/bse/ChangeLog
   trunk/bse/bsedatahandle-resample.cc
   trunk/bse/bseresampler.hh
   trunk/bse/tests/resamplehandle.cc
Log:
Wed Oct 18 21:47:15 2006  Stefan Westerfeld  <stefan space twc de>

	* tests/resamplehandle.cc:
	* bseresampler.hh: Improved comments on delay compensation.

	* bsedatahandle-resample.cc: Reorganized delay compensation code in
	open() a bit, improved comments.


Modified: trunk/bse/ChangeLog
===================================================================
--- trunk/bse/ChangeLog	2006-10-17 21:11:23 UTC (rev 3986)
+++ trunk/bse/ChangeLog	2006-10-18 20:04:18 UTC (rev 3987)
@@ -1,3 +1,11 @@
+Wed Oct 18 21:47:15 2006  Stefan Westerfeld  <stefan space twc de>
+
+	* tests/resamplehandle.cc:
+	* bseresampler.hh: Improved comments on delay compensation.
+
+	* bsedatahandle-resample.cc: Reorganized delay compensation code in
+	open() a bit, improved comments.
+
 Tue Oct 17 23:10:43 2006  Tim Janik  <timj gtk org>
 
 	* bseellipticfilter.c: cosmetics, fixed constants.

Modified: trunk/bse/bsedatahandle-resample.cc
===================================================================
--- trunk/bse/bsedatahandle-resample.cc	2006-10-17 21:11:23 UTC (rev 3986)
+++ trunk/bse/bsedatahandle-resample.cc	2006-10-18 20:04:18 UTC (rev 3987)
@@ -166,23 +166,25 @@
     m_pcm_frame = -2;
     m_pcm_data.resize (m_frame_size);
 
+    /* FIXME: Resampler2::find_precision_for_bits (...) */
+    BseResampler2Precision precision = static_cast<BseResampler2Precision> (m_precision_bits);
     for (guint i = 0; i < setup->n_channels; i++)
       {
-	BseResampler2Precision precision = static_cast<BseResampler2Precision> (m_precision_bits);
 	Resampler2 *resampler = Resampler2::create (mode(), precision);
-	g_assert (resampler); /* FIXME: better error handling */
+	g_assert (resampler);
 
 	m_resamplers.push_back (resampler);
-	m_filter_order = resampler->order();
-	
-	g_assert (m_filter_order % 2 == 0);
-	/* Resampler2::delay() is defined in output samples, but we
-	 * compensate by shifting the input samples, thus the factor 2
-	 */
-	m_filter_delay = mode() == BSE_RESAMPLER2_MODE_UPSAMPLE ?
-	                 (int) round (resampler->delay() / 2) :
-			 (int) round (resampler->delay() * 2);
       }
+    g_assert (!m_resamplers.empty());	  /* n_channels is always > 0 */
+    m_filter_order = m_resampler[0]->order();
+
+    /* Resampler2::delay() is defined in output samples, but we need to
+     * compensate by shifting the input samples to enable seeking, thus the
+     * factor 2
+     */
+    m_filter_delay = (mode() == BSE_RESAMPLER2_MODE_UPSAMPLE ?
+		      (int) round (resampler->delay() / 2) :
+		      (int) round (resampler->delay() * 2));
     return BSE_ERROR_NONE;
   }
   void

Modified: trunk/bse/bseresampler.hh
===================================================================
--- trunk/bse/bseresampler.hh	2006-10-17 21:11:23 UTC (rev 3986)
+++ trunk/bse/bseresampler.hh	2006-10-18 20:04:18 UTC (rev 3987)
@@ -82,9 +82,10 @@
   virtual guint	      order() const = 0;
   /**
    * Return the delay introduced by the resampler. This delay is guaranteed to
-   * be >= 0.0, and for factor 2 resampling always a multiple of 0.5.
+   * be >= 0.0, and for factor 2 resampling always a multiple of 0.5 (2.0 for
+   * upsampling).
    *
-   * The return value can also be thought of the index in the output signal,
+   * The return value can also be thought of as index into the output signal,
    * where the first input sample can be found.
    *
    * Beware of fractional delays, for instance for downsampling, a delay() of

Modified: trunk/bse/tests/resamplehandle.cc
===================================================================
--- trunk/bse/tests/resamplehandle.cc	2006-10-17 21:11:23 UTC (rev 3986)
+++ trunk/bse/tests/resamplehandle.cc	2006-10-18 20:04:18 UTC (rev 3987)
@@ -323,7 +323,7 @@
       size_t i = 0, j = (int) round (delay * 2);
       if (j % 2)
 	{
-	  /* implement half a sample delay (for downsampling only) */
+	  /* implement half a output sample delay (for downsampling only) */
 	  g_assert (params[p].mode == BSE_RESAMPLER2_MODE_DOWNSAMPLE);
 	  i++;
 	  j += 2;




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