예제 #1
0
파일: test-tss.c 프로젝트: aubio/aubio
int main (void)
{
  uint_t n = 10; // compute n times
  uint_t win_s = 1024; // window size
  uint_t hop_s = 256;  // hop size

  // create some vectors
  fvec_t * in       = new_fvec (hop_s); // input buffer
  cvec_t * fftgrain = new_cvec (win_s); // fft norm and phase
  cvec_t * cstead   = new_cvec (win_s); // fft norm and phase
  cvec_t * ctrans   = new_cvec (win_s); // fft norm and phase
  fvec_t * stead    = new_fvec (hop_s); // output buffer
  fvec_t * trans    = new_fvec (hop_s); // output buffer

  // create phase vocoder for analysis of input signal 
  aubio_pvoc_t * pv = new_aubio_pvoc (win_s,hop_s);
  // create transient/steady-state separation object
  aubio_tss_t *  tss = new_aubio_tss(win_s,hop_s);
  // create phase vocoder objects for synthesis of output signals
  aubio_pvoc_t * pvt = new_aubio_pvoc(win_s,hop_s);
  aubio_pvoc_t * pvs = new_aubio_pvoc(win_s,hop_s);

  /* execute stft */
  while ( n-- ) {
    // fftgrain = pv(in)
    aubio_pvoc_do (pv, in, fftgrain);
    // ctrans, cstead = tss (fftgrain)
    aubio_tss_do (tss, fftgrain, ctrans, cstead);
    // stead = pvt_inverse (cstead)
    // trans = pvt_inverse (ctrans)
    aubio_pvoc_rdo (pvt, cstead, stead);
    aubio_pvoc_rdo (pvs, ctrans, trans);
  }

  aubio_tss_set_alpha(tss, 4.);
  aubio_tss_set_beta(tss, 3.);
  aubio_tss_set_threshold(tss, 3.);

  del_aubio_pvoc(pv);
  del_aubio_pvoc(pvt);
  del_aubio_pvoc(pvs);
  del_aubio_tss(tss);

  del_fvec(in);
  del_cvec(fftgrain);
  del_cvec(cstead);
  del_cvec(ctrans);
  del_fvec(stead);
  del_fvec(trans);

  aubio_cleanup();

  return 0;
}
예제 #2
0
void
del_aubio_pitchyinfft (aubio_pitchyinfft_t * p)
{
  del_fvec (p->win);
  del_aubio_fft (p->fft);
  del_fvec (p->yinfft);
  del_fvec (p->sqrmag);
  del_cvec (p->res);
  del_cvec (p->fftout);
  del_fvec (p->winput);
  del_fvec (p->weight);
  AUBIO_FREE (p);
}
예제 #3
0
int main(){
        /* allocate some memory */
        uint_t win_s      = 4096;                       /* window size        */
        uint_t channels   = 100;                        /* number of channels */
        fvec_t * in       = new_fvec (win_s, channels); /* input buffer       */
        cvec_t * fftgrain = new_cvec (win_s, channels); /* fft norm and phase */
        fvec_t * out      = new_fvec (win_s, channels); /* output buffer      */
        /* allocate fft and other memory space */
        aubio_mfft_t * fft = new_aubio_mfft(win_s,channels);
        /* fill input with some data */
        //printf("initialised\n");
        /* execute stft */
        aubio_mfft_do (fft,in,fftgrain);
        //printf("computed forward\n");
        /* execute inverse fourier transform */
        aubio_mfft_rdo(fft,fftgrain,out);
        //printf("computed backard\n");
        del_aubio_mfft(fft);
        del_fvec(in);
        del_cvec(fftgrain);
        del_fvec(out);
        //printf("memory freed\n");
        aubio_cleanup();
        return 0;
}
예제 #4
0
파일: pitch.c 프로젝트: EQ4/aubio-mod
void
del_aubio_pitch (aubio_pitch_t * p)
{
  switch (p->type) {
    case aubio_pitcht_yin:
      del_fvec (p->buf);
      del_aubio_pitchyin (p->p_object);
      break;
    case aubio_pitcht_mcomb:
      del_aubio_pvoc (p->pv);
      del_cvec (p->fftgrain);
      del_aubio_filter (p->filter);
      del_aubio_pitchmcomb (p->p_object);
      break;
    case aubio_pitcht_schmitt:
      del_fvec (p->buf);
      del_aubio_pitchschmitt (p->p_object);
      break;
    case aubio_pitcht_fcomb:
      del_fvec (p->buf);
      del_aubio_pitchfcomb (p->p_object);
      break;
    case aubio_pitcht_yinfft:
      del_fvec (p->buf);
      del_aubio_pitchyinfft (p->p_object);
      break;
    case aubio_pitcht_specacf:
      del_fvec (p->buf);
      del_aubio_pitchspecacf (p->p_object);
      break;
    default:
      break;
  }
  AUBIO_FREE (p);
}
예제 #5
0
int main(int argc, char **argv) {
  // change some default params
  buffer_size  = 512;
  hop_size = 256;

  examples_common_init(argc,argv);

  verbmsg ("using source: %s at %dHz\n", source_uri, samplerate);
  verbmsg ("buffer_size: %d, ", buffer_size);
  verbmsg ("hop_size: %d\n", hop_size);

  pv = new_aubio_pvoc (buffer_size, hop_size);
  fftgrain = new_cvec (buffer_size);
  mfcc = new_aubio_mfcc(buffer_size, n_filters, n_coefs, samplerate);
  mfcc_out = new_fvec(n_coefs);

  examples_common_process((aubio_process_func_t)process_block, process_print);

  del_aubio_pvoc (pv);
  del_cvec (fftgrain);
  del_aubio_mfcc(mfcc);
  del_fvec(mfcc_out);

  examples_common_del();
  return 0;
}
예제 #6
0
파일: test-mfcc.c 프로젝트: iKala/aubio
int main ()
{
  uint_t win_s = 512; // fft size
  uint_t n_filters = 40; // number of filters
  uint_t n_coefs = 13; // number of coefficients
  smpl_t samplerate = 16000.; // samplerate
  cvec_t *in = new_cvec (win_s); // input buffer
  fvec_t *out = new_fvec (n_coefs); // output coefficients

  // create mfcc object
  aubio_mfcc_t *o = new_aubio_mfcc (win_s, n_filters, n_coefs, samplerate);

  cvec_set_all_norm (in, 1.);
  aubio_mfcc_do (o, in, out);
  fvec_print (out);

  cvec_set_all_norm (in, .5);
  aubio_mfcc_do (o, in, out);
  fvec_print (out);

  // clean up
  del_aubio_mfcc (o);
  del_cvec (in);
  del_fvec (out);
  aubio_cleanup ();

  return 0;
}
예제 #7
0
파일: aubiomfcc.c 프로젝트: daphne-yu/aubio
int main(int argc, char **argv) {
  // params
  buffer_size  = 512;
  overlap_size = 256;
  
  examples_common_init(argc,argv);

  /* phase vocoder */
  pv = new_aubio_pvoc (buffer_size, overlap_size);

  fftgrain = new_cvec (buffer_size);

  //populating the filter
  mfcc = new_aubio_mfcc(buffer_size, n_filters, n_coefs, samplerate);
  
  mfcc_out = new_fvec(n_coefs);
  
  //process
  examples_common_process(aubio_process,process_print);
  
  //destroying mfcc 
  del_aubio_pvoc (pv);
  del_cvec (fftgrain);
  del_aubio_mfcc(mfcc);
  del_fvec(mfcc_out);

  examples_common_del();
  debug("End of program.\n");
  fflush(stderr);
  
  return 0;
}
예제 #8
0
int
main (void)
{
  /* allocate some memory */
  uint_t win_s = 512;           /* fft size */
  uint_t n_filters = 40;        /* number of filters */
  cvec_t *in = new_cvec (win_s);      /* input buffer */
  fvec_t *out = new_fvec (win_s);     /* input buffer */
  fmat_t *coeffs = NULL;
  smpl_t samplerate = 16000.;

  /* allocate fft and other memory space */
  aubio_filterbank_t *o = new_aubio_filterbank (n_filters, win_s);

  /* assign Mel-frequency coefficients */
  aubio_filterbank_set_mel_coeffs_slaney (o, samplerate);

  coeffs = aubio_filterbank_get_coeffs (o);
  if (coeffs == NULL) {
    return -1;
  }

  //fmat_print (coeffs);

  //fprintf(stderr, "%f\n", fvec_sum(coeffs));

  aubio_filterbank_do (o, in, out);

  del_aubio_filterbank (o);
  del_cvec (in);
  del_fvec (out);
  aubio_cleanup ();

  return 0;
}
예제 #9
0
static void cleanupTss(LV2_Handle instance)
{
	tss_t* t=(tss_t*)instance;
	del_fvec(t->inbuff);
	del_fvec(t->transbuff);
	del_fvec(t->steadybuff);
	del_cvec (t->ci);
	del_cvec (t->ct);
	del_cvec (t->cs);
	del_aubio_tss(t->tss);
	del_aubio_pvoc(t->pv);
	del_aubio_pvoc(t->pvs);
	del_aubio_pvoc(t->pvt);

	free(instance);
	aubio_cleanup();	//Not sure if I should do this.
}
예제 #10
0
ofxAubioMelBands::~ofxAubioMelBands()
{
    if (spectrum) del_cvec(spectrum);
    if (pv) del_aubio_pvoc(pv);
    if (bands) del_fvec(bands);
    if (fb) del_aubio_filterbank(fb);
    cleanup();
    ofLogNotice() << "deleted ofxAubioMelBands";
}
예제 #11
0
void del_aubio_onset (aubio_onset_t *o)
{
  del_aubio_specdesc(o->od);
  del_aubio_peakpicker(o->pp);
  del_aubio_pvoc(o->pv);
  del_fvec(o->desc);
  del_cvec(o->fftgrain);
  AUBIO_FREE(o);
}
예제 #12
0
void
del_aubio_pitchfcomb (aubio_pitchfcomb_t * p)
{
    del_cvec (p->fftOut);
    del_fvec (p->fftLastPhase);
    del_fvec (p->win);
    del_fvec (p->winput);
    del_aubio_fft (p->fft);
    AUBIO_FREE (p);
}
예제 #13
0
파일: segment.c 프로젝트: gmuller/Dirt
void aubio_destruct() {
    del_aubio_pvoc(pv);
    del_fvec(ibuf);
    del_cvec(fftgrain);
    del_aubio_onsetdetection(o);
    del_aubio_peakpicker(parms);
    del_fvec(onset);
    if (usedoubled)    {
        del_aubio_onsetdetection(o2);
        del_fvec(onset2);
    }
}
예제 #14
0
void del_aubio_tempo (aubio_tempo_t *o)
{
  del_aubio_onsetdetection(o->od);
  del_aubio_beattracking(o->bt);
  del_aubio_peakpicker(o->pp);
  del_aubio_pvoc(o->pv);
  del_fvec(o->out);
  del_fvec(o->of);
  del_cvec(o->fftgrain);
  del_fvec(o->dfframe);
  AUBIO_FREE(o);
  return;
}
예제 #15
0
int main(){
	int i;
        uint_t win_s    = 1024; /* window size                       */
        uint_t hop_s    = 256;  /* hop size                          */
        uint_t channels = 4;  /* number of channels                */
        /* allocate some memory */
        fvec_t * in       = new_fvec (hop_s, channels); /* input buffer       */
        cvec_t * fftgrain = new_cvec (win_s, channels); /* fft norm and phase */
        cvec_t * cstead   = new_cvec (win_s, channels); /* fft norm and phase */
        cvec_t * ctrans   = new_cvec (win_s, channels); /* fft norm and phase */
        fvec_t * stead    = new_fvec (hop_s, channels); /* output buffer      */
        fvec_t * trans    = new_fvec (hop_s, channels); /* output buffer      */
        /* allocate fft and other memory space */
        aubio_pvoc_t * pv = new_aubio_pvoc (win_s,hop_s,channels);
        aubio_pvoc_t * pvt = new_aubio_pvoc(win_s,hop_s,channels);
        aubio_pvoc_t * pvs = new_aubio_pvoc(win_s,hop_s,channels);

	aubio_tss_t *  tss = new_aubio_tss(0.01,3.,4.,win_s,hop_s,channels);
        /* fill input with some data */
        printf("initialised\n");
        /* execute stft */
	for (i = 0; i < 10; i++) {
		aubio_pvoc_do (pv,in,fftgrain);
		aubio_tss_do  (tss,fftgrain,ctrans,cstead);
		aubio_pvoc_rdo(pvt,cstead,stead);
		aubio_pvoc_rdo(pvs,ctrans,trans);
	}
        del_aubio_pvoc(pv);
        del_fvec(in);
        del_cvec(fftgrain);
        del_cvec(cstead);
        del_cvec(ctrans);
        del_fvec(stead);
        del_fvec(trans);
        aubio_cleanup();
        printf("memory freed\n");
        return 0;
}
예제 #16
0
파일: test-fft.c 프로젝트: XunjunYin/aubio
int main (void)
{
  int return_code = 0;
  uint_t i, n_iters = 100; // number of iterations
  uint_t win_s = 500; // window size
  fvec_t * in = new_fvec (win_s); // input buffer
  cvec_t * fftgrain = new_cvec (win_s); // fft norm and phase
  fvec_t * out = new_fvec (win_s); // output buffer
  // create fft object
  aubio_fft_t * fft = new_aubio_fft(win_s);

  if (!fft) {
    return_code = 1;
    goto beach;
  }

  // fill input with some data
  in->data[0] = 1;
  in->data[1] = 2;
  in->data[2] = 3;
  in->data[3] = 4;
  in->data[4] = 5;
  in->data[5] = 6;
  in->data[6] = 5;
  in->data[7] = 6;
  //fvec_print(in);

  for (i = 0; i < n_iters; i++) {
    // execute stft
    aubio_fft_do (fft,in,fftgrain);
    cvec_print(fftgrain);

    // execute inverse fourier transform
    aubio_fft_rdo(fft,fftgrain,out);
  }

  // cleam up
  //fvec_print(out);
  del_aubio_fft(fft);
beach:
  del_fvec(in);
  del_cvec(fftgrain);
  del_fvec(out);
  aubio_cleanup();
  return return_code;
}
예제 #17
0
int main (void)
{
  uint_t n = 6; // compute n times
  uint_t win_s = 32; // window size
  uint_t hop_s = win_s / 4; // hop size

  fvec_t * in = new_fvec (hop_s); // input buffer
  cvec_t * fftgrain = new_cvec (win_s); // fft norm and phase
  fvec_t * out = new_fvec (hop_s); // output buffer

  // allocate fft and other memory space
  aubio_pvoc_t * pv = new_aubio_pvoc(win_s,hop_s);

  // fill input with some data
  fvec_set_all (in, 1.);
  fvec_print (in);

  while ( n-- ) {
    // get some fresh input data
    // ..

    // execute phase vocoder
    aubio_pvoc_do (pv,in,fftgrain);

    // do something with fftgrain
    // ...
    cvec_print (fftgrain);

    // optionally rebuild the signal
    aubio_pvoc_rdo(pv,fftgrain,out);

    // and do something with the result
    // ...
    fvec_print (out);
  }

  // clean up
  del_fvec(in);
  del_cvec(fftgrain);
  del_fvec(out);
  del_aubio_pvoc(pv);
  aubio_cleanup();

  return 0;
}
예제 #18
0
파일: test-cvec.c 프로젝트: famulus/aubio
int main (void)
{
  uint_t i, window_size = 16; // window size
  utils_init_random();
  cvec_t * complex_vector = new_cvec (window_size); // input buffer
  uint_t rand_times = 4;

  while (rand_times -- ) {
    // fill with random phas and norm
    for ( i = 0; i < complex_vector->length; i++ ) {
      complex_vector->norm[i] = ( 2. / RAND_MAX * random() - 1. );
      complex_vector->phas[i] = ( 2. / RAND_MAX * random() - 1. ) * M_PI;
    }
    // print the vector
    cvec_print(complex_vector);
  }

  // set all vector elements to `0`
  cvec_norm_zeros(complex_vector);
  for ( i = 0; i < complex_vector->length; i++ ) {
    assert( complex_vector->norm[i] == 0. );
    // assert( complex_vector->phas[i] == 0 );
  }
  cvec_print(complex_vector);

  // set all vector elements to `1`
  cvec_norm_ones(complex_vector);
  for ( i = 0; i < complex_vector->length; i++ ) {
    assert( complex_vector->norm[i] == 1. );
    // assert( complex_vector->phas[i] == 0 );
  }
  cvec_print(complex_vector);

  cvec_zeros(complex_vector);
  cvec_phas_zeros(complex_vector);
  cvec_norm_zeros(complex_vector);
  cvec_norm_ones(complex_vector);
  cvec_phas_ones(complex_vector);
  cvec_copy(complex_vector, complex_vector);

  // destroy it
  del_cvec(complex_vector);
  return 0;
}
예제 #19
0
int
main (void)
{
  /* allocate some memory */
  uint_t win_s = 1024;          /* window size */
  uint_t n_filters = 13;        /* number of filters */
  cvec_t *in = new_cvec (win_s);      /* input buffer */
  fvec_t *out = new_fvec (win_s);     /* input buffer */
  fmat_t *coeffs = NULL;

  /* allocate fft and other memory space */
  aubio_filterbank_t *o = new_aubio_filterbank (n_filters, win_s);

  coeffs = aubio_filterbank_get_coeffs (o);
  if (coeffs == NULL) {
    return -1;
  }

  /*
  if (fvec_max (coeffs) != 0.) {
    return -1;
  }

  if (fvec_min (coeffs) != 0.) {
    return -1;
  }
  */

  fmat_print (coeffs);

  aubio_filterbank_do (o, in, out);

  del_aubio_filterbank (o);
  del_cvec (in);
  del_fvec (out);
  aubio_cleanup ();

  return 0;
}
예제 #20
0
int main(){
        /* allocate some memory */
        uint_t win_s      = 1024;                       /* window size */
        uint_t hop_s      = win_s/4;                    /* hop size */
        cvec_t * in       = new_cvec (win_s); /* input buffer */
        fvec_t * out      = new_fvec (1); /* input buffer */

        aubio_pitchmcomb_t * o  = new_aubio_pitchmcomb(win_s, hop_s);
        uint_t i = 0;

        while (i < 1000) {
          aubio_pitchmcomb_do (o,in, out);
          i++;
        };

        del_aubio_pitchmcomb(o);
        del_cvec(in);
        del_fvec(out);
        aubio_cleanup();

        return 0;
}
예제 #21
0
int main ()
{
  uint_t win_s = 1024; // window size
  uint_t n_filters = 13; // number of filters

  cvec_t *in_spec = new_cvec (win_s); // input vector of samples
  fvec_t *out_filters = new_fvec (n_filters); // per-band outputs

  // create filterbank object
  aubio_filterbank_t *o = new_aubio_filterbank (n_filters, win_s);

  // apply filterbank ten times
  uint_t n = 10;
  while (n) {
    aubio_filterbank_do (o, in_spec, out_filters);
    n--;
  }

  // print out filterbank coeffs
  fmat_t *coeffs; // pointer to the coefficients
  coeffs = aubio_filterbank_get_coeffs (o);
  fmat_print (coeffs);

  aubio_filterbank_set_coeffs (o, coeffs);
  coeffs = aubio_filterbank_get_coeffs (o);
  fmat_print (coeffs);

  //fvec_print (out_filters);

  // clean up
  del_aubio_filterbank (o);
  del_cvec (in_spec);
  del_fvec (out_filters);
  aubio_cleanup ();

  return 0;
}
예제 #22
0
int main (void)
{
    uint_t samplerate = 16000; // samplerate of signal to filter
    uint_t win_s = 512; // fft size
    uint_t n_filters = 40; // number of filters

    cvec_t *in_spec = new_cvec (win_s); // input vector of samples
    fvec_t *out_filters = new_fvec (n_filters); // per-band outputs

    // create filterbank object
    aubio_filterbank_t *o = new_aubio_filterbank (n_filters, win_s);

    // assign Mel-frequency coefficients
    aubio_filterbank_set_mel_coeffs_slaney (o, samplerate);

    // apply filterbank ten times
    uint_t n = 10;
    while (n) {
        aubio_filterbank_do (o, in_spec, out_filters);
        n--;
    }

    // print out filter coefficients
    fmat_t *coeffs; // pointer to the coefficients
    coeffs = aubio_filterbank_get_coeffs (o);
    fmat_print (coeffs);

    //fvec_print (out_filters);

    del_aubio_filterbank (o);
    del_cvec (in_spec);
    del_fvec (out_filters);
    aubio_cleanup ();

    return 0;
}
예제 #23
0
파일: test-mfcc.c 프로젝트: aubio/aubio
int main (int argc, char** argv)
{
  sint_t err = 0;

  if (argc < 2) {
    err = 2;
    PRINT_WRN("no arguments, running tests\n");
    err = test_wrong_params();
    PRINT_MSG("usage: %s <input_path> [samplerate] [hop_size]\n", argv[0]);
    return err;
  }

  uint_t win_s; // fft size
  uint_t hop_s = 256; // block size
  uint_t samplerate = 0; // samplerate
  uint_t n_filters = 40; // number of filters
  uint_t n_coeffs = 13; // number of coefficients
  uint_t read = 0;

  char_t *source_path = argv[1];

  if ( argc >= 3 ) samplerate = atoi(argv[2]);
  if ( argc >= 4 ) hop_s = atoi(argv[3]);

  win_s = 2 * hop_s;

  aubio_source_t *source = 0;
  aubio_pvoc_t *pv = 0;
  aubio_mfcc_t *mfcc = 0;

  fvec_t *in = new_fvec (hop_s);       // phase vocoder input
  cvec_t *fftgrain = new_cvec (win_s); // pvoc output / mfcc input
  fvec_t *out = new_fvec (n_coeffs);   // mfcc output

  if (!in || !fftgrain || !out) { err = 1; goto failure; }

  // source
  source = new_aubio_source(source_path, samplerate, hop_s);
  if (!source) { err = 1; goto failure; }
  if (samplerate == 0) samplerate = aubio_source_get_samplerate(source);

  // phase vocoder
  pv = new_aubio_pvoc(win_s, hop_s);
  if (!pv) { err = 1; goto failure; }

  // mfcc object
  mfcc = new_aubio_mfcc (win_s, n_filters, n_coeffs, samplerate);
  if (!mfcc) { err = 1; goto failure; }

  // processing loop
  do {
    aubio_source_do(source, in, &read);
    aubio_pvoc_do(pv, in, fftgrain);
    aubio_mfcc_do(mfcc, fftgrain, out);
    fvec_print(out);
  } while (read == hop_s);

failure:

  if (mfcc)
    del_aubio_mfcc(mfcc);
  if (pv)
    del_aubio_pvoc(pv);
  if (source)
    del_aubio_source(source);
  if (in)
    del_fvec(in);
  if (fftgrain)
    del_cvec(fftgrain);
  if (out)
    del_fvec(out);
  aubio_cleanup();
  return err;
}