CSL_Types.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00042
00043 #ifndef CSL_Types_H // All CSL header files can be included only once.
00044 #define CSL_Types_H // That's what these flags are for.
00045
00047
00048 #ifdef Linux // Linux
00049 #define CSL_LINUX
00050 #endif
00051
00052 #ifdef WIN32 // M$_Windows
00053 #define CSL_WINDOWS
00054 #endif
00055
00056 #if defined (__APPLE__) // Mac OSX
00057 #define CSL_MACOSX
00058 #endif
00059
00061
00062 #define CSL_ENUMS // define this to use the various enumerations (which are problematic with SWIG)
00063
00064
00065
00066
00067 #ifndef CSL_WINDOWS
00068 #define DO_TIMING // Gather performance statistics (not on Windows)
00069 #endif
00070
00071
00073
00074 #define CSL_mFrameRate 44100
00075
00076 #ifdef IPHONE
00077 #define CSL_mBlockSize 256
00078 #define CSL_mMaxBufferFrames 1024
00079 #define CSL_mMaxSndFileFrames 2000000
00080 #else
00081 #define CSL_mBlockSize 256
00082 #define CSL_mMaxBufferFrames 8192
00083 #define CSL_mMaxSndFileFrames 128000000
00084 #endif
00085
00086
00088
00089 #define DEFAULT_WTABLE_SIZE CGestalt::maxBufferFrames() // size of wavetables, or use blockSize?
00090
00091 #define CSL_mVerbosity 3
00092 #define CSL_mLoggingPeriod 10
00093
00094 #define CSL_LOG_PREFIX ":: "
00095 // #define CSL_LOG_PREFIX "\nCSL: "
00096
00097 #define CSL_mOutPort 57123
00098 #define CSL_mOSCPort 54321
00099
00100 #define CSL_NAME_LEN 256
00101 #define CSL_LINE_LEN 512
00102
00103 #define CSL_DATA_DIR "~/Code/CSL/CSL_Data/"
00104 #define SAMPS_TO_WRITE (4096 * 10 * 10)
00105
00106 #define OUT_SFILE_NAME "XX_csl.aiff"
00107 //#define OUT_SFILE_NAME "CSLXX.aiff"
00108
00110
00111 #ifdef USE_JSND
00112 #define SoundFile JSoundFile // JUCE snd file class
00113 #endif
00114 #ifdef USE_LSND
00115 #define SoundFile LSoundFile // libSndFile
00116 #endif
00117 #ifdef USE_CASND
00118 #define SoundFile CASoundFile // CoreAudio
00119 #endif
00120
00121 #define Osc WavetableOscillator // default "Osc" -- or use Sine?
00122
00123
00124
00125
00126
00127
00128
00130
00131 #include <vector>
00132 #include <map>
00133 #include <string>
00134
00135 namespace csl {
00136
00137
00139
00141 typedef float sample;
00142 typedef float Sample;
00143
00144 typedef sample* SampleBuffer;
00145 typedef SampleBuffer* SampleBufferVector;
00146 typedef SampleBuffer* SampleBufferArray;
00147
00148 typedef sample SampleComplex[2];
00149 #define cx_r(val) val[0]
00150 #define cx_i(val) val[1]
00151 #define ComplexPtr SampleBuffer
00152
00153
00154
00155
00156
00157
00158 typedef SampleComplex* SampleComplexVector;
00159 typedef SampleComplex* SampleComplexPtr;
00160
00161 class CPoint;
00162 typedef std::vector <CPoint *> PointVector;
00163
00164 typedef void * VOIDFCNPTR(void* arg) ;
00165
00167
00168 class UnitGenerator;
00169 class Port;
00170 class IODevice;
00171
00172 typedef unsigned CSL_MAP_KEY;
00173
00174
00175 typedef std::map <CSL_MAP_KEY, Port *> PortMap;
00177 typedef std::vector <UnitGenerator *> UGenVector;
00179 typedef std::map <std::string, UnitGenerator *> UGenMap;
00181 typedef std::vector <IODevice *> IODeviceVector;
00182
00183
00185
00186 #define CSL_SCALE 1
00187 #define CSL_OFFSET 2
00188 #define CSL_INPUT 3
00189 #define CSL_OPERAND 4
00190 #define CSL_OPERAND2 5
00191 #define CSL_FREQUENCY 6
00192 #define CSL_POSITION 7
00193 #define CSL_POSITIONX 7
00194 #define CSL_POSITIONY 8
00195 #define CSL_POSITIONZ 9
00196 #define CSL_FILTER_FREQUENCY 10
00197 #define CSL_FILTER_AMOUNT 11
00198 #define CSL_RATE 12
00199
00200
00206
00207 typedef unsigned long Timestamp;
00208
00210
00211 typedef struct {
00212 char * name;
00213 void (* fcn)();
00214 } testStruct;
00215
00216
00218
00219 #ifndef csl_min // csl_min(a, b)
00220 #define csl_min(a, b) (((a) < (b)) ? (a) : (b))
00221 #endif
00222
00223 #ifndef csl_max // csl_max(a, b)
00224 #define csl_max(a, b) (((a) > (b)) ? (a) : (b))
00225 #endif
00226
00227
00228
00229 #define csl_between(a, b, c) (((a) >= (b)) && ((a) <= (c)))
00230
00231
00232
00233 #define csl_max_r(a) (((a) > 1.0f) ? (a) : (1.0f/a))
00234 #define csl_min_r(a) (((a) < 1.0f) ? (a) : (1.0f/a))
00235
00236 #define csl_abs(a) (((a) >= 0) ? (a) : (-a))
00237
00238
00239
00240 #define csl_max_d(a, b) ((a > b) ? (a / b) : (b / a))
00241 #define csl_min_d(a, b) ((a < b) ? (a / b) : (b / a))
00242
00243
00244
00245 #define csl_ratio_rem(val1, val2, remainder) \
00246 remainder = csl_max_d(val1, val2); \
00247 remainder -= (int) remainder; \
00248 if (remainder > 0.5f) { \
00249 remainder = csl_max_r(rem); \
00250 remainder -= 1.0f; \
00251 }
00252
00254
00255 #ifndef TRUE
00256 #define TRUE 1
00257 #define FALSE 0
00258 #endif
00259
00261
00262 #define CSL_PI 3.1415926535897932f
00263 #define CSL_TWOPI 6.2831853071795865f
00264 #define CSL_PIHALF 1.570796326795f
00265 #define CSL_SQRT_TWO 1.414213562f
00266 #define CSL_SPEED_OF_SOUND 330.0f
00267 #define CSL_EXP_PER_DB 0.11512925464970228f
00268 #define CSL_SAMPS_PER_METER 133.63636363636364f
00269 #define CSL_DEGS_PER_RAD 57.295779513082321f
00270
00274
00275 #ifdef CSL_WINDOWS // Microsoft is explicit
00276
00277 #define hypotf(av, bv) sqrt((av * av) + (bv * bv))
00278
00279 typedef signed __int64 INT64;
00280 typedef unsigned __int64 UINT64;
00281
00282 #ifdef MSVS6 // ignore pragmas not understood by Microsoft Visual C++
00283 #pragma warning(once:4068 4244 4305 4355)
00284 #pragma warning(once:4290)
00285 #endif
00286
00287 #else
00288
00289 typedef signed long long INT64;
00290 typedef unsigned long long UINT64;
00291
00292 #endif
00293
00294 }
00295
00296 #endif // _CSLTypes_H