- Timestamp:
- Mar 3, 2013, 7:37:43 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:
- 9547247
- Parents:
- 26775a3
- Location:
- tests/src/spectral
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
tests/src/spectral/test-fft.c
r26775a3 r6938a20 1 2 1 #include <aubio.h> 3 2 4 int main(){ 5 /* allocate some memory */ 6 uint_t win_s = 8; /* window size */ 7 fvec_t * in = new_fvec (win_s); /* input buffer */ 8 cvec_t * fftgrain = new_cvec (win_s); /* fft norm and phase */ 9 fvec_t * out = new_fvec (win_s); /* output buffer */ 10 in->data[0] = 1; 11 in->data[1] = 2; 12 in->data[2] = 3; 13 in->data[3] = 4; 14 in->data[4] = 5; 15 in->data[5] = 6; 16 in->data[6] = 5; 17 in->data[7] = 6; 18 /* allocate fft and other memory space */ 19 aubio_fft_t * fft = new_aubio_fft(win_s); 20 /* fill input with some data */ 21 fvec_print(in); 22 /* execute stft */ 23 aubio_fft_do (fft,in,fftgrain); 24 cvec_print(fftgrain); 25 /* execute inverse fourier transform */ 26 aubio_fft_rdo(fft,fftgrain,out); 27 fvec_print(out); 28 del_aubio_fft(fft); 29 del_fvec(in); 30 del_cvec(fftgrain); 31 del_fvec(out); 32 aubio_cleanup(); 33 return 0; 3 int main () 4 { 5 uint_t win_s = 8; // window size 6 fvec_t * in = new_fvec (win_s); // input buffer 7 cvec_t * fftgrain = new_cvec (win_s); // fft norm and phase 8 fvec_t * out = new_fvec (win_s); // output buffer 9 // create fft object 10 aubio_fft_t * fft = new_aubio_fft(win_s); 11 12 // fill input with some data 13 in->data[0] = 1; 14 in->data[1] = 2; 15 in->data[2] = 3; 16 in->data[3] = 4; 17 in->data[4] = 5; 18 in->data[5] = 6; 19 in->data[6] = 5; 20 in->data[7] = 6; 21 fvec_print(in); 22 23 // execute stft 24 aubio_fft_do (fft,in,fftgrain); 25 cvec_print(fftgrain); 26 27 // execute inverse fourier transform 28 aubio_fft_rdo(fft,fftgrain,out); 29 30 // cleam up 31 fvec_print(out); 32 del_aubio_fft(fft); 33 del_fvec(in); 34 del_cvec(fftgrain); 35 del_fvec(out); 36 aubio_cleanup(); 37 return 0; 34 38 } -
tests/src/spectral/test-filterbank.c
r26775a3 r6938a20 1 #define AUBIO_UNSTABLE 12 3 #include <stdio.h>4 1 #include <aubio.h> 5 2 6 int main (void) { 3 int main () 4 { 7 5 uint_t win_s = 1024; // window size 8 6 uint_t n_filters = 13; // number of filters 9 cvec_t *in = new_cvec (win_s); // input buffer10 fvec_t *out = new_fvec (win_s); // vector output */11 fmat_t *coeffs = NULL;12 7 13 // create filterbank 8 cvec_t *in_spec = new_cvec (win_s); // input vector of samples 9 fvec_t *out_filters = new_fvec (n_filters); // per-band outputs 10 fmat_t *coeffs; // pointer to the coefficients 11 12 // create filterbank object 14 13 aubio_filterbank_t *o = new_aubio_filterbank (n_filters, win_s); 15 14 16 15 coeffs = aubio_filterbank_get_coeffs (o); 17 if (coeffs == NULL) {18 return -1;19 }20 16 21 /* 22 if (fvec_max (coeffs) != 0.) { 23 return -1; 24 } 17 aubio_filterbank_do (o, in_spec, out_filters); 25 18 26 if (fvec_min (coeffs) != 0.) { 27 return -1; 28 } 29 */ 30 31 fmat_print (coeffs); 32 33 aubio_filterbank_do (o, in, out); 19 // fmat_print (coeffs); 20 // cvec_print(in_spec); 21 // fvec_print(out_filters); 34 22 35 23 del_aubio_filterbank (o); 36 del_cvec (in );37 del_fvec (out );24 del_cvec (in_spec); 25 del_fvec (out_filters); 38 26 aubio_cleanup (); 39 27 -
tests/src/spectral/test-filterbank_mel.c
r26775a3 r6938a20 1 #define AUBIO_UNSTABLE 12 3 #include <stdio.h>4 1 #include <aubio.h> 5 2 6 int 7 main (void) 3 int main () 8 4 { 9 /* allocate some memory */5 uint_t samplerate = 16000; // samplerate of signal to filter 10 6 uint_t win_s = 512; // fft size 11 7 uint_t n_filters = 40; // number of filters 12 cvec_t *in_spec = new_cvec (win_s); // input buffer */13 fvec_t *out_filters = new_fvec (n_filters); // output coeffs */14 fmat_t *coeffs = NULL;15 smpl_t samplerate = 16000.;16 8 17 /* allocate fft and other memory space */ 9 cvec_t *in_spec = new_cvec (win_s); // input vector of samples 10 fvec_t *out_filters = new_fvec (n_filters); // per-band outputs 11 fmat_t *coeffs; // pointer to the coefficients 12 13 // create filterbank object 18 14 aubio_filterbank_t *o = new_aubio_filterbank (n_filters, win_s); 19 15 20 / * assign Mel-frequency coefficients */16 // assign Mel-frequency coefficients 21 17 aubio_filterbank_set_mel_coeffs_slaney (o, samplerate); 22 18 23 19 coeffs = aubio_filterbank_get_coeffs (o); 24 20 25 fmat_print (coeffs);26 27 //fprintf(stderr, "%f\n", fvec_sum(coeffs));28 29 21 aubio_filterbank_do (o, in_spec, out_filters); 30 22 31 fvec_print(in_spec); 32 fvec_print(out_filters); 23 // fmat_print (coeffs); 24 // cvec_print(in_spec); 25 // fvec_print(out_filters); 33 26 34 27 del_aubio_filterbank (o); -
tests/src/spectral/test-mfcc.c
r26775a3 r6938a20 1 1 #include <aubio.h> 2 2 3 int 4 main (void) 3 int main () 5 4 { 6 /* allocate some memory */ 7 uint_t win_s = 512; /* fft size */ 8 uint_t n_filters = 40; /* number of filters */ 9 uint_t n_coefs = 13; /* number of coefficients */ 10 cvec_t *in = new_cvec (win_s); /* input buffer */ 11 fvec_t *out = new_fvec (n_coefs); /* input buffer */ 12 smpl_t samplerate = 16000.; 5 uint_t win_s = 512; // fft size 6 uint_t n_filters = 40; // number of filters 7 uint_t n_coefs = 13; // number of coefficients 8 smpl_t samplerate = 16000.; // samplerate 9 cvec_t *in = new_cvec (win_s); // input buffer 10 fvec_t *out = new_fvec (n_coefs); // output coefficients 13 11 14 / * allocate fft and other memory space */12 // create mfcc object 15 13 aubio_mfcc_t *o = new_aubio_mfcc (win_s, n_filters, n_coefs, samplerate); 16 14 17 15 cvec_set (in, 1.); 18 19 aubio_mfcc_do (o, in, out);20 fvec_print (out);21 16 aubio_mfcc_do (o, in, out); 22 17 fvec_print (out); 23 18 19 cvec_set (in, .5); 20 aubio_mfcc_do (o, in, out); 21 fvec_print (out); 22 23 // clean up 24 24 del_aubio_mfcc (o); 25 25 del_cvec (in); -
tests/src/spectral/test-phasevoc-jack.c
r26775a3 r6938a20 15 15 #endif /* HAVE_JACK */ 16 16 17 uint_t testing = 0; / * change this to 1 to listen */17 uint_t testing = 0; // change this to 1 to listen 18 18 19 uint_t win_s = 512; /* window size */20 uint_t hop_s = 128; /* hop size */21 uint_t channels = 2; /* number of audio channels */22 uint_t midiin = 4; /* number of midi input channels */23 uint_t midiout = 2; /* number of midi output channels */24 uint_t pos = 0; /* frames%dspblocksize for jack loop */19 uint_t win_s = 512; // window size 20 uint_t hop_s = 128; // hop size 21 uint_t channels = 2; // number of audio channels 22 uint_t midiin = 4; // number of midi input channels 23 uint_t midiout = 2; // number of midi output channels 24 uint_t pos = 0; // frames%dspblocksize for jack loop 25 25 26 26 fvec_t * in[2]; … … 32 32 int aubio_process(float **input, float **output, int nframes); 33 33 34 int main(){ 35 /* allocate some memory */ 34 int main () 35 { 36 /* allocate some memory */ 36 37 uint_t i; 37 38 39 40 41 42 43 38 for (i=0;i<channels;i++) { 39 in[i] = new_fvec (hop_s); /* input buffer */ 40 fftgrain[i] = new_cvec (win_s); /* fft norm and phase */ 41 out[i] = new_fvec (hop_s); /* output buffer */ 42 /* allocate fft and other memory space */ 43 pv[i] = new_aubio_pvoc(win_s,hop_s); 44 } 44 45 45 46 #ifdef HAVE_JACK 46 47 48 49 50 51 52 53 54 55 47 aubio_jack_t * jack_setup; 48 jack_setup = new_aubio_jack(channels, channels, 49 midiin, midiout, 50 (aubio_process_func_t)aubio_process); 51 aubio_jack_activate(jack_setup); 52 /* stay in main jack loop for 1 seconds only */ 53 do { 54 sleep(1); 55 } while(testing); 56 aubio_jack_close(jack_setup); 56 57 #else 57 58 fprintf(stderr, "WARNING: no jack support\n"); 58 59 #endif 59 60 61 62 63 64 65 66 67 60 61 for (i=0;i<channels;i++) { 62 del_aubio_pvoc(pv[i]); 63 del_cvec(fftgrain[i]); 64 del_fvec(in[i]); 65 del_fvec(out[i]); 66 } 67 aubio_cleanup(); 68 return 0; 68 69 } 69 70 … … 81 82 if (pos == hop_s-1) { 82 83 /* block loop */ 83 for (i=0;i<channels;i++) { 84 aubio_pvoc_do (pv[i], in[i], fftgrain[i]); 85 // zero phases of first channel 86 for (i=0;i<fftgrain[i]->length;i++) fftgrain[0]->phas[i] = 0.; 87 // double phases of second channel 88 for (i=0;i<fftgrain[i]->length;i++) { 89 fftgrain[1]->phas[i] = 90 aubio_unwrap2pi (fftgrain[1]->phas[i] * 2.); 84 for (i=0;i<channels;i++) { 85 aubio_pvoc_do (pv[i], in[i], fftgrain[i]); 86 // zero phases of first channel 87 for (i=0;i<fftgrain[i]->length;i++) fftgrain[0]->phas[i] = 0.; 88 // double phases of second channel 89 for (i=0;i<fftgrain[i]->length;i++) { 90 fftgrain[1]->phas[i] = 91 aubio_unwrap2pi (fftgrain[1]->phas[i] * 2.); 92 } 93 // copy second channel to third one 94 aubio_pvoc_rdo(pv[i], fftgrain[i], out[i]); 95 pos = -1; 91 96 } 92 // copy second channel to third one93 aubio_pvoc_rdo(pv[i], fftgrain[i], out[i]);94 pos = -1;95 }96 97 } 97 98 pos++; -
tests/src/spectral/test-phasevoc.c
r26775a3 r6938a20 1 /* test sample for phase vocoder */2 3 #include <stdio.h>4 1 #include <aubio.h> 5 2 6 int main(){ 7 uint_t win_s = 1024; /* window size */ 8 uint_t hop_s = 256; /* hop size */ 9 /* allocate some memory */ 10 fvec_t * in = new_fvec (hop_s); /* input buffer */ 11 cvec_t * fftgrain = new_cvec (win_s); /* fft norm and phase */ 12 fvec_t * out = new_fvec (hop_s); /* output buffer */ 13 /* allocate fft and other memory space */ 14 aubio_pvoc_t * pv = new_aubio_pvoc(win_s,hop_s); 15 /* fill input with some data */ 16 printf("initialised\n"); 17 /* execute stft */ 18 aubio_pvoc_do (pv,in,fftgrain); 19 printf("computed forward\n"); 20 /* execute inverse fourier transform */ 21 aubio_pvoc_rdo(pv,fftgrain,out); 22 printf("computed backard\n"); 23 del_aubio_pvoc(pv); 24 del_fvec(in); 25 del_cvec(fftgrain); 26 del_fvec(out); 27 aubio_cleanup(); 28 printf("memory freed\n"); 29 return 0; 3 int main () 4 { 5 uint_t n = 6; // compute n times 6 uint_t win_s = 32; // window size 7 uint_t hop_s = win_s / 4; // hop size 8 9 fvec_t * in = new_fvec (hop_s); // input buffer 10 cvec_t * fftgrain = new_cvec (win_s); // fft norm and phase 11 fvec_t * out = new_fvec (hop_s); // output buffer 12 13 // allocate fft and other memory space 14 aubio_pvoc_t * pv = new_aubio_pvoc(win_s,hop_s); 15 16 // fill input with some data 17 fvec_set (in, 1.); 18 fvec_print (in); 19 20 while ( n-- ) { 21 // get some fresh input data 22 // .. 23 24 // execute phase vocoder 25 aubio_pvoc_do (pv,in,fftgrain); 26 27 // do something with fftgrain 28 // ... 29 cvec_print (fftgrain); 30 31 // optionnaly rebuild the signa 32 aubio_pvoc_rdo(pv,fftgrain,out); 33 34 // and do something with the result 35 // ... 36 fvec_print (out); 37 } 38 39 // clean up 40 del_fvec(in); 41 del_cvec(fftgrain); 42 del_fvec(out); 43 del_aubio_pvoc(pv); 44 aubio_cleanup(); 45 46 return 0; 30 47 } -
tests/src/spectral/test-specdesc.c
r26775a3 r6938a20 1 2 #define AUBIO_UNSTABLE 13 4 1 #include <aubio.h> 5 2 6 int 7 main () 3 int main () 8 4 { 9 uint_t win_s = 1024; /* window size */10 cvec_t *in = new_cvec (win_s); /* input buffer */11 fvec_t *out = new_fvec (1); / * input buffer */5 uint_t win_s = 1024; // window size 6 cvec_t *in = new_cvec (win_s); // input buffer 7 fvec_t *out = new_fvec (1); // output spectral descriptor 12 8 13 9 aubio_specdesc_t *o; 14 10 15 11 o = new_aubio_specdesc ("energy", win_s); 16 12 aubio_specdesc_do (o, in, out); -
tests/src/spectral/test-tss.c
r26775a3 r6938a20 1 /* test sample for phase vocoder2 *3 * this program should start correctly using JACK_START_SERVER=true and4 * reconstruct each audio input frame perfectly on the corresponding input with5 * a delay equal to the window size, hop_s.6 */7 8 #include <stdio.h>9 #define AUBIO_UNSTABLE 110 1 #include <aubio.h> 11 2 12 int main(){ 13 int i; 14 uint_t win_s = 1024; /* window size */ 15 uint_t hop_s = 256; /* hop size */ 3 int main () 4 { 5 uint_t n = 10; // compute n times 6 uint_t win_s = 1024; // window size 7 uint_t hop_s = 256; // hop size 16 8 17 /* allocate some memory */ 18 fvec_t * in = new_fvec (hop_s); /* input buffer */ 19 cvec_t * fftgrain = new_cvec (win_s); /* fft norm and phase */ 20 cvec_t * cstead = new_cvec (win_s); /* fft norm and phase */ 21 cvec_t * ctrans = new_cvec (win_s); /* fft norm and phase */ 22 fvec_t * stead = new_fvec (hop_s); /* output buffer */ 23 fvec_t * trans = new_fvec (hop_s); /* output buffer */ 24 /* allocate phase vocoders and transient steady-state separation */ 9 // create some vectors 10 fvec_t * in = new_fvec (hop_s); // input buffer 11 cvec_t * fftgrain = new_cvec (win_s); // fft norm and phase 12 cvec_t * cstead = new_cvec (win_s); // fft norm and phase 13 cvec_t * ctrans = new_cvec (win_s); // fft norm and phase 14 fvec_t * stead = new_fvec (hop_s); // output buffer 15 fvec_t * trans = new_fvec (hop_s); // output buffer 16 17 // create phase vocoder for analysis of input signal 25 18 aubio_pvoc_t * pv = new_aubio_pvoc (win_s,hop_s); 19 // create transient/steady-state separation object 20 aubio_tss_t * tss = new_aubio_tss(win_s,hop_s); 21 // create phase vocoder objects for synthesis of output signals 26 22 aubio_pvoc_t * pvt = new_aubio_pvoc(win_s,hop_s); 27 23 aubio_pvoc_t * pvs = new_aubio_pvoc(win_s,hop_s); 28 aubio_tss_t * tss = new_aubio_tss(win_s,hop_s);29 30 /* fill input with some data */31 printf("initialised\n");32 24 33 25 /* execute stft */ 34 for (i = 0; i < 10; i++) { 35 aubio_pvoc_do (pv,in,fftgrain); 36 aubio_tss_do (tss,fftgrain,ctrans,cstead); 37 aubio_pvoc_rdo(pvt,cstead,stead); 38 aubio_pvoc_rdo(pvs,ctrans,trans); 26 while ( n-- ) { 27 // fftgrain = pv(in) 28 aubio_pvoc_do (pv, in, fftgrain); 29 // ctrans, cstead = tss (fftgrain) 30 aubio_tss_do (tss, fftgrain, ctrans, cstead); 31 // stead = pvt_inverse (cstead) 32 // trans = pvt_inverse (ctrans) 33 aubio_pvoc_rdo (pvt, cstead, stead); 34 aubio_pvoc_rdo (pvs, ctrans, trans); 39 35 } 40 36 … … 50 46 del_fvec(stead); 51 47 del_fvec(trans); 48 52 49 aubio_cleanup(); 53 printf("memory freed\n"); 50 54 51 return 0; 55 52 }
Note: See TracChangeset
for help on using the changeset viewer.