[787b5e4] | 1 | /* test sample for phase vocoder |
---|
| 2 | * |
---|
| 3 | * this program should start correctly using JACK_START_SERVER=true and |
---|
| 4 | * reconstruct each audio input frame perfectly on the corresponding input with |
---|
| 5 | * a delay equal to the window size, hop_s. |
---|
| 6 | */ |
---|
| 7 | |
---|
[7ac818f] | 8 | #include <stdio.h> |
---|
[45c0f16] | 9 | #include <aubio.h> |
---|
[787b5e4] | 10 | |
---|
| 11 | int main(){ |
---|
| 12 | int i; |
---|
| 13 | uint_t win_s = 1024; /* window size */ |
---|
| 14 | uint_t hop_s = 256; /* hop size */ |
---|
| 15 | uint_t channels = 4; /* number of channels */ |
---|
| 16 | /* allocate some memory */ |
---|
| 17 | fvec_t * in = new_fvec (hop_s, channels); /* input buffer */ |
---|
| 18 | cvec_t * fftgrain = new_cvec (win_s, channels); /* fft norm and phase */ |
---|
| 19 | cvec_t * cstead = new_cvec (win_s, channels); /* fft norm and phase */ |
---|
| 20 | cvec_t * ctrans = new_cvec (win_s, channels); /* fft norm and phase */ |
---|
| 21 | fvec_t * stead = new_fvec (hop_s, channels); /* output buffer */ |
---|
| 22 | fvec_t * trans = new_fvec (hop_s, channels); /* output buffer */ |
---|
| 23 | /* allocate fft and other memory space */ |
---|
| 24 | aubio_pvoc_t * pv = new_aubio_pvoc (win_s,hop_s,channels); |
---|
| 25 | aubio_pvoc_t * pvt = new_aubio_pvoc(win_s,hop_s,channels); |
---|
| 26 | aubio_pvoc_t * pvs = new_aubio_pvoc(win_s,hop_s,channels); |
---|
| 27 | |
---|
[f1b6aad] | 28 | aubio_tss_t * tss = new_aubio_tss(win_s,hop_s,channels); |
---|
[787b5e4] | 29 | /* fill input with some data */ |
---|
| 30 | printf("initialised\n"); |
---|
| 31 | /* execute stft */ |
---|
[45c0f16] | 32 | for (i = 0; i < 10; i++) { |
---|
[787b5e4] | 33 | aubio_pvoc_do (pv,in,fftgrain); |
---|
| 34 | aubio_tss_do (tss,fftgrain,ctrans,cstead); |
---|
| 35 | aubio_pvoc_rdo(pvt,cstead,stead); |
---|
| 36 | aubio_pvoc_rdo(pvs,ctrans,trans); |
---|
| 37 | } |
---|
| 38 | del_aubio_pvoc(pv); |
---|
| 39 | del_fvec(in); |
---|
| 40 | del_cvec(fftgrain); |
---|
| 41 | del_cvec(cstead); |
---|
| 42 | del_cvec(ctrans); |
---|
| 43 | del_fvec(stead); |
---|
| 44 | del_fvec(trans); |
---|
[45c0f16] | 45 | aubio_cleanup(); |
---|
[787b5e4] | 46 | printf("memory freed\n"); |
---|
| 47 | return 0; |
---|
| 48 | } |
---|