comparison examples/simpletest/simpletest.c @ 207:5357a64124f1

Add MIDICENT to simpletest
author Jamie Bullock <jamie@jamiebullock.com>
date Tue, 11 Mar 2014 19:27:02 +0000
parents bd2db29d33f3
children
comparison
equal deleted inserted replaced
206:c6488df9e5c0 207:5357a64124f1
94 94
95 int main(void) 95 int main(void)
96 { 96 {
97 double mean = 0.0; 97 double mean = 0.0;
98 double f0 = 0.0; 98 double f0 = 0.0;
99 double midicents = 0.0;
99 double flux = 0.0; 100 double flux = 0.0;
100 double centroid = 0.0; 101 double centroid = 0.0;
101 double lowest = 0.0; 102 double lowest = 0.0;
102 double spectrum[BLOCKSIZE] = {0}; 103 double spectrum[BLOCKSIZE] = {0};
103 double windowed[BLOCKSIZE] = {0}; 104 double windowed[BLOCKSIZE] = {0};
111 double samplerate = 44100.0; 112 double samplerate = 44100.0;
112 int n; 113 int n;
113 int rv = XTRACT_SUCCESS; 114 int rv = XTRACT_SUCCESS;
114 xtract_mel_filter mel_filters; 115 xtract_mel_filter mel_filters;
115 116
116 fill_wavetable(344.53125f, NOISE); // 344.53125f = 128 samples @ 44100 Hz 117 // fill_wavetable(344.53125f, NOISE); // 344.53125f = 128 samples @ 44100 Hz
118 fill_wavetable(344.53125f, SINE); // 344.53125f = 128 samples @ 44100 Hz
119
117 /* 120 /*
118 print_wavetable(); 121 print_wavetable();
119 */ 122 */
120 123
121 /* get the F0 */ 124 /* get the F0 */
122 xtract[XTRACT_WAVELET_F0](wavetable, BLOCKSIZE, &samplerate, &f0); 125 xtract[XTRACT_WAVELET_F0](wavetable, BLOCKSIZE, &samplerate, &f0);
123 printf("\nF0: %f\n", f0); 126 printf("\nF0: %f\n", f0);
127
128 /* get the F0 as a MIDI note */
129 xtract[XTRACT_MIDICENT](NULL, 0, &f0, &midicents);
130 printf("\nMIDI cents: %f\n", midicents);
124 131
125 /* get the mean of the input */ 132 /* get the mean of the input */
126 xtract[XTRACT_MEAN](wavetable, BLOCKSIZE, NULL, &mean); 133 xtract[XTRACT_MEAN](wavetable, BLOCKSIZE, NULL, &mean);
127 printf("\nInput mean = %.2f\n\n", mean); /* We expect this to be zero for a square wave */ 134 printf("\nInput mean = %.2f\n\n", mean); /* We expect this to be zero for a square wave */
128 135