示例#1
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;
}
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;
}
示例#3
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;
}
示例#4
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;
}