Changeset c71aa44
- Timestamp:
- Mar 3, 2013, 5:47:05 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:
- 248da64
- Parents:
- e230bb4
- Location:
- tests/src/pitch
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
tests/src/pitch/test-pitch.c
re230bb4 rc71aa44 1 1 #include <aubio.h> 2 2 3 int 4 main () 3 int main () 5 4 { 6 /* allocate some memory */ 7 uint_t win_s = 1024; /* window size */ 8 uint_t hop_s = win_s / 4; /* hop size */ 9 uint_t samplerate = 44100; /* samplerate */ 10 fvec_t *in = new_fvec (hop_s); /* input buffer */ 11 fvec_t *out = new_fvec (1); /* input buffer */ 12 aubio_pitch_t *o = 13 new_aubio_pitch ("default", win_s, hop_s, samplerate); 14 uint_t i = 0; 5 // 1. allocate some memory 6 uint_t n = 0; // frame counter 7 uint_t win_s = 1024; // window size 8 uint_t hop_s = win_s / 4; // hop size 9 uint_t samplerate = 44100; // samplerate 10 // create some vectors 11 fvec_t *input = new_fvec (hop_s); // input buffer 12 fvec_t *out = new_fvec (1); // output candidates 13 // create pitch object 14 aubio_pitch_t *o = new_aubio_pitch ("default", win_s, hop_s, samplerate); 15 15 16 while (i < 100) { 17 aubio_pitch_do (o, in, out); 18 i++; 16 // 2. do something with it 17 while (n < 100) { 18 // get `hop_s` new samples into `input` 19 // ... 20 // exectute pitch 21 aubio_pitch_do (o, input, out); 22 // do something with output candidates 23 // ... 24 n++; 19 25 }; 20 26 27 // 3. clean up memory 21 28 del_aubio_pitch (o); 22 29 del_fvec (out); 23 del_fvec (in );30 del_fvec (input); 24 31 aubio_cleanup (); 25 32 -
tests/src/pitch/test-pitchfcomb.c
re230bb4 rc71aa44 1 1 #define AUBIO_UNSTABLE 1 2 3 // this file uses the unstable aubio api, please use aubio_pitch instead 4 // see src/pitch/pitch.h and tests/src/pitch/test-pitch.c 2 5 3 6 #include <aubio.h> 4 7 5 int main(){ 6 /* allocate some memory */ 7 uint_t win_s = 1024; /* window size */ 8 uint_t hop_s = win_s/4; /* hop size */ 9 fvec_t * in = new_fvec (hop_s); /* input buffer */ 10 fvec_t * out = new_fvec (1); 11 aubio_pitchfcomb_t * o = new_aubio_pitchfcomb ( 12 win_s, hop_s); 13 uint_t i = 0; 8 int main () 9 { 10 uint_t i = 0; 11 uint_t win_s = 1024; // window size 12 uint_t hop_s = win_s/4; // hop size 13 // create some vectors 14 fvec_t * in = new_fvec (hop_s); // input buffer 15 fvec_t * out = new_fvec (1); // output candidates 16 // create pitch object 17 aubio_pitchfcomb_t * o = new_aubio_pitchfcomb ( win_s, hop_s); 14 18 15 while (i < 2) {16 17 18 19 while (i < 10) { 20 aubio_pitchfcomb_do (o,in, out); 21 i++; 22 }; 19 23 20 del_aubio_pitchfcomb(o); 21 del_fvec(out); 22 del_fvec(in); 23 aubio_cleanup(); 24 25 return 0; 24 del_aubio_pitchfcomb(o); 25 del_fvec(out); 26 del_fvec(in); 27 aubio_cleanup(); 28 return 0; 26 29 } -
tests/src/pitch/test-pitchmcomb.c
re230bb4 rc71aa44 1 1 #define AUBIO_UNSTABLE 1 2 3 // this file uses the unstable aubio api, please use aubio_pitch instead 4 // see src/pitch/pitch.h and tests/src/pitch/test-pitch.c 2 5 3 6 #include <aubio.h> 4 7 5 int main(){ 6 /* allocate some memory */ 7 uint_t win_s = 1024; /* window size */ 8 uint_t hop_s = win_s/4; /* hop size */ 9 cvec_t * in = new_cvec (win_s); /* input buffer */ 10 fvec_t * out = new_fvec (1); /* input buffer */ 8 int main () 9 { 10 uint_t n = 10; // compute n times 11 uint_t win_s = 1024; // window size 12 uint_t hop_s = win_s/4; // hop size 13 // create some vectors 14 cvec_t * in_cvec = new_cvec (win_s); // input fftgrain 15 fvec_t * out_cands = new_fvec (1); // pitch candidate 16 // create pitch object 17 aubio_pitchmcomb_t * mcomb = new_aubio_pitchmcomb(win_s, hop_s); 11 18 12 aubio_pitchmcomb_t * o = new_aubio_pitchmcomb(win_s, hop_s); 13 uint_t i = 0; 19 while ( n-- ) { 20 aubio_pitchmcomb_do (mcomb, in_cvec, out_cands); 21 // fvec_print(out_cands); 22 }; 14 23 15 while (i < 1000) {16 aubio_pitchmcomb_do (o,in, out);17 i++;18 };24 // clean up before exiting 25 del_aubio_pitchmcomb(mcomb); 26 del_cvec(in_cvec); 27 del_fvec(out_cands); 19 28 20 del_aubio_pitchmcomb(o); 21 del_cvec(in); 22 del_fvec(out); 23 aubio_cleanup(); 29 aubio_cleanup(); 24 30 25 31 return 0; 26 32 } -
tests/src/pitch/test-pitchschmitt.c
re230bb4 rc71aa44 1 1 #define AUBIO_UNSTABLE 1 2 3 // this file uses the unstable aubio api, please use aubio_pitch instead 4 // see src/pitch/pitch.h and tests/src/pitch/test-pitch.c 2 5 3 6 #include <aubio.h> 4 7 5 int main(){ 6 /* allocate some memory */ 7 uint_t win_s = 1024; /* window size */ 8 fvec_t * in = new_fvec (win_s); /* input buffer */ 9 fvec_t * out = new_fvec (1); /* input buffer */ 10 aubio_pitchschmitt_t * o = new_aubio_pitchschmitt(win_s); 11 uint_t i = 0; 8 int main () 9 { 10 uint_t n = 10; // compute n times 11 uint_t win_s = 1024; // window size 12 // create some vectors 13 fvec_t * in = new_fvec (win_s); // input buffer 14 fvec_t * out = new_fvec (1); // input buffer 15 // create pitch object 16 aubio_pitchschmitt_t * o = new_aubio_pitchschmitt(win_s); 12 17 13 while (i < 1000) { 14 aubio_pitchschmitt_do (o,in, out); 15 i++; 16 }; 18 while ( n-- ) { 19 aubio_pitchschmitt_do (o,in, out); 20 }; 17 21 18 19 20 21 22 del_aubio_pitchschmitt(o); 23 del_fvec(in); 24 del_fvec(out); 25 aubio_cleanup(); 22 26 23 27 return 0; 24 28 } 25 29 -
tests/src/pitch/test-pitchyin.c
re230bb4 rc71aa44 1 1 #define AUBIO_UNSTABLE 1 2 3 // this file uses the unstable aubio api, please use aubio_pitch instead 4 // see src/pitch/pitch.h and tests/src/pitch/test-pitch.c 2 5 3 6 #include <aubio.h> 4 7 5 int main(){ 6 /* allocate some memory */ 7 uint_t win_s = 1024; /* window size */ 8 fvec_t * in = new_fvec (win_s); /* input buffer */ 9 fvec_t * out = new_fvec (win_s/2); /* input buffer */ 10 aubio_pitchyin_t *p = new_aubio_pitchyin (win_s); 11 uint_t i = 0; 8 int main () 9 { 10 uint_t n = 10; // compute n times 11 uint_t win_s = 1024; // window size 12 // create some vectors 13 fvec_t * input_signal = new_fvec (win_s); // input signal 14 fvec_t * output_cands = new_fvec (1); // output candidates 15 // create pitch object 16 aubio_pitchyin_t *p = new_aubio_pitchyin (win_s); 12 17 13 while (i < 10) { 14 aubio_pitchyin_do (p, in,out); 15 i++; 16 }; 18 while ( n-- ) { 19 aubio_pitchyin_do (p, input_signal, output_cands); 20 }; 17 21 18 del_fvec(in); 19 del_fvec(out); 20 del_aubio_pitchyin(p); 21 aubio_cleanup(); 22 fvec_print(output_cands); 22 23 23 return 0; 24 del_fvec(input_signal); 25 del_fvec(output_cands); 26 del_aubio_pitchyin(p); 27 aubio_cleanup(); 28 29 return 0; 24 30 } -
tests/src/pitch/test-pitchyinfft.c
re230bb4 rc71aa44 1 1 #define AUBIO_UNSTABLE 1 2 3 // this file uses the unstable aubio api, please use aubio_pitch instead 4 // see src/pitch/pitch.h and tests/src/pitch/test-pitch.c 2 5 3 6 #include <aubio.h> 4 7 5 int main(){ 6 /* allocate some memory */ 7 uint_t win_s = 1024; /* window size */ 8 fvec_t * in = new_fvec (win_s); /* input buffer */ 9 fvec_t * out = new_fvec (1); /* output pitch periods */ 10 aubio_pitchyinfft_t * o = new_aubio_pitchyinfft(win_s); 11 aubio_pitchyinfft_set_tolerance (o, 0.2); 12 uint_t i = 0; 8 int main () 9 { 10 uint_t n = 10; // compute n times 11 uint_t win_s = 1024; // window size 12 // create some vectors 13 fvec_t * in = new_fvec (win_s); // input buffer 14 fvec_t * out = new_fvec (1); // output candidates 15 // create pitch object 16 aubio_pitchyinfft_t *p = new_aubio_pitchyinfft(win_s); 17 aubio_pitchyinfft_set_tolerance (p, 0.2); 13 18 14 while (i < 10) { 15 aubio_pitchyinfft_do (o,in,out); 16 i++; 17 }; 19 while ( n-- ) { 20 aubio_pitchyinfft_do (p, in,out); 21 }; 18 22 19 del_aubio_pitchyinfft(o); 20 del_fvec(in); 21 del_fvec(out); 22 aubio_cleanup(); 23 fvec_print(out); 23 24 24 return 0; 25 del_fvec(in); 26 del_fvec(out); 27 del_aubio_pitchyinfft(p); 28 aubio_cleanup(); 29 30 return 0; 25 31 } 26
Note: See TracChangeset
for help on using the changeset viewer.