1 /*----------------------------------------------------------------------------
2 ChucK Concurrent, On-the-fly Audio Programming Language
3 Compiler and Virtual Machine
5 Copyright (c) 2004 Ge Wang and Perry R. Cook. All rights reserved.
6 http://chuck.cs.princeton.edu/
7 http://soundlab.cs.princeton.edu/
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 2 of the License, or
12 (at your option) any later version.
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software
21 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
23 -----------------------------------------------------------------------------*/
25 //-----------------------------------------------------------------------------
29 // author: Ge Wang (gewang@cs.princeton.edu)
30 // Perry R. Cook (prc@cs.princeton.edu)
32 //-----------------------------------------------------------------------------
33 #ifndef __CHUCK_DEF_H__
34 #define __CHUCK_DEF_H__
42 #define t_CKTIME double
43 #define t_CKDUR double
44 #define t_CKFLOAT double
45 #define t_CKDOUBLE double
46 #define t_CKSINGLE float
48 #define t_CKDWORD unsigned long
49 #define t_CKUINT t_CKDWORD
50 #define t_CKBOOL t_CKDWORD
51 #define t_CKBYTE unsigned char
53 #define t_CKVOIDPTR void *
56 typedef struct { t_CKFLOAT re
; t_CKFLOAT im
; } t_CKCOMPLEX
;
58 typedef struct { t_CKFLOAT modulus
; t_CKFLOAT phase
; } t_CKPOLAR
;
61 #define sz_TIME sizeof(double)
62 #define sz_DUR sizeof(double)
63 #define sz_FLOAT sizeof(double)
64 #define sz_DOUBLE sizeof(double)
65 #define sz_SINGLE sizeof(float)
66 #define sz_INT sizeof(long)
67 #define sz_DWORD sizeof(unsigned long)
68 #define sz_UINT sizeof(t_CKDWORD)
69 #define sz_BOOL sizeof(t_CKDWORD)
70 #define sz_BYTE sizeof(unsigned char)
72 #define sz_VOIDPTR sizeof(void *)
73 #define sz_COMPLEX sizeof(t_CKCOMPLEX)
74 #define sz_POLAR sizeof(t_CKPOLAR)
77 typedef const char * c_constr
;
80 // #define CK_S_DOUBLE
86 #define CK_DDN CK_DDN_DOUBLE
90 #define CK_DDN CK_DDN_SINGLE
94 typedef struct { SAMPLE re
; SAMPLE im
; } t_CKCOMPLEX_SAMPLE
;
102 // 3.1415926535897932384626433832795028841971693993751058209749445...
103 #define ONE_PI (3.14159265358979323846)
104 #define TWO_PI (2.0 * ONE_PI)
105 #define SQRT2 (1.41421356237309504880)
108 #define SAFE_DELETE(x) do { if(x){ delete x; x = NULL; } } while(0)
109 #define SAFE_DELETE_ARRAY(x) do { if(x){ delete [] x; x = NULL; } } while(0)
110 #define SAFE_RELEASE(x) do { if(x){ x->release(); x = NULL; } } while(0)
111 #define SAFE_ADD_REF(x) do { if(x){ x->add_ref(); } } while(0)
112 #define SAFE_REF_ASSIGN(lhs,rhs) do { SAFE_RELEASE(lhs); (lhs) = (rhs); SAFE_ADD_REF(lhs); } while(0)
116 #define ck_max(x,y) ( (x) >= (y) ? (x) : (y) )
117 #define ck_min(x,y) ( (x) <= (y) ? (x) : (y) )
120 #define CK_DDN_SINGLE(f) f = ( f >= 0 ? \
121 ( ( f > (t_CKSINGLE)1e-15 && f < (t_CKSINGLE)1e15 ) ? f : (t_CKSINGLE)0.0 ) : \
122 ( ( f < (t_CKSINGLE)-1e-15 && f > (t_CKSINGLE)-1e15 ) ? f : (t_CKSINGLE)0.0 ) )
123 #define CK_DDN_DOUBLE(f) f = ( f >= 0 ? \
124 ( ( f > (t_CKDOUBLE)1e-15 && f < (t_CKDOUBLE)1e15 ) ? f : 0.0 ) : \
125 ( ( f < (t_CKDOUBLE)-1e-15 && f > (t_CKDOUBLE)-1e15 ) ? f : 0.0 ) )
129 #if defined(__CHUCK_STAT_TRACK__)
130 #define CK_TRACK( stmt ) stmt
132 #define CK_TRACK( stmt )
135 #ifdef __MACOSX_CORE__
136 #define __PLATFORM_MACOSX__
139 #if defined(__LINUX_ALSA__) || defined(__LINUX_JACK__) || defined(__LINUX_OSS__)
140 #define __PLATFORM_LINUX__
143 #ifdef __PLATFORM_WIN32__
145 #define usleep(x) Sleep( (x / 1000 <= 0 ? 1 : x / 1000) )
147 #pragma warning (disable : 4996) // stdio deprecation
148 #pragma warning (disable : 4786) // stl debug info
149 #pragma warning (disable : 4312) // type casts from void*
150 #pragma warning (disable : 4311) // type casts to void*
151 #pragma warning (disable : 4244) // truncation
152 #pragma warning (disable : 4068) // unknown pragma
156 #define __DISABLE_MIDI__
157 #define __DISABLE_SNDBUF__
158 #define __DISABLE_WATCHDOG__
159 #define __DISABLE_RAW__
160 #define __DISABLE_KBHIT__
161 #define __DISABLE_PROMPTER__
162 #define __DISABLE_RTAUDIO__
163 #define __ALTER_HID__
164 #define __ALTER_ENTRY_POINT__
165 #define __STK_USE_SINGLE_PRECISION__