Esempio n. 1
0
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;
}
AubioOnsetDetector :: ~AubioOnsetDetector(){
		aubio_onsetdetection_free (o);
		del_aubio_pvoc(pv);
		del_aubio_peakpicker(parms);
		del_fvec(vec);
		aubio_cleanup();
}
Esempio n. 3
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;
}
Esempio n. 4
0
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;
}
Esempio n. 5
0
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);
}
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.
}
Esempio n. 7
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);
}
Esempio n. 8
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";
}
Esempio n. 9
0
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);
    }
}
Esempio n. 10
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;
}
Esempio n. 11
0
/* Allocate memory for an onset detection */
aubio_onset_t * new_aubio_onset (const char_t * onset_mode,
    uint_t buf_size, uint_t hop_size, uint_t samplerate)
{
  aubio_onset_t * o = AUBIO_NEW(aubio_onset_t);

  /* check parameters are valid */
  if ((sint_t)hop_size < 1) {
    AUBIO_ERR("onset: got hop_size %d, but can not be < 1\n", hop_size);
    goto beach;
  } else if ((sint_t)buf_size < 2) {
    AUBIO_ERR("onset: got buffer_size %d, but can not be < 2\n", buf_size);
    goto beach;
  } else if (buf_size < hop_size) {
    AUBIO_ERR("onset: hop size (%d) is larger than win size (%d)\n", hop_size, buf_size);
    goto beach;
  } else if ((sint_t)samplerate < 1) {
    AUBIO_ERR("onset: samplerate (%d) can not be < 1\n", samplerate);
    goto beach;
  }

  /* store creation parameters */
  o->samplerate = samplerate;
  o->hop_size = hop_size;

  /* allocate memory */
  o->pv = new_aubio_pvoc(buf_size, o->hop_size);
  o->pp = new_aubio_peakpicker();
  o->od = new_aubio_specdesc(onset_mode,buf_size);
  if (o->od == NULL) goto beach_specdesc;
  o->fftgrain = new_cvec(buf_size);
  o->desc = new_fvec(1);
  o->spectral_whitening = new_aubio_spectral_whitening(buf_size, hop_size, samplerate);

  /* initialize internal variables */
  aubio_onset_set_default_parameters (o, onset_mode);

  aubio_onset_reset(o);
  return o;

beach_specdesc:
  del_aubio_peakpicker(o->pp);
  del_aubio_pvoc(o->pv);
beach:
  AUBIO_FREE(o);
  return NULL;
}
Esempio n. 12
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;
}
Esempio n. 13
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;
}
Esempio n. 14
0
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;
}