r3891 - in trunk/bse: . tests



Author: timj
Date: 2006-09-16 09:53:02 -0400 (Sat, 16 Sep 2006)
New Revision: 3891

Removed:
   trunk/bse/tests/resamplercapi.c
Modified:
   trunk/bse/ChangeLog
   trunk/bse/tests/Makefile.am
   trunk/bse/tests/resamplehandle.cc
Log:
Sat Sep 16 15:50:34 2006  Tim Janik  <timj gtk org>

        * tests/resamplehandle.cc: merged with resamplercapi.c. made internal
        functions "static". fixed TSTART() usages. cleaned up main().

        * tests/Makefile.am, tests/resamplercapi.c: removed resamplercapi.c.




Modified: trunk/bse/ChangeLog
===================================================================
--- trunk/bse/ChangeLog	2006-09-16 13:31:23 UTC (rev 3890)
+++ trunk/bse/ChangeLog	2006-09-16 13:53:02 UTC (rev 3891)
@@ -1,3 +1,10 @@
+Sat Sep 16 15:50:34 2006  Tim Janik  <timj gtk org>
+
+	* tests/resamplehandle.cc: merged with resamplercapi.c. made internal
+	functions "static". fixed TSTART() usages. cleaned up main().
+
+	* tests/Makefile.am, tests/resamplercapi.c: removed resamplercapi.c.
+
 Sat Sep 16 15:19:33 2006  Tim Janik  <timj gtk org>
 
 	* bseresamplerimpl.hh: renamed bseresampler.tcc to bseresamplerimpl.hh

Modified: trunk/bse/tests/Makefile.am
===================================================================
--- trunk/bse/tests/Makefile.am	2006-09-16 13:31:23 UTC (rev 3890)
+++ trunk/bse/tests/Makefile.am	2006-09-16 13:53:02 UTC (rev 3891)
@@ -12,7 +12,7 @@
 
 EXTRA_DIST += arrows.gp filter-defs.gp
 
-TESTS = testfft loophandle testcxx subnormals blocktests resamplehandle resamplercapi
+TESTS = testfft loophandle testcxx subnormals blocktests resamplehandle
 noinst_PROGRAMS = $(TESTS) testresampler
 progs_ldadd = $(top_builddir)/bse/libbse.la
 testfft_SOURCES = testfft.c cxxdummy.cc
@@ -30,6 +30,4 @@
 testresampler_LDADD = $(progs_ldadd)
 resamplehandle_SOURCES = resamplehandle.cc
 resamplehandle_LDADD = $(progs_ldadd)
-resamplercapi_SOURCES = resamplercapi.c
-resamplercapi_LDADD = $(progs_ldadd)
  

Modified: trunk/bse/tests/resamplehandle.cc
===================================================================
--- trunk/bse/tests/resamplehandle.cc	2006-09-16 13:31:23 UTC (rev 3890)
+++ trunk/bse/tests/resamplehandle.cc	2006-09-16 13:53:02 UTC (rev 3891)
@@ -1,5 +1,5 @@
 /* BSE Resampling Datahandles Test
- * Copyright (C) 2001-2002 Tim Janik
+ * Copyright (C) 2001-2006 Tim Janik
  * Copyright (C) 2006 Stefan Westerfeld
  * 
  * This library is free software; you can redistribute it and/or
@@ -17,20 +17,19 @@
  * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
  * Boston, MA 02111-1307, USA.
  */
-#include <bse/gsldatahandle.h>
+#include <bse/bsemathsignal.h>
 #include <bse/bsemain.h>
-#include <bse/bsemathsignal.h>
+// #define TEST_VERBOSE
+#include <birnet/birnettests.h>
 #include <bse/gsldatautils.h>
 #include <bse/bseblockutils.hh>
-// #define TEST_VERBOSE
-#include <birnet/birnettests.h>
 #include <vector>
 
 using std::vector;
 using std::max;
 using std::min;
 
-void
+static void
 read_through (GslDataHandle *handle)
 {
   int64 n_values = gsl_data_handle_n_values (handle);
@@ -47,7 +46,7 @@
   g_assert (offset == n_values);
 }
 
-double
+static double
 check (const vector<float>& input, const vector<double>& expected, int n_channels, int precision_bits, double max_db)
 {
   g_return_val_if_fail (input.size() * 2 == expected.size(), 0);
@@ -123,8 +122,8 @@
   return samples_per_second / 44100.0;
 }
 
-void
-run_tests()
+static void
+run_tests (const char *run_type)
 {
   struct TestParameters {
     int bits;
@@ -156,10 +155,7 @@
 
       // mono test
       {
-	char *x = g_strdup_printf ("ResampleHandle %dbits mono", params[p].bits);
-	TSTART (x);
-	g_free (x);
-
+	TSTART ("ResampleHandle %dbits mono (%s)", params[p].bits, run_type);
 	double streams = check (input, expected, 1, params[p].bits, params[p].mono_db);
 	TDONE();
 
@@ -182,10 +178,7 @@
 
       // stereo test
       {
-	char *x = g_strdup_printf ("ResampleHandle %dbits stereo", params[p].bits);
-	TSTART (x);
-	g_free (x);
-
+        TSTART ("ResampleHandle %dbits stereo (%s)", params[p].bits, run_type);
 	double streams = check (input, expected, 2, params[p].bits, params[p].stereo_db);
 	TDONE();
 
@@ -194,32 +187,60 @@
     }
 }
 
+static void
+test_c_api (const char *run_type)
+{
+  TSTART ("Resampler C API (%s)", run_type);
+  BseResampler2 *resampler = bse_resampler2_create (BSE_RESAMPLER2_MODE_UPSAMPLE, BSE_RESAMPLER2_PREC_96DB);
+  const int INPUT_SIZE = 1024, OUTPUT_SIZE = 2048;
+  float in[INPUT_SIZE];
+  float out[OUTPUT_SIZE];
+  double error = 0;
+  int i;
+
+  for (i = 0; i < INPUT_SIZE; i++)
+    in[i] = sin (i * 440 * 2 * M_PI / 44100) * bse_window_blackman ((double) (i * 2 - INPUT_SIZE) / INPUT_SIZE);
+
+  bse_resampler2_process_block (resampler, in, INPUT_SIZE, out);
+
+  int delay = bse_resampler2_order (resampler) + 2;
+  for (i = 0; i < 2048; i++)
+    {
+      double expected = sin ((i - delay) * 220 * 2 * M_PI / 44100)
+	              * bse_window_blackman ((double) ((i - delay) * 2 - OUTPUT_SIZE) / OUTPUT_SIZE);
+      error = MAX (error, out[i] - expected);
+    }
+
+  double error_db = bse_db_from_factor (error, -200);
+
+  bse_resampler2_destroy (resampler);
+
+  TPRINT ("Test C API delta: %f\n", error_db);
+  TASSERT (error_db < -95);
+  TDONE();
+}
+
 int
 main (int   argc,
       char *argv[])
 {
   birnet_init_test (&argc, &argv);
-  //g_thread_init (NULL);
-  //birnet_init_test (&argc, &argv);
-  //bse_init_intern (&argc, &argv, "TestResample", NULL);
-  //std::set_terminate (__gnu_cxx::__verbose_terminate_handler);
+  
+  test_c_api ("FPU");
+  run_tests ("FPU");
 
-  printf ("*** tests on FPU\n");
-  run_tests();
-
   /* load plugins */
   BirnetInitValue config[] = {
     { "load-core-plugins", "1" },
     { NULL },
   };
   bse_init_test (&argc, &argv, config);
-
   /* check for possible specialization */
   if (Bse::Block::default_singleton() == Bse::Block::current_singleton())
     return 0;   /* nothing changed */
 
-  printf ("*** tests on SSE\n");
-  run_tests();
+  test_c_api ("SSE");
+  run_tests ("SSE");
 
   return 0;
 }

Deleted: trunk/bse/tests/resamplercapi.c
===================================================================
--- trunk/bse/tests/resamplercapi.c	2006-09-16 13:31:23 UTC (rev 3890)
+++ trunk/bse/tests/resamplercapi.c	2006-09-16 13:53:02 UTC (rev 3891)
@@ -1,85 +0,0 @@
-/* BSE Resampling Datahandles Test
- * Copyright (C) 2001-2002 Tim Janik
- * Copyright (C) 2006 Stefan Westerfeld
- * 
- * 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/bsemathsignal.h>
-#include <bse/bseresampler.hh>
-#include <bse/bsemain.h>
-// #define TEST_VERBOSE
-#include <birnet/birnettests.h>
-
-static void
-test_c_api()
-{
-  BseResampler2 *resampler = bse_resampler2_create (BSE_RESAMPLER2_MODE_UPSAMPLE, BSE_RESAMPLER2_PREC_96DB);
-  const int INPUT_SIZE = 1024, OUTPUT_SIZE = 2048;
-  float in[INPUT_SIZE];
-  float out[OUTPUT_SIZE];
-  double error = 0;
-  int i;
-
-  for (i = 0; i < INPUT_SIZE; i++)
-    in[i] = sin (i * 440 * 2 * M_PI / 44100) * bse_window_blackman ((double) (i * 2 - INPUT_SIZE) / INPUT_SIZE);
-
-  bse_resampler2_process_block (resampler, in, INPUT_SIZE, out);
-
-  int delay = bse_resampler2_order (resampler) + 2;
-  for (i = 0; i < 2048; i++)
-    {
-      double expected = sin ((i - delay) * 220 * 2 * M_PI / 44100)
-	              * bse_window_blackman ((double) ((i - delay) * 2 - OUTPUT_SIZE) / OUTPUT_SIZE);
-      error = MAX (error, out[i] - expected);
-    }
-
-  double error_db = bse_db_from_factor (error, -200);
-
-  bse_resampler2_destroy (resampler);
-
-  TPRINT ("Test C API error: %f\n", error_db);
-  TASSERT (error_db < -95);
-}
-
-int
-main (int   argc,
-      char *argv[])
-{
-  birnet_init_test (&argc, &argv);
-
-  TSTART ("Resampler C API (FPU)");
-  test_c_api();
-  TDONE();
-
-  /* load plugins */
-  BirnetInitValue config[] = {
-    { "load-core-plugins", "1" },
-    { NULL },
-  };
-  bse_init_test (&argc, &argv, config);
-
-#if 0 /* FIXME: C? */
-  /* check for possible specialization */
-  if (Bse::Block::default_singleton() == Bse::Block::current_singleton())
-    return 0;   /* nothing changed */
-#endif
-
-  TSTART ("Resampler C API (SSE)");
-  test_c_api();
-  TDONE();
-
-  return 0;
-}




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