source: tests/src/test-mathutils.c @ 332487b

feature/autosinkfeature/cnnfeature/cnn_orgfeature/constantqfeature/crepefeature/crepe_orgfeature/pitchshiftfeature/pydocstringsfeature/timestretchfix/ffmpeg5pitchshiftsamplertimestretchyinfft+
Last change on this file since 332487b was 332487b, checked in by Paul Brossier <piem@piem.org>, 10 years ago

tests/src: clean up includes

  • Property mode set to 100644
File size: 3.1 KB
RevLine 
[7359775]1#define AUBIO_UNSTABLE 1
[332487b]2#include "aubio.h"
3#include "utils_tests.h"
[d314636]4
[0546c1f3]5int test_next_power_of_two (void);
6int test_miditofreq (void);
7int test_freqtomidi (void);
8int test_aubio_window (void);
9
[158e031]10int test_next_power_of_two (void)
[7e35b37]11{
[7359775]12  uint_t a, b;
[7e35b37]13  a = 15; b = aubio_next_power_of_two(a); assert(b == 16);
14  fprintf(stdout, "aubio_next_power_of_two(%d) = %d\n", a, b);
[d314636]15
[7e35b37]16  a = 17; b = aubio_next_power_of_two(a); assert(b == 32);
17  fprintf(stdout, "aubio_next_power_of_two(%d) = %d\n", a, b);
[d314636]18
[7e35b37]19  a = 31; b = aubio_next_power_of_two(a); assert(b == 32);
20  fprintf(stdout, "aubio_next_power_of_two(%d) = %d\n", a, b);
[d314636]21
[7e35b37]22  a = 32; b = aubio_next_power_of_two(a); assert(b == 32);
23  fprintf(stdout, "aubio_next_power_of_two(%d) = %d\n", a, b);
[d314636]24
[7e35b37]25  a = 33; b = aubio_next_power_of_two(a); assert(b == 64);
26  fprintf(stdout, "aubio_next_power_of_two(%d) = %d\n", a, b);
27
28  return 0;
29}
30
[158e031]31int test_miditofreq (void)
[7e35b37]32{
[df9df98]33  smpl_t a, b;
34  fprintf(stdout, "b = aubio_miditofreq(a): [");
35  for ( a = -123.; a < 400.; a += 20. ) {
36    b = aubio_miditofreq(a);
37    fprintf(stdout, "(%.2f,  %.2f), ", a, b);
[7e35b37]38  }
[df9df98]39  b = aubio_miditofreq(a);
40  fprintf(stdout, "(%.2f,  %.2f), ", a, b);
41  a = -69.5;
42  b = aubio_miditofreq(a);
43  fprintf(stdout, "(%.2f,  %.2f), ", a, b);
44  a = -169.5;
45  b = aubio_miditofreq(a);
46  fprintf(stdout, "(%.2f,  %.2f), ", a, b);
47  a = 140.;
48  b = aubio_miditofreq(a);
49  fprintf(stdout, "(%.2f,  %.2f), ", a, b);
50  a = 0;
51  b = aubio_miditofreq(a);
52  fprintf(stdout, "(%.2f,  %.2f), ", a, b);
53  a = 8.2e10;
54  b = aubio_miditofreq(a);
55  fprintf(stdout, "(%.2f,  %.2f), ", a, b);
56  a = -5.e10;
57  fprintf(stdout, "(%.2f,  %.2f)", a, b);
58  fprintf(stdout, "]\n");
[d314636]59  return 0;
60}
61
[158e031]62int test_freqtomidi (void)
[7e35b37]63{
64  smpl_t midi, freq;
[df9df98]65  fprintf(stdout, "b = aubio_freqtomidi(a): [");
[7e35b37]66  for ( freq = 0.; freq < 30000.; freq += 440. ) {
67    midi = aubio_freqtomidi(freq);
[df9df98]68    fprintf(stdout, "(%.2f,  %.2f), ", freq, midi);
[7e35b37]69  }
70  freq = 69.5;
71  midi = aubio_freqtomidi(freq);
[df9df98]72  fprintf(stdout, "(%.2f,  %.2f), ", freq, midi);
[7e35b37]73  freq = -69.5;
74  midi = aubio_freqtomidi(freq);
[df9df98]75  fprintf(stdout, "(%.2f,  %.2f), ", freq, midi);
[7e35b37]76  freq = -169.5;
77  midi = aubio_freqtomidi(freq);
[df9df98]78  fprintf(stdout, "(%.2f,  %.2f), ", freq, midi);
[7e35b37]79  freq = 140.;
80  midi = aubio_freqtomidi(freq);
[df9df98]81  fprintf(stdout, "(%.2f,  %.2f), ", freq, midi);
[7e35b37]82  freq = 0;
83  midi = aubio_freqtomidi(freq);
[df9df98]84  fprintf(stdout, "(%.2f,  %.2f), ", freq, midi);
[7e35b37]85  freq = 8.2e10;
86  midi = aubio_freqtomidi(freq);
[df9df98]87  fprintf(stdout, "(%.2f,  %.2f), ", freq, midi);
[7e35b37]88  freq = -5.;
89  midi = aubio_freqtomidi(freq);
[df9df98]90  fprintf(stdout, "(%.2f,  %.2f)]\n", freq, midi);
[7e35b37]91  return 0;
92}
93
[158e031]94int test_aubio_window (void)
[7e35b37]95{
96  uint_t window_size = 16;
97  fvec_t * window = new_aubio_window("default", window_size);
98  del_fvec(window);
99
100  window = new_fvec(window_size);
101  fvec_set_window(window, "rectangle");
102  fvec_print(window);
103
104  window_size /= 2.;
105  window = new_aubio_window("triangle", window_size);
106  fvec_print(window);
107  del_fvec(window);
108
109  window = new_aubio_window("rectangle", 16);
110  del_fvec (window);
111  return 0;
112}
113
[158e031]114int main (void)
[7e35b37]115{
116  test_next_power_of_two();
117  test_miditofreq();
118  test_freqtomidi();
119  return 0;
120}
Note: See TracBrowser for help on using the repository browser.