6. Extending Yaafe

Before extending Yaafe, the developper have to be aware of Yaafe‘s general architecture. Please read carefully Yaafe internals.

As a summary, keep in mind that a feature is defined by 2 layers:

  1. a python class which builds the directed graph of components, representing the steps to compute the feature
  2. the components used to compute the feature. Each component is a C++ class which process the computations like frame tokenization, fft, cepstrum.

6.1. Defining new features

To define a new feature, the programmer has to create a subclass of AudioFeature. see examples in the yaafefeatures.py file.

class yaafelib.AudioFeature



PARAMS is a list of tuples defining the parameters of the feature. There are 3 differents ways of defining parameters:

Inherits parameters from another feature
(MagnitudeSpectrum, params_dict) inherits parameters from the already defined feature MagnitudeSpectrum
Inherits parameters from a component
('FFT', params_dict) inherits parameters from the components corresponding to the given id string
Define new parameter
('Name','default','description') defines a new parameter with its default value and description.

params_dict is a dictionary which allow overiding parameters default value, or masking a parameter we don’t want the user to provide. For example, {'blockSize':'512', 'FFTWindow':None} will overide blockSize default value and mask the FFTWindow parameter.


TRANSFORM is a flag to tell whether the feature is a transformation to apply on another feature (Cepstrum, StatisticalIntegrator), or a raw feature which is computed directly from the audio signal.

classmethod filter_params(params)

Returns a dictionary holding only parameters defined from the PARAMS attribute with default value for those not in the given params dict.

classmethod get_dataflow(params, samplerate)

Return the dataflow to compute the feature with the given parameters at the given sample rate. This is the main method to overide when subclassing AudioFeature.

  • params (dict) – parameters
  • samplerate – the sample rate

the feature dataflow

Return type:


classmethod get_parameters()

Returns the list of parameters with their description and default value. Subclasses do not have to overide this function, the parameter list is build automatically from the PARAMS class attribute.

6.2. Create new components

A component is a C++ class which represents computational step, such as FrameTokenizer, FFT, Cepstrum, etc.

To create new components, the programmer has to subclass YAAFE::Component (see file src_cpp/yaafe-core/Component.h).

New components have to be registered to the YAAFE::ComponentFactory. The usual way is to create a dynamic library which will be loaded at runtime, and to expose the function registerYaafeComponents (see src_cpp/yaafe-components/registration.h). The programmer who is integrating Yaafe‘s C++ Engine into his program can load components directly from his code.

Table Of Contents

Previous topic

5. The yaafelib Python module

Next topic

Yaafe core features