SpeakerLayout.h

Go to the documentation of this file.
00001 
00005 /*
00006  *  Created by Jorge Castellanos on 6/16/06.
00007  *  Copyright 2006 Jorge Castellanos. All rights reserved.
00008  */
00009 
00010 
00011 #ifndef SPEAKERLAYOUT_H
00012 #define SPEAKERLAYOUT_H
00013 
00014 #include "CSL_Core.h"
00015 #include "CPoint.h"
00016 
00017 namespace csl {
00018 
00019 class Speaker; // Forward declaration. See below.
00020 
00042 class SpeakerLayout : public Model {
00043 public:
00044     // Constructors & destructor:
00045     SpeakerLayout(char *filePath = NULL);   
00046     ~SpeakerLayout();               
00047 
00049     static SpeakerLayout *defaultSpeakerLayout();
00051     static void setDefaultSpeakerLayout(SpeakerLayout *defalutLayout);
00052     
00054     void addSpeaker(float azimuth, float elevation = 0.0, float radius = 1.0);
00055 
00056     unsigned numSpeakers() const { return mSpeakers.size(); };  
00057 
00060     void normalizeSpeakerDistances(float radius = 0);
00061     
00063     Speaker *speakerAtIndex(unsigned speakerIndex) const { return mSpeakers[speakerIndex]; };
00064 
00065     bool isPeriphonic() { return (mDimensions == 3); }; 
00066     void dump();
00067 
00068 private:
00069     vector<Speaker *> mSpeakers;        
00070     unsigned mDimensions;
00071 //  void cartesianToSphericalRadians(); // convert speaker layout given in cartesian coordinates to spherical radians
00072     static SpeakerLayout *sDefaultSpeakerLayout;
00073     float *mSpeakerDistanceDeltas; 
00074     
00075 public:
00076     SpeakerLayout &operator=(const SpeakerLayout &layout); 
00077 };
00078 
00079 
00081 class StereoSpeakerLayout : public SpeakerLayout {
00082 public:
00083     StereoSpeakerLayout();
00084 
00085 };
00086 
00087 
00089 class Speaker {
00090 public:
00094     Speaker(float azimuth = 0.0, float elevation = 0.0, float radius = 1.0) :  mPosition('s', radius, azimuth, elevation) {};
00095     ~Speaker() {};
00096     
00097     CPoint position()   { return mPosition; }; // Return the position of the speaker.
00098     float azimuth()     { return mPosition.theta(); };
00099     float elevation()   { return mPosition.ele(); };
00100     float radius()      { return mPosition.r(); };
00101     void setRadius(float radius); 
00102     
00103     void dump(); 
00104 
00105 protected:
00106     CPoint mPosition;
00107     
00108 }; 
00109 
00110 //class RingBuffer;
00111 
00112 //class ActiveSpeakerLayout : public Effect, public SpeakerLayout  {
00113 //public:
00114 //  ActiveSpeakerLayout(UnitGenerator &input, char *filePath = NULL) {}; ///< Optionally reads loudspeaker layout from file
00115 //  ~ActiveSpeakerLayout() {};
00116 //  
00117 //  setSpeakerDistanceCompensation(bool shouldCompensate) { mCompensatesForDistance = shouldCompensate; };
00118 //  setRemapsChannels(bool remapIOChannels) { mRemapsChannels = remapIOChannels; };
00119 //
00120 //  virtual void nextBuffer(Buffer & outputBuffer, unsigned outBufNum) throw (Exception);
00121 //  
00122 //private:
00123 //  bool mCompensatesForDistance;
00124 //  bool mRemapsChannels;
00126 //  
00127 //};
00128 
00129 }
00130 
00131 #endif

Generated on Fri Apr 6 20:18:14 2007 for CSL by  doxygen 1.4.5-20051010