r4106 - in trunk: . tools



Author: stw
Date: 2006-11-26 10:51:59 -0500 (Sun, 26 Nov 2006)
New Revision: 4106

Modified:
   trunk/ChangeLog
   trunk/tools/bseloopfuncs.c
   trunk/tools/bseloopfuncs.h
   trunk/tools/bsewavetool.cc
Log:
Sun Nov 26 16:25:50 2006  Stefan Westerfeld  <stefan space twc de>

	* tools/bseloopfuncs.[hc]: Moved highpass handle to
	bse/bsedatahandle-fir.cc.

	* tools/bsewavetool.cc: Commented out experimental thinout command.


Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog	2006-11-26 15:50:26 UTC (rev 4105)
+++ trunk/ChangeLog	2006-11-26 15:51:59 UTC (rev 4106)
@@ -1,3 +1,10 @@
+Sun Nov 26 16:25:50 2006  Stefan Westerfeld  <stefan space twc de>
+
+	* tools/bseloopfuncs.[hc]: Moved highpass handle to
+	bse/bsedatahandle-fir.cc.
+
+	* tools/bsewavetool.cc: Commented out experimental thinout command.
+
 Sun Nov 26 15:25:49 2006  Stefan Westerfeld  <stefan space twc de>
 
 	* tools/bseloopfuncs.[hc]: Adapted the API of the highpass handle.

Modified: trunk/tools/bseloopfuncs.c
===================================================================
--- trunk/tools/bseloopfuncs.c	2006-11-26 15:50:26 UTC (rev 4105)
+++ trunk/tools/bseloopfuncs.c	2006-11-26 15:51:59 UTC (rev 4106)
@@ -18,8 +18,6 @@
  */
 #include "bseloopfuncs.h"
 #include <bse/gsldatacache.h>
-#include <bse/gslfilter.h>
-#include <complex.h>
 #include <string.h>
 #include <stdio.h>
 #include <math.h>
@@ -36,134 +34,6 @@
   LoopEntry  entries[1];        /* flexible array */
 } LoopStack;
 
-/*
- * 0db ----------           __________
- *                         /
- *                        /
- *                       /
- * f1_level (dB) - _____/
- *
- *                      |   |
- *                      f1 f2
- *
- * @f1: high pass start frequency [0:PI] (SR = 2*PI)
- * @f2: high pass end frequency [0:PI] (SR = 2*PI)
- */
-
-static void
-fir_hp (const gfloat *src,
-	const guint   n_samples,
-	gfloat       *dest,
-	gdouble       cutoff_freq,
-	guint         iorder)
-{
-  double a[iorder + 1];
-
-  //const guint transfer_func_length = 64;
-  const guint transfer_func_length = 4;
-  double transfer_func_freqs[transfer_func_length];
-  double transfer_func_values[transfer_func_length];
-
-  transfer_func_freqs[0]  = 0;
-  transfer_func_values[0] = 0;
-
-  transfer_func_freqs[1]  = cutoff_freq;
-  transfer_func_values[1] = 0;
-
-  transfer_func_freqs[2]  = cutoff_freq;
-  transfer_func_values[2] = 1.0; // 0 dB
-
-  transfer_func_freqs[3]  = PI;
-  transfer_func_values[3] = 1.0; // 0 dB
-
-  gsl_filter_fir_approx (iorder, a, transfer_func_length, transfer_func_freqs, transfer_func_values, TRUE);
-
-#if 0 // debugging
-  gfloat freq;
-  for (freq = 0; freq < PI; freq += 0.01)
-    {
-      complex z = cexp (I * freq);
-      complex r = 0;
-
-      guint i;
-      for (i = 0; i <= iorder; i++)
-	{
-	  r /= z;
-	  r += a[i];
-	}
-      printf ("%f %f\n", freq, cabs (r));
-    }
-
-  /* normalize */
-  gdouble norm = 0;
-  guint k;
-  for (k = 0; k <= iorder; k++)
-    norm += fabs (a[k]);
-
-  printf ("# norm = %f\n", norm);
-  for (k = 0; k <= iorder; k++)
-    a[k] /= norm;
-#endif
-
-  /* tiny FIR evaluation: not optimized for speed */
-  guint i, j;
-  for (i = 0; i < n_samples; i++)
-    {
-      gdouble accu = 0;
-      for (j = 0; j <= iorder; j++)
-	{
-	  GslLong p = i + j;
-	  p -= iorder / 2;
-
-	  if (p >= 0 && p < n_samples)
-	    accu += a[j] * src[p];
-	}
-      dest[i] = accu;
-    }
-}
-
-GslDataHandle*
-gsl_data_handle_new_fir_highpass (GslDataHandle *src_handle,
-				  gdouble        cutoff_freq,
-				  guint          order)
-{
-  g_return_val_if_fail (src_handle != NULL, NULL);
-  
-  /* check out data handle */
-  if (gsl_data_handle_open (src_handle) != BSE_ERROR_NONE)
-    return NULL;
-  
-  GslLong src_handle_n_values   = gsl_data_handle_n_values (src_handle);
-  GslLong src_handle_n_channels = gsl_data_handle_n_channels (src_handle);
-  GslLong src_handle_mix_freq   = gsl_data_handle_mix_freq (src_handle);
-  GslLong src_handle_osc_freq   = gsl_data_handle_osc_freq (src_handle);
-  
-  /* read input */
-  gfloat *src_values = g_new (gfloat, src_handle_n_values);
-  GslLong i;
-  GslDataPeekBuffer pbuf = { +1, };
-  for (i = 0; i < src_handle_n_values; i++) /* FIXME: use gsl_data_handle_read() */
-    src_values[i] = gsl_data_handle_peek_value (src_handle, i, &pbuf);
-  
-  /* apply fir filter to new memory buffer */
-  gfloat *dest_values = g_new (gfloat, src_handle_n_values);
-  fir_hp (src_values, src_handle_n_values, dest_values, cutoff_freq / src_handle_mix_freq, order);
-  g_free (src_values);
-  
-  /* create a mem handle with filtered data */
-  GslDataHandle *mhandle = gsl_data_handle_new_mem (src_handle_n_channels,
-                                                    32, // bit_depth: possibly increased by filtering
-                                                    src_handle_mix_freq,
-                                                    src_handle_osc_freq,
-                                                    src_handle_n_values,
-                                                    dest_values,
-                                                    g_free);
-  GslDataHandle *dhandle = gsl_data_handle_new_add_xinfos (mhandle, src_handle->setup.xinfos);
-  gsl_data_handle_close (src_handle);
-  gsl_data_handle_unref (mhandle);
-  return dhandle;
-}
-
 static gdouble
 score_headloop (GslDataHandle *dhandle,
                 const gfloat  *ls, /* loop start */

Modified: trunk/tools/bseloopfuncs.h
===================================================================
--- trunk/tools/bseloopfuncs.h	2006-11-26 15:50:26 UTC (rev 4105)
+++ trunk/tools/bseloopfuncs.h	2006-11-26 15:51:59 UTC (rev 4106)
@@ -44,23 +44,6 @@
   double        detail_scores[64];
 } GslDataLoopConfig;
 
-/*
- *           __________
- *          /
- *         /
- *        /
- *  _____/
- *         |
- *    cutoff_freq
- *
- * @cutoff_freq: cutoff frequency in Hz in intervall [0..SR/2]
- * @order:       number of falter coefficients
- */
-
-GslDataHandle* gsl_data_handle_new_fir_highpass (GslDataHandle *src_handle,
-				                 gdouble        cutoff_freq,
-						 guint          order);
-
 /* mem-cached loop position and size finder. tests through all possible
  * loop sizes around center points determined by block/(analysis_points+1).
  * uses full-block comparisons (centering comparison area around the

Modified: trunk/tools/bsewavetool.cc
===================================================================
--- trunk/tools/bsewavetool.cc	2006-11-26 15:50:26 UTC (rev 4105)
+++ trunk/tools/bsewavetool.cc	2006-11-26 15:51:59 UTC (rev 4106)
@@ -1352,6 +1352,7 @@
   }
 } cmd_loop ("loop");
 
+#if 0
 class ThinOutCmd : public Command {
   GslLong max_total_size;
   gdouble max_chunk_error;
@@ -1725,6 +1726,7 @@
       }
   }
 } cmd_thinout ("thinout");
+#endif
 
 class Highpass : public Command {
 public:




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