diff --git a/cmake/externals/gverb/CMakeLists.txt b/cmake/externals/gverb/CMakeLists.txt deleted file mode 100644 index 4da19e1d31..0000000000 --- a/cmake/externals/gverb/CMakeLists.txt +++ /dev/null @@ -1,31 +0,0 @@ -set(EXTERNAL_NAME gverb) - -if (ANDROID) - set(ANDROID_CMAKE_ARGS "-DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}" "-DANDROID_NATIVE_API_LEVEL=19") -endif () - -include(ExternalProject) -ExternalProject_Add( - ${EXTERNAL_NAME} - URL http://hifi-public.s3.amazonaws.com/dependencies/gverb-master.zip - URL_MD5 8b16d586390a2102804e46b87820dfc6 - CMAKE_ARGS ${ANDROID_CMAKE_ARGS} -DCMAKE_INSTALL_PREFIX:PATH= - BINARY_DIR ${EXTERNAL_PROJECT_PREFIX}/build - LOG_DOWNLOAD 1 - LOG_CONFIGURE 1 - LOG_BUILD 1 -) - -# Hide this external target (for ide users) -set_target_properties(${EXTERNAL_NAME} PROPERTIES FOLDER "hidden/externals") - -ExternalProject_Get_Property(${EXTERNAL_NAME} INSTALL_DIR) - -string(TOUPPER ${EXTERNAL_NAME} EXTERNAL_NAME_UPPER) -set(${EXTERNAL_NAME_UPPER}_INCLUDE_DIRS ${INSTALL_DIR}/include CACHE FILEPATH "Path to gverb include directory") - -if (WIN32) - set(${EXTERNAL_NAME_UPPER}_LIBRARIES ${INSTALL_DIR}/lib/gverb.lib CACHE FILEPATH "List of gverb libraries") -else () - set(${EXTERNAL_NAME_UPPER}_LIBRARIES ${INSTALL_DIR}/lib/libgverb.a CACHE FILEPATH "List of gverb libraries") -endif () \ No newline at end of file diff --git a/libraries/audio-client/CMakeLists.txt b/libraries/audio-client/CMakeLists.txt index 90937edc5d..2c0fc0a9cd 100644 --- a/libraries/audio-client/CMakeLists.txt +++ b/libraries/audio-client/CMakeLists.txt @@ -6,11 +6,6 @@ link_hifi_libraries(audio) target_include_directories(${TARGET_NAME} PUBLIC "${HIFI_LIBRARY_DIR}/audio/src") # have CMake grab externals for us -add_dependency_external_projects(gverb) -find_package(Gverb REQUIRED) -target_link_libraries(${TARGET_NAME} ${GVERB_LIBRARIES}) -target_include_directories(${TARGET_NAME} PRIVATE ${GVERB_INCLUDE_DIRS}) - if (APPLE) find_library(CoreAudio CoreAudio) find_library(CoreFoundation CoreFoundation) diff --git a/libraries/audio/src/AudioReverb.cpp b/libraries/audio/src/AudioReverb.cpp index ff286d780b..5c57e92ce5 100644 --- a/libraries/audio/src/AudioReverb.cpp +++ b/libraries/audio/src/AudioReverb.cpp @@ -34,6 +34,7 @@ inline static int MULHI(int a, int b) { #endif static const float PHI = 0.6180339887f; // maximum allpass diffusion +static const float TWOPI = 6.283185307f; static const double PI = 3.14159265358979323846; static const double SQRT2 = 1.41421356237309504880; @@ -383,7 +384,7 @@ static void BQPeakAbovePi(double coef[5], double w0, double dbgain, double Q) { // Biquad Peaking EQ using analog matching. // Supports full range of w0. // -static void BQPeak(double coef[5], double w0, double dbgain, double Q) { +void BQPeak(double coef[5], double w0, double dbgain, double Q) { w0 = MAX(w0, 0.0); // allow w0 > pi Q = MIN(MAX(Q, 1.0e-6), 1.0e+6); @@ -402,7 +403,7 @@ static void BQPeak(double coef[5], double w0, double dbgain, double Q) { // // Biquad Shelf using analog matching. // -static void BQShelf(double coef[5], double w0, double dbgain, double resonance, int isHigh) { +void BQShelf(double coef[5], double w0, double dbgain, double resonance, int isHigh) { double G, G1; double wpi, wn, wd; double wna, wda; @@ -499,7 +500,7 @@ static void BQShelf(double coef[5], double w0, double dbgain, double resonance, // Biquad Lowpass/Highpass using analog matching. // Q = sqrt(0.5) = 2nd order Butterworth // -static void BQFilter(double coef[5], double w0, int isHigh) { +void BQFilter(double coef[5], double w0, int isHigh) { double G1; double wpi, wn, wd; double wna, wda; @@ -587,7 +588,7 @@ static void BQFilter(double coef[5], double w0, int isHigh) { // PoleZero Shelf. For Lowpass/Highpass, setCoef dbgain to -100dB. // NOTE: w0 always sets the pole frequency (3dB corner from unity gain) // -static void PZShelf(double coef[3], double w0, double dbgain, int isHigh) { +void PZShelf(double coef[3], double w0, double dbgain, int isHigh) { double G, G0, G1; double b0, b1, a0, a1; double temp, scale; @@ -653,7 +654,7 @@ public: // lowpass filter, -3dB @ freq double coef[5]; - BQFilter(coef, PI * freq / (0.5 * sampleRate), 0); + BQFilter(coef, TWOPI * freq / sampleRate, 0); _b0 = (float)coef[0]; _b1 = (float)coef[1]; _b2 = (float)coef[2]; @@ -661,7 +662,7 @@ public: _a2 = (float)coef[4]; // DC-blocking filter, -3dB @ 10Hz - _alpha = (float)(1.0 - exp(-PI * 10.0 / (0.5 * sampleRate))); + _alpha = 1.0f - expf(-TWOPI * 10.0f / sampleRate); } void process(float input0, float input1, float& output0, float& output1) { @@ -807,11 +808,13 @@ public: freq = MIN(freq, 1/16.0f * sampleRate); freq = MAX(freq, 1/16777216.0f * sampleRate); - // amplitude slightly less than 1.0 - _y0 = (int32_t)(0.000 * FIXQ31); - _y1 = (int32_t)(0.999 * cos(PI * freq / sampleRate) * FIXQ31); + double w = PI * (double)freq / (double)sampleRate; - _k = (int32_t)(2.0 * sin(PI * freq / sampleRate) * FIXQ32); + // amplitude slightly less than 1.0 + _y0 = 0; + _y1 = (int32_t)(0.999 * cos(w) * FIXQ31); + + _k = (int32_t)(2.0 * sin(w) * FIXQ32); } void setGain(int32_t gain) { @@ -985,8 +988,8 @@ public: freq1 = MIN(MAX(freq1, 1.0f), 24000.0f); double coefLo[3], coefHi[3]; - PZShelf(coefLo, PI * freq0 / (0.5 * sampleRate), dBgain0, 0); // low shelf - PZShelf(coefHi, PI * freq1 / (0.5 * sampleRate), dBgain1, 1); // high shelf + PZShelf(coefLo, TWOPI * freq0 / sampleRate, dBgain0, 0); // low shelf + PZShelf(coefHi, TWOPI * freq1 / sampleRate, dBgain1, 1); // high shelf // convolve into a single biquad _b0 = (float)(coefLo[0] * coefHi[0]); @@ -1407,7 +1410,7 @@ void ReverbImpl::setParameters(ReverbParameters *p) { // Modulation _lfo.setFreq(p->modRate, sampleRate); - _lfo.setGain((int32_t)MIN(MAX(p->modDepth * (1/100.0) * FIXQ31, 0.0), 0X7fffffff)); + _lfo.setGain((int32_t)MIN(MAX((double)p->modDepth * (1/100.0) * FIXQ31, 0.0), (double)0x7fffffff)); // // Set delays