コード例 #1
0
/* function Py_sink_do */
static PyObject *
Py_sink_do(Py_sink * self, PyObject * args)
{
  /* input vectors python prototypes */
  PyObject * write_data_obj;

  /* input vectors prototypes */
  fvec_t* write_data;
  uint_t write;


  if (!PyArg_ParseTuple (args, "OI", &write_data_obj, &write)) {
    return NULL;
  }


  /* input vectors parsing */
  write_data = PyAubio_ArrayToCFvec (write_data_obj);

  if (write_data == NULL) {
    return NULL;
  }





  /* compute _do function */
  aubio_sink_do (self->o, write_data, write);

  Py_RETURN_NONE;
}
コード例 #2
0
ファイル: test-sampler.c プロジェクト: XunjunYin/aubio
int main (int argc, char **argv)
{
    sint_t err = 0;

    if (argc < 4) {
        err = 2;
        PRINT_ERR("not enough arguments\n");
        PRINT_MSG("usage: %s <input_path> <output_path> <sample_path> [samplerate]\n", argv[0]);
        return err;
    }

    uint_t samplerate = 0; // default is the samplerate of input_path
    uint_t hop_size = 256;
    uint_t n_frames = 0, read = 0;

    char_t *source_path = argv[1];
    char_t *sink_path = argv[2];
    char_t *sample_path = argv[3];
    if ( argc == 5 ) samplerate = atoi(argv[4]);

    fvec_t *vec = new_fvec(hop_size);
    aubio_source_t *source = new_aubio_source(source_path, samplerate, hop_size);
    if (samplerate == 0 ) samplerate = aubio_source_get_samplerate(source);
    aubio_sink_t *sink = new_aubio_sink(sink_path, samplerate);

    aubio_sampler_t * sampler = new_aubio_sampler (samplerate, hop_size);

    aubio_sampler_load (sampler, sample_path);

    do {
        aubio_source_do(source, vec, &read);
        if (n_frames / hop_size == 10) {
            aubio_sampler_play ( sampler );
        }
        if (n_frames / hop_size == 40) {
            aubio_sampler_play ( sampler );
        }
        if (n_frames / hop_size == 70) {
            aubio_sampler_play ( sampler );
        }
        if (n_frames > 10.0 * samplerate) {
            aubio_sampler_stop ( sampler );
        }
        aubio_sampler_do (sampler, vec, vec);
        aubio_sink_do(sink, vec, read);
        n_frames += read;
    } while ( read == hop_size );

    del_aubio_sampler(sampler);
    del_aubio_source(source);
    del_aubio_sink(sink);
    del_fvec(vec);
    aubio_cleanup();

    return 0;
}
コード例 #3
0
ファイル: test-sink.c プロジェクト: famulus/aubio
int main (int argc, char **argv)
{
  sint_t err = 0;

  if (argc < 3) {
    err = 2;
    PRINT_ERR("not enough arguments\n");
    PRINT_MSG("usage: %s <input_path> <output_path> [samplerate] [hop_size]\n", argv[0]);
    return err;
  }

  char_t *source_path = argv[1];
  char_t *sink_path = argv[2];

  uint_t samplerate = 0;
  uint_t hop_size = 256;
  if ( argc >= 4 ) samplerate = atoi(argv[3]);
  if ( argc >= 5 ) hop_size = atoi(argv[4]);
  if ( argc >= 6 ) {
    err = 2;
    PRINT_ERR("too many arguments\n");
    return err;
  }

  fvec_t *vec = new_fvec(hop_size);
  if (!vec) { err = 1; goto beach_fvec; }

  aubio_source_t *i = new_aubio_source(source_path, samplerate, hop_size);
  if (!i) { err = 1; goto beach_source; }

  if (samplerate == 0 ) samplerate = aubio_source_get_samplerate(i);

  aubio_sink_t *o = new_aubio_sink(sink_path, samplerate);
  if (!o) { err = 1; goto beach_sink; }

  uint_t n_frames = 0, read = 0;

  do {
    aubio_source_do(i, vec, &read);
    aubio_sink_do(o, vec, read);
    n_frames += read;
  } while ( read == hop_size );

  PRINT_MSG("read %d frames at %dHz (%d blocks) from %s written to %s\n",
      n_frames, samplerate, n_frames / hop_size,
      source_path, sink_path);

  del_aubio_sink(o);
beach_sink:
  del_aubio_source(i);
beach_source:
  del_fvec(vec);
beach_fvec:
  return err;
}
コード例 #4
0
ファイル: utils.c プロジェクト: anthonylauzon/aubio
void examples_common_process (aubio_process_func_t process_func,
    aubio_print_func_t print)
{

  uint_t read = 0;
  if (usejack) {

#ifdef HAVE_JACK
    ev.size = 3;
    ev.buffer = malloc (3 * sizeof (jack_midi_data_t));
    ev.time = 0; // send it now
    debug ("Jack activation ...\n");
    aubio_jack_activate (jack_setup, process_func);
    debug ("Processing (Ctrl+C to quit) ...\n");
    pause ();
    aubio_jack_close (jack_setup);
#else /* HAVE_JACK */
    usage (stderr, 1);
    outmsg ("Compiled without jack output, exiting.\n");
#endif /* HAVE_JACK */

  } else {

    uint_t total_read = 0;
    blocks = 0;

    do {
      aubio_source_do (this_source, ibuf, &read);
      process_func (ibuf, obuf);
      // print to console if verbose or no output given
      if (verbose || sink_uri == NULL) {
        print();
      }
      if (this_sink) {
        aubio_sink_do (this_sink, obuf, hop_size);
      }
      blocks++;
      total_read += read;
    } while (read == hop_size);

    verbmsg ("read %.2fs (%d samples in %d blocks of %d) from %s at %dHz\n",
        total_read * 1. / samplerate,
        total_read, blocks, hop_size, source_uri, samplerate);

    del_aubio_source (this_source);
    del_aubio_sink   (this_sink);

  }
}