Audaspace:
authorJoerg Mueller <nexyon@gmail.com>
Mon, 10 Dec 2012 16:58:47 +0000 (16:58 +0000)
committerJoerg Mueller <nexyon@gmail.com>
Mon, 10 Dec 2012 16:58:47 +0000 (16:58 +0000)
Implemented forgotten Calculator classes from boost migration.

18 files changed:
intern/audaspace/CMakeLists.txt
intern/audaspace/FX/AUD_BandpassCalculator.cpp [new file with mode: 0644]
intern/audaspace/FX/AUD_BandpassCalculator.h [new file with mode: 0644]
intern/audaspace/FX/AUD_ButterworthCalculator.cpp [new file with mode: 0644]
intern/audaspace/FX/AUD_ButterworthCalculator.h [new file with mode: 0644]
intern/audaspace/FX/AUD_ButterworthFactory.cpp
intern/audaspace/FX/AUD_ButterworthFactory.h
intern/audaspace/FX/AUD_DynamicIIRFilterFactory.cpp
intern/audaspace/FX/AUD_DynamicIIRFilterFactory.h
intern/audaspace/FX/AUD_HighpassCalculator.cpp [new file with mode: 0644]
intern/audaspace/FX/AUD_HighpassCalculator.h [new file with mode: 0644]
intern/audaspace/FX/AUD_HighpassFactory.cpp
intern/audaspace/FX/AUD_HighpassFactory.h
intern/audaspace/FX/AUD_IDynamicIIRFilterCalculator.h
intern/audaspace/FX/AUD_LowpassCalculator.cpp [new file with mode: 0644]
intern/audaspace/FX/AUD_LowpassCalculator.h [new file with mode: 0644]
intern/audaspace/FX/AUD_LowpassFactory.cpp
intern/audaspace/FX/AUD_LowpassFactory.h

index 1617e520ac7e44b37ce66a4505cbc90118a566d5..91b0549f7422ca9adb459508965245c87060fe2c 100644 (file)
@@ -34,6 +34,7 @@ set(INC_SYS
 set(SRC
        FX/AUD_AccumulatorFactory.cpp
        FX/AUD_BaseIIRFilterReader.cpp
+       FX/AUD_ButterworthCalculator.cpp
        FX/AUD_ButterworthFactory.cpp
        FX/AUD_CallbackIIRFilterReader.cpp
        FX/AUD_DelayFactory.cpp
@@ -47,6 +48,7 @@ set(SRC
        FX/AUD_EnvelopeFactory.cpp
        FX/AUD_FaderFactory.cpp
        FX/AUD_FaderReader.cpp
+       FX/AUD_HighpassCalculator.cpp
        FX/AUD_HighpassFactory.cpp
        FX/AUD_IIRFilterFactory.cpp
        FX/AUD_IIRFilterReader.cpp
@@ -54,6 +56,7 @@ set(SRC
        FX/AUD_LimiterReader.cpp
        FX/AUD_LoopFactory.cpp
        FX/AUD_LoopReader.cpp
+       FX/AUD_LowpassCalculator.cpp
        FX/AUD_LowpassFactory.cpp
        FX/AUD_PingPongFactory.cpp
        FX/AUD_PitchFactory.cpp
@@ -145,6 +148,7 @@ set(SRC
 
        FX/AUD_AccumulatorFactory.h
        FX/AUD_BaseIIRFilterReader.h
+       FX/AUD_ButterworthCalculator.h
        FX/AUD_ButterworthFactory.h
        FX/AUD_CallbackIIRFilterReader.h
        FX/AUD_DelayFactory.h
@@ -159,6 +163,7 @@ set(SRC
        FX/AUD_EnvelopeFactory.h
        FX/AUD_FaderFactory.h
        FX/AUD_FaderReader.h
+       FX/AUD_HighpassCalculator.h
        FX/AUD_HighpassFactory.h
        FX/AUD_IIRFilterFactory.h
        FX/AUD_IIRFilterReader.h
@@ -166,6 +171,7 @@ set(SRC
        FX/AUD_LimiterReader.h
        FX/AUD_LoopFactory.h
        FX/AUD_LoopReader.h
+       FX/AUD_LowpassCalculator.h
        FX/AUD_LowpassFactory.h
        FX/AUD_PingPongFactory.h
        FX/AUD_PitchFactory.h
diff --git a/intern/audaspace/FX/AUD_BandpassCalculator.cpp b/intern/audaspace/FX/AUD_BandpassCalculator.cpp
new file mode 100644 (file)
index 0000000..f5bbd63
--- /dev/null
@@ -0,0 +1,5 @@
+#include "AUD_BandpassCalculator.h"
+
+AUD_BandpassCalculator::AUD_BandpassCalculator()
+{
+}
diff --git a/intern/audaspace/FX/AUD_BandpassCalculator.h b/intern/audaspace/FX/AUD_BandpassCalculator.h
new file mode 100644 (file)
index 0000000..b5b3cad
--- /dev/null
@@ -0,0 +1,10 @@
+#ifndef AUD_BANDPASSCALCULATOR_H
+#define AUD_BANDPASSCALCULATOR_H
+
+class AUD_BandpassCalculator
+{
+public:
+  AUD_BandpassCalculator();
+};
+
+#endif // AUD_BANDPASSCALCULATOR_H
diff --git a/intern/audaspace/FX/AUD_ButterworthCalculator.cpp b/intern/audaspace/FX/AUD_ButterworthCalculator.cpp
new file mode 100644 (file)
index 0000000..7a3c6f7
--- /dev/null
@@ -0,0 +1,38 @@
+#include "AUD_ButterworthCalculator.h"
+
+#include <cmath>
+
+#ifndef M_PI
+#define M_PI 3.14159265358979323846
+#endif
+
+#define BWPB41 0.76536686473
+#define BWPB42 1.84775906502
+
+AUD_ButterworthCalculator::AUD_ButterworthCalculator(float frequency) :
+       m_frequency(frequency)
+{
+}
+
+void AUD_ButterworthCalculator::recalculateCoefficients(AUD_SampleRate rate, std::vector<float> &b, std::vector<float> &a)
+{
+       float omega = 2 * tan(m_frequency * M_PI / rate);
+       float o2 = omega * omega;
+       float o4 = o2 * o2;
+       float x1 = o2 + 2.0f * (float)BWPB41 * omega + 4.0f;
+       float x2 = o2 + 2.0f * (float)BWPB42 * omega + 4.0f;
+       float y1 = o2 - 2.0f * (float)BWPB41 * omega + 4.0f;
+       float y2 = o2 - 2.0f * (float)BWPB42 * omega + 4.0f;
+       float o228 = 2.0f * o2 - 8.0f;
+       float norm = x1 * x2;
+       a.push_back(1);
+       a.push_back((x1 + x2) * o228 / norm);
+       a.push_back((x1 * y2 + x2 * y1 + o228 * o228) / norm);
+       a.push_back((y1 + y2) * o228 / norm);
+       a.push_back(y1 * y2 / norm);
+       b.push_back(o4 / norm);
+       b.push_back(4 * o4 / norm);
+       b.push_back(6 * o4 / norm);
+       b.push_back(b[1]);
+       b.push_back(b[0]);
+}
diff --git a/intern/audaspace/FX/AUD_ButterworthCalculator.h b/intern/audaspace/FX/AUD_ButterworthCalculator.h
new file mode 100644 (file)
index 0000000..a7ae196
--- /dev/null
@@ -0,0 +1,20 @@
+#ifndef AUD_BUTTERWORTHCALCULATOR_H
+#define AUD_BUTTERWORTHCALCULATOR_H
+
+#include "AUD_IDynamicIIRFilterCalculator.h"
+
+class AUD_ButterworthCalculator : public AUD_IDynamicIIRFilterCalculator
+{
+private:
+       /**
+        * The attack value in seconds.
+        */
+       const float m_frequency;
+
+public:
+       AUD_ButterworthCalculator(float frequency);
+
+       virtual void recalculateCoefficients(AUD_SampleRate rate, std::vector<float> &b, std::vector<float> &a);
+};
+
+#endif // AUD_BUTTERWORTHCALCULATOR_H
index 97d85c8122fc026da682c68349927905906b6ada..12c4306c2f7689872a510a706a4fcedef3c53806 100644 (file)
 
 #include "AUD_ButterworthFactory.h"
 #include "AUD_IIRFilterReader.h"
-
-#include <cmath>
-
-#ifndef M_PI
-#define M_PI 3.14159265358979323846
-#endif
-
-#define BWPB41 0.76536686473
-#define BWPB42 1.84775906502
+#include "AUD_ButterworthCalculator.h"
 
 AUD_ButterworthFactory::AUD_ButterworthFactory(boost::shared_ptr<AUD_IFactory> factory,
                                                                                           float frequency) :
-               AUD_DynamicIIRFilterFactory(factory),
-               m_frequency(frequency)
+               AUD_DynamicIIRFilterFactory(factory, boost::shared_ptr<AUD_IDynamicIIRFilterCalculator>(new AUD_ButterworthCalculator(frequency)))
 {
 }
 
-void AUD_ButterworthFactory::recalculateCoefficients(AUD_SampleRate rate,
-                                                                                                        std::vector<float> &b,
-                                                                                                        std::vector<float> &a)
-{
-       float omega = 2 * tan(m_frequency * M_PI / rate);
-       float o2 = omega * omega;
-       float o4 = o2 * o2;
-       float x1 = o2 + 2.0f * (float)BWPB41 * omega + 4.0f;
-       float x2 = o2 + 2.0f * (float)BWPB42 * omega + 4.0f;
-       float y1 = o2 - 2.0f * (float)BWPB41 * omega + 4.0f;
-       float y2 = o2 - 2.0f * (float)BWPB42 * omega + 4.0f;
-       float o228 = 2.0f * o2 - 8.0f;
-       float norm = x1 * x2;
-       a.push_back(1);
-       a.push_back((x1 + x2) * o228 / norm);
-       a.push_back((x1 * y2 + x2 * y1 + o228 * o228) / norm);
-       a.push_back((y1 + y2) * o228 / norm);
-       a.push_back(y1 * y2 / norm);
-       b.push_back(o4 / norm);
-       b.push_back(4 * o4 / norm);
-       b.push_back(6 * o4 / norm);
-       b.push_back(b[1]);
-       b.push_back(b[0]);
-}
index e796f76aa29321bcd4efb4d20b189ee79ec44722..3a86b14a7a6cfda25a1bf2d484457c7511db64ed 100644 (file)
 class AUD_ButterworthFactory : public AUD_DynamicIIRFilterFactory
 {
 private:
-       /**
-        * The attack value in seconds.
-        */
-       const float m_frequency;
-
        // hide copy constructor and operator=
        AUD_ButterworthFactory(const AUD_ButterworthFactory&);
        AUD_ButterworthFactory& operator=(const AUD_ButterworthFactory&);
@@ -54,10 +49,6 @@ public:
         * \param frequency The cutoff frequency.
         */
        AUD_ButterworthFactory(boost::shared_ptr<AUD_IFactory> factory, float frequency);
-
-       virtual void recalculateCoefficients(AUD_SampleRate rate,
-                                            std::vector<float>& b,
-                                            std::vector<float>& a);
 };
 
 #endif //__AUD_BUTTERWORTHFACTORY_H__
index e8ea4323b2e8948f302f86e574ea979b38f842e2..319a78cfedd42ba29e753ea722f937406691c10c 100644 (file)
 #include "AUD_DynamicIIRFilterReader.h"
 
 
-AUD_DynamicIIRFilterFactory::AUD_DynamicIIRFilterFactory(boost::shared_ptr<AUD_IFactory> factory) :
-       AUD_EffectFactory(factory)
+AUD_DynamicIIRFilterFactory::AUD_DynamicIIRFilterFactory(boost::shared_ptr<AUD_IFactory> factory,
+                                                                                                                boost::shared_ptr<AUD_IDynamicIIRFilterCalculator> calculator) :
+       AUD_EffectFactory(factory),
+       m_calculator(calculator)
 {
 }
 
index f36a37f44b45ef0495d3873d3bc224d9819431d2..aece7a8c2ef60fc40a6b0f1e73ea1c7c286ed02e 100644 (file)
@@ -49,7 +49,8 @@ public:
         * Creates a new Dynmic IIR filter factory.
         * \param factory The input factory.
         */
-       AUD_DynamicIIRFilterFactory(boost::shared_ptr<AUD_IFactory> factory);
+       AUD_DynamicIIRFilterFactory(boost::shared_ptr<AUD_IFactory> factory,
+                                                               boost::shared_ptr<AUD_IDynamicIIRFilterCalculator> calculator);
 
        virtual boost::shared_ptr<AUD_IReader> createReader();
 };
diff --git a/intern/audaspace/FX/AUD_HighpassCalculator.cpp b/intern/audaspace/FX/AUD_HighpassCalculator.cpp
new file mode 100644 (file)
index 0000000..573bba1
--- /dev/null
@@ -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]);
+}
diff --git a/intern/audaspace/FX/AUD_HighpassCalculator.h b/intern/audaspace/FX/AUD_HighpassCalculator.h
new file mode 100644 (file)
index 0000000..bad1c08
--- /dev/null
@@ -0,0 +1,25 @@
+#ifndef AUD_HIGHPASSCALCULATOR_H
+#define AUD_HIGHPASSCALCULATOR_H
+
+#include "AUD_IDynamicIIRFilterCalculator.h"
+
+class AUD_HighpassCalculator : public AUD_IDynamicIIRFilterCalculator
+{
+private:
+       /**
+        * The cutoff frequency.
+        */
+       const float m_frequency;
+
+       /**
+        * The Q factor.
+        */
+       const float m_Q;
+
+public:
+       AUD_HighpassCalculator(float frequency, float Q);
+
+       virtual void recalculateCoefficients(AUD_SampleRate rate, std::vector<float> &b, std::vector<float> &a);
+};
+
+#endif // AUD_HIGHPASSCALCULATOR_H
index ba5297d21edcdc8db10210b76c0d3de376f0a8c3..2456085a8a1d66cccf69a1130e853ffb06642b0c 100644 (file)
 
 #include "AUD_HighpassFactory.h"
 #include "AUD_IIRFilterReader.h"
-
-#include <cmath>
-
-#ifndef M_PI
-#define M_PI 3.14159265358979323846
-#endif
+#include "AUD_HighpassCalculator.h"
 
 AUD_HighpassFactory::AUD_HighpassFactory(boost::shared_ptr<AUD_IFactory> factory, float frequency,
                                                                                 float Q) :
-               AUD_DynamicIIRFilterFactory(factory),
-               m_frequency(frequency),
-               m_Q(Q)
+               AUD_DynamicIIRFilterFactory(factory, boost::shared_ptr<AUD_IDynamicIIRFilterCalculator>(new AUD_HighpassCalculator(frequency, Q)))
 {
 }
 
-void AUD_HighpassFactory::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]);
-}
index ed7e9db44a41be2347a3f3e73141cbb4dd18a74b..56ced91c53cbcc658fac0f54afc3c236a23a1c14 100644 (file)
 class AUD_HighpassFactory : public AUD_DynamicIIRFilterFactory
 {
 private:
-       /**
-        * The cutoff frequency.
-        */
-       const float m_frequency;
-
-       /**
-        * The Q factor.
-        */
-       const float m_Q;
-
        // hide copy constructor and operator=
        AUD_HighpassFactory(const AUD_HighpassFactory&);
        AUD_HighpassFactory& operator=(const AUD_HighpassFactory&);
@@ -60,8 +50,6 @@ public:
         * \param Q The Q factor.
         */
        AUD_HighpassFactory(boost::shared_ptr<AUD_IFactory> factory, float frequency, float Q = 1.0f);
-
-       virtual void recalculateCoefficients(AUD_SampleRate rate, std::vector<float> &b, std::vector<float> &a);
 };
 
 #endif //__AUD_HIGHPASSFACTORY_H__
index 77d83360255dc4f6ba5d5c18c36af39295405934..29b87e57ad0a25b1ee25142656d14f918b6eef46 100644 (file)
@@ -29,6 +29,8 @@
 #ifndef AUD_IDYNAMICIIRFILTERCALCULATOR_H
 #define AUD_IDYNAMICIIRFILTERCALCULATOR_H
 
+#include "AUD_Space.h"
+
 #include <vector>
 
 /**
diff --git a/intern/audaspace/FX/AUD_LowpassCalculator.cpp b/intern/audaspace/FX/AUD_LowpassCalculator.cpp
new file mode 100644 (file)
index 0000000..57452f0
--- /dev/null
@@ -0,0 +1,27 @@
+#include "AUD_LowpassCalculator.h"
+
+#include <cmath>
+
+#ifndef M_PI
+#define M_PI 3.14159265358979323846
+#endif
+
+AUD_LowpassCalculator::AUD_LowpassCalculator(float frequency, float Q) :
+       m_frequency(frequency),
+       m_Q(Q)
+{
+}
+
+void AUD_LowpassCalculator::recalculateCoefficients(AUD_SampleRate rate, std::vector<float> &b, std::vector<float> &a)
+{
+       float w0 = 2 * M_PI * m_frequency / rate;
+       float alpha = sin(w0) / (2 * 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]);
+}
diff --git a/intern/audaspace/FX/AUD_LowpassCalculator.h b/intern/audaspace/FX/AUD_LowpassCalculator.h
new file mode 100644 (file)
index 0000000..18bb11f
--- /dev/null
@@ -0,0 +1,25 @@
+#ifndef AUD_LOWPASSCALCULATOR_H
+#define AUD_LOWPASSCALCULATOR_H
+
+#include "AUD_IDynamicIIRFilterCalculator.h"
+
+class AUD_LowpassCalculator : public AUD_IDynamicIIRFilterCalculator
+{
+private:
+       /**
+        * The cutoff frequency.
+        */
+       const float m_frequency;
+
+       /**
+        * The Q factor.
+        */
+       const float m_Q;
+
+public:
+       AUD_LowpassCalculator(float frequency, float Q);
+
+       virtual void recalculateCoefficients(AUD_SampleRate rate, std::vector<float> &b, std::vector<float> &a);
+};
+
+#endif // AUD_LOWPASSCALCULATOR_H
index e2faa241ac9ae0b176088e07e1bdda452b09586c..bd225998392a342a6b40bd34f8f076903ae78da2 100644 (file)
 
 #include "AUD_LowpassFactory.h"
 #include "AUD_IIRFilterReader.h"
-
-#include <cmath>
-
-#ifndef M_PI
-#define M_PI 3.14159265358979323846
-#endif
+#include "AUD_LowpassCalculator.h"
 
 AUD_LowpassFactory::AUD_LowpassFactory(boost::shared_ptr<AUD_IFactory> factory, float frequency,
                                                                           float Q) :
-               AUD_DynamicIIRFilterFactory(factory),
-               m_frequency(frequency),
-               m_Q(Q)
-{
-}
-
-void AUD_LowpassFactory::recalculateCoefficients(AUD_SampleRate rate,
-                                                                                                std::vector<float> &b,
-                                                                                                std::vector<float> &a)
+               AUD_DynamicIIRFilterFactory(factory, boost::shared_ptr<AUD_IDynamicIIRFilterCalculator>(new AUD_LowpassCalculator(frequency, Q)))
 {
-       float w0 = 2 * M_PI * m_frequency / rate;
-       float alpha = sin(w0) / (2 * 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]);
 }
index fdbc6e5d91d73682eada0cb8a5c7867b280f83ad..dfd8ab355212783bf803352935f618fec502e1bb 100644 (file)
 class AUD_LowpassFactory : public AUD_DynamicIIRFilterFactory
 {
 private:
-       /**
-        * The cutoff frequency.
-        */
-       const float m_frequency;
-
-       /**
-        * The Q factor.
-        */
-       const float m_Q;
-
        // hide copy constructor and operator=
        AUD_LowpassFactory(const AUD_LowpassFactory&);
        AUD_LowpassFactory& operator=(const AUD_LowpassFactory&);
@@ -60,8 +50,6 @@ public:
         * \param Q The Q factor.
         */
        AUD_LowpassFactory(boost::shared_ptr<AUD_IFactory> factory, float frequency, float Q = 1.0f);
-
-       virtual void recalculateCoefficients(AUD_SampleRate rate, std::vector<float> &b, std::vector<float> &a);
 };
 
 #endif //__AUD_LOWPASSFACTORY_H__