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;
void logMsg(const char *format,...)
These are the public logging messages.
static SpeakerLayout * sDefaultSpeakerLayout
virtual ~SpeakerLayout()
destructor
float * mSpeakerDistanceDeltas
Holds the diference of the optimal speaker distance and the real one. Only used if distances are norm...
AdditiveInstrument.h – Sum-of-sines synthesis instrument class.
Speaker * speakerAtIndex(unsigned speakerIndex) const
Returns the speaker at the specified index.
void normalizeSpeakerDistances(float radius=0)
Returns the number of loudspeakers in the layout.
Speaker(float azimuth, float elevation, float radius=1.0)
Speaker constructor. The speaker class should only be used by the speaker layout. Clients should modi...
SpeakerLayout(const char *filePath=NULL)
Creates an empty speaker layout. Optionally reads loudspeaker layout from file.
void readSpeakerFile(const char *filePath)
Reads the speaker listing file according to the specification.
void changed(void *argument)
this is what I send to myself to notify my observers; It's not overridden in general. It results in the observers receiving update() calls < override evaluate to filter updates to the observer map
Represents a speaker as a position relative to the center of a space.
void dump()
Print speaker information.
vector< Speaker * > mSpeakers
Vector of pointers to the loudspeakers.
static void setDefaultSpeakerLayout(SpeakerLayout *defaultLayout)
Use it to set a layout as default. Clients (e.g. a Panner) can then make use of this layout...
void dump()
If any of the speakers in the layout has an elevation other than 0, it returns true.
unsigned numSpeakers() const
static SpeakerLayout * defaultSpeakerLayout()
Returns a pointer to the default layout. If no default exists, it creates one.
void setRadius(float radius)
Specify the distance from the center of the coordinate space to the speaker.
void addSpeaker(float azimuth, float elevation=0.0, float radius=1.0)
Add a speaker specifying its position in degrees from the center of the listening space...
SpeakerLayout & operator=(const SpeakerLayout &layout)
Overloaded "=" operator allows copying the layout.
Standard "Stereo Speaker Layout", where two speakers are positioned 30¼ left, 30¼ right and no elevat...