r4069 - in trunk: . tests
- From: stw svn gnome org
- To: svn-commits-list gnome org
- Subject: r4069 - in trunk: . tests
- Date: Wed, 8 Nov 2006 16:08:41 -0500 (EST)
Author: stw
Date: 2006-11-08 16:08:28 -0500 (Wed, 08 Nov 2006)
New Revision: 4069
Modified:
trunk/ChangeLog
trunk/tests/testresampler.cc
Log:
Wed Nov 8 22:00:55 2006 Stefan Westerfeld <stefan space twc de>
* tests/testresampler.cc: Introduce phase wrapping for sine
computation, so that the comparision results don't get worse with the
length of the input signal.
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog 2006-11-05 03:24:19 UTC (rev 4068)
+++ trunk/ChangeLog 2006-11-08 21:08:28 UTC (rev 4069)
@@ -1,3 +1,9 @@
+Wed Nov 8 22:00:55 2006 Stefan Westerfeld <stefan space twc de>
+
+ * tests/testresampler.cc: Introduce phase wrapping for sine
+ computation, so that the comparision results don't get worse with the
+ length of the input signal.
+
Sun Nov 5 03:21:41 2006 Tim Janik <timj gtk org>
* tools/bsefextract.cc: work around a g++-3.3 bug.
Modified: trunk/tests/testresampler.cc
===================================================================
--- trunk/tests/testresampler.cc 2006-11-05 03:24:19 UTC (rev 4068)
+++ trunk/tests/testresampler.cc 2006-11-08 21:08:28 UTC (rev 4069)
@@ -414,7 +414,7 @@
for (double test_frequency = freq_min; test_frequency < (freq_max + 1); test_frequency += freq_inc)
{
long long k = 0;
- double phase = 0;
+ double phase = 0, output_phase = 0;
double test_frequency_max_diff = 0; /* for monitoring frequency scanning */
for (int b = 0; b < 1000; b++)
@@ -429,6 +429,8 @@
{
input[i+misalign] = sin (phase);
phase += test_frequency/44100.0 * 2 * M_PI;
+ while (phase > 2 * M_PI)
+ phase -= 2 * M_PI;
}
if (RESAMPLE == RES_DOWNSAMPLE || RESAMPLE == RES_SUBSAMPLE)
{
@@ -482,32 +484,37 @@
}
for (unsigned int i = 0; i < out_bs; i++, k++)
- if (k > (ups->order() * 4))
- {
- /* The expected resampler output signal is a sine signal with
- * different frequency and is phase shifted a bit.
- */
- double correct_output = sin ((k - sin_shift) * 2 * freq_factor * test_frequency / 44100.0 * M_PI);
+ {
+ if (k > (ups->order() * 4))
+ {
+ /* The expected resampler output signal is a sine signal with
+ * different frequency and is phase shifted a bit.
+ */
+ double correct_output = sin (output_phase - sin_shift * 2 * freq_factor * test_frequency / 44100.0 * M_PI);
- /* For some frequencies the expected output signal amplitude is
- * zero, because it needed to be filtered out; this fact is
- * taken into account here.
- */
- correct_output *= correct_volume;
- if (TEST == TEST_ERROR_TABLE)
- {
- printf ("%lld %.17f %.17f %.17f\n", k, check[i], correct_output, correct_output - check[i]);
- }
- else if (TEST == TEST_ERROR_SPECTRUM)
- {
- error_spectrum_error.push_back (correct_output - check[i]);
- }
- else
- {
- test_frequency_max_diff = max (test_frequency_max_diff, check[i] - correct_output);
- max_diff = max (max_diff, check[i] - correct_output);
- }
- }
+ /* For some frequencies the expected output signal amplitude is
+ * zero, because it needed to be filtered out; this fact is
+ * taken into account here.
+ */
+ correct_output *= correct_volume;
+ if (TEST == TEST_ERROR_TABLE)
+ {
+ printf ("%lld %.17f %.17f %.17f\n", k, check[i], correct_output, correct_output - check[i]);
+ }
+ else if (TEST == TEST_ERROR_SPECTRUM)
+ {
+ error_spectrum_error.push_back (correct_output - check[i]);
+ }
+ else
+ {
+ test_frequency_max_diff = max (test_frequency_max_diff, check[i] - correct_output);
+ max_diff = max (max_diff, check[i] - correct_output);
+ }
+ }
+ output_phase += freq_factor * test_frequency / 44100.0 * 2 * M_PI;
+ while (output_phase > 2 * M_PI)
+ output_phase -= 2 * M_PI;
+ }
}
double test_frequency_max_diff_db = 20 * log (test_frequency_max_diff) / log (10);
if (options.freq_scan_verbose)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]