16 #define INV_SQRT2 (1/1.414213562)
75 for (
unsigned i = 0; i <
mSpeakers.size(); ++i)
85 if (filePath != NULL) {
87 char lineBuffer[1024];
88 char *file = (
char *) malloc(strlen(filePath));
89 strcpy(file, filePath);
90 const char *cartesian =
"CARTESIAN";
91 const char *degrees =
"SPHERICAL-DEGREES";
92 const char *normal =
"WITH-NORMAL";
93 bool isCartesian =
false;
94 bool isDegrees =
false;
95 bool withNormal =
false;
100 ifstream inputFile(file, ios::in);
106 while ((testChar = inputFile.peek()) != EOF) {
107 if (testChar ==
'/') {
108 inputFile.getline(lineBuffer, 1023);
110 }
else if (testChar ==
' ' || testChar ==
'\t' || testChar ==
'\n') {
112 }
else if ( ! isdigit(testChar) && testChar !=
'-') {
113 inputFile.get(lineBuffer, 32);
114 if ( ! strcmp(lineBuffer, cartesian)) isCartesian =
true;
115 if ( ! strcmp(lineBuffer, degrees)) isDegrees =
true;
116 if ( ! strcmp(lineBuffer, normal)) withNormal =
true;
120 inputFile >> tempSpeaker.
x >> tempSpeaker.
y >> tempSpeaker.
z >> tempNormal.
x >> tempNormal.
y >> tempNormal.
z >> tempGain;
121 this->
addSpeaker(tempSpeaker.
x, tempSpeaker.
y, tempSpeaker.
z, tempNormal.
x, tempNormal.
y, tempNormal.
z, tempGain);
124 inputFile >> tempSpeaker.
x >> tempSpeaker.
y >> tempSpeaker.
z;
125 this->
addSpeaker(tempSpeaker.
x, tempSpeaker.
y, tempSpeaker.
z);
151 float scaleAz = azimuth *
CSL_PI/180.0;
152 float scaledEl = elevation *
CSL_PI/180.0;
166 Speaker * newSpeaker =
new Speaker(x,y,z,xNorm,yNorm,zNorm, gain);
171 cout <<
" Pos = " << x <<
" "<< y <<
" "<< z <<
" Norm = " << xNorm <<
" " << yNorm <<
" " << zNorm << endl;
179 unsigned nnumSpeakers =
mSpeakers.size();
185 float theRadius = radius;
187 float tempRadius = 0;
189 for (
unsigned i = 0; i < nnumSpeakers; i++) {
191 if (tempRadius > theRadius)
192 theRadius = tempRadius;
196 for (
unsigned i = 0; i < nnumSpeakers; i++) {
205 unsigned nnumSpeakers =
mSpeakers.size();
206 cout <<
"Number of Loudspeakers: " << nnumSpeakers << endl;
207 for (
unsigned i = 0; i < nnumSpeakers; i++) {
208 cout <<
"Speaker #" << i <<
": ";
216 if (
this != &layout) {
217 unsigned nnumSpeakers =
mSpeakers.size();
219 for (
unsigned i = 0; i < nnumSpeakers; ++i)
224 for (
unsigned i = 0; i < nnumSpeakers; ++i) {
225 tempSpeaker =
new Speaker(0, 0);
246 Speaker::Speaker(
float x,
float y,
float z,
float xNorm,
float yNorm,
float zNorm,
float gain)
250 float spNormX,spNormY,spNormZ;
253 spNormX = xNorm - x; spNormY = yNorm - y; spNormZ = zNorm - z;
255 float mag = sqrt(spNormX * spNormX + spNormY * spNormY + spNormZ * spNormZ);
262 mag = sqrt(x * x + y * y + z * z);
277 <<
"\tDistance: " <<
radius() << endl;