AmbisonicUtilities.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008 #ifndef AMBISONIC_UTILITIES_H
00009 #define AMBISONIC_UTILITIES_H
00010
00011 #include "CSL_Core.h"
00012 #include "Ambisonic.h"
00013
00014 #define AMBI_INVSQRT2 (1/1.414213562)
00015
00016 namespace csl {
00017
00019
00020 void singularValueDecomposition(sample** a, int m, int n, sample* w, sample** v);
00021
00023
00024 void fumaEncodingWeights(SampleBuffer weights, const AmbisonicOrder &order, sample azimuth, sample elevation);
00025
00027
00028 void fumaIndexedEncodingWeights(SampleBuffer weights, const AmbisonicOrder &order, sample &azimuth, sample &elevation);
00029
00030
00031
00032
00033
00034
00035
00036 class AmbisonicMixer : public AmbisonicUnitGenerator {
00037 public:
00038
00039
00040 AmbisonicMixer(unsigned order = 1);
00041 AmbisonicMixer(unsigned hOrder, unsigned vOrder);
00042
00044
00045
00046 ~AmbisonicMixer();
00047
00049 void initialize();
00050
00052 void addInput(AmbisonicUnitGenerator &input);
00053 void addInput(UnitGenerator &input);
00054
00055 unsigned numInputs() { return mInputs.size(); };
00056
00057
00058 virtual void nextBuffer(Buffer &outputBuffer, unsigned outBufNum) throw(CException);
00059
00060 protected:
00061 UGenVector mInputs;
00062 Buffer *mInBuffer;
00063 float mInvNumInputs;
00064
00065 };
00066
00067 typedef enum {
00068 kTILT = 0,
00069 kTUMBLE,
00070 kROTATE
00071 } Axes;
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084 class AmbisonicRotator : public AmbisonicUnitGenerator {
00085 public:
00086
00088 AmbisonicRotator(AmbisonicUnitGenerator &input);
00090 AmbisonicRotator(UnitGenerator &input, unsigned order);
00092 AmbisonicRotator(UnitGenerator &input, unsigned vorder, unsigned horder);
00093
00094 ~AmbisonicRotator();
00095
00096
00097
00098 void setNthInput(float amount, Axes axis);
00099 void setTilt(float amount);
00100 void setTumble(float amount);
00101 void setRotate(float amount);
00102
00103
00104 virtual void nextBuffer(Buffer &outputBuffer, unsigned outBufNum) throw(CException);
00105
00106 protected:
00107 unsigned mNumFrames;
00108 unsigned mGreaterOrder;
00109 unsigned mNumChannelsGreaterOrder;
00110 unsigned *mChannelIndex;
00111 unsigned *mInputChannelIndex;
00112 bool mShouldRotate, mShouldTurn, mShouldTilt;
00113
00114 private:
00115 Port *mInputPort;
00116
00117 sample mRotate, mTumble, mTilt;
00118 SampleBuffer mSinAngle, mCosAngle;
00119 SampleBufferVector mOutPtr, mInPtr;
00120
00121 void initialize(UnitGenerator &input);
00122
00123
00124 void tiltFirstOrder();
00125 void tiltSecondOrder();
00126 void tiltThirdOrder();
00127
00128 void tumbleFirstOrder();
00129 void tumbleSecondOrder();
00130 void tumbleThirdOrder();
00131
00132
00133
00134 void rotateZerothOrder();
00135 void rotateFirstOrderHorizontal();
00136 void rotateSecondOrderHorizontal();
00137 void rotateThirdOrderHorizontal();
00138 void rotateFirstOrderVertical();
00139 void rotateSecondOrderVertical();
00140 void rotateThirdOrderVertical();
00141 };
00142
00143 }
00144
00145 #endif