source: tests/src/onset/test-onset.c @ 4b943729

feature/autosinkfeature/cnnfeature/cnn_orgfeature/constantqfeature/crepefeature/crepe_orgfeature/pitchshiftfeature/pydocstringsfeature/timestretchfix/ffmpeg5
Last change on this file since 4b943729 was 986131d, checked in by Eduard Müller <mueller.eduard@googlemail.com>, 7 years ago

Intel IPP support for aubio

See emuell/aubio/ intel_ipp2 for details please

  • Property mode set to 100644
File size: 1.7 KB
RevLine 
[4e9101e]1#include <aubio.h>
[f69e3bd]2#include "utils_tests.h"
[4e9101e]3
[f69e3bd]4int main (int argc, char **argv)
[26775a3]5{
[986131d]6  aubio_init();
7 
[f69e3bd]8  uint_t err = 0;
9  if (argc < 2) {
10    err = 2;
11    PRINT_ERR("not enough arguments\n");
12    PRINT_MSG("read a wave file as a mono vector\n");
13    PRINT_MSG("usage: %s <source_path> [samplerate] [hop_size]\n", argv[0]);
14    return err;
15  }
16  uint_t samplerate = 0;
[26775a3]17  uint_t win_s = 1024; // window size
[f69e3bd]18  uint_t hop_size = win_s / 4;
19  uint_t n_frames = 0, read = 0;
20  if ( argc == 3 ) samplerate = atoi(argv[2]);
21  if ( argc == 4 ) hop_size = atoi(argv[3]);
22
23  char_t *source_path = argv[1];
24  aubio_source_t * source = new_aubio_source(source_path, samplerate, hop_size);
25  if (!source) { err = 1; goto beach; }
26
27  if (samplerate == 0 ) samplerate = aubio_source_get_samplerate(source);
28
[26775a3]29  // create some vectors
[f69e3bd]30  fvec_t * in = new_fvec (hop_size); // input audio buffer
31  fvec_t * out = new_fvec (2); // output position
32
[26775a3]33  // create onset object
[f69e3bd]34  aubio_onset_t * o = new_aubio_onset("default", win_s, hop_size, samplerate);
35
36  do {
37    // put some fresh data in input vector
38    aubio_source_do(source, in, &read);
39    // execute onset
40    aubio_onset_do(o,in,out);
41    // do something with the onsets
42    if (out->data[0] != 0) {
43      PRINT_MSG("onset at %.3fms, %.3fs, frame %d\n",
44          aubio_onset_get_last_ms(o), aubio_onset_get_last_s(o),
45          aubio_onset_get_last(o));
46    }
47    n_frames += read;
48  } while ( read == hop_size );
49
50  PRINT_MSG("read %.2fs, %d frames at %dHz (%d blocks) from %s\n",
51      n_frames * 1. / samplerate,
52      n_frames, samplerate,
53      n_frames / hop_size, source_path);
54
55  // clean up memory
[2e17371]56  del_aubio_source(source);
[f69e3bd]57  del_aubio_onset(o);
58  del_fvec(in);
[26775a3]59  del_fvec(out);
[f69e3bd]60beach:
[26775a3]61  aubio_cleanup();
[4e9101e]62
[f69e3bd]63  return err;
[4e9101e]64}
Note: See TracBrowser for help on using the repository browser.