Code Monkey home page Code Monkey logo

mtg / essentia Goto Github PK

View Code? Open in Web Editor NEW
2.7K 108.0 521.0 305.74 MB

C++ library for audio and music analysis, description and synthesis, including Python bindings

Home Page: http://essentia.upf.edu

License: GNU Affero General Public License v3.0

Shell 0.24% Python 29.73% NSIS 0.31% C++ 69.23% C 0.12% MATLAB 0.36% Csound Score 0.02%
audio music dsp essentia python c-plus-plus music-information-retrieval audio-analysis sound-processing

essentia's Introduction

Essentia

Build wheels status License: AGPL v3 PyPI downloads: essentia PyPI downloads: essentia-tensorflow

Essentia is an open-source C++ library for audio analysis and audio-based music information retrieval released under the Affero GPLv3 license. It contains an extensive collection of reusable algorithms which implement audio input/output functionality, standard digital signal processing blocks, statistical characterization of data, and a large set of spectral, temporal, tonal and high-level music descriptors. The library is also wrapped in Python and includes a number of predefined executable extractors for the available music descriptors, which facilitates its use for fast prototyping and allows setting up research experiments very rapidly. Furthermore, it includes a Vamp plugin to be used with Sonic Visualiser for visualization purposes. Essentia is designed with a focus on the robustness of the provided music descriptors and is optimized in terms of the computational cost of the algorithms. The provided functionality, specifically the music descriptors included in-the-box and signal processing algorithms, is easily expandable and allows for both research experiments and development of large-scale industrial applications.

Documentation online: http://essentia.upf.edu

Installation

The library is cross-platform and currently supports Linux, macOS, Windows, iOS and Android systems. Read installation instructions:

Install from master for the latest updates.

To use in Python (Linux x86_64, i686): pip install essentia or pip install essentia-tensorflow.

Docker images: https://hub.docker.com/r/mtgupf/essentia/

You can download and use prebuilt static binaries for a number of Essentia's command-line music extractors instead of installing the complete library

Quick start

Quick start using Python:

Command-line tools to compute common music descriptors:

Asking for help

Read frequently asked questions.

Create an issue on github or open a new discussion if your question was not answered before.

Versions

Official releases: https://github.com/MTG/essentia/releases

Github branches:

  • master: latest updates; if you got any problem, try it first.

If you use example extractors (located in src/examples), or your own code employing Essentia algorithms to compute descriptors, you should be aware of possible incompatibilities when using different versions of Essentia.

How to contribute

We are more than happy to collaborate and receive your contributions to Essentia. The best practice of submitting your code is by creating pull requests to our GitHub repository following our contribution policy. By submitting your code you authorize that it complies with the Developer's Certificate of Origin. For more details see: http://essentia.upf.edu/documentation/contribute.html

You are also more than welcome to suggest any improvements, including proposals for new algorithms, etc.

essentia's People

Contributors

alastair avatar albertmayol avatar albincorreya avatar alia-morsi avatar amcap1712 avatar angelfaraldo avatar carthach avatar christianfrisson avatar cvf-bcn-gituser avatar dbogdanov avatar dimastro avatar ffont avatar giuband avatar hector avatar jayaddison avatar jjaner avatar jpauwels avatar leighsmith avatar martchus avatar martinhn avatar mckelvin avatar nadinekroher avatar oriolromani avatar palonso avatar ronggong avatar seeker-liu avatar sertansenturk avatar wackou avatar xaviliz avatar xserra avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

essentia's Issues

Compiling on windows

From the installation pages :
"Weโ€™re sorry, but youโ€™re pretty much on your own if you want to develop on Windows..."

Has someone tried it successfully anyways? Is there hope to actually compile the library on windows, or do you see a major obstacle for that?

Any pointers would help.

Thanks.

Building on iOS/ARM mobile platforms

Any project to run the whole library on mobile iOS ?

FFWT
TagLib
LibYAML

should be compilable on iOS easily.

An idea could be to make a lightweight release of the library without the Python wrappers.

Output times in LogAttackTime algorithm

It would be nice to also output the start and end time of the LogAttackTime algorithm.
Those times are already detected, it is just a matter of outputting them.

configuration issue on mac (Getting pyembed flags from python-config: Could not build a python embedded interpreter)

After
./waf configure --mode=release --with-python --with-cpptests --with-examples --with-vamp

I got this

python executable ... differs from system...
...
Checking for library python2.7 in LIBPATH_PYEMBED: not found
Checking for library python2.7 in LIBDIR: not found
Checking for library python2.7 in python_LIBPL: not found
Checking for library python2.7 in $prefix/libs: not found
...
Getting pyembed flags from python-config: Could not build a python embedded interpreter
...

The configuration failed

any pointer on how to resolve this? thanks.

compatibility issues with ffmpeg

Hi,
I was having a lot of problems trying to compile essentia on Linux.
Errors were related with libavformat.a.
Finally I could compile Essentia succesfully by removing ffmpeg, as sugested somewhere on the internet.
Is there any way to go around this compatibility problem?

Incorrect behavior of CentralMoments on arrays with negative values

Add support for arrays with negative values. CentralMoments algorithm is suited for computation of central moments of the non-negative array only because it considers array values as a probability distribution function. If negative values are present, negative variance is output which further leads to NaN errors in the output of DistributionShape algorithm, when the two are connected in a chain.

Installed Libraries are "not found" when compiling (mac 10.8.4)

I successfully installed the dependent libraries via:

brew install libyaml fftw ffmpeg libsamplerate libtag

however when I try to compile none of these relevant libraries are found and Essentia will not compile.

I have completely deinstalled macports and deleted associated files, so I am relatively sure that that isn't the problem. I suspect it might be because I don't have the right version of the libraries??

Here is the log:

โ†’ Building in release mode
Checking for 'g++' (c++ compiler)        : clang++ 
Checking for 'gcc' (c compiler)          : clang 
Checking for program pkg-config          : /usr/bin/pkg-config 
Checking for 'libavcodec'                : not found 
Checking for 'libavformat'               : not found 
Checking for 'libavutil'                 : not found 
Checking for 'libswresample'             : not found 
Checking for 'taglib'                    : not found 
Checking for 'yaml-0.1'                  : not found 
The configuration failed
(complete log in /Users/caroline/Desktop/school/abbyWork/essentia/essentia-2.0/build/config.log)
cmu-414606:essentia-2.0 caroline$ brew install libyaml fftw ffmpeg libsamplerate libtag
Warning: Your Xcode (4.6.3) is outdated
Please update to Xcode 5.0.1.
Xcode can be updated from the App Store.
Warning: libyaml-0.1.5 already installed
Warning: fftw-3.3.3 already installed
Warning: ffmpeg-2.1.3 already installed
Warning: libsamplerate-0.1.8 already installed
Warning: taglib-1.9.1 already installed
cmu-414606:essentia-2.0 caroline$ ```

Python Memory Leak with MonoLoader in Standard Mode

Similar to this report:
#40

I am trying to open and analyze multiple files using the MonoLoader algorithm, but this results in a memory leak that keeps growing as more and more files are loaded. Here's the code I was using to get the durations of the audio files in my music library: (please correct me if there's a better way to do this, but I couldn't find anything in the documentation about 'unloading' a file once it's been loaded, or a way to open a different file with the same instance of MonoLoader/AudioLoader)

import os
import essentia 
import essentia.standard
import essentia.streaming

from os.path import join, getsize

extensions = dict()
durations = []
with open('durations.txt', 'wb') as f:
    for root, dirs, files in os.walk('/path/to/music/library'):
        if 'CVS' in dirs:
            dirs.remove('CVS')  # don't visit CVS directories
        #print sum(getsize(join(root, name)) for name in files),
        print 'album: {0}\n'.format(root)
        for name in files:
            if name.endswith(('.wav', '.aif', 'aiff', '.flac', '.mp3', '.m4a')):
                #print root
                # and then we actually perform the loading:
                try:
                    loader = essentia.standard.MonoLoader(filename = join(root, name))
                    audio = loader()
                    duration_in_seconds = len(audio)/44100.
                    f.write('{0}, '.format(duration_in_seconds))
                    print '{0},'.format(duration_in_seconds),
                    #del loader #making these calls has no effect
                    #del audio #...
                    #gc.collect() #...
                except (RuntimeError, TypeError, NameError):
                    #print 'could not parse file $s\n' % name
                    continue

Compilation broken for new OSX 10.9 Mavericks

Following the official installation instructions for OSX 10.6 Snow Leopard provided good results.

In OSX 10.8 Mountain Lion they still worked, with the exception of having to install matplotlib with homebrew (preferably numpy and scipy also).

In OSX 10.9 Mavericks the compilation fails with the following error:

[ 29/307] cxx: src/algorithms/spectral/hpcp.cpp -> build/src/algorithms/spectral/hpcp.cpp.1.o
In file included from ../src/algorithms/rhythm/rhythmextractor2013.cpp:21:
In file included from ../src/algorithms/rhythm/rhythmextractor2013.h:23:
In file included from /Users/hector/.installers/essentia/src/essentia/streaming/streamingalgorithmcomposite.h:23:
In file included from /Users/hector/.installers/essentia/src/essentia/streaming/streamingalgorithm.h:271:
In file included from /Users/hector/.installers/essentia/src/essentia/streaming/source.h:138:
In file included from /Users/hector/.installers/essentia/src/essentia/streaming/phantombuffer.h:25:
/Users/hector/.installers/essentia/src/essentia/streaming/../roguevector.h:127:40: error: no member named '_M_impl' in 'essentia::RogueVector<std::__1::vector<float, std::__1::allocator > >'
inline void setData(T* data) { this->_M_impl._M_start = data; }
~~~~ ^


Waf is using the clang and clang++ compiler provided by OSX which seems to have some incompatibility issues.

For now a workaround is to install the latest gcc (tested with 4.7 and 4.8) with homebrew, for example. And after the configuration step (waf configure [...]) replace manually in the file 'build/c4che/_cache.py' all the occurrences of:

  • gcc and clang with gcc-4.8
  • g++ and clang++ with g++-4.8

I don't know if it should be fixed by updating essentia code to play nice with clang compiler or force OSX users to install the regular gcc and make waf detect and select it.

Registrar fails for Algorithms that don't inherit directly from Algorithm

I am implementing an extension of the streaming RingBufferInput algorithm that will create a JACK client and copy it's data into essentia through a ring buffer.

When I use RingBufferInput as the base class though, an empty entry is generated in the Registrar. essentia_algorithms_reg.cpp contains a line like AlgorithmFactory::Registrar<>;
When I use Algorithm directly it seems to work, but obviously this isn't really the right thing to do.

Am I missing something, or is this the way the registrar is implemented?

Incorrect outputs for predominant melody algorithm using essentia

Hi,

I have been trying out a few algorithms in essentia package. While trying out the predominant melody algorithm, I gave a song sang by me without any instrumental background as the input to the algorithm. I observed that the output pitch values have some abnormalities with some sudden overshoots to frequency ranges of 800- 1400Hz at several portions, and for the rest it seems very reasonable with average pitch values around 150-280. The same repeated for many songs. I believe the overshoot frequencies(800- 1400Hz) are beyond normal ranges while singing and I am suspecting the predominant melody extraction fails. I tried out changing the input parameter values, but it didn't improve. :-(

Am I missing some initialization of the parameters here? Or is it having anything to do inside the predominant melody algorithm.

Following is a snapshot of my output.

image

Issues detecting and building with gaia2 within virtualenv

I had a heck of a time getting waf to detect and build with gaia2 within a virtualenv, so figured I'd note some of the things I had to do in case it helps anyone smarter than me make the process more seamless for future users.

After running gaia2's waf configure (with --prefix=$VIRTUAL_ENV), build, and install within my virtualenv, the first problem was that essentia's waf configure (again with --prefix=$VIRTUAL_ENV) couldn't find my gaia2 installation. I figured out that this was because pkg-config couldn't find gaia2 when it got installed to $VIRTUAL_ENV/lib/pkgconfig. The only quick way I could see to get things to work was to modify my virtualenv's activate script to update/reset the $PKG_CONFIG_PATH appropriately upon activate/deactivate.

essentia's waf could then detect gaia2, but was running into compilation errors:

In file included from ../src/algorithms/essentia_algorithms_reg.cpp:117:0:
/home/njhwang/Documents/my-dev/essentia/src/algorithms/highlevel/gaiatransform.h:23:34: fatal error: gaia2/transformation.h: No such file or directory
compilation terminated.

The g++ invocation had the following flag to include the gaia2 headers that were installed in my virtualenv, which definitely contained transformation.h:

-I/home/njhwang/Documents/pyenvs/sirenuse/include/gaia2

Since transformation.h was executing "#include <gaia2/transformation.h>", I thought perhaps it was looking for another gaia2 folder within the included directory mentioned above.

I modified the gaia2.pc file in my $VIRTUAL_ENV/lib/pkgconfig directory to make sure that the following got included to the g++ flags:

-I/home/njhwang/Documents/pyenvs/sirenuse/include

I was then able to completely build and install essentia from a virtualenv.

detection of atomicity.h

On OSX 10.8 compilation fails at atomic.h because it tries to find atomicity.h as <bits/atomicity.h>. It looks like it may be a problem with ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED

Errors in gaiatransform.h during building Essentia

Hi,

I've installed Gaia2 at first.
Then, the configuration for Essentia is done.

$ ./waf configure --mode=release --with-python --with-cpptests --with-examples
Checking for 'g++' (c++ compiler)        : /usr/bin/g++
Checking for 'gcc' (c compiler)          : /usr/bin/gcc
Checking for program pkg-config          : /usr/bin/pkg-config
Checking for 'libavcodec'                : yes
Checking for 'libavformat'               : yes
Checking for 'libavutil'                 : yes
Checking for 'libswresample'             : yes
Checking for 'taglib'                    : yes
Checking for 'yaml-0.1'                  : yes
Checking for 'fftw3f'                    : yes
Checking for 'samplerate'                : yes
Checking for 'gaia2'                     : yes
Checking for program python              : /usr/local/python-2.6.4/bin/python
Checking for python version              : (2, 6, 4, 'final', 0)
Checking for library python2.6 in LIBDIR : yes
Checking for program /usr/local/python-2.6.4/bin/python-config,python2.6-config,python-config-2.6,python2.6m-config : /usr/local/python-2.6.4/bin/python-config
Checking for header Python.h                                                                                        : yes
================================ CONFIGURATION SUMMARY ================================
- FFmpeg / libav detected!
  The following algorithms will be included: ['AudioLoader', 'MonoLoader', 'EqloudLoader', 'EasyLoader', 'MonoWriter', 'AudioWriter']
- libsamplerate (SRC) detected!
  The following algorithms will be included: ['Resample']
- TagLib detected!
  The following algorithms will be included: ['MetadataReader']
- Gaia2 detected!
  The following algorithms will be included: ['GaiaTransform']
=======================================================================================
'configure' finished successfully (0.326s)

But, building for Essentia is failed with following errors

$ ./waf
....
.... 
[ 44/279] cxx: src/algorithms/standard/noiseadder.cpp -> build/src/algorithms/standard/noiseadder.cpp.1.o
[ 45/279] cxx: src/algorithms/io/monowriter.cpp -> build/src/algorithms/io/monowriter.cpp.1.o
../src/algorithms/highlevel/gaiatransform.h:37: error: โ€˜TransfoChainโ€™ in namespace โ€˜gaia2โ€™ does not name a type
../src/algorithms/highlevel/gaiatransform.h: In constructor โ€˜essentia::standard::GaiaTransform::GaiaTransform()โ€™:
../src/algorithms/highlevel/gaiatransform.h:47: error: โ€˜initโ€™ is not a member of โ€˜gaia2โ€™
../src/essentia/scheduler/network.cpp: In function โ€˜bool isExcludedFromInfo(const std::string&)โ€™:
../src/essentia/scheduler/network.cpp:923: warning: comparison between signed and unsigned integer expressions 

Is there anyone who knows the solution?

ffmpeg version

On OSX the latest ffmpeg version installed by homebrew (1.1.3) produces a crash when trying an example extractor. Version 0.8 worked for me. The latest supported version should be in the documentation.

Building with libc++ on OSX

Hey there,

I've been having a great time working with this excellent library. I'm currently trying to incorporate it into a C++ project I need to build with libc++. Can someone point me in the right direction for compiling the libessentia binary against libc++ (and not libstdc++)?

I've compiled/installed all the dependencies for Essentia via Homebrew as instructed in the documentation. Would I need to recompile the dependencies with clang++/libc++ as well?

Sorry for what might be a basic question - this is my first time getting this involved with the compile/link process.

Thanks so much,
S

build a simple first application

Hi!
i would create a simple application in C/C++ that takes as input my voice from microphone in real time and send in output (speakers of my PC) what I say.

Can You help me, please?

thanks!

ImportError: No module named essentia

$ python
Python 2.7.5 |Anaconda 1.8.0 (x86_64)| (default, Oct 24 2013, 07:02:20)
[GCC 4.0.1 (Apple Inc. build 5493)] on darwin
Type "help", "copyright", "credits" or "license" for more information.

import essentia
Traceback (most recent call last):
File "", line 1, in
ImportError: No module named essentia

I had essentia compiled but in python I still got importError, how to check if essentia is in my pythonpath (Python 2.7.5)? (I on 10.8 and have python 2.6 and 2.7)

32 bits version of the library for OS X

Has anyone managed to compile a 32 bits i386 or universal version of the library for OS X?

  • I have compiled universal versions of all the dependent libraries (libyaml fftw ffmpeg libsamplerate lib tag)

  • and added in the configure section of the wscript
    ctx.env.append_value('CXXFLAGS', '-arch')
    ctx.env.append_value('CXXFLAGS', 'i386')
    ctx.env.append_value('CXXFLAGS', '-arch')
    ctx.env.append_value('CXXFLAGS', 'x86_64')

    ctx.env.append_value('LINKFLAGS', '-arch')
    ctx.env.append_value('LINKFLAGS', 'i386')
    ctx.env.append_value('LINKFLAGS', '-arch')
    ctx.env.append_value('LINKFLAGS', 'x86_64')
    

Everything compiles fine, yet the final libessentia library is x86_64 and not universal.
Any idea what I might have missed?
Thanks

Install help file

On Linux, I could only install python dependencies with sudo.

Similarly, ./waf install must be sudo ./waf install

Buffer size in ChordsDetection

For some sounds, ChordsDetection throws the following:

While trying to push item into source ChordsDetection::chords:
ChordsDetection::chords: Could not push 1 value, output buffer is full
stderr: terminate called after throwing an instance of 'essentia::EssentiaException'
what(): While trying to push item into source ChordsDetection::chords:
ChordsDetection::chords: Could not push 1 value, output buffer is full

A workaround seems to be increasing the frame size to 8192.

Example (without chords):
http://www.freesound.org/people/Yacob_l/sounds/194802/

Compilation error

Hi,
I'm trying to have a remote collaborator install essentia on his machine, and the compilation fails (I think at the python bindings step). Here's the first error :

In file included from ../src/python/pytypes/boolean.cpp:20:
/Users/jspindell/Desktop/essentia/src/python/typedefs.h:26:10: fatal error: 'numpy/ndarrayobject.h' file not found

include "numpy/ndarrayobject.h"

          ^

We located the numpy core headers folder on his machine and tried to export CFGLAGS :

export CFLAGS=-I/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/numpy/core/include/
export CPPFLAGS=-I/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/numpy/core/include/

but that didn't help. Do your have any suggestion?

The machine is running macosx with mountain lion.

Thank you!

Segmentation Fault in Python module tutorial

Hey guys,

Exciting looking library - can't wait to fully play with it.

Just going through the beginner's Python tutorial on the website, and I'm experiencing a segmentation fault on the audio = loader() step. I've tried with several different mp3s (always using MonoLoader), and it happens every time.

Any ideas?
S

python test for rhythmextractor fails on testImpulseTrain

Python test for RhythmExtractor fails on synthetic test input (testImpulseTrain) when running RhythmExtractor algorithm without tempoHints. Results ticks and bpm intervals do not correspond to the expected ones, although BPM estimates are correct.

Probably this was a normal behavior when running without tempoHits. The RhythmExtractor algorithm itself is outdated.

Question about outputs and parameters

Hey there,

This is a general question and I must admit I feel pretty stupid for not being able to figure it out myself -- perhaps someone can shed some light on this for me?

I'm writing a simple extractor in C++ in standard mode. My question is: How would you go about setting a parameter on one algorithm based on the output of another algorithm?

To get a bit more specific: I'm attempting to use the ticks output of RhythmExtractor2013 for the beats parameter of BeatsLoudness. I've got this working fine in Python, but for some reason my C++ isn't working at all. Specifically, my loudness vector isn't filling up with data. Would the answer to my question above even help me with this problem?

A truncated version of my code is as follows:

#include <iostream>
#include <fstream>
#include "algorithmfactory.h"
#include "essentiamath.h"
#include "pool.h"

using namespace std;
using namespace essentia;
using namespace essentia::standard;

int main(int argc, const char * argv[])
{
   if (argc != 2) {
       cout << "ERROR: incorrect number of arguments." << endl;
       cout << "Usage: " << argv[0] << " audio_input" << endl;
       exit(1);
   }

    string audioFilename = argv[1];

    essentia::init();
    Pool pool;

    /////// PARAMS //////////////
    int sampleRate = 44100;
    int maxTempo = 208;
    string method = "multifeature";
    int minTempo = 40;

    AlgorithmFactory& factory = standard::AlgorithmFactory::instance();

    Algorithm* audio = factory.create("MonoLoader",
                                      "filename", audioFilename,
                                      "sampleRate", sampleRate);

    Algorithm* re2013 = factory.create("RhythmExtractor2013",
                                       "maxTempo", maxTempo,
                                       "method", method,
                                       "minTempo", minTempo);

    /////////// CONNECTING THE ALGORITHMS ////////////////
    vector<Real> audioBuffer;
    audio->output("audio").set(audioBuffer);

    re2013->input("signal").set(audioBuffer);

    Real bpm, confidence;
    vector<Real> ticks, estimates, bpmIntervals;

    re2013->output("bpm").set(bpm);
    re2013->output("confidence").set(confidence);
    re2013->output("ticks").set(ticks);
    re2013->output("estimates").set(estimates);
    re2013->output("bpmIntervals").set(bpmIntervals);

    Algorithm* bl = factory.create("BeatsLoudness",
                                   "beats", ticks);
    bl->input("signal").set(audioBuffer);

    audio->compute();
    re2013->compute();

    vector<Real> loudness;
    vector<vector<Real>> loudnessBandRatio;
    bl->output("loudness").set(loudness);
    bl->output("loudnessBandRatio").set(loudnessBandRatio);

    bl->compute();

    cout << endl;
    cout << "Ticks size: " << ticks.size() << endl;
    cout << "Loudness size: " << loudness.size() << endl;
    cout << endl;

    delete audio;
    delete re2013;
    delete bl;

    essentia::shutdown();

    return 0;
}

AudioLoader memory leak on python steaming mode

Creating an instance of AudioLoader (streaming) on python allocates memory that is never collected.

Test:

from essentia.streaming import AudioLoader
f = "test/audio/recorded/musicbox.wav"
for i in range(1,1000): a= AudioLoader(filename=f)

Audio loader problem

Hi,

I get the following error message when using the examples (tried nearly all of them):

libc++abi.dylib: terminating with uncaught exception of type essentia::EssentiaException: Could not initialize swresample context

I guess this somehow comes from the audio loader. I tried different audio files in 44.1 kHz and 48kHz. Any ideas?

AudioLoader: more than 1 frame in packet, dropping remaining bytes...

I have a feature extractor in a python which uses essentia in streaming mode. For a specific file I get the following warnings:

[ WARNING  ] AudioLoader: more than 1 frame in packet, dropping remaining bytes...
[ WARNING  ] at sample index: 0
[ WARNING  ] decoded samples: 1024
[ WARNING  ] packet size: 4096
[ WARNING  ] AudioLoader: more than 1 frame in packet, dropping remaining bytes...
[ WARNING  ] at sample index: 2036
[ WARNING  ] decoded samples: 1024
[ WARNING  ] packet size: 4096
[ WARNING  ] AudioLoader: more than 1 frame in packet, dropping remaining bytes...
[ WARNING  ] at sample index: 4072
[ WARNING  ] decoded samples: 1024
[ WARNING  ] packet size: 4096
[   INFO   ] MelBands: input spectrum size (513) does not correspond to the "inputSize" parameter (1025). Recomputing the filter bank.
[ WARNING  ] AudioLoader: more than 1 frame in packet, dropping remaining bytes...
[ WARNING  ] at sample index: 6108
[ WARNING  ] decoded samples: 1024
[ WARNING  ] packet size: 4096
[ WARNING  ] AudioLoader: more than 1 frame in packet, dropping remaining bytes...
[ WARNING  ] at sample index: 8144
[ WARNING  ] decoded samples: 1024
[ WARNING  ] packet size: 4096
[ WARNING  ] AudioLoader: more than 1 frame in packet, dropping remaining bytes...
[ WARNING  ] at sample index: 10180
[ WARNING  ] decoded samples: 1024
[ WARNING  ] packet size: 4096
[ WARNING  ] AudioLoader: more than 1 frame in packet, dropping remaining bytes...
[ WARNING  ] at sample index: 12216
[ WARNING  ] decoded samples: 1024
[ WARNING  ] packet size: 4096
[ WARNING  ] AudioLoader: more than 1 frame in packet, dropping remaining bytes...
[ WARNING  ] at sample index: 14252
[ WARNING  ] decoded samples: 1024
[ WARNING  ] packet size: 4096
[ WARNING  ] AudioLoader: more than 1 frame in packet, dropping remaining bytes...
[ WARNING  ] at sample index: 16288
[ WARNING  ] decoded samples: 1024
[ WARNING  ] packet size: 4096

I had a quick look at the source code for the audio loader and found this comment:

if (len != _packet.size) {
        // FIXME: investigate why this happens and whether it is a big issue
        //        (looks like it only loses silent samples at the end of files)

        // more than 1 frame in a packet, happens a lot with flac for instance...
        E_WARNING("AudioLoader: more than 1 frame in packet, dropping remaining bytes...");
        E_WARNING("at sample index: " << output("audio").totalProduced());
        E_WARNING("decoded samples: " << len);
        E_WARNING("packet size: " << _packet.size);
    }

Here's the sound that gives these warnings: http://www.freesound.org/people/davidou/sounds/88466/

Run C++ Extractor Client Code

Looking at the examples like the rhythm extractor:

https://github.com/MTG/essentia/blob/master/src/examples/streaming_rhythmextractor_multifeature.cpp

in the essentia architecture an extractor is used in pipe with an audio input node:

Algorithm* mono = factory.create("MonoMixer");
Algorithm* rhythmextractor = factory.create("RhythmExtractor2013");
rhythmextractor->configure("method", "multifeature");
connect(audioloader->output("audio"), mono->input("audio"));
connect(audioloader->output("numberChannels"), mono->input("numberChannels"));
connect(audioloader->output("sampleRate"), pool, "metadata.sampleRate");
connect(mono->output("audio"), rhythmextractor->input("signal"));

and then connected to the ouput:

connect(mono->output("audio"), rhythmextractor->input("signal"));

Finally the network run the nodes:

Network network(audioloader);
network.run();

Is it possible to run the extractor directly i.e. using the constructor class:

essentia::init();
essentia::streaming::RhythmExtractor2013 *rythmExt =
new essentia::streaming::RhythmExtractor2013();

/// pass the pcm input signal

rythmExt->process();

Peak Detection error type (Python)

For the PeakDetection function I'm feeding a numpy.ndarray type of float64 and get the following error:

TypeError('essentia can currently only accept one-dimensional numpy arrays of dtype '
TypeError: essentia can currently only accept one-dimensional numpy arrays of dtype {"single", "int", "complex64"}

If it is not supported it would be a good enhancement because it is a very common data type.

segfault in streaming mode implementation

streaming_extractor_archive music will fail occasionally produce segfault on some audio files

[ WARNING  ] No more output for FrameCutter. Scheduler needs to do something or we're toast...
[ WARNING  ] No more output for FrameCutter. Scheduler needs to do something or we're toast...
[ WARNING  ] No more output for FrameCutter. Scheduler needs to do something or we're toast...
Segmentation fault
Program received signal SIGSEGV, Segmentation fault.
#0  0x081aa67d in essentia::streaming::PhantomBuffer<float>::acquireForWrite (this=0x86b4328, requested=8192) at /home/dbogdanov/essentia/src/essentia/streaming/phantombuffer_impl.h:101
#1  0x081ab413 in essentia::streaming::Source<float>::acquire (this=0x86b42c4, n=8192) at /home/dbogdanov/essentia/src/essentia/streaming/source.h:86
#2  0x08105528 in essentia::streaming::StreamConnector::acquire (this=0x86b42cc) at ../src/essentia/streaming/../streamconnector.h:49
#3  0x08104b0a in essentia::streaming::Algorithm::acquireData (this=0x86b41b0) at ../src/essentia/streaming/streamingalgorithm.cpp:208
#4  0x0832eef6 in essentia::streaming::StreamingAlgorithmWrapper::process (this=0x86b41b0) at ../src/essentia/streaming/streamingalgorithmwrapper.cpp:136
#5  0x0832fde9 in essentia::streaming::StreamingAlgorithmWrapper::process (this=0x86b41b0) at ../src/essentia/streaming/streamingalgorithmwrapper.cpp:205
#6  0x0832fde9 in essentia::streaming::StreamingAlgorithmWrapper::process (this=0x86b41b0) at ../src/essentia/streaming/streamingalgorithmwrapper.cpp:205
....
#2994 0x0832fde9 in essentia::streaming::StreamingAlgorithmWrapper::process (this=0x86b41b0) at ../src/essentia/streaming/streamingalgorithmwrapper.cpp:205
#2995 0x0832fde9 in essentia::streaming::StreamingAlgorithmWrapper::process (this=0x86b41b0) at ../src/essentia/streaming/streamingalgorithmwrapper.cpp:205
#2996 0x0832fde9 in essentia::streaming::StreamingAlgorithmWrapper::process (this=0x86b41b0) at ../src/essentia/streaming/streamingalgorithmwrapper.cpp:205
#2997 0x0832fde9 in essentia::streaming::StreamingAlgorithmWrapper::process (this=0x86b41b0) at ../src/essentia/streaming/streamingalgorithmwrapper.cpp:205
#2998 0x080ccb85 in essentia::scheduler::Network::run (this=0xbfffeda0) at ../src/essentia/scheduler/network.cpp:274
#2999 0x08072c2e in computeStep2 (audioFilename=..., pool=..., options=..., startTime=0, endTime=77.9864883) at ../src/examples/streaming_extractor_archivemusic.cpp:309
#3000 0x0806ff68 in compute (audioFilename=..., outputFilename=..., pool=..., options=...) at ../src/examples/streaming_extractor_archivemusic.cpp:115
#3001 0x0806fba2 in main (argc=3, argv=0xbffff664) at ../src/examples/streaming_extractor_archivemusic.cpp:87

streaming_extractor fails on the same example with exception:

terminate called after throwing an instance of 'essentia::EssentiaException'
  what():  acquireForWrite: Requested number of tokens (266240) > phantom size (131072) in EqualLoudness::signal

LowLevelSpectralExtractor fails due to a bug in scheduler

import essentia.standard as es
loader = es.EasyLoader(filename='01.wav')
lowLevelSpectralExtractor = es.LowLevelSpectralExtractor(frameSize=2048, hopSize=1024, sampleRate=44100)
audio = loader()
features = lowLevelSpectralExtractor(audio)
...

produces
RuntimeError: In LowLevelSpectralExtractor.compute: VectorInput: internal error: output buffer full

the problem is the bug in the streaming scheduler

HarmonicPeaks algorithm only selects octaves

HarmonicPeaks algorithm is selecting only those peaks that are octaves of the fundamental frequency (F0 * 2^harmonic_number) while it should select any peak multiple of F0 (F0 * harmonic_number).

See picture with the wrong behaviour (detected peaks in red, selected harmonic peaks in green):
essentia harmonic detection

We could port the standard solution used in the literature (from DAFX book, download matlab code for chapter 10, file: harmonicmodel.m). However, this algorithm still presents a problem (that you can also see on the previous picture for the peak around 7kHz) for which it may select more than one peak for a harmonic position.

Last year I implemented a more complete algorithm (also in matlab) that could be ported.
Anyway, I'd like to list the complete requirements I think this algorithm should comply with so that anybody can add or change ideas (just answering to this).

HarmonicPeaks requirements:

  • Select those peaks whose frequency is a multiple of the fundamental frequency (ideal harmonics)
  • Have a parameter to tolerate deviation from ideal harmonics. In my opinion, this parameter has to be a percentage over the F0. For example: if the F0 is 100Hz you may decide to allow a deviation of 20%, that is a fixed deviation of 20Hz; for the harmonic series it is: [180-220], [280-320], [380-420], etc. Currently in Essentia this is fixed at a maximum deviation of half a semitone.
  • The general strategy is to pick the closest detected peak to an ideal harmonic to represent it.
  • When the tolerance is greater than 50%, the same detected peak could be assigned to two ideal harmonics; we need to avoid that. Here the strategy should be to assign the detected peaks to ideal harmonics in order; the closest the first, but taking into account that a detected peak that has been assigned can not be reassigned.
  • In case there were equidistant detected peaks to a harmonic its amplitude decides; the highest gets picked.

We can discuss other methodologies out there to define harmonics' deviation tolerance:

  • In the DAFX book they also use a percentage but respect the ideal harmonics. In other words, it means that for a F0=100Hz and tolerance of 20% the first ideal harmonic (200Hz) will have a range of [160-240]Hz and so on. The problem is that, for example, for the harmonic of 1000Hz, we already have a range of [800-1200]Hz, which covers four other harmonics (800, 900, 1100, 1200). Even though a much smaller tolerance percentage could be used the behaviour will still be the same.
  • Currently in Essentia is used a tolerance equivalent to half a semitone. Clearly the intention is to use a perceptual measure. Here the problem is that even though a logarithmic scale (semitones) is being used, the distance between harmonics in terms of semitones gets smaller and smaller for higher harmonics, until a point this distance is smaller than half a semitone (see graphic below).
    semitones

From my point of view, it is intuitively more reasonable to use a fixed tolerance because the harmonics distance is also fixed, instead of using something linear or logarithmic, but it would be great to hear more opinions!

run_python_tests fails on Xubuntu 13.10

I am unable to run the python tests:

The installed GLIBC is 2.17

ptnx@ptnx-TA970:~/Documents/Code/essentia-master$ ./waf run_python_testsTraceback (most recent call last):
File "test/src/unittest/all_tests.py", line 27, in
import essentia
File "/home/ptnx/anaconda/lib/python2.7/site-packages/essentia/init.py", line 1, in
import _essentia
ImportError: /home/ptnx/anaconda/bin/../lib/libm.so.6: version `GLIBC_2.15' not found (required by /usr/lib/x86_64-linux-gnu/libvorbis.so.0)

Essentia in Xcode 4.6 on OSX 10.8

I'm not sure if anyone can help with this problem, but here I go --

I'm trying to use Essentia in a C++ project I'm developing with Xcode. I was able to use the Python bindings to great effect to quickly prototype the collection of algorithms I'd like to use and plot my data with Python and matplotlib. I'm now trying to translate the same extractor into a C++ project.

Does anyone have any advice on setting up a blank new Xcode project that will successfully compile a command line C++ project that uses Essentia?

Note: For now, it is enough for me to be able to compile a simple standard extractor that runs on the command line, but eventually I'd like to be able to include/use Essentia in a larger application that runs a GUI / OpenGL / etc.

I'm afraid I'm just not familiar enough with compiling/linking this level of code in Xcode.

Any help will be greatly appreciated. Thanks!

Python test errors after install

I tried to run the python tests after the install and there were a few errors.

ERROR: testAbnormalValues (rhythm.test_bpmhistogramdescriptors.TestBPMHistogramDescriptors)

Traceback (most recent call last):
File "/home/marius/Documents/Software/essentia-master/test/src/unittest/rhythm/test_bpmhistogramdescriptors.py", line 58, in testAbnormalValues
bpm1, weight1, spread1, bpm2, weight2, spread2 = BPMHistogramDescriptors()(intervals)
NameError: global name 'BPMHistogramDescriptors' is not defined

ERROR: testResetStandard (io.test_audioloader_streaming.TestAudioLoader_Streaming)

Traceback (most recent call last):
File "/home/marius/Documents/Software/essentia-master/test/src/unittest/io/test_audioloader_streaming.py", line 159, in testResetStandard
audio1, sr1, nChannels1 = loader();
File "test/src/unittest/all_tests.py", line 105, in computeResetCompute
File "/usr/local/lib/python2.7/dist-packages/essentia/standard.py", line 85, in compute
results = self.compute(*convertedArgs)
RuntimeError: In AudioLoader.compute: std::bad_alloc

I am on a 32 bits Ubuntu 12.04. Everything went well during compilation and I guess that during the install too.

configuration issue on mac 10.8 (taglib and yaml not found)

I tried to configure essentia on my mac and wondered how to proceed? how should i resolve this "taglib" and "yaml" not found? Thanks.

here is my configuration line:
$ ./waf configure --mode=release --with-python --with-cpptests --with-examples --with-vamp

here is the log i got:
Setting top to : .../essentia_solution/essentia-2.0
Setting out to : .../essentia_solution/essentia-2.0/build
โ†’ configuring the project in .../essentia_solution/essentia-2.0
โ†’ Building in release mode
Checking for 'g++' (c++ compiler) : clang++
Checking for 'gcc' (c compiler) : clang
Checking for program pkg-config : /opt/local/bin/pkg-config
Checking for 'libavcodec' : yes
Checking for 'libavformat' : yes
Checking for 'libavutil' : yes
Checking for 'libswresample' : yes
Checking for 'taglib' : not found
Checking for 'yaml-0.1' : not found
The configuration failed
(complete log in .../essentia-2.0/build/config.log)

Can't have a unicode filename in python bindings

e.g.

audio = essentia.standard.MonoLoader(filename=fname)()

causes

/home/alastair/code/dunya/env/local/lib/python2.7/site-packages/essentia/standard.py in configure(self, **kwargs)
     56                 kwargs[name] = convertedVal
     57 
---> 58             self.__configure__(**kwargs)
     59 
     60         def compute(self, *args):

RuntimeError: Error while parsing parameters: String::fromPythonCopy: input not a PyString: <type 'unicode'>

Error running onsetdetection_example on 10.9.1- essentia::EssentiaException: Error encoding last frames

$ python onsetdetection_example.py

usage: onsetdetection_example.py
$ python onsetdetection_example.py noise.wav
Loading audio file...
Computing onset detection functions...
Computing onset times...
Writing audio files to disk with onsets marked...
Traceback (most recent call last):
File "onsetdetection_example.py", line 98, in
MonoWriter(filename = 'onsets_complex.mp3', format = 'mp3')(marker(audio))
File "/usr/local/Cellar/python/2.7.6/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/essentia/standard.py", line 96, in call
return self.compute(_args)
File "/usr/local/Cellar/python/2.7.6/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/essentia/standard.py", line 85, in compute
results = self.compute(_convertedArgs)
RuntimeError: In MonoWriter.compute: Error encoding last frames
libc++abi.dylib: terminating with uncaught exception of type essentia::EssentiaException: Error encoding last frames
Abort trap: 6

However, there is an output file with onset annotation with beep. Any idea how to to resolve error? thanks.

INFO message in Envelope

The following seems to appear always when using Envelope in streaming mode:

[ INFO ] On source Envelope::signal:
[ INFO ] BUFFER SIZE MISMATCH: max=0 - asked for write size 4096
[ INFO ] resizing buffer to 36040/4505

MetadataReader loads corrupted album/artist/comment/genre/title tags on OSX

To reproduce:

./build/src/examples/streaming_extractor  test/audio/recorded/cat_purrrr.wav /tmp/foo.sig

Album/artist/comment/genre/title will look completely corrupted.

The error seems to be in the code loading metadata via TagLib

  _title.get()   = formatString(f.tag()->title());
  _artist.get()  = formatString(f.tag()->artist());
  _album.get()   = formatString(f.tag()->album());
  _comment.get() = formatString(f.tag()->comment());
  _genre.get()   = formatString(f.tag()->genre());

This issue does not happen on Linux (tested with the same version of TagLib).

better ChordsDetection algorithm

ChordsDetection does not perform well according to some user report.

The algorithm is very simplistic. It estimates chords for a window sliding accors HPCP frames. The frame size is arbitrary. The hop size is set to 1 HPCP frame. Maybe it could be a smart idea to jump from 1 beat to another or from 1 onset to another instead using sliced based on fixed amount a time.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.