00001
00002
00003
00004
00005
00006
00007 #ifndef CSL_VBAP_H
00008 #define CSL_VBAP_H
00009
00010 #include "CSL_Core.h"
00011 #include "SpatialPanner.h"
00012
00013
00014
00015 #define MAX_NUM_VBAP_SOURCES 8
00016
00017 #include <iostream>
00018
00020 #define _NO_EXCEPTION
00021
00022 #include "matrix.h"
00023
00024 #ifndef _NO_NAMESPACE
00025 using namespace std;
00026 using namespace math;
00027 # define STD std
00028 #else
00029 # define STD
00030 #endif
00031
00032 # define TRYBEGIN()
00033 # define CATCHERROR()
00034
00035 typedef matrix<double> CSLMatrix;
00037
00038 namespace csl {
00039
00040 #define deg2rad(x) (((double)x ) * CSL_TWOPI) / 360.0
00041
00043 typedef enum {
00044 kAuto = 0,
00045 kPantophonic = 2,
00046 kPeriphonic = 3
00047 } VBAPMode;
00048
00049 class SpeakerSetLayout;
00050
00051
00053
00058 class VBAP : public SpatialPanner {
00059 public:
00062 VBAP(VBAPMode mode = kAuto, SpeakerLayout *layout = SpeakerLayout::defaultSpeakerLayout());
00063
00064 virtual ~VBAP();
00065
00067 void nextBuffer(Buffer &outputBuffer, unsigned outBufNum) throw (CException);
00068
00069 void dump() { };
00070
00071 protected:
00072 VBAPMode mMode;
00073 SpeakerSetLayout *mSpeakerSetLayout;
00074
00075 virtual void *cache();
00076 virtual void speakerLayoutChanged();
00077
00078 };
00079
00082 class StereoPanner : public VBAP {
00083 public:
00084 StereoPanner();
00085 virtual ~StereoPanner();
00086
00087 void addInput(UnitGenerator &input, float panPosition);
00088
00089 };
00090
00093 class SurroundPanner : public VBAP {
00094 public:
00096 SurroundPanner(unsigned numSpeakers = 5, bool useSubwoofer = true);
00097 virtual ~SurroundPanner();
00098
00099 };
00100
00101
00102
00103 class VBAPSourceCache {
00104 public:
00105 VBAPSourceCache() : tripletIndex(0) { };
00106 ~VBAPSourceCache() { };
00107
00108 float gains[3];
00109 unsigned tripletIndex;
00110 };
00111
00113 class SpeakerSet {
00114 public:
00115 SpeakerSet(unsigned size = 3);
00116 ~SpeakerSet();
00117
00118 unsigned *nodes;
00119 CSLMatrix *invL;
00120 void dump();
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
00146
00147
00148 class SpeakerSetLayout {
00149 friend class VBAP;
00150 public:
00152 SpeakerSetLayout(SpeakerLayout *aLayout, VBAPMode mode = kAuto);
00153 ~SpeakerSetLayout();
00154
00156 SpeakerLayout *speakerLayout() { return mSpeakerLayout; };
00157
00158 void dump();
00159
00160 private:
00161
00162 SpeakerSet **mTriplets;
00163 SpeakerLayout *mSpeakerLayout;
00164 unsigned mNumTriplets;
00165 unsigned mMode;
00166
00167 void findSpeakerTriplets() throw(CException);
00168 void findSpeakerPairs() throw(CException);
00169 void invertTripleMatrix(SpeakerSet *lst);
00170 void addTriple(SpeakerSet *lst);
00171 void removeTriple(SpeakerSet *lst);
00172 bool evaluateCrossing(CPoint &li, CPoint &lj, CPoint &ln, CPoint &lm);
00173 };
00174
00175 }
00176
00177 #endif
00178