MTG/essentia.js

Switch to object-oriented interface

jmarcosfer opened this issue · 0 comments

Description

Change library's interface to object-oriented, where each algorithm consists of a class with a .compute() method.

// E.g.
const framecutter = new essentia.FrameCutter( {frameSize: 2048, hopSize: 512} );
const output = framecutter.compute(audioVector);

Why?

With the current interface, where each algorithm is a function, each call to a given algorithm involves creating an AlgorithmFactory, an instance of the algorithm, and deleting said instance at the end of the compute cycle (see here, for example).

An OO interface (class + compute method) would avoid such drawback, potentially making the library use resources more efficiently. Additionally, it would match the upstream Essentia Python bindings' interface that so many existing users are already be familiar with.

How?

This requires editing /src/python/code_generator.py to change how it generates the c++ wrapper around the upstream library's algorithms.