Changeset c3f4173 for tests/src


Ignore:
Timestamp:
Sep 25, 2009, 6:58:40 AM (15 years ago)
Author:
Paul Brossier <piem@piem.org>
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:
50bc5f2
Parents:
bccac6b
Message:

tests/src/test-phasevoc-jack.c: update to also test midi ports and make funny noises

File:
1 edited

Legend:

Unmodified
Added
Removed
  • tests/src/test-phasevoc-jack.c

    rbccac6b rc3f4173  
    1 /* test sample for phase vocoder
     1/** Test for phase vocoder in jack
    22 *
    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.
     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).
     7 *
    68 */
    79
    8 #include <unistd.h>  /* pause() or sleep() */
     10#include <unistd.h>  /* sleep() */
    911#include <aubio.h>
    1012#include <aubioext.h>
    1113
    12 uint_t win_s    = 32; /* window size                       */
    13 uint_t hop_s    = 8;  /* hop size                          */
    14 uint_t channels = 4;  /* number of channels                */
     14uint_t testing  = 1;  /* change this to 1 to listen        */
     15
     16uint_t win_s    = 512;/* window size                       */
     17uint_t hop_s    = 128;/* hop size                          */
     18uint_t channels = 2;  /* number of audio channels          */
     19uint_t midiin   = 4;  /* number of midi input channels     */
     20uint_t midiout  = 2;  /* number of midi output channels    */
    1521uint_t pos      = 0;  /* frames%dspblocksize for jack loop */
    1622
     
    2026
    2127aubio_pvoc_t * pv;
    22 
    23 #ifdef HAVE_JACK
    24 aubio_jack_t * jack_setup;
    25 #endif
    2628
    2729int aubio_process(float **input, float **output, int nframes);
     
    3436        /* allocate fft and other memory space */
    3537        pv = new_aubio_pvoc(win_s,hop_s,channels);
    36         /* fill input with some data */
    37         printf("initialised\n");
    38         /* execute stft */
    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");
    4438
    4539#ifdef HAVE_JACK
    46         jack_setup  = new_aubio_jack(channels, channels,
    47                         (aubio_process_func_t)aubio_process);
     40        aubio_jack_t * jack_setup;
     41        jack_setup  = new_aubio_jack(channels, channels,
     42            midiin, midiout,
     43            (aubio_process_func_t)aubio_process);
    4844        aubio_jack_activate(jack_setup);
    49         sleep(10); //pause(); /* enter main jack loop */
     45        /* stay in main jack loop for 1 seconds only */
     46        do {
     47          sleep(1);
     48        } while(testing);
    5049        aubio_jack_close(jack_setup);
    5150#endif
     
    5655        del_fvec(out);
    5756        aubio_cleanup();
    58         printf("memory freed\n");
    5957        return 0;
    6058}
     
    7472      /* block loop */
    7573      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.;
     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.);
     80      }
     81      // copy second channel to third one
    7882      aubio_pvoc_rdo(pv,fftgrain,out);
    7983      pos = -1;
Note: See TracChangeset for help on using the changeset viewer.