Changes in tests/src/test-mathutils.c [7359775:7e35b37]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified tests/src/test-mathutils.c ¶
r7359775 r7e35b37 4 4 #include <aubio.h> 5 5 6 int main(){ 6 int test_next_power_of_two() 7 { 7 8 uint_t a, b; 9 a = 15; b = aubio_next_power_of_two(a); assert(b == 16); 10 fprintf(stdout, "aubio_next_power_of_two(%d) = %d\n", a, b); 8 11 9 a = 31; b = aubio_next_power_of_two(a); 10 fprintf(stdout, "next_power_of_two of %d is %d\n", a, b); 11 assert(b == 32); 12 a = 17; b = aubio_next_power_of_two(a); assert(b == 32); 13 fprintf(stdout, "aubio_next_power_of_two(%d) = %d\n", a, b); 12 14 13 a = 32; b = aubio_next_power_of_two(a); 14 fprintf(stdout, "next_power_of_two of %d is %d\n", a, b); 15 assert(b == 32); 15 a = 31; b = aubio_next_power_of_two(a); assert(b == 32); 16 fprintf(stdout, "aubio_next_power_of_two(%d) = %d\n", a, b); 16 17 17 a = 33; b = aubio_next_power_of_two(a); 18 fprintf(stdout, "next_power_of_two of %d is %d\n", a, b); 19 assert(b == 64); 18 a = 32; b = aubio_next_power_of_two(a); assert(b == 32); 19 fprintf(stdout, "aubio_next_power_of_two(%d) = %d\n", a, b); 20 21 a = 33; b = aubio_next_power_of_two(a); assert(b == 64); 22 fprintf(stdout, "aubio_next_power_of_two(%d) = %d\n", a, b); 20 23 21 24 return 0; 22 25 } 23 26 27 int test_miditofreq() 28 { 29 smpl_t midi, freq; 30 for ( midi = 0; midi < 128; midi += 3 ) { 31 freq = aubio_miditofreq(midi); 32 fprintf(stdout, "aubio_miditofreq(%.2f) = %.2f\n", midi, freq); 33 } 34 midi = 69.5; 35 freq = aubio_miditofreq(midi); 36 fprintf(stdout, "aubio_miditofreq(%.2f) = %.2f\n", midi, freq); 37 midi = -69.5; 38 freq = aubio_miditofreq(midi); 39 fprintf(stdout, "aubio_miditofreq(%.2f) = %.2f\n", midi, freq); 40 midi = -169.5; 41 freq = aubio_miditofreq(midi); 42 fprintf(stdout, "aubio_miditofreq(%.2f) = %.2f\n", midi, freq); 43 midi = 140.; 44 freq = aubio_miditofreq(midi); 45 fprintf(stdout, "aubio_miditofreq(%.2f) = %.2f\n", midi, freq); 46 midi = 0; 47 freq = aubio_miditofreq(midi); 48 fprintf(stdout, "aubio_miditofreq(%.2f) = %.2f\n", midi, freq); 49 midi = 8.2e10; 50 freq = aubio_miditofreq(midi); 51 fprintf(stdout, "aubio_miditofreq(%.2f) = %.2f\n", midi, freq); 52 midi = -5.e10; 53 freq = aubio_miditofreq(midi); 54 fprintf(stdout, "aubio_miditofreq(%.2f) = %.2f\n", midi, freq); 55 return 0; 56 } 57 58 int test_freqtomidi() 59 { 60 smpl_t midi, freq; 61 for ( freq = 0.; freq < 30000.; freq += 440. ) { 62 midi = aubio_freqtomidi(freq); 63 fprintf(stdout, "aubio_freqtomidi(%.2f) = %.2f\n", freq, midi); 64 } 65 freq = 69.5; 66 midi = aubio_freqtomidi(freq); 67 fprintf(stdout, "aubio_freqtomidi(%.2f) = %.2f\n", freq, midi); 68 freq = -69.5; 69 midi = aubio_freqtomidi(freq); 70 fprintf(stdout, "aubio_freqtomidi(%.2f) = %.2f\n", freq, midi); 71 freq = -169.5; 72 midi = aubio_freqtomidi(freq); 73 fprintf(stdout, "aubio_freqtomidi(%.2f) = %.2f\n", freq, midi); 74 freq = 140.; 75 midi = aubio_freqtomidi(freq); 76 fprintf(stdout, "aubio_freqtomidi(%.2f) = %.2f\n", freq, midi); 77 freq = 0; 78 midi = aubio_freqtomidi(freq); 79 fprintf(stdout, "aubio_freqtomidi(%.2f) = %.2f\n", freq, midi); 80 freq = 8.2e10; 81 midi = aubio_freqtomidi(freq); 82 fprintf(stdout, "aubio_freqtomidi(%.2f) = %.2f\n", freq, midi); 83 freq = -5.; 84 midi = aubio_freqtomidi(freq); 85 fprintf(stdout, "aubio_freqtomidi(%.2f) = %.2f\n", freq, midi); 86 return 0; 87 } 88 89 int test_aubio_window() 90 { 91 uint_t window_size = 16; 92 fvec_t * window = new_aubio_window("default", window_size); 93 del_fvec(window); 94 95 window = new_fvec(window_size); 96 fvec_set_window(window, "rectangle"); 97 fvec_print(window); 98 99 window_size /= 2.; 100 window = new_aubio_window("triangle", window_size); 101 fvec_print(window); 102 del_fvec(window); 103 104 window = new_aubio_window("rectangle", 16); 105 del_fvec (window); 106 return 0; 107 } 108 109 int main () 110 { 111 test_next_power_of_two(); 112 test_miditofreq(); 113 test_freqtomidi(); 114 return 0; 115 }
Note: See TracChangeset
for help on using the changeset viewer.