77 typedef double StkFloat;
100 PROCESS_SOCKET_IPADDR,
107 std::string message_;
112 StkError(
const std::string& message, Type type = StkError::UNSPECIFIED)
113 : message_(message), type_(type) {}
119 virtual void printMessage(
void) { std::cerr <<
'\n' << message_ <<
"\n\n"; }
122 virtual const Type&
getType(
void) {
return type_; }
125 virtual const std::string&
getMessage(
void) {
return message_; }
136 typedef unsigned long StkFormat;
185 static void swap16(
unsigned char *ptr );
188 static void swap32(
unsigned char *ptr );
191 static void swap64(
unsigned char *ptr );
194 static void sleep(
unsigned long milliseconds );
197 static bool inRange( StkFloat value, StkFloat min, StkFloat max ) {
198 if ( value < min )
return false;
199 else if ( value > max )
return false;
204 static void handleError(
const char *message, StkError::Type type );
207 static void handleError( std::string message, StkError::Type type );
216 static StkFloat srate_;
217 static std::string rawwavepath_;
218 static bool showWarnings_;
219 static bool printErrors_;
220 static std::vector<Stk *> alertList_;
224 static std::ostringstream oStream_;
225 bool ignoreSampleRateChange_;
231 virtual ~Stk(
void );
280 StkFrames(
unsigned int nFrames = 0,
unsigned int nChannels = 0 );
283 StkFrames(
const StkFloat& value,
unsigned int nFrames,
unsigned int nChannels );
342 StkFloat&
operator() (
size_t frame,
unsigned int channel );
350 StkFloat
operator() (
size_t frame,
unsigned int channel )
const;
359 StkFloat
interpolate( StkFloat frame,
unsigned int channel = 0 )
const;
362 size_t size()
const {
return size_; };
375 void resize(
size_t nFrames,
unsigned int nChannels = 1 );
385 void resize(
size_t nFrames,
unsigned int nChannels, StkFloat value );
401 void setChannel(
unsigned int channel,
const StkFrames &sourceFrames,
unsigned int sourceChannel);
404 unsigned int channels(
void )
const {
return nChannels_; };
407 unsigned int frames(
void )
const {
return (
unsigned int)nFrames_; };
421 StkFloat
dataRate(
void )
const {
return dataRate_; };
428 unsigned int nChannels_;
436 if ( size_ > 0 )
return false;
442 #if defined(_STK_DEBUG_)
444 std::ostringstream error;
445 error <<
"StkFrames::operator[]: invalid index (" << n <<
") value!";
455 #if defined(_STK_DEBUG_)
457 std::ostringstream error;
458 error <<
"StkFrames::operator[]: invalid index (" << n <<
") value!";
468 #if defined(_STK_DEBUG_)
469 if ( frame >= nFrames_ || channel >= nChannels_ ) {
470 std::ostringstream error;
471 error <<
"StkFrames::operator(): invalid frame (" << frame <<
") or channel (" << channel <<
") value!";
476 return data_[ frame * nChannels_ + channel ];
481 #if defined(_STK_DEBUG_)
482 if ( frame >= nFrames_ || channel >= nChannels_ ) {
483 std::ostringstream error;
484 error <<
"StkFrames::operator(): invalid frame (" << frame <<
") or channel (" << channel <<
") value!";
489 return data_[ frame * nChannels_ + channel ];
494 #if defined(_STK_DEBUG_)
496 std::ostringstream error;
497 error <<
"StkFrames::operator+: frames argument must be of equal dimensions!";
501 StkFrames sum((
unsigned int)nFrames_,nChannels_);
502 StkFloat *sumPtr = &sum[0];
503 const StkFloat *fptr = f.data_;
504 const StkFloat *dPtr = data_;
505 for (
unsigned int i = 0; i < size_; i++) {
506 *sumPtr++ = *fptr++ + *dPtr++;
513 #if defined(_STK_DEBUG_)
515 std::ostringstream error;
516 error <<
"StkFrames::operator+=: frames argument must be of equal dimensions!";
521 StkFloat *fptr = &f[0];
522 StkFloat *dptr = data_;
523 for (
unsigned int i=0; i<size_; i++ )
529 #if defined(_STK_DEBUG_)
531 std::ostringstream error;
532 error <<
"StkFrames::operator*=: frames argument must be of equal dimensions!";
537 StkFloat *fptr = &f[0];
538 StkFloat *dptr = data_;
539 for (
unsigned int i=0; i<size_; i++ )
544 typedef unsigned short UINT16;
545 typedef unsigned int UINT32;
546 typedef signed short SINT16;
547 typedef signed int SINT32;
548 typedef float FLOAT32;
549 typedef double FLOAT64;
552 const StkFloat SRATE = 44100.0;
558 const unsigned int RT_BUFFER_SIZE = 512;
569 #if !defined(RAWWAVE_PATH)
570 #define RAWWAVE_PATH "../../rawwaves/"
573 const StkFloat PI = 3.14159265358979;
574 const StkFloat TWO_PI = 2 * PI;
575 const StkFloat ONE_OVER_128 = 0.0078125;
577 #if defined(__WINDOWS_DS__) || defined(__WINDOWS_ASIO__) || defined(__WINDOWS_MM__)
578 #define __OS_WINDOWS__
579 #define __STK_REALTIME__
580 #elif defined(__LINUX_OSS__) || defined(__LINUX_ALSA__) || defined(__UNIX_JACK__)
582 #define __STK_REALTIME__
583 #elif defined(__IRIX_AL__)
585 #elif defined(__MACOSX_CORE__) || defined(__UNIX_JACK__)
586 #define __OS_MACOSX__
587 #define __STK_REALTIME__