SpeakerLayout.h

Go to the documentation of this file.
00001 //
00002 //  SpeakerLayout.h -- Class for loading and parsing loudspeaker position information used 
00003 //      by the Spatializer and Auralizer classes.
00004 //  See the copyright notice and acknowledgment of authors in the file COPYRIGHT
00005 //  Created by Jorge Castellanos on 6/16/06. Hacked 8/09 by STP.
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;      // Forward declaration. See below.
00017 
00039 class SpeakerLayout : public Model {
00040 public:
00041     // Constructors & destructor:
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 //  void cartesianToSphericalRadians(); // convert speaker layout given in cartesian coordinates to spherical radians
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     // constructor with normal point. x,y,z are position, xNorm,yNorm,zNorm are a point to which the speaker is facing. converted to a normalized vector by Speaker class.
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; }; // Return the position of the speaker.
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; }; // Return the normal of the speaker.
00112     float speakerGain()     { return mGain;};
00113     
00114     void dump(); 
00115 
00116 protected:
00117     CPoint mPosition;
00118     CPoint mNormal; // normal vector for speaker
00119     float mGain;    // a speaker dependant gain, defaults to 1.
00120 }; 
00121 
00122 }
00123 
00124 #endif

Generated on Thu Sep 17 23:14:16 2009 for CSL by  doxygen 1.5.8