1 /* test sample for phase vocoder
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.
8 #include <unistd.h> /* pause() or sleep() */
12 uint_t win_s = 32; /* window size */
13 uint_t hop_s = 8; /* hop size */
14 uint_t channels = 4; /* number of channels */
15 uint_t pos = 0; /* frames%dspblocksize for jack loop */
24 aubio_jack_t * jack_setup;
27 int aubio_process(float **input, float **output, int nframes);
30 /* allocate some memory */
31 in = new_fvec (hop_s, channels); /* input buffer */
32 fftgrain = new_cvec (win_s, channels); /* fft norm and phase */
33 out = new_fvec (hop_s, channels); /* output buffer */
34 /* allocate fft and other memory space */
35 pv = new_aubio_pvoc(win_s,hop_s,channels);
36 /* fill input with some data */
37 printf("initialised\n");
39 aubio_pvoc_do (pv,in,fftgrain);
40 printf("computed forward\n");
41 /* execute inverse fourier transform */
42 aubio_pvoc_rdo(pv,fftgrain,out);
43 printf("computed backard\n");
46 jack_setup = new_aubio_jack(channels, channels,
47 (aubio_process_func_t)aubio_process);
48 aubio_jack_activate(jack_setup);
49 sleep(10); //pause(); /* enter main jack loop */
50 aubio_jack_close(jack_setup);
58 printf("memory freed\n");
62 int aubio_process(float **input, float **output, int nframes) {
63 uint_t i; /*channels*/
65 for (j=0;j<(unsigned)nframes;j++) {
66 for (i=0;i<channels;i++) {
67 /* write input to datanew */
68 fvec_write_sample(in, input[i][j], i, pos);
69 /* put synthnew in output */
70 output[i][j] = fvec_read_sample(out, i, pos);
75 aubio_pvoc_do (pv,in, fftgrain);
76 //for (i=0;i<fftgrain->length;i++) fftgrain->phas[0][i] *= 2.;
77 //for (i=0;i<fftgrain->length;i++) fftgrain->phas[0][i] = 0.;
78 aubio_pvoc_rdo(pv,fftgrain,out);