HOA_Rotator.h

Go to the documentation of this file.
00001 /*
00002 
00003 HOA_Rotator.h -- Higher Order Ambisonic rotator class
00004 See the copyright notice and acknowledgment of authors in the file COPYRIGHT
00005 Higher Order Ambisonic classes written by Jorge Castellanos, Graham Wakefield, Florian Hollerweger, 2005
00006 
00007 Higher Order Ambisonic class for rotating an Ambisonic encoded sound field (e.g. the output of the HOA_Encoder)
00008 around any combination of x, y and z axes. Rotation is applied by using the method "setNthInput" with the flags
00009 HOA_TILT, HOA_TUMBLE, HOA_ROTATE as desired. The order of the incoming Ambisonic framestream can be degraded to
00010 match the maximum order of the available decoding system (number of available speakers). It is possible to specify
00011 either one uniform Ambisonic order or to define the horizontal and vertical order separately (hybrid order rotating).
00012 If no order(s) is/are specified, the order(s) of the Ambisonic encoded input framestream will be used.
00013 
00014 
00015 */
00016 
00017 #ifndef HOA_ROTATOR_H
00018 #define HOA_ROTATOR_H
00019 
00020 #include "CSL_Core.h"
00021 #include "Variable.h"
00022 #include "CPoint.h"
00023 #include "HOA_Utilities.h"
00024 #include "HOA_AmbisonicFramestream.h"
00025 
00026 namespace csl {
00027 
00028 /*
00029 
00030 CONVENTIONS USED IN THIS CODE:
00031 ------------------------------
00032 
00033 ***coordinate system***
00034 Left oriented
00035 Azimuth = 0 on the x/z plane and increasing towards the positive y direction
00036 Elevation = 0 on x/y plane and increasing towards the positive z direction
00037 Internal angle representation: spherical radians
00038 
00039 ***encoding convention***
00040 following the Furse-Malham set (Ambisonic channel weighting for uniform energy distribution)
00041 
00042 ***abbreviations used in code and comments***
00043 M   ... Ambisonic order (in uniform order system)
00044 M_h ... horizontal Ambisonic order (in hybrid order systems)
00045 M_v ... horizontal Ambisonic order (in hybrid order systems)
00046 N   ... total number of Ambisonic encoded channels (horizontal and vertical)
00047 N_h ... number of horizontal Ambisonic channels (in hybrid order systems)
00048 N_v ... number of vertical Ambisonic channels (in hybrid order systems)
00049 L   ... number of available loudspeakers
00050 
00051 ***ordering and naming of Ambisonic channels = spherical harmonics***
00052 These conventions follow the ones used in the thesis by Jerome Daniel.
00053 The 3rd order naming convention (which Daniel doesn't provide) follows the one used in the thesis of David Malham.
00054 Watch out for different conventions in other papers!
00055 index           0   1   2   3   4   5   6   7   8   9   10  11  12  13  14  15
00056 M (order)       0   1   1   1   2   2   2   2   2   3   3   3   3   3   3   3
00057 m (=M)          0   1   1   1   2   2   2   2   2   3   3   3   3   3   3   3
00058 n               0   1   1   0   2   2   1   1   0   3   3   2   2   1   1   0
00059 sigma           '1' 1   -1  '1' 1   -1  1   -1  '1' 1   -1  1   -1  1   -1  '1'
00060 name            W   X   Y   Z   U   V   S   T   R   P   Q   N   O   L   M   K
00061 hor/vert/omni   om  h   h   v   h   h   v   v   v   h   h   v   v   v   v   v
00062 
00063 */
00064 
00065 typedef enum {
00066     HOA_TILT = 0, HOA_TUMBLE, HOA_ROTATE    // to be used with the "setNthInput" method to add control sources
00067 } Axes;                                     // tilt -> x axis, tumble -> y axis, rotate -> z axis
00068 
00069 
00070 class HOA_Rotator : public FrameStream, public Processor, public HOA_AmbisonicFramestream {
00071 private:
00072 
00073     sample mRotate, mTumble, mTilt;                 // the current amount of rotation in each axis (in radians)
00074     sample *mSinAngle, *mCosAngle;                  // Used to hold sines/cosines of tilt, tumble, rotate angles during audio processing
00075     sample **mOutPtr, **mInPtr;                     // pointers to Ambisonic encoded input and Ambisonic encoded & rotated output buffers
00076     sample mTemp1, mTemp2, mTemp3, mTemp4, mTemp5;  // temp variables used in audio processing (to avoid creating temporaries during DSP)
00077     int mNumFrames;                                 // current block size
00078     
00079     void initialize(FrameStream &input);    
00080     
00081     // functions for tilt, tumble & rotate at each order
00082     void tiltFirstOrder();
00083     void tiltSecondOrder();
00084     void tiltThirdOrder();
00085     
00086     void tumbleFirstOrder();
00087     void tumbleSecondOrder();
00088     void tumbleThirdOrder();
00089     
00090     // methods for rotation at each order
00091     // separated by horizontal & vertical for hybrid order systems (which can be rotated, but not tilted or tumbled)
00092     void rotateZerothOrder();
00093     void rotateFirstOrderHorizontal();  
00094     void rotateSecondOrderHorizontal();
00095     void rotateThirdOrderHorizontal();
00096     void rotateFirstOrderVertical();    
00097     void rotateSecondOrderVertical();
00098     void rotateThirdOrderVertical();
00099 
00100                 
00101 protected:
00102 
00103     unsigned mNumChannels;          // the number of Ambisonic channels.
00104     unsigned mNumControlChannels;   // how many control inputs to use (3 for uniform, 1 for hybrid order)
00105     unsigned *mChannelIndex;        // index to the output buffer in the encoding functions.
00106     unsigned *mInputChannelIndex;   // index to the input buffer in the encoding functions (in case input order != output order)
00107     bool rotBool, tumBool, tilBool; // flags to note whether rotation in each axis is being used
00108     Buffer *mInBuffer;              // Ambisonic encoded multi-channel audio input
00109     Buffer *mCtrlBuffer;            // the buffers of input control data (tilt, tumble, rotation angles)
00110     FrameStream **mCtrlPtr;         // input controllers for tilt, tumble and rotation.
00111      
00112 public:
00113     
00114     // Constructors & destructor:
00115     
00116     // default constructor, initializes to 1st order with no rotation 
00117     HOA_Rotator();
00118     
00119     // initializes with no rotation
00120     HOA_Rotator(FrameStream &input);
00121     
00122     // initializes with uniform Ambisonic order and no rotation
00123     HOA_Rotator(FrameStream &input, unsigned order);
00124     
00125     // initializes with hybrid Ambisonic  order and no rotation
00126     HOA_Rotator(FrameStream &input, unsigned vorder, unsigned horder);
00127     ~HOA_Rotator(); // destructor
00128     
00129     
00130     // set control input sources according axis flag
00131     void setNthInput(float input, Axes axis);
00132     void setTilt(float input);
00133     void setTumble(float input);
00134     void setRotate(float input);
00135     
00136     // Overriding Framestream::next_buffer(). Does the DSP processing for the Ambisonic Rotator.
00137     virtual status next_buffer(Buffer &inputBuffer, Buffer &outputBuffer);
00138     
00139 };
00140 
00141 }
00142 
00143 #endif

Generated on Fri Apr 6 20:18:13 2007 for CSL by  doxygen 1.4.5-20051010