- Timestamp:
- Mar 3, 2013, 7:38:32 PM (12 years ago)
- Branches:
- feature/autosink, feature/cnn, feature/cnn_org, feature/constantq, feature/crepe, feature/crepe_org, feature/pitchshift, feature/pydocstrings, feature/timestretch, fix/ffmpeg5, master, pitchshift, sampler, timestretch, yinfft+
- Children:
- 3684ab4
- Parents:
- 6938a20
- Location:
- tests/src/tempo
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
tests/src/tempo/test-beattracking.c
r6938a20 r9547247 1 1 #define AUBIO_UNSTABLE 1 2 2 3 #include <stdio.h>4 3 #include <aubio.h> 5 4 6 int main(){ 7 /* allocate some memory */ 8 uint_t win_s = 1024; /* window size */ 9 fvec_t * in = new_fvec (win_s); /* input buffer */ 10 fvec_t * out = new_fvec (win_s/4); /* input buffer */ 11 12 /* allocate fft and other memory space */ 13 aubio_beattracking_t * tempo = new_aubio_beattracking(win_s); 5 int main () 6 { 7 uint_t i = 0; 8 uint_t win_s = 1024; // window size 9 fvec_t * in = new_fvec (win_s); // input buffer 10 fvec_t * out = new_fvec (2); // output beat position 14 11 15 uint_t i = 0; 12 // create beattracking object 13 aubio_beattracking_t * tempo = new_aubio_beattracking(win_s); 16 14 17 smpl_t curtempo, curtempoconf;15 smpl_t bpm, confidence; 18 16 19 while (i < 10) { 20 aubio_beattracking_do(tempo,in,out); 21 curtempo = aubio_beattracking_get_bpm(tempo); 22 if (curtempo != 0.) { 23 fprintf(stdout,"%f\n",curtempo); 24 return 1; 25 } 26 curtempoconf = aubio_beattracking_get_confidence(tempo); 27 if (curtempoconf != 0.) { 28 fprintf(stdout,"%f\n",curtempo); 29 return 1; 30 } 31 i++; 32 }; 17 while (i < 10) { 18 // put some fresh data in feature vector 19 // ... 33 20 34 del_aubio_beattracking(tempo); 35 del_fvec(in); 36 del_fvec(out); 37 aubio_cleanup(); 21 aubio_beattracking_do(tempo,in,out); 22 // do something with the beats 23 // ... 38 24 39 return 0; 25 // get bpm and confidence 26 bpm = aubio_beattracking_get_bpm(tempo); 27 confidence = aubio_beattracking_get_confidence(tempo); 28 i++; 29 }; 30 31 del_aubio_beattracking(tempo); 32 del_fvec(in); 33 del_fvec(out); 34 aubio_cleanup(); 35 36 return 0; 40 37 } 41 38 -
tests/src/tempo/test-tempo.c
r6938a20 r9547247 1 #include <stdio.h>2 1 #include <aubio.h> 3 2 4 int main(){ 5 /* allocate some memory */ 6 uint_t win_s = 1024; /* window size */ 7 fvec_t * in = new_fvec (win_s); /* input buffer */ 8 fvec_t * out = new_fvec (2); /* input buffer */ 9 aubio_tempo_t * o = new_aubio_tempo("complex", win_s, win_s/4, 44100.); 10 uint_t i = 0; 3 int main () 4 { 5 uint_t i = 0; 6 uint_t win_s = 1024; // window size 7 fvec_t * in = new_fvec (win_s); // input vector 8 fvec_t * out = new_fvec (2); // output beat position 11 9 12 smpl_t curtempo, curtempoconf; 10 // create tempo object 11 aubio_tempo_t * o = new_aubio_tempo("complex", win_s, win_s/4, 44100.); 13 12 14 while (i < 1000) { 15 aubio_tempo_do(o,in,out); 16 curtempo = aubio_tempo_get_bpm(o); 17 if (curtempo != 0.) { 18 fprintf(stdout,"%f\n",curtempo); 19 return 1; 20 } 21 curtempoconf = aubio_tempo_get_confidence(o); 22 if (curtempoconf != 0.) { 23 fprintf(stdout,"%f\n",curtempo); 24 return 1; 25 } 26 i++; 27 }; 13 smpl_t bpm, confidence; 28 14 29 del_aubio_tempo(o); 30 del_fvec(in); 31 del_fvec(out); 32 aubio_cleanup(); 15 while (i < 1000) { 16 // put some fresh data in input vector 17 // ... 33 18 34 return 0; 19 // execute tempo 20 aubio_tempo_do(o,in,out); 21 // do something with the beats 22 // ... 23 24 // get bpm and confidence 25 bpm = aubio_tempo_get_bpm(o); 26 confidence = aubio_tempo_get_confidence(o); 27 28 i++; 29 }; 30 31 del_aubio_tempo(o); 32 del_fvec(in); 33 del_fvec(out); 34 aubio_cleanup(); 35 36 return 0; 35 37 }
Note: See TracChangeset
for help on using the changeset viewer.