00001
00002
00003
00004
00005
00006 #ifndef CSL_VBAP_H
00007 #define CSL_VBAP_H
00008
00009 #include "CSL_Core.h"
00010 #include "Panner.h"
00011
00012
00013
00014 #include <iostream>
00015
00017 #define _NO_EXCEPTION
00018
00019 #include "matrix.h"
00020
00021 #ifndef _NO_NAMESPACE
00022 using namespace std;
00023 using namespace math;
00024 # define STD std
00025 #else
00026 # define STD
00027 #endif
00028
00029 # define TRYBEGIN()
00030 # define CATCHERROR()
00031
00032 typedef matrix<double> CSLMatrix;
00034
00035 namespace csl {
00036
00037 #define deg2rad(x) ( ( (double)x ) * CSL_TWOPI) / 360.0
00038
00040 typedef enum {
00041 kAuto = 0,
00042 kPantophonic = 2,
00043 kPeriphonic = 3
00044 } VBAPMode;
00045
00046 class SpeakerSetLayout;
00047
00048
00050
00055 class VBAP : public Panner {
00056 public:
00059 VBAP(VBAPMode mode = kAuto, SpeakerLayout *layout = SpeakerLayout::defaultSpeakerLayout());
00060
00061 virtual ~VBAP();
00062
00064 void nextBuffer(Buffer &outputBuffer, unsigned outBufNum) throw (CException);
00065
00066 void dump() {};
00067
00068 protected:
00069 VBAPMode mMode;
00070 SpeakerSetLayout *mSpeakerSetLayout;
00071
00072 virtual void *cache();
00073 virtual void speakerLayoutChanged();
00074
00075 };
00076
00079 class StereoPanner : public VBAP {
00080 public:
00081 StereoPanner();
00082 virtual ~StereoPanner();
00083
00084 void addInput(UnitGenerator &input, float panPosition);
00085
00086 };
00087
00090 class SurroundPanner : public VBAP {
00091 public:
00093 SurroundPanner(unsigned numSpeakers = 5, bool useSubwoofer = true);
00094 virtual ~SurroundPanner();
00095
00096 };
00097
00098
00099
00100 class VBAPSourceCache {
00101 public:
00102 VBAPSourceCache() : tripletIndex(0) {};
00103 ~VBAPSourceCache() {};
00104
00105 float gains[3];
00106 unsigned tripletIndex;
00107 };
00108
00110 class SpeakerSet {
00111 public:
00112 SpeakerSet(unsigned size = 3);
00113 ~SpeakerSet();
00114
00115 unsigned *nodes;
00116 CSLMatrix *invL;
00117 void dump();
00118 };
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140
00141
00142
00143
00144
00145 class SpeakerSetLayout {
00146 friend class VBAP;
00147 public:
00149 SpeakerSetLayout(SpeakerLayout *aLayout, VBAPMode mode = kAuto);
00150 ~SpeakerSetLayout();
00151
00153 SpeakerLayout *speakerLayout() { return mSpeakerLayout; };
00154
00155 void dump();
00156
00157 private:
00158
00159 SpeakerSet **mTriplets;
00160 SpeakerLayout *mSpeakerLayout;
00161 unsigned mNumTriplets;
00162 unsigned mMode;
00163
00164 void findSpeakerTriplets() throw(CException);
00165 void findSpeakerPairs() throw(CException);
00166 void invertTripleMatrix(SpeakerSet *lst);
00167 void addTriple( SpeakerSet *lst);
00168 void removeTriple(SpeakerSet *lst);
00169 bool evaluateCrossing( CPoint &li, CPoint &lj, CPoint &ln, CPoint &lm);
00170 };
00171
00172
00173 }
00174
00175 #endif
00176