00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 #ifndef AMBISONIC_UTILITIES_H
00012 #define AMBISONIC_UTILITIES_H
00013
00014 #include "CSL_Core.h"
00015 #include "Ambisonic.h"
00016
00017 #define AMBI_INVSQRT2 (1/1.414213562)
00018
00019 namespace csl {
00020
00021
00023 void singularValueDecomposition(sample** a, int m, int n, sample* w, sample** v);
00024
00026 void fumaEncodingWeights(sample *weights, const AmbisonicOrder &order, sample azimuth, sample elevation);
00027
00029 void fumaIndexedEncodingWeights(sample *weights, const AmbisonicOrder &order, sample &azimuth, sample &elevation);
00030
00031
00038 class AmbisonicMixer : public AmbisonicUnitGenerator {
00039 public:
00040
00041
00042 AmbisonicMixer(unsigned order = 1);
00043 AmbisonicMixer(unsigned hOrder, unsigned vOrder);
00044
00046
00047
00048 ~AmbisonicMixer();
00049
00051 void initialize();
00052
00054 void addInput(AmbisonicUnitGenerator &input);
00055 void addInput(UnitGenerator &input);
00056
00057 unsigned numInputs() { return mInputs.size(); };
00058
00059
00060 virtual void nextBuffer(Buffer &outputBuffer, unsigned outBufNum) throw(CException);
00061
00062 protected:
00063
00064 vector<UnitGenerator *> mInputs;
00065 Buffer *mInBuffer;
00066
00067 float mInvNumInputs;
00068
00069 };
00070
00071 typedef enum {
00072 kTILT = 0,
00073 kTUMBLE,
00074 kROTATE
00075 } Axes;
00076
00092 class AmbisonicRotator : public AmbisonicUnitGenerator {
00093 public:
00094
00095
00096
00098 AmbisonicRotator(AmbisonicUnitGenerator &input);
00099
00101 AmbisonicRotator(UnitGenerator &input, unsigned order);
00102
00104 AmbisonicRotator(UnitGenerator &input, unsigned vorder, unsigned horder);
00105
00106 ~AmbisonicRotator();
00107
00108
00109
00110 void setNthInput(float amount, Axes axis);
00111 void setTilt(float amount);
00112 void setTumble(float amount);
00113 void setRotate(float amount);
00114
00115
00116 virtual void nextBuffer(Buffer &outputBuffer, unsigned outBufNum) throw(CException);
00117
00118 protected:
00119 unsigned mNumFrames;
00120 unsigned mGreaterOrder;
00121 unsigned mNumChannelsGreaterOrder;
00122 unsigned *mChannelIndex;
00123 unsigned *mInputChannelIndex;
00124 bool mShouldRotate, mShouldTurn, mShouldTilt;
00125
00126 private:
00127 UGenPort *mInputPort;
00128
00129 sample mRotate, mTumble, mTilt;
00130 sample *mSinAngle, *mCosAngle;
00131 sample **mOutPtr, **mInPtr;
00132
00133 void initialize(UnitGenerator &input);
00134
00135
00136 void tiltFirstOrder();
00137 void tiltSecondOrder();
00138 void tiltThirdOrder();
00139
00140 void tumbleFirstOrder();
00141 void tumbleSecondOrder();
00142 void tumbleThirdOrder();
00143
00144
00145
00146 void rotateZerothOrder();
00147 void rotateFirstOrderHorizontal();
00148 void rotateSecondOrderHorizontal();
00149 void rotateThirdOrderHorizontal();
00150 void rotateFirstOrderVertical();
00151 void rotateSecondOrderVertical();
00152 void rotateThirdOrderVertical();
00153
00154
00155 };
00156
00157
00158 }
00159
00160 #endif