Home Information Classes Download Usage Mail List Requirements Links Tutorial
00001 /***************************************************/ 00013 /***************************************************/ 00014 00015 #if !defined(__STK_H) 00016 #define __STK_H 00017 00018 #include <string> 00019 00020 // Most data in STK is passed and calculated with the 00021 // following user-definable floating-point type. You 00022 // can change this to "float" if you prefer or perhaps 00023 // a "long double" in the future. 00024 typedef double MY_FLOAT; 00025 00026 // The "MY_FLOAT" type will be deprecated in STK 00027 // versions higher than 4.1.2 and replaced with the variable 00028 // "StkFloat". 00029 //typedef double StkFloat; 00030 //#if defined(__WINDOWS_DS__) || defined(__WINDOWS_ASIO__) 00031 // #pragma deprecated(MY_FLOAT) 00032 //#else 00033 // typedef StkFloat MY_FLOAT __attribute__ ((deprecated)); 00034 //#endif 00035 00037 00042 class StkError 00043 { 00044 public: 00045 enum TYPE { 00046 WARNING, 00047 DEBUG_WARNING, 00048 FUNCTION_ARGUMENT, 00049 FILE_NOT_FOUND, 00050 FILE_UNKNOWN_FORMAT, 00051 FILE_ERROR, 00052 PROCESS_THREAD, 00053 PROCESS_SOCKET, 00054 PROCESS_SOCKET_IPADDR, 00055 AUDIO_SYSTEM, 00056 MIDI_SYSTEM, 00057 UNSPECIFIED 00058 }; 00059 00060 protected: 00061 char message[256]; 00062 TYPE type; 00063 00064 public: 00066 StkError(const char *p, TYPE tipe = StkError::UNSPECIFIED); 00067 00069 virtual ~StkError(void); 00070 00072 virtual void printMessage(void); 00073 00075 virtual const TYPE& getType(void) { return type; } 00076 00078 virtual const char *getMessage(void) const { return message; } 00079 }; 00080 00081 00082 class Stk 00083 { 00084 public: 00085 00086 typedef unsigned long STK_FORMAT; 00087 static const STK_FORMAT STK_SINT8; 00088 static const STK_FORMAT STK_SINT16; 00089 static const STK_FORMAT STK_SINT32; 00090 static const STK_FORMAT MY_FLOAT32; 00091 static const STK_FORMAT MY_FLOAT64; 00093 00094 static MY_FLOAT sampleRate(void); 00095 00097 00105 static void setSampleRate(MY_FLOAT newRate); 00106 00108 static std::string rawwavePath(void); 00109 00111 static void setRawwavePath(std::string newPath); 00112 00114 static void swap16(unsigned char *ptr); 00115 00117 static void swap32(unsigned char *ptr); 00118 00120 static void swap64(unsigned char *ptr); 00121 00123 static void sleep(unsigned long milliseconds); 00124 00125 private: 00126 static MY_FLOAT srate; 00127 static std::string rawwavepath; 00128 00129 protected: 00130 00132 Stk(void); 00133 00135 virtual ~Stk(void); 00136 00138 static void handleError( const char *message, StkError::TYPE type ); 00139 00140 }; 00141 00142 // Here are a few other useful typedefs. 00143 typedef signed short SINT16; 00144 typedef signed int SINT32; 00145 typedef float FLOAT32; 00146 typedef double FLOAT64; 00147 00148 // Boolean values 00149 #define FALSE 0 00150 #define TRUE 1 00151 00152 // The default sampling rate. 00153 #define SRATE (MY_FLOAT) 44100.0 00154 00155 // The default real-time audio input and output buffer size. If 00156 // clicks are occuring in the input and/or output sound stream, a 00157 // larger buffer size may help. Larger buffer sizes, however, produce 00158 // more latency. 00159 #define RT_BUFFER_SIZE 512 00160 00161 // The default rawwave path value is set with the preprocessor 00162 // definition RAWWAVE_PATH. This can be specified as an argument to 00163 // the configure script, in an integrated development environment, or 00164 // below. The global STK rawwave path variable can be dynamically set 00165 // with the Stk::setRawwavePath() function. This value is 00166 // concatenated to the beginning of all references to rawwave files in 00167 // the various STK core classes (ex. Clarinet.cpp). If you wish to 00168 // move the rawwaves directory to a different location in your file 00169 // system, you will need to set this path definition appropriately. 00170 #if !defined(RAWWAVE_PATH) 00171 #define RAWWAVE_PATH "../../rawwaves/" 00172 #endif 00173 00174 #define PI (MY_FLOAT) 3.14159265359 00175 #define TWO_PI (MY_FLOAT) (MY_FLOAT) (2 * PI) 00176 00177 #define ONE_OVER_128 (MY_FLOAT) 0.0078125 00178 00179 #if defined(__WINDOWS_DS__) || defined(__WINDOWS_ASIO__) 00180 #define __OS_WINDOWS__ 00181 #define __STK_REALTIME__ 00182 #elif defined(__LINUX_OSS__) || defined(__LINUX_ALSA__) || defined(__LINUX_JACK__) 00183 #define __OS_LINUX__ 00184 #define __STK_REALTIME__ 00185 #elif defined(__IRIX_AL__) 00186 #define __OS_IRIX__ 00187 #define __STK_REALTIME__ 00188 #elif defined(__MACOSX_CORE__) 00189 #define __OS_MACOSX__ 00190 #define __STK_REALTIME__ 00191 #endif 00192 00193 //#define _STK_DEBUG_ 00194 00195 #endif
The Synthesis ToolKit in C++ (STK) |
©1995-2004 Perry R. Cook and Gary P. Scavone. All Rights Reserved. |