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