00001 /* 00002 00003 HOA_SpeakerLayout.h -- Higher Order Ambisonic speaker layout 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 loading and parsing loudspeaker position information used by the "HOA_Decoder" class. 00008 Loudspeaker layouts should be provided as textfiles folowing the following format: 00009 -> A / indicates the start of a comment, which lasts until the end of the line (??????????????????????). 00010 -> The Keywords CARTESIAN, SPHERICAL-DEGREES, SPHERICAL-RADIANS are used to specify the format of the provided speaker positions. 00011 The class will do necessary conversions to the internal representation in spherical radians. 00012 If no keyword is specified, spherical radians are assumed(??????????????????????). 00013 -> Non-comment or non-keyword lines should contain speaker position information as three tab-separated coordinates. 00014 Each line will be interpreted as a new speaker. 00015 Examples of parsable speaker layout files are provided with the code (.dat files). 00016 00017 */ 00018 00019 #ifndef HOA_SPEAKERLAYOUT_H 00020 #define HOA_SPEAKERLAYOUT_H 00021 00022 #include "CSL_Core.h" 00023 #include "Variable.h" 00024 #include "CPoint.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 // a type to represent speaker position, relative to listener 00066 typedef struct speaker 00067 { 00068 float coord1, coord2, coord3; 00069 }; 00070 00071 class HOA_SpeakerLayout { 00072 00073 private: 00074 unsigned int mNumSpeakers; // the number of loudspeakers in the layout 00075 speaker *mSpeakers; // pointer to the loudspeakers 00076 char *file; // pointer to the speaker layout file 00077 void cartesianToSphericalRadians(); // convert speaker layout given in cartesian coordinates to spherical radians 00078 00079 public: 00080 00081 // Constructors & destructor: 00082 HOA_SpeakerLayout(); // default constructor, uses regular tetrahedron with 4 speakers 00083 HOA_SpeakerLayout(char *filePath); // reads loudspeaker layout from file 00084 ~HOA_SpeakerLayout(); // destructor 00085 00086 int getNumSpeakers(); // getter for the number of loudspeakers in the layout 00087 speaker getSpeaker(int n); 00088 00089 void limitSpeakers(int n) { mNumSpeakers = n; }; // ignore extra speakers if there are more than n defined 00090 00091 00092 }; 00093 00094 } 00095 00096 #endif
1.4.5-20051010