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 
00031 
00032 
00033 
00034 
00035 
00036 
00037 
00038 
00039 
00040 
00041 
00042 
00043 
00044 
00045 
00046 
00047 
00048 
00049 
00050 
00051 
00052 
00053 
00054 #ifndef CSL_Types_H                         // All CSL header files can be included only once.
00055 #define CSL_Types_H                         // That's what these flags are for.
00056 
00058 
00059 #ifdef Linux                                // Linux
00060     #define CSL_LINUX 
00061 #endif
00062 
00063 #ifdef WIN32                                // M$_Windows
00064     #define CSL_WINDOWS
00065 #endif
00066 
00067 #if defined (__APPLE__)                     // Mac OSX
00068     #define CSL_MACOSX
00069 #endif
00070 
00072 
00073 #define CSL_ENUMS               // define this to use the various enumerations (which are problematic with SWIG)
00074 // #define CSL_DEBUG            // define this for very verbose debugging of constructors and call-backs
00075 // #define CSL_DSP_BUFFER       // define this for Buffer Sample Processing (feature extraction)
00076 // #define USE_JUCE             // use JUCE for all IO (now set as a command-line flag)
00077 
00081 
00082 #define CSL_mFrameRate 44100                
00083 
00084 #ifdef IPHONE
00085     #define CSL_mBlockSize 256              
00086     #define CSL_mMaxBufferFrames 1024       
00087     #define CSL_mMaxSndFileFrames 2000000   
00088 #else                                       
00089     #define CSL_mBlockSize 512              
00090     #define CSL_mMaxBufferFrames 8192       
00091     #define CSL_mMaxSndFileFrames 128000000 
00092 #endif
00093 
00094 //#define READ_IO_PROPS                     ///< overwrite the system frame rate and block size from the 
00096 
00097 #define DEFAULT_WTABLE_SIZE CGestalt::maxBufferFrames() // size of wavetables, or use blockSize?
00098 
00099 #define CSL_mVerbosity 3                    
00100 #define CSL_mLoggingPeriod 10               
00101 
00102 #define CSL_LOG_PREFIX ":: "                
00103 // #define CSL_LOG_PREFIX "\nCSL: "         
00104 
00105 #define CSL_mOutPort 57123                  
00106 #define CSL_mOSCPort 54321                  
00107 
00108 #define CSL_WORD_LEN 32                     
00109 #define CSL_NAME_LEN 256                    
00110 #define CSL_LINE_LEN 512                    
00111 #define CSL_STR_LEN 1024                    
00112 
00113 #define SAMPS_TO_WRITE (4096 * 10 * 10)     
00114 #define OUT_SFILE_NAME "XX_csl.aiff"        
00115 //#define OUT_SFILE_NAME "CSLXX.aiff"       
00116 
00117 #ifdef CSL_WINDOWS
00118 #define CSL_DATA_DIR "..\\..\\..\\CSL_Data\\"   
00119 #define CSL_INIT_FILE "..\\..\\..\\csl.ini"     
00120 #else
00121 #define CSL_DATA_DIR "~/Code/CSL/CSL_Data/"     
00122 #define CSL_INIT_FILE "~/.cslrc"                
00123 #define DO_TIMING                               
00124 #endif
00125 
00127 
00128 #ifdef USE_JSND
00129     #define SoundFile JSoundFile            // JUCE snd file class
00130 #endif
00131 #ifdef USE_LSND
00132     #define SoundFile LSoundFile            // libSndFile
00133 #endif
00134 #ifdef USE_CASND
00135     #define SoundFile CASoundFile           // CoreAudio
00136 #endif
00137 
00140 
00141 #define USE_JMIDI
00142 
00144 
00145 #ifndef CSL_WINDOWS
00146 #define USE_LOSC                            // liblo for OSC
00147 #endif
00148 
00150 
00151 #define Osc WavetableOscillator             // default "Osc" -- or use Sine?
00152 
00153 
00154 // Which FFT wrapper class to use? (choose with a compiler option, -DUSE_FFTW)
00155 
00156 //#define USE_FFTW                          // use FFTW (faster but complicated to build)
00157 //#define USE_FFTREAL                       // use FFTReal (smaller and simpler)
00158 
00159 
00161 
00162 #include <vector>                           
00163 #include <map>
00164 #include <string>   
00165 
00166 namespace csl {                             
00167 
00168 
00170 
00172 typedef float sample;                           
00173 typedef float Sample;                           
00174 
00175 typedef sample* SampleBuffer;                   
00176 typedef SampleBuffer* SampleBufferVector;       
00177 typedef SampleBuffer* SampleBufferArray;        
00178 
00179 typedef sample SampleComplex[2];                
00180 #define cx_r(val) val[0]                        
00181 #define cx_i(val) val[1]
00182 #define ComplexPtr SampleBuffer                 
00183 
00184 //typedef struct { sample re; sample im; } SampleComplex;   ///< alternate Complex # struct
00185 //#define cx_r(val) val.re                      /// complex # accesor macros
00186 //#define cx_i(val) val.im
00187 //#define ComplexPtr SampleComplex              ///< shorthand
00188 
00189 typedef SampleComplex* SampleComplexVector;     
00190 typedef SampleComplex* SampleComplexPtr;        
00191  
00192 class CPoint;                                   
00193 typedef std::vector <CPoint *> PointVector;     
00194 
00195 typedef void * VOIDFCNPTR(void * arg) ;         
00196 
00198 
00199 class UnitGenerator;                            
00200 class Port;                                     
00201 class IODevice;                                 
00202 class Instrument;                               
00203 class Observer;                             
00204 
00205 typedef unsigned CSL_MAP_KEY;                   
00206 
00207 
00208 typedef std::map <CSL_MAP_KEY, Port *> PortMap;
00210 typedef std::vector <UnitGenerator *> UGenVector;
00212 typedef std::map <std::string, UnitGenerator *> UGenMap;
00214 typedef std::vector <IODevice *> IODeviceVector;
00216 typedef std::vector <Instrument *> InstrumentVector;
00217 typedef std::map <int, InstrumentVector> InstrumentLibrary;
00218 typedef std::map <std::string, Instrument *> InstrumentMap;
00219 
00221 
00222 #define CSL_SCALE 1
00223 #define CSL_OFFSET 2
00224 #define CSL_INPUT 3
00225 #define CSL_OPERAND 4
00226 #define CSL_OPERAND2 5
00227 #define CSL_FREQUENCY 6
00228 #define CSL_POSITION 7
00229 #define CSL_POSITIONX 7
00230 #define CSL_POSITIONY 8
00231 #define CSL_POSITIONZ 9
00232 #define CSL_FILTER_FREQUENCY 10
00233 #define CSL_FILTER_AMOUNT 11
00234 #define CSL_RATE 12
00235 
00240 
00241 typedef unsigned long Timestamp;
00242 
00244 
00245 typedef struct {
00246     char * name;            // test name (menu item)
00247     void (* fcn)();         // test void fcn ptr
00248     char * comment;         // test comment
00249 } testStruct;
00250 
00254 
00255 #ifndef csl_min                         // csl_min(a, b)
00256 #define csl_min(a, b)   (((a) < (b)) ? (a) : (b))
00257 #endif
00258 
00259 #ifndef csl_max                         // csl_max(a, b)
00260 #define csl_max(a, b)   (((a) > (b)) ? (a) : (b))
00261 #endif
00262 
00263 // inclusive between-ness
00264 
00265 #define csl_between(a, b, c)    (((a) >= (b)) && ((a) <= (c)))
00266 
00267 // max/min ratio macros
00268 
00269 #define csl_max_r(a)    (((a) > 1.0f) ? (a) : (1.0f/a))
00270 #define csl_min_r(a)    (((a) < 1.0f) ? (a) : (1.0f/a))
00271 
00272 #define csl_abs(a)      (((a) >= 0) ? (a) : (-a))
00273 
00274 // min/max ratio of 2 values
00275 
00276 #define csl_max_d(a, b) ((a > b) ? (a / b) : (b / a))
00277 #define csl_min_d(a, b) ((a < b) ? (a / b) : (b / a))
00278 
00279 // ratio/remainder -- is v1 ~= N * v2?
00280 
00281 #define csl_ratio_rem(val1, val2, remainder)        \
00282     remainder = csl_max_d(val1, val2);              \
00283     remainder -= (int) remainder;                   \
00284     if (remainder > 0.5f) {                         \
00285         remainder = csl_max_r(rem);                 \
00286         remainder -= 1.0f;                          \
00287     }
00288 
00290 
00291 #ifndef TRUE
00292 #define TRUE 1
00293 #define FALSE 0
00294 #endif
00295 
00297 
00298 #define CSL_PI                  3.1415926535897933f
00299 // #define CSL_PI 3.141592653589793238462643383279502884197169399375108209749445923ld
00300 #define CSL_TWOPI               6.2831853071795865f
00301 #define CSL_PIHALF              1.570796326795f
00302 #define CSL_SQRT_TWO            1.414213562f
00303 #define CSL_SPEED_OF_SOUND      330.0f
00304 #define CSL_EXP_PER_DB          0.11512925464970228f
00305 #define CSL_SAMPS_PER_METER     133.63636363636364f
00306 #define CSL_DEGS_PER_RAD        57.295779513082321f
00307 
00311 
00312 #ifdef CSL_WINDOWS          // Microsoft is explicit
00313 //#include "stdafx.h"
00314                             // Hypotenuse = complex-to-real-magnitude
00315     #define hypotf(av, bv)  sqrt((av * av) + (bv * bv))
00316 
00317 #ifdef MSVS6                // ignore pragmas not understood by Microsoft Visual C++
00318     #pragma warning(once:4068 4244 4305 4355)
00319     #pragma warning(once:4290)
00320 #endif
00321 
00322 //#else
00323 //                          // GCC long long is 64 bits on both 32 and 64 bit operating systems (long is only 64 on 64)
00324 //  typedef signed long long INT64;
00325 //  typedef unsigned long long UINT64;
00326 
00327 #endif
00328 
00329 } // end of namespace
00330 
00331 #endif // _CSLTypes_H

Generated on Sat Oct 17 14:12:30 2009 for CSL by  doxygen 1.4.5-20051010