2021-02-05 16:42:13 +00:00
project (
'Rubber Band Library' ,
'c' , 'cpp' ,
2023-03-27 16:29:54 +01:00
version : '3.2.0' ,
2021-02-10 11:09:50 +00:00
license : 'GPL-2.0-or-later' ,
2021-02-05 16:42:13 +00:00
default_options : [
2022-05-20 16:48:44 +01:00
'cpp_std=c++11' ,
2022-06-14 15:15:55 +01:00
'warning_level=3' ,
2021-02-05 16:42:13 +00:00
'buildtype=release' ,
2022-01-04 17:11:31 +00:00
'default_library=both' ,
2021-02-05 16:42:13 +00:00
'b_ndebug=if-release' ,
'b_lundef=true' ,
] ,
2021-02-09 12:06:07 +00:00
meson_version : '>= 0.53.0'
2021-02-05 16:42:13 +00:00
)
2023-03-27 16:29:54 +01:00
rubberband_dynamic_library_version = '2.2.3'
2021-02-05 16:42:13 +00:00
2021-04-07 11:03:33 +01:00
system = host_machine . system ( )
2021-02-05 16:42:13 +00:00
architecture = host_machine . cpu_family ( )
2021-02-09 10:16:02 +00:00
cpp = meson . get_compiler ( 'cpp' )
2021-02-05 16:42:13 +00:00
pkg = import ( 'pkgconfig' )
# Define the project source sets
public_headers = [
'rubberband/rubberband-c.h' ,
'rubberband/RubberBandStretcher.h' ,
]
library_sources = [
'src/rubberband-c.cpp' ,
'src/RubberBandStretcher.cpp' ,
2022-05-19 13:34:51 +01:00
'src/faster/AudioCurveCalculator.cpp' ,
'src/faster/CompoundAudioCurve.cpp' ,
'src/faster/HighFrequencyAudioCurve.cpp' ,
'src/faster/SilentAudioCurve.cpp' ,
'src/faster/PercussiveAudioCurve.cpp' ,
2022-06-21 10:25:08 +01:00
'src/faster/R2Stretcher.cpp' ,
2022-05-19 13:34:51 +01:00
'src/faster/StretcherChannelData.cpp' ,
'src/faster/StretcherProcess.cpp' ,
2022-06-21 16:06:16 +01:00
'src/common/Allocators.cpp' ,
'src/common/FFT.cpp' ,
'src/common/Log.cpp' ,
2022-05-19 13:34:51 +01:00
'src/common/Profiler.cpp' ,
'src/common/Resampler.cpp' ,
2022-05-23 17:59:40 +01:00
'src/common/StretchCalculator.cpp' ,
2022-05-19 13:34:51 +01:00
'src/common/sysutils.cpp' ,
2022-09-02 12:07:29 +01:00
'src/common/mathmisc.cpp' ,
2022-05-19 13:34:51 +01:00
'src/common/Thread.cpp' ,
2022-06-21 10:25:08 +01:00
'src/finer/R3Stretcher.cpp' ,
2021-02-05 16:42:13 +00:00
]
jni_sources = [
'src/jni/RubberBandStretcherJNI.cpp' ,
]
java_sources = [
'com/breakfastquay/rubberband/RubberBandStretcher.java' ,
]
program_sources = [
'main/main.cpp' ,
]
2021-02-09 11:12:20 +00:00
if system == 'windows'
program_sources + = [
2022-06-14 16:47:06 +01:00
'src/ext/getopt/getopt.c' ,
'src/ext/getopt/getopt_long.c'
2021-02-09 11:12:20 +00:00
]
endif
2021-02-05 16:42:13 +00:00
vamp_sources = [
'vamp/RubberBandVampPlugin.cpp' ,
'vamp/libmain.cpp' ,
]
ladspa_sources = [
2022-01-07 13:33:18 +00:00
'ladspa-lv2/libmain-ladspa.cpp' ,
]
lv2_sources = [
'ladspa-lv2/libmain-lv2.cpp' ,
2021-02-05 16:42:13 +00:00
]
2022-06-08 09:57:12 +01:00
unit_test_sources = [
'src/test/TestAllocators.cpp' ,
'src/test/TestFFT.cpp' ,
'src/test/TestResampler.cpp' ,
'src/test/TestVectorOpsComplex.cpp' ,
'src/test/TestVectorOps.cpp' ,
2022-06-08 10:35:51 +01:00
'src/test/TestSignalBits.cpp' ,
2022-06-23 11:53:35 +01:00
'src/test/TestStretchCalculator.cpp' ,
2022-06-23 15:13:48 +01:00
'src/test/TestStretcher.cpp' ,
2022-06-14 13:59:17 +01:00
'src/test/TestBinClassifier.cpp' ,
2022-06-08 09:57:12 +01:00
'src/test/test.cpp' ,
]
2021-02-05 16:42:13 +00:00
general_include_dirs = [
'rubberband' ,
'src' ,
]
# Scan for any dependencies we may use later; all are optional
2021-03-12 09:52:54 +00:00
extra_include_args = [ ]
foreach d : get_option ( 'extra_include_dirs' )
extra_include_args + = [ '-I' + d ]
endforeach
2021-02-05 16:42:13 +00:00
fftw3_dep = dependency ( 'fftw3' , version : '>= 3.0.0' , required : false )
2022-08-09 15:50:02 +01:00
sleef_dep = dependency ( 'sleef' , version : '>= 3.3.0' , required : false )
sleefdft_dep = dependency ( 'sleefdft' , version : '>= 3.3.0' , required : false )
2021-02-05 16:42:13 +00:00
samplerate_dep = dependency ( 'samplerate' , version : '>= 0.1.8' , required : false )
2022-09-02 11:10:44 +01:00
speexdsp_dep = dependency ( 'speexdsp' , version : '>= 1.0.0' , required : false )
2022-09-26 09:39:10 +01:00
2022-10-31 12:03:46 +00:00
sndfile_dep = dependency ( 'sndfile' , version : '>= 1.0.16' , required : get_option ( 'cmdline' ) )
vamp_dep = dependency ( 'vamp-sdk' , version : '>= 2.9' , required : get_option ( 'vamp' ) )
boost_unit_test_dep = dependency ( 'boost' , modules : [ 'unit_test_framework' ] , version : '>= 1.73' , required : get_option ( 'tests' ) )
2021-02-05 16:42:13 +00:00
thread_dep = dependency ( 'threads' )
2022-10-31 12:03:46 +00:00
have_ladspa = cpp . has_header ( 'ladspa.h' , args : extra_include_args , required : get_option ( 'ladspa' ) )
have_lv2 = cpp . has_header ( 'lv2.h' , args : extra_include_args , required : get_option ( 'lv2' ) )
2021-04-09 17:35:59 +01:00
have_sincos = cpp . has_function ( 'sincos' ,
prefix : '#define _GNU_SOURCE\n#include <math.h>' ,
args : '-lm' )
2022-09-26 09:39:10 +01:00
2022-10-13 13:16:31 +01:00
# Find out whether we can build the optional JNI target. Thanks to Eli
# Schwartz for the fix here; this has been through a few previous
# iterations. Initially we just looked for jni.h, but it's often in an
# obscure place so that didn't work very well. Then tried Meson's
2022-10-13 13:29:18 +01:00
# automatic dependency('jni') handling, but that bails out in Meson
2022-10-13 13:16:31 +01:00
# 0.62/0.63 if javac is not present (even if required is false). Then
# tried guarding that check behind a successful find_program('javac'),
2022-10-13 13:29:18 +01:00
# but that bails out on systems in which a stub javac is installed
# that is not a compiler (because the subsequent Meson jni magic still
2022-10-13 13:16:31 +01:00
# requires javac as a compiler). Now try adding Java as a complete
# language pack, optionally, and only go on to JNI if that succeeds,
# making sure that nothing "clever" happens if Java is not found.
2022-11-04 10:49:11 +00:00
# Note even if jni_dep is found, we still need to check that the
# compiler can find jni.h because the jni autodetection can't really
# be trusted, especially in a macOS frameworks environment.
2022-10-13 13:16:31 +01:00
#
2022-11-04 10:49:11 +00:00
have_jni = false
2022-10-31 12:03:46 +00:00
have_java = add_languages ( 'java' , required : get_option ( 'jni' ) )
2022-10-13 13:16:31 +01:00
if have_java
2022-09-26 12:48:44 +01:00
jni_dep = dependency ( 'jni' , version : '>= 7.0.0' , required : false )
2022-11-04 10:49:11 +00:00
have_jni = cpp . has_header ( 'jni.h' , dependencies : jni_dep , args : extra_include_args )
2022-09-26 12:48:44 +01:00
endif
2021-02-05 16:42:13 +00:00
# Check FFT and resampler options and set up dependencies and paths
feature_dependencies = [ ]
feature_defines = [ ]
feature_libraries = [ ]
feature_sources = [ ]
pkgconfig_requirements = [ ]
2021-05-10 10:38:35 +01:00
pkgconfig_libraries = [ ]
2021-02-05 17:08:17 +00:00
arch_flags = [ ]
2021-02-05 16:42:13 +00:00
2021-02-10 11:28:05 +00:00
config_summary = { }
target_summary = { }
2021-02-05 16:42:13 +00:00
resampler = get_option ( 'resampler' )
fft = get_option ( 'fft' )
ipp_path = get_option ( 'ipp_path' )
2021-02-09 11:12:20 +00:00
ipp_needed = false
2021-02-05 16:42:13 +00:00
if fft == 'auto'
if system == 'darwin'
fft = 'vdsp'
else
2021-04-08 14:23:27 +01:00
fft = 'builtin'
2021-02-05 16:42:13 +00:00
endif
endif
if resampler == 'auto'
2022-01-12 10:10:34 +00:00
resampler = 'builtin'
2021-02-05 16:42:13 +00:00
endif
2021-04-08 14:23:27 +01:00
if fft == 'builtin'
config_summary + = { 'FFT' : 'Built-in' }
message ( 'For FFT: using built-in implementation' )
if fftw3_dep . found ( )
message ( '(to use FFTW instead, reconfigure with -Dfft=fftw)' )
endif
2022-08-09 15:50:02 +01:00
if sleef_dep . found ( )
message ( '(to use SLEEF instead, reconfigure with -Dfft=sleef)' )
endif
2021-04-08 14:23:27 +01:00
feature_defines + = [ '-DUSE_BUILTIN_FFT' ]
elif fft == 'kissfft'
2021-02-10 11:28:05 +00:00
config_summary + = { 'FFT' : 'KissFFT' }
2021-02-05 16:42:13 +00:00
message ( 'For FFT: using KissFFT' )
if fftw3_dep . found ( )
message ( '(to use FFTW instead, reconfigure with -Dfft=fftw)' )
endif
2022-08-09 15:50:02 +01:00
if sleef_dep . found ( )
message ( '(to use SLEEF instead, reconfigure with -Dfft=sleef)' )
endif
2022-07-01 13:14:21 +01:00
feature_sources + = [ 'src/ext/kissfft/kiss_fft.c' , 'src/ext/kissfft/kiss_fftr.c' ]
2021-04-08 14:23:27 +01:00
feature_defines + = [ '-DHAVE_KISSFFT' ]
2022-07-01 13:14:21 +01:00
general_include_dirs + = 'src/ext/kissfft'
2021-02-05 16:42:13 +00:00
elif fft == 'fftw'
2022-09-02 11:10:44 +01:00
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 )
2021-02-05 16:42:13 +00:00
endif
2022-09-02 11:10:44 +01:00
config_summary + = { 'FFT' : 'FFTW' }
message ( 'For FFT: using FFTW' )
2022-09-02 11:12:35 +01:00
if sleef_dep . found ( )
message ( '(to use SLEEF instead, reconfigure with -Dfft=sleef)' )
2021-02-05 16:42:13 +00:00
endif
2022-09-02 11:10:44 +01:00
pkgconfig_requirements + = fftw3_dep
2021-02-05 16:42:13 +00:00
feature_dependencies + = fftw3_dep
feature_defines + = [ '-DHAVE_FFTW3' , '-DFFTW_DOUBLE_ONLY' ]
2022-08-09 15:50:02 +01:00
elif fft == 'sleef'
if sleefdft_dep . found ( ) and sleef_dep . found ( )
config_summary + = { 'FFT' : 'SLEEF' }
message ( 'For FFT: using SLEEF' )
pkgconfig_requirements + = sleefdft_dep
pkgconfig_requirements + = sleef_dep
else
sleefdft_dep = cpp . find_library ( 'sleefdft' ,
dirs : get_option ( 'extra_lib_dirs' ) ,
has_headers : [ 'sleefdft.h' ] ,
header_args : extra_include_args ,
required : true )
sleef_dep = cpp . find_library ( 'sleef' ,
dirs : get_option ( 'extra_lib_dirs' ) ,
has_headers : [ 'sleef.h' ] ,
header_args : extra_include_args ,
required : true )
config_summary + = { 'FFT' : 'SLEEF' }
endif
feature_dependencies + = sleefdft_dep
feature_dependencies + = sleef_dep
feature_defines + = [ '-DHAVE_SLEEF' ]
2021-02-05 16:42:13 +00:00
elif fft == 'vdsp'
2021-02-10 11:28:05 +00:00
config_summary + = { 'FFT' : 'vDSP' }
2021-02-05 16:42:13 +00:00
message ( 'For FFT: using vDSP' )
feature_defines + = [ '-DHAVE_VDSP' ]
feature_libraries + = [ '-framework' , 'Accelerate' ]
2021-05-10 10:38:35 +01:00
pkgconfig_libraries + = [ '-framework' , 'Accelerate' ]
2021-02-05 16:42:13 +00:00
elif fft == 'ipp'
if ipp_path != ''
2021-02-10 11:28:05 +00:00
config_summary + = { 'FFT' : 'Intel IPP' }
2021-02-05 17:28:20 +00:00
message ( 'For FFT: using IPP' )
2021-02-05 16:42:13 +00:00
message ( 'IPP path defined as ' + ipp_path )
else
error ( 'For FFT: IPP selected, but ipp_path not specified' )
endif
ipp_needed = true
else
error ( 'Unknown or unsupported FFT option: ' + fft )
endif # fft
2021-05-10 18:11:35 +01:00
if resampler == 'builtin'
config_summary + = { 'Resampler' : 'Built-in' }
message ( 'For resampler: using built-in implementation' )
2022-01-12 10:10:34 +00:00
if samplerate_dep . found ( )
message ( '(to use libsamplerate instead, reconfigure with -Dresampler=libsamplerate)' )
endif
2022-05-19 13:34:51 +01:00
library_sources + = 'src/common/BQResampler.cpp'
2021-05-10 18:11:35 +01:00
feature_defines + = [ '-DUSE_BQRESAMPLER' ]
elif resampler == 'libsamplerate'
2022-09-02 11:10:44 +01:00
if not samplerate_dep . found ( )
2021-02-09 11:12:20 +00:00
samplerate_dep = cpp . find_library ( 'samplerate' ,
2021-03-05 10:33:27 +00:00
dirs : get_option ( 'extra_lib_dirs' ) ,
has_headers : [ 'samplerate.h' ] ,
header_args : extra_include_args ,
required : true )
2021-02-05 16:42:13 +00:00
endif
2022-09-02 11:10:44 +01:00
config_summary + = { 'Resampler' : 'libsamplerate' }
message ( 'For resampler: using libsamplerate' )
2021-02-05 16:42:13 +00:00
feature_dependencies + = samplerate_dep
2022-09-02 11:10:44 +01:00
pkgconfig_requirements + = samplerate_dep
2021-02-05 16:42:13 +00:00
feature_defines + = [ '-DHAVE_LIBSAMPLERATE' ]
elif resampler == 'speex'
2021-02-10 11:28:05 +00:00
config_summary + = { 'Resampler' : 'Speex' }
2022-09-02 11:10:44 +01:00
message ( 'For resampler: using bundled Speex' )
2021-02-05 16:42:13 +00:00
message ( '(consider libsamplerate if time-varying pitch shift is required)' )
2022-06-30 14:00:14 +01:00
feature_sources + = [ 'src/ext/speex/resample.c' ]
2021-02-05 16:42:13 +00:00
feature_defines + = [ '-DUSE_SPEEX' ]
2022-09-02 11:10:44 +01:00
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
2022-09-02 15:58:08 +01:00
config_summary + = { 'Resampler' : 'Speex DSP' }
2022-09-02 11:10:44 +01:00
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' ]
2021-02-05 16:42:13 +00:00
elif resampler == 'ipp'
if ipp_path != ''
2021-02-10 11:28:05 +00:00
config_summary + = { 'Resampler' : 'Intel IPP' }
2021-02-05 17:28:20 +00:00
message ( 'For resampler: using IPP' )
2021-02-05 16:42:13 +00:00
message ( '(consider libsamplerate if time-varying pitch shift is required)' )
message ( 'IPP path defined as ' + ipp_path )
else
error ( 'For resampler: IPP selected, but ipp_path not specified' )
endif
ipp_needed = true
else
error ( 'Unknown or unsupported resampler option: ' + resampler )
endif # resampler
2021-04-09 17:35:59 +01:00
if not have_sincos
feature_defines + = [ '-DLACK_SINCOS' ]
endif
2021-02-05 16:42:13 +00:00
if ipp_needed
feature_defines + = [
'-DHAVE_IPP' ,
'-DUSE_IPP_STATIC' ,
'-I' + ipp_path / 'include'
]
if architecture == 'x86'
feature_libraries + = [
'-L' + ipp_path / 'lib/ia32' ,
]
elif architecture == 'x86_64'
feature_libraries + = [
'-L' + ipp_path / 'lib/intel64' ,
]
else
error ( 'IPP is not supported for this architecture' )
endif
if system == 'windows'
feature_libraries + = [
'-lippsmt' , '-lippvmmt' , '-lippcoremt' ,
]
elif system == 'linux'
feature_libraries + = [
'-Wl,-Bstatic' , '-lipps' , '-lippvm' , '-lippcore' , '-Wl,-Bdynamic' ,
]
else
feature_libraries + = [
'-lipps' , '-lippvm' , '-lippcore' ,
]
endif
endif # ipp_needed
2021-02-09 11:12:20 +00:00
if not vamp_dep . found ( )
vamp_dep = cpp . find_library ( 'VampPluginSDK' ,
2021-03-05 10:33:27 +00:00
dirs : get_option ( 'extra_lib_dirs' ) ,
has_headers : [ 'vamp-sdk.h' ] ,
header_args : extra_include_args ,
2022-10-31 12:03:46 +00:00
required : get_option ( 'vamp' ) )
2021-02-09 11:12:20 +00:00
if not vamp_dep . found ( )
vamp_dep = cpp . find_library ( 'vamp-sdk' ,
2021-03-05 10:33:27 +00:00
dirs : get_option ( 'extra_lib_dirs' ) ,
has_headers : [ 'vamp-sdk.h' ] ,
header_args : extra_include_args ,
2022-10-31 12:03:46 +00:00
required : get_option ( 'vamp' ) )
2021-02-09 11:12:20 +00:00
endif
endif
have_vamp = vamp_dep . found ( )
if not sndfile_dep . found ( )
sndfile_dep = cpp . find_library ( 'sndfile' ,
2021-03-05 10:33:27 +00:00
dirs : get_option ( 'extra_lib_dirs' ) ,
has_headers : [ 'sndfile.h' ] ,
header_args : extra_include_args ,
2022-10-31 12:03:46 +00:00
required : get_option ( 'cmdline' ) )
2021-03-05 10:31:00 +00:00
if not sndfile_dep . found ( )
sndfile_dep = cpp . find_library ( 'sndfile-1' ,
2021-03-05 10:33:27 +00:00
dirs : get_option ( 'extra_lib_dirs' ) ,
has_headers : [ 'sndfile.h' ] ,
header_args : extra_include_args ,
2022-10-31 12:03:46 +00:00
required : get_option ( 'cmdline' ) )
2021-03-05 10:31:00 +00:00
endif
2021-02-09 11:12:20 +00:00
endif
have_sndfile = sndfile_dep . found ( )
2022-06-08 09:57:12 +01:00
have_boost_unit_test = boost_unit_test_dep . found ( )
2021-02-05 16:42:13 +00:00
# General platform and compiler expectations
ladspa_symbol_args = [ ]
2022-01-07 13:33:18 +00:00
lv2_symbol_args = [ ]
2021-02-05 16:42:13 +00:00
vamp_symbol_args = [ ]
if get_option ( 'buildtype' ) . startswith ( 'release' )
2021-02-10 11:28:05 +00:00
config_summary + = { 'Build type' : 'Release' }
2021-02-05 16:42:13 +00:00
feature_defines + = [ '-DNO_THREAD_CHECKS' , '-DNO_TIMING' , '-DNDEBUG' ]
2021-02-10 11:28:05 +00:00
else
config_summary + = { 'Build type' : 'Debug' }
2021-02-05 16:42:13 +00:00
endif
if system == 'darwin'
feature_defines + = [ '-DUSE_PTHREADS' , '-DMALLOC_IS_ALIGNED' ]
ladspa_symbol_args + = [
2022-01-07 13:33:18 +00:00
'-exported_symbols_list' , meson . current_source_dir ( ) / 'ladspa-lv2/ladspa-plugin.list'
]
lv2_symbol_args + = [
'-exported_symbols_list' , meson . current_source_dir ( ) / 'ladspa-lv2/lv2-plugin.list'
2021-02-05 16:42:13 +00:00
]
vamp_symbol_args + = [
2022-01-06 11:49:42 +00:00
'-exported_symbols_list' , meson . current_source_dir ( ) / 'vamp/vamp-plugin.list'
2021-02-05 16:42:13 +00:00
]
2021-02-10 14:24:17 +00:00
2021-02-05 17:08:17 +00:00
if architecture == 'aarch64'
2021-08-18 14:51:58 +01:00
arch_flags + = [
2021-02-10 14:24:17 +00:00
'-arch' , 'arm64' ,
2021-02-05 17:08:17 +00:00
]
elif architecture == 'x86_64'
2021-08-18 14:51:58 +01:00
arch_flags + = [
2021-02-05 17:08:17 +00:00
'-arch' , 'x86_64' ,
]
2021-02-10 14:24:17 +00:00
else # begin architecture != 'aarch64' or 'x86_64'
error ( 'Build for architecture ' + architecture + ' is not supported on this platform' )
endif # end architecture
2021-02-05 17:08:17 +00:00
2021-09-08 11:23:23 +01:00
have_version_min = false
foreach arg : get_option ( 'cpp_args' )
if arg . contains ( 'version-min' )
have_version_min = true
bits = arg . split ( '=' )
if bits . length ( ) > 1
config_summary + = { 'Target OS' : bits [ 1 ] + '+' }
else
config_summary + = { 'Target OS' : '(unknown)' }
endif
endif
endforeach
if not have_version_min
message ( 'Using default minimum target OS version' )
message ( '(consider specifying this in cross-file if earlier target is desired)' )
if architecture == 'aarch64'
arch_flags + = [ '-mmacosx-version-min=11' ]
config_summary + = { 'Target OS' : '11+' }
else
arch_flags + = [ '-mmacosx-version-min=10.13' ]
config_summary + = { 'Target OS' : '10.13+' }
endif
endif
2021-02-05 16:42:13 +00:00
elif system == 'windows'
2021-03-05 10:31:00 +00:00
feature_defines + = [ '-D_WIN32' , '-DNOMINMAX' , '-D_USE_MATH_DEFINES' , '-DGETOPT_API=' ]
2021-02-09 10:16:02 +00:00
if cpp . get_id ( ) == 'msvc'
2021-02-05 16:42:13 +00:00
ladspa_symbol_args + = [ '-EXPORT:ladspa_descriptor' ]
2022-01-07 13:33:18 +00:00
lv2_symbol_args + = [ '-EXPORT:lv2_descriptor' ]
2021-02-05 16:42:13 +00:00
vamp_symbol_args + = [ '-EXPORT:vampGetPluginDescriptor' ]
endif
2021-02-05 17:08:17 +00:00
else # system not darwin or windows
2021-02-05 16:42:13 +00:00
feature_defines + = [ '-DUSE_PTHREADS' , '-DHAVE_POSIX_MEMALIGN' ]
ladspa_symbol_args + = [
2022-01-07 13:33:18 +00:00
'-Wl,--version-script=' + meson . current_source_dir ( ) / 'ladspa-lv2/ladspa-plugin.map'
]
lv2_symbol_args + = [
'-Wl,--version-script=' + meson . current_source_dir ( ) / 'ladspa-lv2/lv2-plugin.map'
2021-02-05 16:42:13 +00:00
]
vamp_symbol_args + = [
2022-01-06 11:49:42 +00:00
'-Wl,--version-script=' + meson . current_source_dir ( ) / 'vamp/vamp-plugin.map'
2021-02-05 16:42:13 +00:00
]
2021-02-05 17:08:17 +00:00
endif # system
2021-02-05 16:42:13 +00:00
2021-02-09 11:12:20 +00:00
general_include_dirs + = get_option ( 'extra_include_dirs' )
general_compile_args = [ arch_flags , feature_defines ]
general_dependencies = [ feature_dependencies , thread_dep ]
2022-01-04 17:11:31 +00:00
rubberband_additional_static_lib = ''
2021-12-13 17:47:43 +00:00
if cpp . get_id ( ) == 'msvc'
2022-01-04 17:11:31 +00:00
#
# In the MSVC world we have a quandary, partly as a result of
# wanting to use naming compatible with our previous/other build
# systems.
#
# Meson would like to use rubberband.dll for the dynamic library,
# rubberband.lib for the import library, and librubberband.a for the
# static library. This is kind of ok, even though lib*.a is not a
# very familiar naming style here - except that previously we called
# the static library rubberband-static.lib. (It would be usual to
# expect some .lib file to be produced as a static library,
# especially if default_library=static is set.)
#
# Our "solution" is to leave alone if default_library=shared (when
# the Meson and MSVC ways are the same), but emit an additional
2022-01-04 17:39:10 +00:00
# static .lib called rubberband-static.lib otherwise.
2022-01-04 17:11:31 +00:00
#
2022-01-04 17:39:10 +00:00
if get_option ( 'default_library' ) != 'shared'
2022-01-04 17:11:31 +00:00
rubberband_additional_static_lib = 'rubberband-static'
2022-10-13 13:16:31 +01:00
endif
2022-01-04 17:11:31 +00:00
rubberband_library_name = 'rubberband'
2021-02-09 11:12:20 +00:00
rubberband_program_name = 'rubberband-program'
2022-06-15 11:31:35 +01:00
rubberband_program_name_r3 = 'rubberband-program-r3'
2021-02-10 11:28:05 +00:00
rubberband_ladspa_name = 'ladspa-rubberband'
2022-01-07 13:33:18 +00:00
rubberband_lv2_name = 'lv2-rubberband'
2021-02-10 11:28:05 +00:00
rubberband_vamp_name = 'vamp-rubberband'
2021-03-12 09:52:54 +00:00
rubberband_jni_name = 'rubberband-jni'
2022-06-08 09:57:12 +01:00
unit_tests_name = 'tests'
2021-02-09 11:12:20 +00:00
else
2022-01-04 17:11:31 +00:00
rubberband_library_name = 'rubberband'
2021-02-09 11:12:20 +00:00
rubberband_dynamic_name = 'rubberband'
rubberband_program_name = 'rubberband'
2022-06-15 11:31:35 +01:00
rubberband_program_name_r3 = 'rubberband-r3'
2021-02-10 11:28:05 +00:00
rubberband_ladspa_name = 'ladspa-rubberband'
2022-01-07 13:33:18 +00:00
rubberband_lv2_name = 'lv2-rubberband'
2021-02-10 11:28:05 +00:00
rubberband_vamp_name = 'vamp-rubberband'
2021-03-12 09:52:54 +00:00
rubberband_jni_name = 'rubberband-jni'
2022-06-08 09:57:12 +01:00
unit_tests_name = 'tests'
2021-02-09 11:12:20 +00:00
endif
2022-01-04 17:11:31 +00:00
rubberband_objlib = static_library (
'rubberband_objlib' ,
2021-02-05 16:42:13 +00:00
library_sources ,
feature_sources ,
2021-02-09 11:12:20 +00:00
include_directories : general_include_dirs ,
cpp_args : general_compile_args ,
c_args : general_compile_args ,
dependencies : general_dependencies ,
2021-02-05 16:42:13 +00:00
pic : true ,
2022-01-04 17:11:31 +00:00
install : false ,
2021-02-05 16:42:13 +00:00
)
2022-01-04 17:11:31 +00:00
rubberband_objlib_dep = declare_dependency (
link_with : rubberband_objlib ,
2021-02-05 16:42:13 +00:00
)
2022-01-04 17:11:31 +00:00
# And the build targets: Static and dynamic libraries, command-line
2022-01-07 13:33:18 +00:00
# utility, LADSPA and LV2 plugins, Vamp plugin, JNI library
2022-01-04 17:11:31 +00:00
if get_option ( 'default_library' ) == 'shared'
message ( 'Not building Rubber Band Library static library: default_library option is set to shared' )
target_summary + = { 'Static library' : false }
else
message ( 'Will build Rubber Band Library static library' )
if rubberband_additional_static_lib != ''
target_summary + = { 'Static library' : [ true , 'Name: ' + rubberband_additional_static_lib ] }
else
target_summary + = { 'Static library' : [ true , 'Name: ' + rubberband_library_name ] }
endif
endif
if get_option ( 'default_library' ) == 'static'
message ( 'Not building Rubber Band Library dynamic library: default_library option is set to static' )
target_summary + = { 'Dynamic library' : false }
2021-02-09 11:12:20 +00:00
else
2022-01-04 17:11:31 +00:00
message ( 'Will build Rubber Band Library dynamic library' )
target_summary + = { 'Dynamic library' : [ true , 'Name: ' + rubberband_library_name ] }
endif
rubberband_library = library (
rubberband_library_name ,
2022-01-04 17:39:10 +00:00
# We would like to write "link_with: rubberband_objlib",
# but that didn't work with MSVC when I tried it: no
# DLL entry point found
objects : rubberband_objlib . extract_all_objects ( recursive : true ) ,
2022-01-04 17:11:31 +00:00
link_args : [
arch_flags ,
feature_libraries ,
] ,
dependencies : general_dependencies ,
version : rubberband_dynamic_library_version ,
install : true ,
)
2022-01-05 12:55:01 +00:00
# This dependency is not used in this build file, but is declared
# for use when including this project as a subproject using Wrap
#
2022-01-05 08:54:45 +00:00
rubberband_dep = declare_dependency (
link_with : rubberband_library ,
2022-01-06 11:39:50 +00:00
include_directories : '.' ,
2022-01-05 08:54:45 +00:00
)
2022-01-04 17:11:31 +00:00
if get_option ( 'default_library' ) != 'shared' and rubberband_additional_static_lib != ''
rubberband_additional_library = static_library (
rubberband_additional_static_lib ,
link_with : rubberband_objlib ,
name_prefix : '' ,
name_suffix : 'lib' ,
install : true
)
2021-02-09 11:12:20 +00:00
endif
2021-02-05 16:42:13 +00:00
2022-11-04 10:49:11 +00:00
if have_jni
2021-03-12 09:52:54 +00:00
target_summary + = { 'JNI library' : [ true , 'Name: ' + rubberband_jni_name ] }
message ( 'Will build Java Native Interface' )
rubberband_jni = shared_library (
rubberband_jni_name ,
jni_sources ,
include_directories : general_include_dirs ,
cpp_args : general_compile_args ,
c_args : general_compile_args ,
link_args : [
arch_flags ,
feature_libraries ,
] ,
dependencies : [
2022-01-04 17:11:31 +00:00
rubberband_objlib_dep ,
2022-09-26 09:39:10 +01:00
jni_dep ,
2021-03-12 09:52:54 +00:00
general_dependencies ,
] ,
# NB the JNI library is not versioned
install : true ,
)
2022-10-13 13:29:18 +01:00
jar ( 'rubberband' , 'com/breakfastquay/rubberband/RubberBandStretcher.java' )
2021-03-12 09:52:54 +00:00
else
target_summary + = { 'JNI library' : false }
2022-10-13 13:16:31 +01:00
if not have_java
2022-09-26 12:48:44 +01:00
message ( 'Not building Java Native Interface: Java compiler or archiver missing' )
else
message ( 'Not building Java Native Interface: JNI header not found' )
2021-03-12 09:52:54 +00:00
endif
endif
2021-03-10 08:06:45 +00:00
install_headers (
2023-03-08 14:45:08 +00:00
public_headers ,
2021-03-10 08:06:45 +00:00
subdir : 'rubberband'
)
2021-02-05 16:42:13 +00:00
if have_ladspa
2021-02-10 11:28:05 +00:00
target_summary + = { 'LADSPA plugin' : [ true , 'Name: ' + rubberband_ladspa_name ] }
2021-02-05 16:42:13 +00:00
message ( 'Will build LADSPA plugin' )
rubberband_ladspa = shared_library (
2021-02-10 11:28:05 +00:00
rubberband_ladspa_name ,
2021-02-05 16:42:13 +00:00
ladspa_sources ,
2021-02-09 11:12:20 +00:00
include_directories : general_include_dirs ,
cpp_args : general_compile_args ,
c_args : general_compile_args ,
2021-02-05 16:42:13 +00:00
link_args : [
2021-02-05 17:08:17 +00:00
arch_flags ,
2021-02-05 16:42:13 +00:00
feature_libraries ,
ladspa_symbol_args ,
] ,
dependencies : [
2022-01-04 17:11:31 +00:00
rubberband_objlib_dep ,
2021-02-09 11:12:20 +00:00
general_dependencies ,
2021-02-05 16:42:13 +00:00
] ,
name_prefix : '' ,
install : true ,
install_dir : get_option ( 'libdir' ) / 'ladspa' ,
)
install_data (
2022-01-07 13:33:18 +00:00
'ladspa-lv2/ladspa-rubberband.cat' ,
2021-02-05 16:42:13 +00:00
install_dir : get_option ( 'libdir' ) / 'ladspa' ,
)
install_data (
2022-01-07 13:33:18 +00:00
'ladspa-lv2/ladspa-rubberband.rdf' ,
2021-02-05 16:42:13 +00:00
install_dir : get_option ( 'datadir' ) / 'ladspa/rdf' ,
)
else
2021-02-10 11:28:05 +00:00
target_summary + = { 'LADSPA plugin' : false }
2021-02-05 16:42:13 +00:00
message ( 'Not building LADSPA plugin: ladspa.h header not found' )
endif
2022-01-07 13:33:18 +00:00
if have_lv2
target_summary + = { 'LV2 plugin' : [ true , 'Name: ' + rubberband_lv2_name ] }
message ( 'Will build LV2 plugin' )
rubberband_lv2 = shared_library (
rubberband_lv2_name ,
lv2_sources ,
include_directories : general_include_dirs ,
cpp_args : general_compile_args ,
c_args : general_compile_args ,
link_args : [
arch_flags ,
feature_libraries ,
lv2_symbol_args ,
] ,
dependencies : [
rubberband_objlib_dep ,
general_dependencies ,
] ,
name_prefix : '' ,
install : true ,
2022-01-07 14:22:54 +00:00
install_dir : get_option ( 'libdir' ) / 'lv2/rubberband.lv2' ,
)
install_data (
'ladspa-lv2/rubberband.lv2/manifest.ttl' ,
'ladspa-lv2/rubberband.lv2/lv2-rubberband.ttl' ,
install_dir : get_option ( 'libdir' ) / 'lv2/rubberband.lv2' ,
2022-01-07 13:33:18 +00:00
)
else
target_summary + = { 'LV2 plugin' : false }
message ( 'Not building LV2 plugin: lv2.h header not found' )
endif
2021-02-09 11:12:20 +00:00
if have_vamp
2021-02-10 11:28:05 +00:00
target_summary + = { 'Vamp plugin' : [ true , 'Name: ' + rubberband_vamp_name ] }
2021-02-05 16:42:13 +00:00
message ( 'Will build Vamp plugin' )
rubberband_vamp = shared_library (
2021-02-10 11:28:05 +00:00
rubberband_vamp_name ,
2021-02-05 16:42:13 +00:00
vamp_sources ,
2021-02-09 11:12:20 +00:00
include_directories : general_include_dirs ,
cpp_args : general_compile_args ,
c_args : general_compile_args ,
2021-02-05 16:42:13 +00:00
link_args : [
2021-02-05 17:08:17 +00:00
arch_flags ,
2021-02-05 16:42:13 +00:00
feature_libraries ,
vamp_symbol_args ,
] ,
dependencies : [
2022-01-04 17:11:31 +00:00
rubberband_objlib_dep ,
2021-02-09 11:12:20 +00:00
general_dependencies ,
2021-02-05 16:42:13 +00:00
vamp_dep ,
] ,
name_prefix : '' ,
install : true ,
install_dir : get_option ( 'libdir' ) / 'vamp' ,
)
install_data (
'vamp/vamp-rubberband.cat' ,
install_dir : get_option ( 'libdir' ) / 'vamp' ,
)
else
2021-02-10 11:28:05 +00:00
target_summary + = { 'Vamp plugin' : false }
2021-02-05 16:42:13 +00:00
message ( 'Not building Vamp plugin: Vamp dependency not found' )
endif
2021-02-09 11:12:20 +00:00
if have_sndfile
2022-06-15 11:31:35 +01:00
message ( 'Will build command-line utilities' )
target_summary + = { 'Command-line utility (R2)' : [ true , 'Name: ' + rubberband_program_name ] }
2021-02-05 16:42:13 +00:00
rubberband_program = executable (
2021-02-09 11:12:20 +00:00
rubberband_program_name ,
2021-02-05 16:42:13 +00:00
program_sources ,
2021-02-09 11:12:20 +00:00
include_directories : general_include_dirs ,
cpp_args : general_compile_args ,
c_args : general_compile_args ,
2021-02-05 16:42:13 +00:00
link_args : [
2021-02-05 17:08:17 +00:00
arch_flags ,
2021-02-05 16:42:13 +00:00
feature_libraries ,
] ,
dependencies : [
2022-01-04 17:11:31 +00:00
rubberband_objlib_dep ,
2021-02-09 11:12:20 +00:00
general_dependencies ,
2021-02-05 16:42:13 +00:00
sndfile_dep ,
] ,
install : true ,
)
2022-06-15 11:31:35 +01:00
target_summary + = { 'Command-line utility (R3)' : [ true , 'Name: ' + rubberband_program_name_r3 ] }
rubberband_program_r3 = executable (
rubberband_program_name_r3 ,
program_sources ,
include_directories : general_include_dirs ,
cpp_args : general_compile_args ,
c_args : general_compile_args ,
link_args : [
arch_flags ,
feature_libraries ,
] ,
dependencies : [
rubberband_objlib_dep ,
general_dependencies ,
sndfile_dep ,
] ,
install : true ,
)
2021-02-05 16:42:13 +00:00
else
2022-06-15 11:31:35 +01:00
message ( 'Not building command-line utilities: libsndfile dependency not found' )
target_summary + = { 'Command-line utility (R2)' : false }
target_summary + = { 'Command-line utility (R3)' : false }
2021-02-05 16:42:13 +00:00
endif
2022-06-08 09:57:12 +01:00
if have_boost_unit_test
target_summary + = { 'Unit tests' : [ true , 'Name: ' + unit_tests_name ] }
message ( 'Will build unit tests: use "meson test -C <builddir>" to run them' )
unit_tests = executable (
unit_tests_name ,
unit_test_sources ,
cpp_args : general_compile_args ,
c_args : general_compile_args ,
link_args : [
arch_flags ,
feature_libraries ,
] ,
dependencies : [
rubberband_objlib_dep ,
general_dependencies ,
boost_unit_test_dep ,
] ,
install : false ,
build_by_default : false
)
general_test_args = [ '--log_level=message' ]
test ( 'Allocators' ,
unit_tests , args : [ '--run_test=TestAllocators' , general_test_args ] )
test ( 'FFT' ,
unit_tests , args : [ '--run_test=TestFFT' , general_test_args ] )
test ( 'Resampler' ,
unit_tests , args : [ '--run_test=TestResampler' , general_test_args ] )
test ( 'VectorOps' ,
unit_tests , args : [ '--run_test=TestVectorOps' , general_test_args ] )
test ( 'VectorOpsComplex' ,
unit_tests , args : [ '--run_test=TestVectorOpsComplex' , general_test_args ] )
2022-06-08 10:35:51 +01:00
test ( 'SignalBits' ,
unit_tests , args : [ '--run_test=TestSignalBits' , general_test_args ] )
2023-03-08 14:45:08 +00:00
test ( 'StretchCalculator' ,
unit_tests , args : [ '--run_test=TestStretchCalculator' , general_test_args ] )
2023-02-21 10:28:57 +00:00
test ( 'Stretcher' ,
unit_tests , args : [ '--run_test=TestStretcher' , general_test_args ] )
2022-06-08 09:57:12 +01:00
else
target_summary + = { 'Unit tests' : false }
message ( 'Not building unit tests: boost_unit_test_framework dependency not found' )
endif
2021-02-05 16:42:13 +00:00
pkg . generate (
name : 'rubberband' ,
description : 'Audio time-stretching and pitch-shifting library' ,
url : 'https://breakfastquay.com/rubberband/' ,
version : meson . project_version ( ) ,
requires : pkgconfig_requirements ,
2021-05-10 10:38:35 +01:00
libraries : [ '-L${libdir} -lrubberband' ] + pkgconfig_libraries ,
2021-02-05 16:42:13 +00:00
extra_cflags : '-I${includedir}' ,
)
2021-02-10 11:28:05 +00:00
summary ( { 'prefix' : get_option ( 'prefix' ) ,
'bindir' : get_option ( 'bindir' ) ,
'libdir' : get_option ( 'libdir' ) ,
'datadir' : get_option ( 'datadir' ) ,
} , section : 'Directories' )
2021-02-10 14:24:17 +00:00
summary ( config_summary + { 'Architecture' : architecture } ,
2021-03-05 10:33:27 +00:00
section : 'Configuration' , bool_yn : true )
2021-02-10 11:28:05 +00:00
summary ( target_summary , section : 'Build targets' , bool_yn : true )
2021-03-05 11:17:53 +00:00
if system == 'darwin'
foreach arg : get_option ( 'cpp_args' )
if arg . contains ( 'iPhone' )
summary ( { 'Please note' : 'You cannot legally distribute the Rubber Band Library\n in an iOS app on the App Store, unless you have first obtained a\n commercial licence.' } , section : '***' )
break
endif
endforeach
endif