From 3d95f28fb9a1efbbed78087372f0c65eeb576f9f Mon Sep 17 00:00:00 2001 From: Craig Hansen-Sturm Date: Mon, 11 Aug 2014 11:51:49 -0700 Subject: [PATCH] added apache licensing/removed implicit double<->float conversions/addressed style guide issues --- libraries/audio/src/AudioFilter.cpp | 13 ++++++++----- libraries/audio/src/AudioFilter.h | 17 ++++++++++------- 2 files changed, 18 insertions(+), 12 deletions(-) diff --git a/libraries/audio/src/AudioFilter.cpp b/libraries/audio/src/AudioFilter.cpp index 61e5e20171..28e7716578 100644 --- a/libraries/audio/src/AudioFilter.cpp +++ b/libraries/audio/src/AudioFilter.cpp @@ -3,7 +3,10 @@ // hifi // // Created by Craig Hansen-Sturm on 8/10/14. +// Copyright 2014 High Fidelity, Inc. // +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // #include @@ -15,9 +18,9 @@ template<> AudioFilterPEQ3::FilterParameter AudioFilterPEQ3::_profiles[ AudioFilterPEQ3::_profileCount ][ AudioFilterPEQ3::_filterCount ] = { - { { 300., 1., 1. }, { 1000., 1., 1. }, { 4000., 1., 1. } }, // flat response (default) - { { 300., 1., 1. }, { 1000., 1., 1. }, { 4000., .1, 1. } }, // treble cut - { { 300., .1, 1. }, { 1000., 1., 1. }, { 4000., 1., 1. } }, // bass cut - { { 300., 1.5, 0.71 }, { 1000., .5, 1. }, { 4000., 1.5, 0.71 } } // smiley curve + // Freq Gain Q Freq Gain Q Freq Gain Q + { { 300.0f, 1.0f, 1.0f }, { 1000.0f, 1.0f, 1.0f }, { 4000.0f, 1.0f, 1.0f } }, // flat response (default) + { { 300.0f, 1.0f, 1.0f }, { 1000.0f, 1.0f, 1.0f }, { 4000.0f, 0.1f, 1.0f } }, // treble cut + { { 300.0f, 0.1f, 1.0f }, { 1000.0f, 1.0f, 1.0f }, { 4000.0f, 1.0f, 1.0f } }, // bass cut + { { 300.0f, 1.5f, 0.71f }, { 1000.0f, 0.5f, 1.0f }, { 4000.0f, 1.50f, 0.71f } } // smiley curve }; - diff --git a/libraries/audio/src/AudioFilter.h b/libraries/audio/src/AudioFilter.h index 44dcd261d6..0f3ec06f64 100644 --- a/libraries/audio/src/AudioFilter.h +++ b/libraries/audio/src/AudioFilter.h @@ -3,7 +3,10 @@ // hifi // // Created by Craig Hansen-Sturm on 8/9/14. +// Copyright 2014 High Fidelity, Inc. // +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // #ifndef hifi_AudioFilter_h @@ -117,14 +120,14 @@ class AudioParametricEQ { const float a = _gain; const float omega = TWO_PI * _frequency / _sampleRate; - const float alpha = 0.5 * sinf(omega) / _slope; - const float gamma = 1.0 / ( 1.0 + (alpha/a) ); + const float alpha = 0.5f * sinf(omega) / _slope; + const float gamma = 1.0f / ( 1.0f + (alpha/a) ); - const float a0 = 1.0 + (alpha*a); - const float a1 = -2.0 * cosf(omega); - const float a2 = 1.0 - (alpha*a); + const float a0 = 1.0f + (alpha*a); + const float a1 = -2.0f * cosf(omega); + const float a2 = 1.0f - (alpha*a); const float b1 = a1; - const float b2 = 1.0 - (alpha/a); + const float b2 = 1.0f - (alpha/a); _kernel.setParameters( a0*gamma,a1*gamma,a2*gamma,b1*gamma,b2*gamma ); } @@ -257,7 +260,7 @@ public: } void render( const int16_t* in, int16_t* out, const int frameCount ) { - if( !_buffer || ( frameCount > _frameCount ) ) + if (!_buffer || ( frameCount > _frameCount )) return; const int scale = (2 << ((8*sizeof(int16_t))-1));