diff --git a/CMakeLists.txt b/CMakeLists.txt index 250ab265c..f99425d85 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -59,10 +59,6 @@ set(ESSENTIA_USE_TENSORFLOW OFF) set(ESSENTIA_USE_VAMP OFF) set(ESSENTIA_USE_GAIA OFF) -if(FFMPEG_FOUND) - set(ESSENTIA_USE_FFMPEG ON) -endif() - if(USE_KISSFFT) set(ESSENTIA_USE_KISSFFT ON) else() @@ -81,6 +77,12 @@ else() endif() endif() +if(FFMPEG_FOUND) + set(ESSENTIA_USE_FFMPEG ON) +else() + message(WARNING "FFmpeg not found - compilation of audio loaders/writers disabled!") +endif() + if(SAMPLERATE_FOUND) set(ESSENTIA_USE_LIBSAMPLERATE ON) endif() diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 93edd69db..52af26d12 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -25,6 +25,8 @@ target_link_libraries(essentia PUBLIC Eigen3::Eigen) if(ESSENTIA_USE_FFMPEG) include_directories(${AVCODEC_INCLUDE_DIRS} ${AVFORMAT_INCLUDE_DIRS} ${AVUTIL_INCLUDE_DIRS} ${SWRESAMPLE_INCLUDE_DIRS}) target_link_libraries(essentia PUBLIC ${AVCODEC_LIBRARIES} ${AVFORMAT_LIBRARIES} ${AVUTIL_LIBRARIES} ${SWRESAMPLE_LIBRARIES}) + set(ENABLE_AUDIOLOADER ON) + set(ENABLE_AUDIOWRITER ON) endif() if(ESSENTIA_USE_FFTW) diff --git a/src/algorithms/essentia_algorithms_reg_2.cpp b/src/algorithms/essentia_algorithms_reg_2.cpp index 1489b3625..64d3edbaa 100644 --- a/src/algorithms/essentia_algorithms_reg_2.cpp +++ b/src/algorithms/essentia_algorithms_reg_2.cpp @@ -52,17 +52,21 @@ #include "algorithms/highlevel/intensity.h" #include "algorithms/highlevel/pca.h" #include "algorithms/highlevel/sbic.h" -#include "algorithms/io/audioloader.h" #include "algorithms/io/audioonsetsmarker.h" -#include "algorithms/io/audiowriter.h" +#if ENABLE_AUDIOLOADER +#include "algorithms/io/audioloader.h" #include "algorithms/io/easyloader.h" #include "algorithms/io/eqloudloader.h" +#include "algorithms/io/monoloader.h" +#endif +#if ENABLE_AUDIOWRITER +#include "algorithms/io/audiowriter.h" +#include "algorithms/io/monowriter.h" +#endif #include "algorithms/io/fileoutputproxy.h" #if ENABLE_TAGLIB #include "algorithms/io/metadatareader.h" #endif -#include "algorithms/io/monoloader.h" -#include "algorithms/io/monowriter.h" #if ENABLE_YAML #include "algorithms/io/yamlinput.h" #endif @@ -350,16 +354,20 @@ ESSENTIA_API void registerAlgorithm() { AlgorithmFactory::Registrar regIntensity; AlgorithmFactory::Registrar regPCA; AlgorithmFactory::Registrar regSBic; - AlgorithmFactory::Registrar regAudioLoader; AlgorithmFactory::Registrar regAudioOnsetsMarker; - AlgorithmFactory::Registrar regAudioWriter; +#if ENABLE_AUDIOLOADER + AlgorithmFactory::Registrar regAudioLoader; AlgorithmFactory::Registrar regEasyLoader; AlgorithmFactory::Registrar regEqloudLoader; + AlgorithmFactory::Registrar regMonoLoader; +#endif +#if ENABLE_AUDIOWRITER + AlgorithmFactory::Registrar regAudioWriter; + AlgorithmFactory::Registrar regMonoWriter; +#endif #if ENABLE_TAGLIB AlgorithmFactory::Registrar regMetadataReader; #endif - AlgorithmFactory::Registrar regMonoLoader; - AlgorithmFactory::Registrar regMonoWriter; #if ENABLE_YAML AlgorithmFactory::Registrar regYamlInput; #endif @@ -633,17 +641,21 @@ ESSENTIA_API void registerAlgorithm() { AlgorithmFactory::Registrar regDynamicComplexity; AlgorithmFactory::Registrar regFadeDetection; AlgorithmFactory::Registrar regSBic; - AlgorithmFactory::Registrar regAudioLoader; AlgorithmFactory::Registrar regAudioOnsetsMarker; - AlgorithmFactory::Registrar regAudioWriter; +#if ENABLE_AUDIOLOADER + AlgorithmFactory::Registrar regAudioLoader; AlgorithmFactory::Registrar regEasyLoader; +#endif +#if ENABLE_AUDIOWRITER AlgorithmFactory::Registrar regEqloudLoader; + AlgorithmFactory::Registrar regMonoLoader; + AlgorithmFactory::Registrar regAudioWriter; + AlgorithmFactory::Registrar regMonoWriter; +#endif AlgorithmFactory::Registrar regFileOutputProxy; #if ENABLE_TAGLIB AlgorithmFactory::Registrar regMetadataReader; #endif - AlgorithmFactory::Registrar regMonoLoader; - AlgorithmFactory::Registrar regMonoWriter; AlgorithmFactory::Registrar regBeatsLoudness; AlgorithmFactory::Registrar regBeatTrackerDegara; AlgorithmFactory::Registrar regBeatTrackerMultiFeature; diff --git a/src/algorithms/essentia_algorithms_reg_2.h.in b/src/algorithms/essentia_algorithms_reg_2.h.in index 065ca851e..67c22d037 100644 --- a/src/algorithms/essentia_algorithms_reg_2.h.in +++ b/src/algorithms/essentia_algorithms_reg_2.h.in @@ -5,6 +5,14 @@ #ifndef ESSENTIA_ALGORITHMS_REG_H_ #define ESSENTIA_ALGORITHMS_REG_H_ +#ifndef ENABLE_AUDIOLOADER +#cmakedefine01 ENABLE_AUDIOLOADER +#endif + +#ifndef ENABLE_AUDIOWRITER +#cmakedefine01 ENABLE_AUDIOWRITER +#endif + #ifndef ENABLE_FFTW #cmakedefine01 ENABLE_FFTW #endif diff --git a/src/algorithms/io/CMakeLists.txt b/src/algorithms/io/CMakeLists.txt index d494f97cc..3e8814421 100644 --- a/src/algorithms/io/CMakeLists.txt +++ b/src/algorithms/io/CMakeLists.txt @@ -1,27 +1,27 @@ target_sources(essentia PRIVATE audioonsetsmarker.cpp - audiowriter.cpp - easyloader.cpp - eqloudloader.cpp fileoutputproxy.cpp - monoloader.cpp - monowriter.cpp yamloutput.cpp audioonsetsmarker.h - audiowriter.h - easyloader.h - eqloudloader.h fileoutputproxy.h - monoloader.h - monowriter.h yamloutput.h) if(ESSENTIA_USE_FFMPEG) target_sources(essentia PRIVATE audioloader.cpp - audioloader.h) + audiowriter.cpp + easyloader.cpp + eqloudloader.cpp + monoloader.cpp + monowriter.cpp + audioloader.h + audiowriter.h + easyloader.h + eqloudloader.h + monoloader.h + monowriter.h) endif() if(ESSENTIA_USE_YAML)