Skip to content

Commit

Permalink
Fix segfault in Vamp plugin. Closes #635 and #371
Browse files Browse the repository at this point in the history
Fix segfault that would occure in the Vamp plugin if Essentia was
built with --build-static flag. Store Algorithm::name, category and
description always in the standard scope.
  • Loading branch information
dbogdanov committed Aug 31, 2017
1 parent 3c8aa4d commit d3e436a
Show file tree
Hide file tree
Showing 24 changed files with 312 additions and 287 deletions.
14 changes: 8 additions & 6 deletions src/algorithms/extractor/keyextractor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,10 @@ using namespace std;
namespace essentia {
namespace streaming {

const char* KeyExtractor::name = "KeyExtractor";
const char* KeyExtractor::category = "Tonal";
const char* KeyExtractor::description = DOC("This algorithm extracts key/scale for an audio signal");
const char* KeyExtractor::name = essentia::standard::KeyExtractor::name;
const char* KeyExtractor::category = essentia::standard::KeyExtractor::category;
const char* KeyExtractor::description = essentia::standard::KeyExtractor::description;


KeyExtractor::KeyExtractor(): _frameCutter(0), _windowing(0), _spectrum(0), _spectralPeaks(0),
_hpcpKey(0), _key(0) {
Expand Down Expand Up @@ -106,9 +107,10 @@ KeyExtractor::~KeyExtractor() {
namespace essentia {
namespace standard {

const char* KeyExtractor::name = essentia::streaming::KeyExtractor::name;
const char* KeyExtractor::category = essentia::streaming::KeyExtractor::category;
const char* KeyExtractor::description = essentia::streaming::KeyExtractor::description;
const char* KeyExtractor::name = "KeyExtractor";
const char* KeyExtractor::category = "Tonal";
const char* KeyExtractor::description = DOC("This algorithm extracts key/scale for an audio signal");


KeyExtractor::KeyExtractor() {
declareInput(_audio, "audio", "the audio input signal");
Expand Down
13 changes: 7 additions & 6 deletions src/algorithms/extractor/levelextractor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ using namespace std;
namespace essentia {
namespace streaming {

const char* LevelExtractor::name = essentia::standard::LevelExtractor::name;
const char* LevelExtractor::category = essentia::standard::LevelExtractor::category;
const char* LevelExtractor::description = essentia::standard::LevelExtractor::description;

const char* LevelExtractor::name = "LevelExtractor";
const char* LevelExtractor::category = "Loudness/dynamics";
const char* LevelExtractor::description = DOC("This algorithm extracts the loudness of an audio signal in frames using Loudness algorithm.");

LevelExtractor::LevelExtractor() {

Expand Down Expand Up @@ -66,9 +66,10 @@ LevelExtractor::~LevelExtractor() {
namespace essentia {
namespace standard {

const char* LevelExtractor::name = essentia::streaming::LevelExtractor::name;
const char* LevelExtractor::category = essentia::streaming::LevelExtractor::category;
const char* LevelExtractor::description = essentia::streaming::LevelExtractor::description;
const char* LevelExtractor::name = "LevelExtractor";
const char* LevelExtractor::category = "Loudness/dynamics";
const char* LevelExtractor::description = DOC("This algorithm extracts the loudness of an audio signal in frames using Loudness algorithm.");


LevelExtractor::LevelExtractor() {
declareInput(_signal, "signal", "the audio input signal");
Expand Down
18 changes: 10 additions & 8 deletions src/algorithms/extractor/lowlevelspectraleqloudextractor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,10 @@ using namespace std;
namespace essentia {
namespace streaming {

const char* LowLevelSpectralEqloudExtractor::name = "LowLevelSpectralEqloudExtractor";
const char* LowLevelSpectralEqloudExtractor::category = "Extractors";
const char* LowLevelSpectralEqloudExtractor::description = DOC("This algorithm extracts a set of level spectral features for which it is recommended to apply a preliminary equal-loudness filter over an input audio signal (according to the internal evaluations conducted at Music Technology Group). To this end, you are expected to provide the output of EqualLoudness algorithm as an input for this algorithm. Still, you are free to provide an unprocessed audio input in the case you want to compute these features without equal-loudness filter.\n"
"\n"
"Note that at present we do not dispose any reference to justify the necessity of equal-loudness filter. Our recommendation is grounded on internal evaluations conducted at Music Technology Group that have shown the increase in numeric robustness as a function of the audio encoders used (mp3, ogg, ...) for these features.");
const char* LowLevelSpectralEqloudExtractor::name = essentia::standard::LowLevelSpectralEqloudExtractor::name;
const char* LowLevelSpectralEqloudExtractor::category = essentia::standard::LowLevelSpectralEqloudExtractor::category;
const char* LowLevelSpectralEqloudExtractor::description = essentia::standard::LowLevelSpectralEqloudExtractor::description;


LowLevelSpectralEqloudExtractor::LowLevelSpectralEqloudExtractor() : _configured(false) {

Expand Down Expand Up @@ -119,9 +118,12 @@ LowLevelSpectralEqloudExtractor::~LowLevelSpectralEqloudExtractor() {
namespace essentia {
namespace standard {

const char* LowLevelSpectralEqloudExtractor::name = essentia::streaming::LowLevelSpectralEqloudExtractor::name;
const char* LowLevelSpectralEqloudExtractor::category = essentia::streaming::LowLevelSpectralEqloudExtractor::category;
const char* LowLevelSpectralEqloudExtractor::description = essentia::streaming::LowLevelSpectralEqloudExtractor::description;
const char* LowLevelSpectralEqloudExtractor::name = "LowLevelSpectralEqloudExtractor";
const char* LowLevelSpectralEqloudExtractor::category = "Extractors";
const char* LowLevelSpectralEqloudExtractor::description = DOC("This algorithm extracts a set of level spectral features for which it is recommended to apply a preliminary equal-loudness filter over an input audio signal (according to the internal evaluations conducted at Music Technology Group). To this end, you are expected to provide the output of EqualLoudness algorithm as an input for this algorithm. Still, you are free to provide an unprocessed audio input in the case you want to compute these features without equal-loudness filter.\n"
"\n"
"Note that at present we do not dispose any reference to justify the necessity of equal-loudness filter. Our recommendation is grounded on internal evaluations conducted at Music Technology Group that have shown the increase in numeric robustness as a function of the audio encoders used (mp3, ogg, ...) for these features.");


LowLevelSpectralEqloudExtractor::LowLevelSpectralEqloudExtractor() {
declareInput(_signal, "signal", "the input audio signal");
Expand Down
14 changes: 8 additions & 6 deletions src/algorithms/extractor/lowlevelspectralextractor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,10 @@ using namespace std;
using namespace essentia;
using namespace essentia::streaming;

const char* LowLevelSpectralExtractor::name = "LowLevelSpectralExtractor";
const char* LowLevelSpectralExtractor::category = "Extractors";
const char* LowLevelSpectralExtractor::description = DOC("This algorithm extracts all low-level spectral features, which do not require an equal-loudness filter for their computation, from an audio signal");
const char* LowLevelSpectralExtractor::name = essentia::standard::LowLevelSpectralExtractor::name;
const char* LowLevelSpectralExtractor::category = essentia::standard::LowLevelSpectralExtractor::category;
const char* LowLevelSpectralExtractor::description = essentia::standard::LowLevelSpectralExtractor::description;


LowLevelSpectralExtractor::LowLevelSpectralExtractor() : _configured(false) {

Expand Down Expand Up @@ -242,9 +243,10 @@ void LowLevelSpectralExtractor::clearAlgos() {
namespace essentia {
namespace standard {

const char* LowLevelSpectralExtractor::name = essentia::streaming::LowLevelSpectralExtractor::name;
const char* LowLevelSpectralExtractor::category = essentia::streaming::LowLevelSpectralExtractor::category;
const char* LowLevelSpectralExtractor::description = essentia::streaming::LowLevelSpectralExtractor::description;
const char* LowLevelSpectralExtractor::name = "LowLevelSpectralExtractor";
const char* LowLevelSpectralExtractor::category = "Extractors";
const char* LowLevelSpectralExtractor::description = DOC("This algorithm extracts all low-level spectral features, which do not require an equal-loudness filter for their computation, from an audio signal");


LowLevelSpectralExtractor::LowLevelSpectralExtractor() {
declareInput(_signal, "signal", "the audio input signal");
Expand Down
13 changes: 7 additions & 6 deletions src/algorithms/extractor/rhythmdescriptors.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ using namespace std;
namespace essentia {
namespace streaming {

const char* RhythmDescriptors::name = "RhythmDescriptors";
const char* RhythmDescriptors::category = "Rhythm";
const char* RhythmDescriptors::description = DOC("This algorithm computes rhythm features (bpm, beat positions, beat histogram peaks) for an audio signal. It combines RhythmExtractor2013 for beat tracking and BPM estimation with BpmHistogramDescriptors algorithms.");
const char* RhythmDescriptors::name = essentia::standard::RhythmDescriptors::name;
const char* RhythmDescriptors::category = essentia::standard::RhythmDescriptors::category;
const char* RhythmDescriptors::description = essentia::standard::RhythmDescriptors::description;


RhythmDescriptors::RhythmDescriptors() {
Expand Down Expand Up @@ -137,9 +137,10 @@ void RhythmDescriptors::reset() {
namespace essentia {
namespace standard {

const char* RhythmDescriptors::name = essentia::streaming::RhythmDescriptors::name;
const char* RhythmDescriptors::category = essentia::streaming::RhythmDescriptors::category;
const char* RhythmDescriptors::description = essentia::streaming::RhythmDescriptors::description;
const char* RhythmDescriptors::name = "RhythmDescriptors";
const char* RhythmDescriptors::category = "Rhythm";
const char* RhythmDescriptors::description = DOC("This algorithm computes rhythm features (bpm, beat positions, beat histogram peaks) for an audio signal. It combines RhythmExtractor2013 for beat tracking and BPM estimation with BpmHistogramDescriptors algorithms.");


RhythmDescriptors::RhythmDescriptors() {
declareInput(_signal, "signal", "the audio input signal");
Expand Down
14 changes: 8 additions & 6 deletions src/algorithms/extractor/tonalextractor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,10 @@ using namespace std;
namespace essentia {
namespace streaming {

const char* TonalExtractor::name = "TonalExtractor";
const char* TonalExtractor::category = "Tonal";
const char* TonalExtractor::description = DOC("This algorithm computes tonal features for an audio signal");
const char* TonalExtractor::name = essentia::standard::TonalExtractor::name;
const char* TonalExtractor::category = essentia::standard::TonalExtractor::category;
const char* TonalExtractor::description = essentia::standard::TonalExtractor::description;


TonalExtractor::TonalExtractor(): _frameCutter(0), _windowing(0), _spectrum(0), _spectralPeaks(0),
_hpcpKey(0), _hpcpChord(0), _hpcpTuning(0), _key(0),
Expand Down Expand Up @@ -160,9 +161,10 @@ TonalExtractor::~TonalExtractor() {
namespace essentia {
namespace standard {

const char* TonalExtractor::name = essentia::streaming::TonalExtractor::name;
const char* TonalExtractor::category = essentia::streaming::TonalExtractor::category;
const char* TonalExtractor::description = essentia::streaming::TonalExtractor::description;
const char* TonalExtractor::name = "TonalExtractor";
const char* TonalExtractor::category = "Tonal";
const char* TonalExtractor::description = DOC("This algorithm computes tonal features for an audio signal");


TonalExtractor::TonalExtractor() {
declareInput(_signal, "signal", "the audio input signal");
Expand Down
14 changes: 8 additions & 6 deletions src/algorithms/extractor/tuningfrequencyextractor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,10 @@ using namespace std;
namespace essentia {
namespace streaming {

const char* TuningFrequencyExtractor::name = "TuningFrequencyExtractor";
const char* TuningFrequencyExtractor::category = "Tonal";
const char* TuningFrequencyExtractor::description = DOC("This algorithm extracts the tuning frequency of an audio signal");
const char* TuningFrequencyExtractor::name = essentia::standard::TuningFrequencyExtractor::name;
const char* TuningFrequencyExtractor::category = essentia::standard::TuningFrequencyExtractor::category;
const char* TuningFrequencyExtractor::description = essentia::standard::TuningFrequencyExtractor::description;


TuningFrequencyExtractor::TuningFrequencyExtractor(): _frameCutter(0), _spectralPeaks(0), _spectrum(0), _tuningFrequency(0), _windowing(0) {
createInnerNetwork();
Expand Down Expand Up @@ -87,9 +88,10 @@ TuningFrequencyExtractor::~TuningFrequencyExtractor() {
namespace essentia {
namespace standard {

const char* TuningFrequencyExtractor::name = essentia::streaming::TuningFrequencyExtractor::name;
const char* TuningFrequencyExtractor::category = essentia::streaming::TuningFrequencyExtractor::category;
const char* TuningFrequencyExtractor::description = essentia::streaming::TuningFrequencyExtractor::description;
const char* TuningFrequencyExtractor::name = "TuningFrequencyExtractor";
const char* TuningFrequencyExtractor::category = "Tonal";
const char* TuningFrequencyExtractor::description = DOC("This algorithm extracts the tuning frequency of an audio signal");


TuningFrequencyExtractor::TuningFrequencyExtractor() {
declareInput(_signal, "signal", "the audio input signal");
Expand Down
42 changes: 21 additions & 21 deletions src/algorithms/io/audioloader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,24 +26,9 @@ using namespace std;
namespace essentia {
namespace streaming {

const char* AudioLoader::name = "AudioLoader";
const char* AudioLoader::category = "Input/output";
const char* AudioLoader::description = DOC("This algorithm loads the single audio stream contained in a given audio or video file. Supported formats are all those supported by the ffmpeg library including wav, aiff, flac, ogg and mp3.\n"
"\n"
"This algorithm will throw an exception if it was not properly configured which is normally due to not specifying a valid filename. Invalid names comprise those with extensions different than the supported formats and non existent files. If using this algorithm on Windows, you must ensure that the filename is encoded as UTF-8\n\n"
"Note: ogg files are decoded in reverse phase, due to be using ffmpeg library.\n"
"\n"
"References:\n"
" [1] WAV - Wikipedia, the free encyclopedia,\n"
" http://en.wikipedia.org/wiki/Wav\n"
" [2] Audio Interchange File Format - Wikipedia, the free encyclopedia,\n"
" http://en.wikipedia.org/wiki/Aiff\n"
" [3] Free Lossless Audio Codec - Wikipedia, the free encyclopedia,\n"
" http://en.wikipedia.org/wiki/Flac\n"
" [4] Vorbis - Wikipedia, the free encyclopedia,\n"
" http://en.wikipedia.org/wiki/Vorbis\n"
" [5] MP3 - Wikipedia, the free encyclopedia,\n"
" http://en.wikipedia.org/wiki/Mp3");
const char* AudioLoader::name = essentia::standard::AudioLoader::name;
const char* AudioLoader::category = essentia::standard::AudioLoader::category;
const char* AudioLoader::description = essentia::standard::AudioLoader::description;


AudioLoader::~AudioLoader() {
Expand Down Expand Up @@ -502,9 +487,24 @@ void AudioLoader::reset() {
namespace essentia {
namespace standard {

const char* AudioLoader::name = essentia::streaming::AudioLoader::name;
const char* AudioLoader::category = essentia::streaming::AudioLoader::category;
const char* AudioLoader::description = essentia::streaming::AudioLoader::description;
const char* AudioLoader::name = "AudioLoader";
const char* AudioLoader::category = "Input/output";
const char* AudioLoader::description = DOC("This algorithm loads the single audio stream contained in a given audio or video file. Supported formats are all those supported by the ffmpeg library including wav, aiff, flac, ogg and mp3.\n"
"\n"
"This algorithm will throw an exception if it was not properly configured which is normally due to not specifying a valid filename. Invalid names comprise those with extensions different than the supported formats and non existent files. If using this algorithm on Windows, you must ensure that the filename is encoded as UTF-8\n\n"
"Note: ogg files are decoded in reverse phase, due to be using ffmpeg library.\n"
"\n"
"References:\n"
" [1] WAV - Wikipedia, the free encyclopedia,\n"
" http://en.wikipedia.org/wiki/Wav\n"
" [2] Audio Interchange File Format - Wikipedia, the free encyclopedia,\n"
" http://en.wikipedia.org/wiki/Aiff\n"
" [3] Free Lossless Audio Codec - Wikipedia, the free encyclopedia,\n"
" http://en.wikipedia.org/wiki/Flac\n"
" [4] Vorbis - Wikipedia, the free encyclopedia,\n"
" http://en.wikipedia.org/wiki/Vorbis\n"
" [5] MP3 - Wikipedia, the free encyclopedia,\n"
" http://en.wikipedia.org/wiki/Mp3");


void AudioLoader::createInnerNetwork() {
Expand Down
17 changes: 9 additions & 8 deletions src/algorithms/io/audiowriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,9 @@ using namespace std;
namespace essentia {
namespace streaming {

const char* AudioWriter::name = "AudioWriter";
const char* AudioWriter::category = "Input/output";
const char* AudioWriter::description = DOC("This algorithm encodes an input signal into a stereo audio file.\n\n"
"Supported formats are wav, aiff, mp3, flac and ogg.\n\n"
"An exception is thrown when other extensions are given. Note that to encode in mp3 format it is mandatory that ffmpeg was configured with mp3 enabled.");
const char* AudioWriter::name = essentia::standard::AudioWriter::name;
const char* AudioWriter::category = essentia::standard::AudioWriter::category;
const char* AudioWriter::description = essentia::standard::AudioWriter::description;


void AudioWriter::configure() {
Expand Down Expand Up @@ -119,9 +117,12 @@ void AudioWriter::reset() {
namespace essentia {
namespace standard {

const char* AudioWriter::name = essentia::streaming::AudioWriter::name;
const char* AudioWriter::category = essentia::streaming::AudioWriter::category;
const char* AudioWriter::description = essentia::streaming::AudioWriter::description;
const char* AudioWriter::name = "AudioWriter";
const char* AudioWriter::category = "Input/output";
const char* AudioWriter::description = DOC("This algorithm encodes an input signal into a stereo audio file.\n\n"
"Supported formats are wav, aiff, mp3, flac and ogg.\n\n"
"An exception is thrown when other extensions are given. Note that to encode in mp3 format it is mandatory that ffmpeg was configured with mp3 enabled.");


void AudioWriter::createInnerNetwork() {
_writer = streaming::AlgorithmFactory::create("AudioWriter");
Expand Down
25 changes: 13 additions & 12 deletions src/algorithms/io/easyloader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,9 @@ using namespace std;
namespace essentia {
namespace streaming {

const char* EasyLoader::name = "EasyLoader";
const char* EasyLoader::category = "Input/output";
const char* EasyLoader::description = DOC("This algorithm loads the raw audio data from an audio file, downmixes it to mono and normalizes using replayGain. The audio is resampled in case the given sampling rate does not match the sampling rate of the input signal and is normalized by the given replayGain value.\n"
"\n"
"This algorithm uses MonoLoader and therefore inherits all of its input requirements and exceptions.\n"
"\n"
"References:\n"
" [1] Replay Gain - A Proposed Standard,\n"
" http://replaygain.hydrogenaudio.org");
const char* EasyLoader::name = essentia::standard::EasyLoader::name;
const char* EasyLoader::category = essentia::standard::EasyLoader::category;
const char* EasyLoader::description = essentia::standard::EasyLoader::description;


EasyLoader::EasyLoader() : AlgorithmComposite(),
Expand Down Expand Up @@ -88,9 +82,16 @@ void EasyLoader::configure() {
namespace essentia {
namespace standard {

const char* EasyLoader::name = essentia::streaming::EasyLoader::name;
const char* EasyLoader::category = essentia::streaming::EasyLoader::category;
const char* EasyLoader::description = essentia::streaming::EasyLoader::description;
const char* EasyLoader::name = "EasyLoader";
const char* EasyLoader::category = "Input/output";
const char* EasyLoader::description = DOC("This algorithm loads the raw audio data from an audio file, downmixes it to mono and normalizes using replayGain. The audio is resampled in case the given sampling rate does not match the sampling rate of the input signal and is normalized by the given replayGain value.\n"
"\n"
"This algorithm uses MonoLoader and therefore inherits all of its input requirements and exceptions.\n"
"\n"
"References:\n"
" [1] Replay Gain - A Proposed Standard,\n"
" http://replaygain.hydrogenaudio.org");


void EasyLoader::createInnerNetwork() {
_loader = streaming::AlgorithmFactory::create("EasyLoader");
Expand Down
Loading

0 comments on commit d3e436a

Please sign in to comment.