diff options
author | Bent Bisballe Nyeng <deva@aasimon.org> | 2014-01-04 15:38:43 +0100 |
---|---|---|
committer | Bent Bisballe Nyeng <deva@aasimon.org> | 2014-01-04 15:38:43 +0100 |
commit | aff06750c0cd62e7276e3230fa5dd8220b903132 (patch) | |
tree | 4861f1d6f048c9ff465644c2b1cf5e0f7b0df30f | |
parent | 960702b18260b8e238288e2e4df22d1521d521fe (diff) |
Disable/enable resample on compiletime. Enable/disable using env on runtime.
-rw-r--r-- | configure.ac | 14 | ||||
-rw-r--r-- | src/audiofile.cc | 15 |
2 files changed, 23 insertions, 6 deletions
diff --git a/configure.ac b/configure.ac index 820c627..7c3a0ed 100644 --- a/configure.ac +++ b/configure.ac @@ -301,10 +301,16 @@ dnl Check for sndfile dnl ====================== PKG_CHECK_MODULES(SNDFILE, sndfile >= 1.0.20) -dnl ====================== -dnl Check for libsamplerate -dnl ====================== -PKG_CHECK_MODULES(SAMPLERATE, samplerate >= 0.1.7) +AC_ARG_WITH(resample, [ --with-resample Build with resample support]) +if test x$with_resample == xyes; then + AC_MSG_WARN([*** Building resample support!]) + AC_DEFINE(WITH_RESAMPLE, [], [Use resample]) + + dnl ====================== + dnl Check for libsamplerate + dnl ====================== + PKG_CHECK_MODULES(SAMPLERATE, samplerate >= 0.1.7) +fi #dnl ====================== #dnl Check for libpng diff --git a/src/audiofile.cc b/src/audiofile.cc index 169e11a..bb620df 100644 --- a/src/audiofile.cc +++ b/src/audiofile.cc @@ -37,6 +37,8 @@ #include "configuration.h" +#include <config.h> + AudioFile::AudioFile(std::string filename) { is_loaded = false; @@ -127,7 +129,15 @@ void AudioFile::load(int num_samples) sf_close(fh); - if(Conf::samplerate != sf_info.samplerate) { +#ifdef WITH_RESAMPLE + + // Check environment to see if resample should be disabled. + // Defaults to "1" which is 'enable'. All other values are 'disabled'. + char *env_res = getenv("DRUMGIZMO_RESAMPLE"); + if(env_res == NULL) env_res = "1"; + + if( (strcmp(env_res, "1") == 0) && + Conf::samplerate != sf_info.samplerate) { // Resample data... size_t osize = size * ratio; sample_t *odata = new sample_t[osize]; @@ -150,7 +160,8 @@ void AudioFile::load(int num_samples) DEBUG(audiofile,"Converted into %d samples %p\n", (int)size, this); } - +#endif/*WITH_RESAMPLE*/ + this->data = data; is_loaded = true; |