00001 /* 00002 00003 HOA_Mixer.h -- Higher Order Ambisonic mixing 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 mixing encoded ambisonic encoded audio streams. All incoming streams should have 00008 the same order; the order used is derived from the first stream added. 00009 00010 */ 00011 00012 #ifndef HOA_MIXER_H 00013 #define HOA_MIXER_H 00014 00015 #include "CSL_Core.h" 00016 #include "Variable.h" 00017 #include "CPoint.h" 00018 #include "HOA_Utilities.h" 00019 #include "HOA_AmbisonicFramestream.h" 00020 00021 namespace csl { 00022 00023 /* 00024 00025 CONVENTIONS USED IN THIS CODE: 00026 ------------------------------ 00027 00028 ***coordinate system*** 00029 Left oriented 00030 Azimuth = 0 on the x/z plane and increasing towards the positive y direction 00031 Elevation = 0 on x/y plane and increasing towards the positive z direction 00032 Internal angle representation: spherical radians 00033 00034 ***encoding convention*** 00035 following the Furse-Malham set (Ambisonic channel weighting for uniform energy distribution) 00036 00037 ***abbreviations used in code and comments*** 00038 M ... Ambisonic order (in uniform order system) 00039 M_h ... horizontal Ambisonic order (in hybrid order systems) 00040 M_v ... horizontal Ambisonic order (in hybrid order systems) 00041 N ... total number of Ambisonic encoded channels (horizontal and vertical) 00042 N_h ... number of horizontal Ambisonic channels (in hybrid order systems) 00043 N_v ... number of vertical Ambisonic channels (in hybrid order systems) 00044 L ... number of available loudspeakers 00045 00046 ***ordering and naming of Ambisonic channels = spherical harmonics*** 00047 These conventions follow the ones used in the thesis by Jerome Daniel. 00048 The 3rd order naming convention (which Daniel doesn't provide) follows the one used in the thesis of David Malham. 00049 Watch out for different conventions in other papers! 00050 index 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 00051 M (order) 0 1 1 1 2 2 2 2 2 3 3 3 3 3 3 3 00052 m (=M) 0 1 1 1 2 2 2 2 2 3 3 3 3 3 3 3 00053 n 0 1 1 0 2 2 1 1 0 3 3 2 2 1 1 0 00054 sigma '1' 1 -1 '1' 1 -1 1 -1 '1' 1 -1 1 -1 1 -1 '1' 00055 name W X Y Z U V S T R P Q N O L M K 00056 hor/vert/omni om h h v h h v v v h h v v v v v 00057 00058 */ 00059 00060 class HOA_Mixer : public FrameStream, public HOA_AmbisonicFramestream { 00061 00062 protected: 00063 00064 unsigned mNumInputs; // the number of ambisonic-encoded inputs 00065 sample mInvNumInputs; // the inverse of the number of inputs (used for normalization) 00066 unsigned mMaxInputs; // the maximum no. of inputs this mixer will accept. 00067 unsigned mNumFrames; // blocksize 00068 sample *mInPtr; // pointer to input buffers (sound sources to be encoded) 00069 sample **mOutPtr; // pointer to Ambisonic encoded output buffers 00070 00071 FrameStream ** mInputs; // list of inputs, arbitrary # of channels 00072 unsigned _num_inputs; // number of active inputs 00073 00074 Buffer *mInBuffer; // buffer for the input framestream 00075 00076 public: 00077 00078 // Constructors & destructor: 00079 00080 // default constructor 00081 HOA_Mixer(unsigned maxInputs = 64); 00082 00083 // initialize with one input, derive the Mixer ambisonic order from this input 00084 HOA_Mixer(FrameStream &input, unsigned maxInputs = 64); 00085 00086 // destructor 00087 ~HOA_Mixer(); 00088 00089 // initializing method called by constructors 00090 void initialize(unsigned maxInputs); 00091 00092 // methods for adding/removing another input to the mixer 00093 bool addInput(FrameStream &input); 00094 00095 unsigned getNumInputs(void) { return mNumInputs; }; // number of active inputs 00096 00097 // Overriding Framestream::next_buffer(). Does the DSP processing for the Ambisonic Mixer. 00098 virtual status next_buffer(Buffer &inputBuffer, Buffer &outputBuffer); 00099 00100 }; 00101 00102 } 00103 00104 #endif
1.4.5-20051010