1 /** Test for phase vocoder in jack
3 * This program should start correctly, when jackd is started or when
4 * using JACK_START_SERVER=true and reconstruct each audio input channel
5 * on the corresponding output channel with some strange effects and a
6 * delay equal to the hop size (hop_s).
10 #include <unistd.h> /* sleep() */
14 uint_t testing = 1; /* change this to 1 to listen */
16 uint_t win_s = 512;/* window size */
17 uint_t hop_s = 128;/* hop size */
18 uint_t channels = 2; /* number of audio channels */
19 uint_t midiin = 4; /* number of midi input channels */
20 uint_t midiout = 2; /* number of midi output channels */
21 uint_t pos = 0; /* frames%dspblocksize for jack loop */
29 int aubio_process(float **input, float **output, int nframes);
32 /* allocate some memory */
33 in = new_fvec (hop_s, channels); /* input buffer */
34 fftgrain = new_cvec (win_s, channels); /* fft norm and phase */
35 out = new_fvec (hop_s, channels); /* output buffer */
36 /* allocate fft and other memory space */
37 pv = new_aubio_pvoc(win_s,hop_s,channels);
40 aubio_jack_t * jack_setup;
41 jack_setup = new_aubio_jack(channels, channels,
43 (aubio_process_func_t)aubio_process);
44 aubio_jack_activate(jack_setup);
45 /* stay in main jack loop for 1 seconds only */
49 aubio_jack_close(jack_setup);
60 int aubio_process(float **input, float **output, int nframes) {
61 uint_t i; /*channels*/
63 for (j=0;j<(unsigned)nframes;j++) {
64 for (i=0;i<channels;i++) {
65 /* write input to datanew */
66 fvec_write_sample(in, input[i][j], i, pos);
67 /* put synthnew in output */
68 output[i][j] = fvec_read_sample(out, i, pos);
73 aubio_pvoc_do (pv,in, fftgrain);
74 // zero phases of first channel
75 for (i=0;i<fftgrain->length;i++) fftgrain->phas[0][i] = 0.;
76 // double phases of second channel
77 for (i=0;i<fftgrain->length;i++) {
78 fftgrain->phas[1][i] =
79 aubio_unwrap2pi (fftgrain->phas[1][i] * 2.);
81 // copy second channel to third one
82 aubio_pvoc_rdo(pv,fftgrain,out);