MTG / essentia.js

JavaScript library for music/audio analysis and processing powered by Essentia WebAssembly
https://essentia.upf.edu/essentiajs
GNU Affero General Public License v3.0
628 stars 41 forks source link

Switch to object-oriented interface #64

Open jmarcosfer opened 2 years ago

jmarcosfer commented 2 years ago

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.