diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2012-12-10 21:05:33 +0400 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2012-12-10 21:05:33 +0400 |
commit | decffdc556794541ba0a724c9d4eff052e6a53b5 (patch) | |
tree | fb7c6b8eaac7916b387e929f972da150f8ac6d39 /intern/audaspace/FX/AUD_HighpassCalculator.cpp | |
parent | 14d3870c2fc51670856a56d2ed3aa759d91d4d78 (diff) | |
parent | 245345fba5f44b5c8562c826ca0053fa5bbd2ff3 (diff) |
Merging r52851 through r52858 from trunk into blender-2.65-release
Diffstat (limited to 'intern/audaspace/FX/AUD_HighpassCalculator.cpp')
-rw-r--r-- | intern/audaspace/FX/AUD_HighpassCalculator.cpp | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/intern/audaspace/FX/AUD_HighpassCalculator.cpp b/intern/audaspace/FX/AUD_HighpassCalculator.cpp new file mode 100644 index 00000000000..573bba1c62b --- /dev/null +++ b/intern/audaspace/FX/AUD_HighpassCalculator.cpp @@ -0,0 +1,27 @@ +#include "AUD_HighpassCalculator.h" + +#include <cmath> + +#ifndef M_PI +#define M_PI 3.14159265358979323846 +#endif + +AUD_HighpassCalculator::AUD_HighpassCalculator(float frequency, float Q) : + m_frequency(frequency), + m_Q(Q) +{ +} + +void AUD_HighpassCalculator::recalculateCoefficients(AUD_SampleRate rate, std::vector<float> &b, std::vector<float> &a) +{ + float w0 = 2.0 * M_PI * (AUD_SampleRate)m_frequency / rate; + float alpha = (float)(sin(w0) / (2.0 * (double)m_Q)); + float norm = 1 + alpha; + float c = cos(w0); + a.push_back(1); + a.push_back(-2 * c / norm); + a.push_back((1 - alpha) / norm); + b.push_back((1 + c) / (2 * norm)); + b.push_back((-1 - c) / norm); + b.push_back(b[0]); +} |