# HG changeset patch # User Chris Cannam # Date 1662113444 -3600 # Fri Sep 02 11:10:44 2022 +0100 # Branch speexdsp # Node ID a5e9d29292d42e840549cffe7702cab3913600d3 # Parent 1d27402926ad89a26112642dcb7eb45eb75593a9 Add support for external libspeexdsp diff --git a/meson.build b/meson.build --- a/meson.build +++ b/meson.build @@ -113,6 +113,7 @@ 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 @@ 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 @@ 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' } diff --git a/meson_options.txt b/meson_options.txt --- a/meson_options.txt +++ b/meson_options.txt @@ -7,7 +7,7 @@ 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.') diff --git a/src/common/Resampler.cpp b/src/common/Resampler.cpp --- a/src/common/Resampler.cpp +++ b/src/common/Resampler.cpp @@ -55,6 +55,10 @@ #ifdef USE_SPEEX #include "../ext/speex/speex_resampler.h" +#else +#ifdef HAVE_LIBSPEEXDSP +#include +#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 @@ #endif /* USE_BQRESAMPLER */ -#ifdef USE_SPEEX +#if defined(USE_SPEEX) || defined(HAVE_LIBSPEEXDSP) class D_Speex : public Resampler::Impl { @@ -1404,6 +1410,9 @@ #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 @@ #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 @@ #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 @@ break; case 2: -#ifdef USE_SPEEX +#if defined(USE_SPEEX) || defined(HAVE_LIBSPEEXDSP) d = new Resamplers::D_Speex (params.quality, params.ratioChange, channels,