Add support for external libspeexdsp
3 files changed, 48 insertions(+), 19 deletions(-)

M meson.build
M meson_options.txt
M src/common/Resampler.cpp
M meson.build +30 -16
@@ 113,6 113,7 @@ endforeach
 
 fftw3_dep = dependency('fftw3', version: '>= 3.0.0', required: false)
 samplerate_dep = dependency('samplerate', version: '>= 0.1.8', required: false)
+speexdsp_dep = dependency('speexdsp', version: '>= 1.0.0', required: false)
 sndfile_dep = dependency('sndfile', version: '>= 1.0.16', required: false)
 vamp_dep = dependency('vamp-sdk', version: '>= 2.9', required: false)
 boost_unit_test_dep = dependency('boost', modules: ['unit_test_framework'], version: '>= 1.73', required: false)

          
@@ 177,17 178,16 @@ elif fft == 'kissfft'
   general_include_dirs += 'src/ext/kissfft'
 
 elif fft == 'fftw'
-  if fftw3_dep.found()
-    config_summary += { 'FFT': 'FFTW' }
-    message('For FFT: using FFTW')
-    pkgconfig_requirements += fftw3_dep
-  else 
-    fftw_dep = cpp.find_library('fftw3',
-                                dirs: get_option('extra_lib_dirs'),
-                                has_headers: ['fftw3.h'],
-                                header_args: extra_include_args,
-                                required: true)
+  if not fftw3_dep.found()
+    fftw3_dep = cpp.find_library('fftw3',
+                                 dirs: get_option('extra_lib_dirs'),
+                                 has_headers: ['fftw3.h'],
+                                 header_args: extra_include_args,
+                                 required: true)
   endif
+  config_summary += { 'FFT': 'FFTW' }
+  message('For FFT: using FFTW')
+  pkgconfig_requirements += fftw3_dep
   feature_dependencies += fftw3_dep
   feature_defines += ['-DHAVE_FFTW3', '-DFFTW_DOUBLE_ONLY']
 

          
@@ 223,27 223,41 @@ if resampler == 'builtin'
   feature_defines += ['-DUSE_BQRESAMPLER']
 
 elif resampler == 'libsamplerate'
-  if samplerate_dep.found()
-    config_summary += { 'Resampler': 'libsamplerate' }
-    message('For resampler: using libsamplerate')
-    pkgconfig_requirements += samplerate_dep
-  else 
+  if not samplerate_dep.found()
     samplerate_dep = cpp.find_library('samplerate',
                                       dirs: get_option('extra_lib_dirs'),
                                       has_headers: ['samplerate.h'],
                                       header_args: extra_include_args,
                                       required: true)
   endif
+  config_summary += { 'Resampler': 'libsamplerate' }
+  message('For resampler: using libsamplerate')
   feature_dependencies += samplerate_dep
+  pkgconfig_requirements += samplerate_dep
   feature_defines += ['-DHAVE_LIBSAMPLERATE']
   
 elif resampler == 'speex'
   config_summary += { 'Resampler': 'Speex' }
-  message('For resampler: using Speex')
+  message('For resampler: using bundled Speex')
   message('(consider libsamplerate if time-varying pitch shift is required)')
   feature_sources += ['src/ext/speex/resample.c']
   feature_defines += ['-DUSE_SPEEX']
   
+elif resampler == 'libspeexdsp'
+  if not speexdsp_dep.found()
+    speexdsp_dep = cpp.find_library('speexdsp',
+                                    dirs: get_option('extra_lib_dirs'),
+                                    has_headers: ['speex/speex_resampler.h'],
+                                    header_args: extra_include_args,
+                                    required: true)
+  endif
+  config_summary += { 'Resampler': 'libspeexdsp' }
+  message('For resampler: using Speex DSP library')
+  message('(consider libsamplerate if time-varying pitch shift is required)')
+  feature_dependencies += speexdsp_dep
+  pkgconfig_requirements += speexdsp_dep
+  feature_defines += ['-DHAVE_LIBSPEEXDSP']
+  
 elif resampler == 'ipp'
   if ipp_path != ''
     config_summary += { 'Resampler': 'Intel IPP' }

          
M meson_options.txt +1 -1
@@ 7,7 7,7 @@ option('fft',
 
 option('resampler',
        type: 'combo',
-       choices: ['auto', 'builtin', 'libsamplerate', 'speex', 'ipp'],
+       choices: ['auto', 'builtin', 'libsamplerate', 'speex', 'libspeexdsp', 'ipp'],
        value: 'auto',
        description: 'Resampler library to use. The default (auto) simply uses the builtin implementation.')
 

          
M src/common/Resampler.cpp +17 -2
@@ 55,6 55,10 @@ 
 
 #ifdef USE_SPEEX
 #include "../ext/speex/speex_resampler.h"
+#else
+#ifdef HAVE_LIBSPEEXDSP
+#include <speex/speex_resampler.h>
+#endif
 #endif
 
 #ifdef USE_BQRESAMPLER

          
@@ 64,6 68,7 @@ 
 #ifndef HAVE_IPP
 #ifndef HAVE_LIBSAMPLERATE
 #ifndef HAVE_LIBRESAMPLE
+#ifndef HAVE_LIBSPEEXDSP
 #ifndef USE_SPEEX
 #ifndef USE_BQRESAMPLER
 #error No resampler implementation selected!

          
@@ 72,6 77,7 @@ 
 #endif
 #endif
 #endif
+#endif
 
 #define BQ_R__ R__
 

          
@@ 1106,7 1112,7 @@ D_BQResampler::reset()
 
 #endif /* USE_BQRESAMPLER */
 
-#ifdef USE_SPEEX
+#if defined(USE_SPEEX) || defined(HAVE_LIBSPEEXDSP)
     
 class D_Speex : public Resampler::Impl
 {

          
@@ 1404,6 1410,9 @@ Resampler::Resampler(Resampler::Paramete
 #ifdef USE_SPEEX
         m_method = 2;
 #endif
+#ifdef HAVE_LIBSPEEXDSP
+        m_method = 2;
+#endif
 #ifdef HAVE_LIBRESAMPLE
         m_method = 3;
 #endif

          
@@ 1425,6 1434,9 @@ Resampler::Resampler(Resampler::Paramete
 #ifdef USE_SPEEX
         m_method = 2;
 #endif
+#ifdef HAVE_LIBSPEEXDSP
+        m_method = 2;
+#endif
 #ifdef USE_BQRESAMPLER
         m_method = 4;
 #endif

          
@@ 1443,6 1455,9 @@ Resampler::Resampler(Resampler::Paramete
 #ifdef USE_SPEEX
         m_method = 2;
 #endif
+#ifdef HAVE_LIBSPEEXDSP
+        m_method = 2;
+#endif
 #ifdef USE_BQRESAMPLER
         m_method = 4;
 #endif

          
@@ 1483,7 1498,7 @@ Resampler::Resampler(Resampler::Paramete
         break;
 
     case 2:
-#ifdef USE_SPEEX
+#if defined(USE_SPEEX) || defined(HAVE_LIBSPEEXDSP)
         d = new Resamplers::D_Speex
             (params.quality, params.ratioChange,
              channels,