shithub: aubio

Download patch

ref: df9df98abce06f360f638c354a1e0ddd471bce9e
parent: e9436a689ccbecfbd2fbf1257a5cab01905158dc
author: Paul Brossier <piem@piem.org>
date: Wed Mar 6 11:08:25 EST 2013

tests/src/test-mathutils.c: improve

--- a/tests/src/test-mathutils.c
+++ b/tests/src/test-mathutils.c
@@ -26,32 +26,32 @@
 
 int test_miditofreq()
 {
-  smpl_t midi, freq;
-  for ( midi = 0; midi < 128; midi += 3 ) {
-    freq = aubio_miditofreq(midi);
-    fprintf(stdout, "aubio_miditofreq(%.2f) = %.2f\n", midi, freq);
+  smpl_t a, b;
+  fprintf(stdout, "b = aubio_miditofreq(a): [");
+  for ( a = -123.; a < 400.; a += 20. ) {
+    b = aubio_miditofreq(a);
+    fprintf(stdout, "(%.2f,  %.2f), ", a, b);
   }
-  midi = 69.5;
-  freq = aubio_miditofreq(midi);
-  fprintf(stdout, "aubio_miditofreq(%.2f) = %.2f\n", midi, freq);
-  midi = -69.5;
-  freq = aubio_miditofreq(midi);
-  fprintf(stdout, "aubio_miditofreq(%.2f) = %.2f\n", midi, freq);
-  midi = -169.5;
-  freq = aubio_miditofreq(midi);
-  fprintf(stdout, "aubio_miditofreq(%.2f) = %.2f\n", midi, freq);
-  midi = 140.;
-  freq = aubio_miditofreq(midi);
-  fprintf(stdout, "aubio_miditofreq(%.2f) = %.2f\n", midi, freq);
-  midi = 0;
-  freq = aubio_miditofreq(midi);
-  fprintf(stdout, "aubio_miditofreq(%.2f) = %.2f\n", midi, freq);
-  midi = 8.2e10;
-  freq = aubio_miditofreq(midi);
-  fprintf(stdout, "aubio_miditofreq(%.2f) = %.2f\n", midi, freq);
-  midi = -5.e10;
-  freq = aubio_miditofreq(midi);
-  fprintf(stdout, "aubio_miditofreq(%.2f) = %.2f\n", midi, freq);
+  b = aubio_miditofreq(a);
+  fprintf(stdout, "(%.2f,  %.2f), ", a, b);
+  a = -69.5;
+  b = aubio_miditofreq(a);
+  fprintf(stdout, "(%.2f,  %.2f), ", a, b);
+  a = -169.5;
+  b = aubio_miditofreq(a);
+  fprintf(stdout, "(%.2f,  %.2f), ", a, b);
+  a = 140.;
+  b = aubio_miditofreq(a);
+  fprintf(stdout, "(%.2f,  %.2f), ", a, b);
+  a = 0;
+  b = aubio_miditofreq(a);
+  fprintf(stdout, "(%.2f,  %.2f), ", a, b);
+  a = 8.2e10;
+  b = aubio_miditofreq(a);
+  fprintf(stdout, "(%.2f,  %.2f), ", a, b);
+  a = -5.e10;
+  fprintf(stdout, "(%.2f,  %.2f)", a, b);
+  fprintf(stdout, "]\n");
   return 0;
 }
 
@@ -58,31 +58,32 @@
 int test_freqtomidi()
 {
   smpl_t midi, freq;
+  fprintf(stdout, "b = aubio_freqtomidi(a): [");
   for ( freq = 0.; freq < 30000.; freq += 440. ) {
     midi = aubio_freqtomidi(freq);
-    fprintf(stdout, "aubio_freqtomidi(%.2f) = %.2f\n", freq, midi);
+    fprintf(stdout, "(%.2f,  %.2f), ", freq, midi);
   }
   freq = 69.5;
   midi = aubio_freqtomidi(freq);
-  fprintf(stdout, "aubio_freqtomidi(%.2f) = %.2f\n", freq, midi);
+  fprintf(stdout, "(%.2f,  %.2f), ", freq, midi);
   freq = -69.5;
   midi = aubio_freqtomidi(freq);
-  fprintf(stdout, "aubio_freqtomidi(%.2f) = %.2f\n", freq, midi);
+  fprintf(stdout, "(%.2f,  %.2f), ", freq, midi);
   freq = -169.5;
   midi = aubio_freqtomidi(freq);
-  fprintf(stdout, "aubio_freqtomidi(%.2f) = %.2f\n", freq, midi);
+  fprintf(stdout, "(%.2f,  %.2f), ", freq, midi);
   freq = 140.;
   midi = aubio_freqtomidi(freq);
-  fprintf(stdout, "aubio_freqtomidi(%.2f) = %.2f\n", freq, midi);
+  fprintf(stdout, "(%.2f,  %.2f), ", freq, midi);
   freq = 0;
   midi = aubio_freqtomidi(freq);
-  fprintf(stdout, "aubio_freqtomidi(%.2f) = %.2f\n", freq, midi);
+  fprintf(stdout, "(%.2f,  %.2f), ", freq, midi);
   freq = 8.2e10;
   midi = aubio_freqtomidi(freq);
-  fprintf(stdout, "aubio_freqtomidi(%.2f) = %.2f\n", freq, midi);
+  fprintf(stdout, "(%.2f,  %.2f), ", freq, midi);
   freq = -5.;
   midi = aubio_freqtomidi(freq);
-  fprintf(stdout, "aubio_freqtomidi(%.2f) = %.2f\n", freq, midi);
+  fprintf(stdout, "(%.2f,  %.2f)]\n", freq, midi);
   return 0;
 }