SpeakerLayout.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008 #ifndef SPEAKERLAYOUT_H
00009 #define SPEAKERLAYOUT_H
00010
00011 #include "CSL_Core.h"
00012 #include "CPoint.h"
00013
00014 namespace csl {
00015
00016 class Speaker;
00017
00039 class SpeakerLayout : public Model {
00040 public:
00041
00042 SpeakerLayout(const char *filePath = NULL);
00043 virtual ~SpeakerLayout();
00044
00046 void readSpeakerFile(const char *filePath);
00047
00049 static SpeakerLayout *defaultSpeakerLayout();
00051 static void setDefaultSpeakerLayout(SpeakerLayout *defaultLayout);
00052
00054 void addSpeaker(float azimuth, float elevation = 0.0, float radius = 1.0);
00056 void addSpeaker(float x, float y, float z, float xNorm, float yNorm, float zNorm, float gain);
00057
00058 unsigned numSpeakers() const { return mSpeakers.size(); };
00059
00062 void normalizeSpeakerDistances(float radius = 0);
00063
00065 Speaker *speakerAtIndex(unsigned speakerIndex) const { return mSpeakers[speakerIndex]; };
00066
00067 bool isPeriphonic() { return (mDimensions == 3); };
00068 void dump();
00069
00070 protected:
00071 vector<Speaker *> mSpeakers;
00072
00073
00074 private:
00075 unsigned mDimensions;
00076
00077 static SpeakerLayout *sDefaultSpeakerLayout;
00078 float *mSpeakerDistanceDeltas;
00079
00080 public:
00081 SpeakerLayout &operator=(const SpeakerLayout &layout);
00082 };
00083
00085
00086 class StereoSpeakerLayout : public SpeakerLayout {
00087 public:
00088 StereoSpeakerLayout();
00089 };
00090
00091
00093 class Speaker {
00094 public:
00098 Speaker(float azimuth, float elevation, float radius = 1.0);
00099
00100
00101 Speaker(float x, float y, float z, float xNorm, float yNorm, float zNorm, float gain = 1.0);
00102
00103 ~Speaker() { };
00104
00105 CPoint position() { return mPosition; };
00106 float azimuth() { return mPosition.theta(); };
00107 float elevation() { return mPosition.ele(); };
00108 float radius() { return mPosition.r(); };
00109 void setRadius(float radius);
00110
00111 CPoint normal() { return mNormal; };
00112 float speakerGain() { return mGain;};
00113
00114 void dump();
00115
00116 protected:
00117 CPoint mPosition;
00118 CPoint mNormal;
00119 float mGain;
00120 };
00121
00122 }
00123
00124 #endif