00001 /* 00002 * SpatialSource.h 00003 * CSL 00004 * 00005 * Created by Jorge Castellanos on 6/16/06. 00006 * Copyright 2006 Jorge Castellanos. All rights reserved. 00007 * 00008 */ 00009 00012 00013 #ifndef SOUND_SOURCE_H 00014 #define SOUND_SOURCE_H 00015 00016 #include "CSL_Core.h" 00017 #include "CPoint.h" 00018 00019 namespace csl { 00020 00021 //class SpatialProperties { 00022 //public: 00023 // SpatialProperties() : mPosition(0.f), mRoot(NULL), mPositionChanged(true) {}; 00024 // ~SpatialProperties() {}; 00025 // 00026 // float mPosition; 00027 // UnitGenerator *mRoot; 00028 // bool mPositionChanged; //< true if this source's position has changed 00029 // 00030 //}; 00031 00033 class SpatSource : public UnitGenerator, public virtual Scalable { 00034 public: 00035 SpatSource(); 00036 SpatSource(UnitGenerator &input, float azi = 0.0, float ele = 0.0, float dist = 1.0); 00037 virtual ~SpatSource(); 00038 00040 virtual void setPosition(float x = 0., float y = 0., float z = 0.); 00042 virtual void setPosition(char s, float azi = 0, float ele = 0, float dist = 1.0) ; 00043 00044 // void setOrientation(float horizontalAngle, float verticalAngle); // Specify what direction is the object facing 00045 // void setDirectivity(float innerConeAngle, float outerConeAngle); // This is the actual sound radiation pattern of the sound object. 00046 00048 00049 float azimuth() { return mPosition->theta(); }; 00050 float elevation() { return mPosition->ele(); }; 00051 float distance() { return mPosition->r(); }; 00052 00053 CPoint *position(unsigned channelNum = 0); 00054 00056 bool positionChanged() { return mPositionChanged; }; 00057 00058 virtual void nextBuffer(Buffer & outputBuffer, unsigned outBufNum) throw (CException); 00059 virtual void nextBuffer(Buffer & outputBuffer) throw (CException); 00060 00061 void dump(); 00062 00063 protected: 00064 CPoint *mPosition; 00065 // float mInnerCone; 00066 // float mOuterCone; 00067 // float mHorizontalOrientation; 00068 // float mVerticalOrientation; 00069 00070 bool mPositionChanged; //< true if this source's position has changed 00071 00072 }; 00073 00074 /* 00075 DESIGN THOUGHTS: 00076 Possibly Source could be called PositionableSource and be the base class of other Spatial Sources. 00077 For example, a subclass could include directivity and radiation pattern, wich is less common than position 00078 Also, different ways of sound radiation could be implemented by subclasses. 00079 00080 A second option is to specify sound radiation directly to the object that does the actual computation. 00081 This way the different processors could accept their very particular way of doing things. 00082 This approach would break with the concept of having the sound source KNOW its own characteristics. 00083 Cons: not only the processors of directivity, but also procesors of room acoustics would make use of 00084 such info, so user would have to specify it twice (this could be a feature, as it would allow different 00085 types, one simpler for reflections, and a possibly complex one for the direct sound. 00086 00087 Maybe the answer is that sound radiation is not just a record class, but it responds with an actual value 00088 (or filter?) when asked for the value at x angle. That way the different types of pattern would know how to 00089 do their shit, but mantaining a common interface and return type, so it can be processed. 00090 00091 Or.. should I just decide for one method and stick to it? That would defeat the purpose of an extensible 00092 framework made to be used for research, as well as for making content. 00093 00094 */ 00095 00096 00097 } 00098 00099 #endif
1.4.5-20051010