Developping with aubio

Read Contribute to report issues and request new features.

See Doxygen documentation for the complete documentation of the C library, built using Doxygen.

Below is a brief Library overview.

Library overview

Here is a brief overview of the C library. See also the Doxygen documentation for a more detailed list of available functions.

Vectors and matrix

fvec_t are used to hold vectors of float (smpl_t).

  fvec_t * vec = new_fvec (vec_size);
// set some elements
vec->data[511] = 2.;
vec->data[vec->length-2] = 1.;

Similarly, fmat_t are used to hold matrix of floats.

  uint_t height = 3, length = 9, i, j;
  // create fmat_t object
  fmat_t * mat = new_fmat (height, length);
  for ( i = 0; i < mat->height; i++ ) {
    for ( j = 0; j < mat->length; j++ ) {
      // all elements are already initialized to 0.
      assert(mat->data[i][j] == 0);
      // setting element of row i, column j
      mat->data[i][j] = i * 1. + j *.1;
    }
  }

Reading a sound file

In this example, aubio_source is used to read a media file.

First, create the objects we need.

  uint_t samplerate = 0;
  uint_t hop_size = 256;
  uint_t n_frames = 0, read = 0;

  aubio_source_t* s =
    new_aubio_source(source_path, samplerate, hop_size);
  fvec_t *vec = new_fvec(hop_size);

Note

With samplerate = 0, aubio_source will be created with the file’s original samplerate.

Now for the processing loop:

  do {
    aubio_source_do(s, vec, &read);
    fvec_print (vec);
    n_frames += read;
  } while ( read == hop_size );

At the end of the processing loop, clean-up and de-allocate memory:

  // close the file (optional)
  aubio_source_close(s);
  // test closing the file a second time
  aubio_source_close(s);

  del_fvec (vec);
  del_aubio_source (s);

See the complete example: test-source.c.

Computing the spectrum

Now let’s create a phase vocoder:

  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

The processing loop could now look like:

    // 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
    // ...

See the complete example: test-phasevoc.c.

Doxygen documentation

The latest version of the doxygen documentation is available at:

Contribute

Please report any issue and feature request at the Github issue tracker. Patches and pull-requests welcome!

Table Of Contents

Previous topic

Command line features