History

undo test commenting out code with preprocessor directives

Jack Atherton committed 7 years ago

Commit b91dd1e1 parent db1a1dd26 files · +7454 −7195Browse files

Unified · Split

26 files
  1. src/core/chuck.cpp +30 −14
  2. src/core/chuck.h +23 −5
  3. src/core/chuck.lex +1 −0
  4. src/core/chuck.y +1 −0
  5. src/core/chuck_carrier.h +22 −11
  6. src/core/chuck_compile.cpp +36 −10
  7. src/core/chuck_errmsg.cpp +12 −5
  8. src/core/chuck_instr.cpp +3 −1
  9. src/core/chuck_lang.cpp +1314 −1292
  10. src/core/chuck_lang.h +83 −77
  11. src/core/chuck_oo.cpp +943 −896
  12. src/core/chuck_oo.h +90 −81
  13. src/core/chuck_type.cpp +15 −5
  14. src/core/chuck_type.h +3 −1
  15. src/core/chuck_vm.cpp +59 −42
  16. src/core/chuck_vm.h +10 −4
  17. src/core/chuck_win32.c +510 −508
  18. src/core/ugen_stk.cpp +4085 −4070
  19. src/core/ugen_stk.h +128 −125
  20. src/core/ugen_xxx.cpp +7 −5
  21. src/core/ulib_machine.h +1 −1
  22. src/core/ulib_std.cpp +9 −3
  23. src/core/util_buffers.cpp +33 −11
  24. src/core/util_buffers.h +6 −2
  25. src/core/util_string.cpp +25 −24
  26. src/makefile +5 −2
src/core/chuck.cpp+30−14
@@ -36,10 +36,20 @@ · 35 unmodified lines
3636 //-----------------------------------------------------------------------------
3737 #include "chuck.h"
3838 #include "chuck_errmsg.h"
39−//#include "chuck_io.h"
40−//#include "chuck_otf.h"
41−//#include "ulib_machine.h"
42−//#include "util_network.h"
39+
40+#ifndef __DISABLE_SERIAL__
41+#include "chuck_io.h"
42+#endif
43+
44+#ifndef __DISABLE_OTF_SERVER__
45+#include "chuck_otf.h"
46+#include "ulib_machine.h"
47+#endif
48+
49+#ifndef __DISABLE_NETWORK__
50+#include "util_network.h"
51+#endif
52+
4353 #include "util_string.h"
4454 #include "ugen_stk.h"
4555
@@ -100,14 +110,16 @@ const char * ChucK::version() · 54 unmodified lines
100110
101111
102112
103−////-----------------------------------------------------------------------------
104−//// name: intSize()
105−//// desc: get chuck int size (in bits)
106−////-----------------------------------------------------------------------------
107−//t_CKUINT ChucK::intSize()
108−//{
109−// return machine_intsize();
110−//}
113+#ifndef __DISABLE_OTF_SERVER__
114+//-----------------------------------------------------------------------------
115+// name: intSize()
116+// desc: get chuck int size (in bits)
117+//-----------------------------------------------------------------------------
118+t_CKUINT ChucK::intSize()
119+{
120+ return machine_intsize();
121+}
122+#endif
111123
112124
113125
@@ -1322,8 +1334,10 @@ void ChucK::globalCleanup() · 1208 unmodified lines
13221334 HidInManager::cleanup();
13231335 #endif // __ALTER_HID__
13241336
1337+ #ifndef __DISABLE_SERIAL__
13251338 // shutdown serial
1326−// Chuck_IO_Serial::shutdown();
1339+ Chuck_IO_Serial::shutdown();
1340+ #endif
13271341
13281342 #ifndef __DISABLE_KBHIT__
13291343 // shutdown kb loop
@@ -1368,5 +1382,7 @@ t_CKINT ChucK::getLogLevel() · 38 unmodified lines
13681382 //-----------------------------------------------------------------------------
13691383 void ChucK::poop()
13701384 {
1371−// ::uh();
1385+ #ifndef __DISABLE_OTF_SERVER__
1386+ ::uh();
1387+ #endif
13721388 }
src/core/chuck.h+23−5
@@ -40,13 +40,27 @@ · 39 unmodified lines
4040 #include "chuck_compile.h"
4141 #include "chuck_dl.h"
4242 #include "chuck_vm.h"
43−//#include "chuck_shell.h"
43+
44+#ifndef __DISABLE_SHELL__
45+#include "chuck_shell.h"
46+#endif
47+
4448 #include "chuck_carrier.h"
45−//#include "ulib_machine.h"
49+#ifndef __DISABLE_OTF_SERVER
50+#include "ulib_machine.h"
51+#endif
52+
4653 #include "util_math.h"
4754 #include "util_string.h"
48−//#include "hidio_sdl.h"
49−//#include "midiio_rtmidi.h"
55+
56+#ifndef __DISABLE_HID__
57+#include "hidio_sdl.h"
58+#endif
59+
60+#ifndef __DISABLE_MIDI__
61+#include "midiio_rtmidi.h"
62+#endif
63+
5064 #include <string>
5165 #include <map>
5266
@@ -180,8 +194,12 @@ protected: · 127 unmodified lines
180194 public: // static functions
181195 // chuck version
182196 static const char * version();
197+ #ifndef __DISABLE_OTF_SERVER__
183198 // chuck int size (in bits)
184−// static t_CKUINT intSize();
199+ // (this depends on machine, which depends on OTF, so
200+ // disable it if we don't have OTF)
201+ static t_CKUINT intSize();
202+ #endif
185203 // number of ChucK's
186204 static t_CKUINT numVMs() { return o_numVMs; };
187205 // --poop compatibilty
src/core/chuck.lex+1−0
@@ -46,6 +46,7 @@ IS (u|U|l|L)* · 45 unmodified lines
4646
4747 #include <stdlib.h>
4848 #include <string.h>
49+#include <unistd.h>
4950 #include "chuck_utils.h"
5051 #include "chuck_absyn.h"
5152 #include "chuck_errmsg.h"
src/core/chuck.y+1−0
@@ -38,6 +38,7 @@ · 37 unmodified lines
3838 #include <stdio.h>
3939 #include <string.h>
4040 #include <stdlib.h>
41+#include <unistd.h>
4142 #include "chuck_utils.h"
4243 #include "chuck_errmsg.h"
4344 #include "chuck_absyn.h"
src/core/chuck_carrier.h+22−11
@@ -36,7 +36,9 @@ · 35 unmodified lines
3636 #define __CHUCK_CARRIER_H__
3737
3838 #include "chuck_def.h"
39−//#include "util_thread.h"
39+#ifndef __DISABLE_OTF_SERVER__
40+#include "util_thread.h"
41+#endif
4042 #include <map>
4143
4244
@@ -74,14 +76,18 @@ struct Chuck_Carrier · 31 unmodified lines
7476 Chuck_IO_Chout * chout;
7577 Chuck_IO_Cherr * cherr;
7678
77−// // OTF programming things
78−// ck_socket otf_socket;
79−// t_CKINT otf_port;
80−// CHUCK_THREAD otf_thread;
79+ #ifndef __DISABLE_OTF_SERVER__
80+ // OTF programming things
81+ ck_socket otf_socket;
82+ t_CKINT otf_port;
83+ CHUCK_THREAD otf_thread;
84+ #endif
8185
8286 // STK-specific
83−// XWriteThread * stk_writeThread;
84−// std::map<WvOut *, WvOut *> stk_wvOutMap;
87+ #ifndef __DISABLE_WVOUT__
88+ XWriteThread * stk_writeThread;
89+ std::map<WvOut *, WvOut *> stk_wvOutMap;
90+ #endif
8591
8692 // constructor
8793 Chuck_Carrier() :
@@ -89,12 +95,17 @@ struct Chuck_Carrier · 1 unmodified line
8995 compiler( NULL ),
9096 env( NULL ),
9197 vm( NULL ),
98+ #ifndef __DISABLE_OTF_SERVER__
99+ otf_socket( NULL ),
100+ otf_port( 0 ),
101+ otf_thread( 0 ),
102+ #endif
103+ #ifndef __DISABLE_WVOUT__
104+ stk_writeThread( NULL ),
105+ #endif
92106 chout( NULL ),
93107 cherr( NULL )
94−// otf_socket( NULL ),
95−// otf_port( 0 ),
96−// otf_thread( 0 ),
97−// stk_writeThread( NULL )
108+
98109 { }
99110
100111 // get hint: is realtime audio?
src/core/chuck_compile.cpp+36−10
@@ -32,7 +32,9 @@ · 31 unmodified lines
3232 #include "chuck_compile.h"
3333 #include "chuck_lang.h"
3434 #include "chuck_errmsg.h"
35−//#include "chuck_otf.h"
35+#ifndef __DISABLE_OTF_SERVER__
36+#include "chuck_otf.h"
37+#endif
3638
3739 #include "ugen_osc.h"
3840 #include "ugen_xxx.h"
@@ -40,12 +42,23 @@ · 1 unmodified line
4042 #include "ugen_stk.h"
4143 #include "uana_xform.h"
4244 #include "uana_extract.h"
43−//#include "ulib_machine.h"
45+
46+#ifndef __DISABLE_OTF_SERVER__
47+#include "ulib_machine.h"
48+#endif
49+
4450 #include "ulib_math.h"
4551 #include "ulib_std.h"
46−//#include "ulib_opsc.h"
52+
53+#ifndef __DISABLE_NETWORK__
54+#include "ulib_opsc.h"
55+#endif
56+
4757 #include "ulib_regex.h"
48−//#include "chuck_io.h"
58+
59+#ifndef __DISABLE_SERIAL__
60+#include "chuck_io.h"
61+#endif
4962
5063 #if defined(__PLATFORM_WIN32__)
5164 #include "dirent_win32.h"
@@ -649,22 +662,35 @@ t_CKBOOL load_internal_modules( Chuck_Compiler * compiler ) · 597 unmodified lines
649662 load_module( compiler, env, extract_query, "extract", "global" );
650663
651664 // load
665+ #ifndef __DISABLE_OTF_SERVER__
652666 EM_log( CK_LOG_SEVERE, "class 'machine'..." );
653−// if( !load_module( compiler, env, machine_query, "Machine", "global" ) ) goto error;
654−// machine_init( compiler, otf_process_msg );
667+ if( !load_module( compiler, env, machine_query, "Machine", "global" ) ) goto error;
668+ machine_init( compiler, otf_process_msg );
669+ #endif
670+
655671 EM_log( CK_LOG_SEVERE, "class 'std'..." );
656672 if( !load_module( compiler, env, libstd_query, "Std", "global" ) ) goto error;
657673 EM_log( CK_LOG_SEVERE, "class 'math'..." );
658674 if( !load_module( compiler, env, libmath_query, "Math", "global" ) ) goto error;
659675
660−// EM_log( CK_LOG_SEVERE, "class 'opsc'..." );
661−// if( !load_module( compiler, env, opensoundcontrol_query, "opsc", "global" ) ) goto error;
676+ #ifndef __DISABLE_NETWORK__
677+ EM_log( CK_LOG_SEVERE, "class 'opsc'..." );
678+ if( !load_module( compiler, env, opensoundcontrol_query, "opsc", "global" ) ) goto error;
679+ #endif
680+
662681 EM_log( CK_LOG_SEVERE, "class 'RegEx'..." );
663682 if( !load_module( compiler, env, regex_query, "RegEx", "global" ) ) goto error;
683+
684+ // Deprecated:
664685 // if( !load_module( compiler, env, net_query, "net", "global" ) ) goto error;
665686
666−// if( !init_class_HID( env ) ) goto error;
667−// if( !init_class_serialio( env ) ) goto error;
687+ #ifndef __DISABLE_HID__
688+ if( !init_class_HID( env ) ) goto error;
689+ #endif
690+
691+ #ifndef __DISABLE_SERIAL__
692+ if( !init_class_serialio( env ) ) goto error;
693+ #endif
668694
669695 // clear context
670696 type_engine_unload_context( env );
src/core/chuck_errmsg.cpp+12−5
@@ -38,8 +38,9 @@ · 37 unmodified lines
3838 #include <iostream>
3939 #include "chuck_utils.h"
4040 #include "chuck_errmsg.h"
41−//#include "util_thread.h"
42−
41+#ifndef __DISABLE_THREADS__
42+#include "util_thread.h"
43+#endif
4344
4445 // global
4546 int EM_tokPos = 0;
@@ -57,7 +58,9 @@ static size_t g_lasterrorIndex = strlen(g_lasterror); · 11 unmodified lines
5758 // log globals
5859 t_CKINT g_loglevel = CK_LOG_CORE;
5960 t_CKINT g_logstack = 0;
60−//XMutex g_logmutex;
61+#ifndef __DISABLE_THREADS__
62+XMutex g_logmutex;
63+#endif
6164
6265 // more local globals
6366 static const size_t g_buffer2_size = 1024;
@@ -574,7 +577,9 @@ void EM_log( t_CKINT level, const char * message, ... ) · 510 unmodified lines
574577 // check level
575578 if( level > g_loglevel ) return;
576579
577−// g_logmutex.acquire();
580+ #ifndef __DISABLE_THREADS__
581+ g_logmutex.acquire();
582+ #endif
578583 CK_FPRINTF_STDERR( "[chuck]:" );
579584 CK_FPRINTF_STDERR( "(%i:%s): ", level, g_str[level] );
580585
@@ -588,7 +593,9 @@ void EM_log( t_CKINT level, const char * message, ... ) · 7 unmodified lines
588593
589594 CK_FPRINTF_STDERR( "\n" );
590595 CK_FFLUSH_STDERR();
591−// g_logmutex.release();
596+ #ifndef __DISABLE_THREADS__
597+ g_logmutex.release();
598+ #endif
592599 }
593600
594601
src/core/chuck_instr.cpp+3−1
@@ -3902,7 +3902,9 @@ Chuck_Object * instantiate_and_initialize_object( Chuck_Type * type, Chuck_VM_Sh · 3901 unmodified lines
39023902 // check type TODO: make this faster
39033903 if( type->allocator )
39043904 object = type->allocator( vm, shred, Chuck_DL_Api::Api::instance() );
3905−// else if( isa( type, vm->env()->t_fileio ) ) object = new Chuck_IO_File( vm );
3905+ #ifndef __DISABLE_FILEIO__
3906+ else if( isa( type, vm->env()->t_fileio ) ) object = new Chuck_IO_File( vm );
3907+ #endif
39063908 else if( isa( type, vm->env()->t_event ) ) object = new Chuck_Event;
39073909 else if( isa( type, vm->env()->t_string ) ) object = new Chuck_String;
39083910 // TODO: is this ok?
src/core/chuck_lang.cpp+1314−1292
@@ -38,9 +38,16 @@ · 37 unmodified lines
3838 #include "chuck_vm.h"
3939 #include "chuck_errmsg.h"
4040 #include "chuck_ugen.h"
41−//#include "hidio_sdl.h"
41+
42+#ifndef __DISABLE_HID__
43+#include "hidio_sdl.h"
44+#endif
45+
4246 #include "util_string.h"
43−//#include "util_serial.h"
47+
48+#ifndef __DISABLE_SERIAL__
49+#include "util_serial.h"
50+#endif
4451
4552 #ifndef __DISABLE_MIDI__
4653 #include "midiio_rtmidi.h"
@@ -839,164 +846,166 @@ error: · 792 unmodified lines
839846
840847
841848
849+#ifndef __DISABLE_FILEIO__
842850 //-----------------------------------------------------------------------------
843851 // name: init_class_fileio()
844852 // desc: ...
845853 //-----------------------------------------------------------------------------
846−//t_CKBOOL init_class_fileio( Chuck_Env * env, Chuck_Type * type )
847−//{
848−// // init as base class
849−// Chuck_DL_Func * func = NULL;
850−//
851−// // log
852−// EM_log( CK_LOG_SEVERE, "class 'fileio'" );
853−//
854−// // init as base class
855−// // TODO: ctor/dtor?
856−// // TODO: replace dummy with pure function
857−// if( !type_engine_import_class_begin( env, type, env->global(), fileio_ctor, fileio_dtor ) )
858−// return FALSE;
859−//
860−// // add open(string)
861−// func = make_new_mfun( "int", "open", fileio_open );
862−// func->add_arg( "string", "path" );
863−// if( !type_engine_import_mfun( env, func ) ) goto error;
864−//
865−// // add open(string, flags)
866−// func = make_new_mfun( "int", "open", fileio_openflags );
867−// func->add_arg( "string", "path" );
868−// func->add_arg( "int", "flags" );
869−// if( !type_engine_import_mfun( env, func ) ) goto error;
870−//
871−// // add good()
872−// func = make_new_mfun( "int", "good", fileio_good );
873−// if( !type_engine_import_mfun( env, func ) ) goto error;
874−//
875−// // add close()
876−// func = make_new_mfun( "void", "close", fileio_close );
877−// if( !type_engine_import_mfun( env, func ) ) goto error;
878−//
879−// // add flush()
880−// func = make_new_mfun( "void", "flush", fileio_flush );
881−// if( !type_engine_import_mfun( env, func ) ) goto error;
882−//
883−// // add mode()
884−// func = make_new_mfun( "int", "mode", fileio_getmode );
885−// if( !type_engine_import_mfun( env, func ) ) goto error;
886−//
887−// // add mode(int)
888−// func = make_new_mfun( "int", "mode", fileio_setmode );
889−// func->add_arg( "int", "flag" );
890−// if( !type_engine_import_mfun( env, func ) ) goto error;
891−//
892−// // add size()
893−// func = make_new_mfun( "int", "size", fileio_size );
894−// if( !type_engine_import_mfun( env, func ) ) goto error;
895−//
896−// // add seek(int)
897−// func = make_new_mfun( "void", "seek", fileio_seek );
898−// func->add_arg( "int", "pos" );
899−// if( !type_engine_import_mfun( env, func ) ) goto error;
900−//
901−// // add tell()
902−// func = make_new_mfun( "int", "tell", fileio_tell );
903−// if( !type_engine_import_mfun( env, func ) ) goto error;
904−//
905−// // add isDir()
906−// func = make_new_mfun( "int", "isDir", fileio_isdir );
907−// if( !type_engine_import_mfun( env, func ) ) goto error;
908−//
909−// // add dirList()
910−// func = make_new_mfun( "string[]", "dirList", fileio_dirlist );
911−// if( !type_engine_import_mfun( env, func ) ) goto error;
912−//
913−// // add read()
914−// // func = make_new_mfun( "string", "read", fileio_read );
915−// // func->add_arg( "int", "length" );
916−// // if( !type_engine_import_mfun( env, func ) ) goto error;
917−//
918−// // add readLine()
919−// func = make_new_mfun( "string", "readLine", fileio_readline );
920−// if( !type_engine_import_mfun( env, func ) ) goto error;
921−//
922−// // add readInt()
923−// // func = make_new_mfun( "int", "readInt", fileio_readint );
924−// // if( !type_engine_import_mfun( env, func ) ) goto error;
925−//
926−// // add readInt(int)
927−// func = make_new_mfun( "int", "readInt", fileio_readintflags );
928−// func->add_arg( "int", "flags" );
929−// if( !type_engine_import_mfun( env, func ) ) goto error;
930−//
931−// // add readFloat()
932−// // func = make_new_mfun( "float", "readFloat", fileio_readfloat );
933−// // if( !type_engine_import_mfun( env, func ) ) goto error;
934−//
935−// // add eof()
936−// func = make_new_mfun( "int", "eof", fileio_eof );
937−// if( !type_engine_import_mfun( env, func ) ) goto error;
938−//
939−// // add more()
940−// func = make_new_mfun( "int", "more", fileio_more );
941−// if( !type_engine_import_mfun( env, func ) ) goto error;
942−//
943−// // add write(string)
944−// func = make_new_mfun( "void", "write", fileio_writestring );
945−// func->add_arg( "string", "val" );
946−// if( !type_engine_import_mfun( env, func ) ) goto error;
947−//
948−// // add write(int)
949−// func = make_new_mfun( "void", "write", fileio_writeint );
950−// func->add_arg( "int", "val" );
951−// if( !type_engine_import_mfun( env, func ) ) goto error;
952−//
953−// // add write(int,flags)
954−// func = make_new_mfun( "void", "write", fileio_writeintflags );
955−// func->add_arg( "int", "val" );
956−// func->add_arg( "int", "flags" );
957−// if( !type_engine_import_mfun( env, func ) ) goto error;
958−//
959−// // add write(float)
960−// func = make_new_mfun( "void", "write", fileio_writefloat );
961−// func->add_arg( "float", "val" );
962−// if( !type_engine_import_mfun( env, func ) ) goto error;
963−//
964−// // add FLAG_READ_WRITE
965−// if( !type_engine_import_svar( env, "int", "READ_WRITE",
966−// TRUE, (t_CKUINT)&Chuck_IO_File::FLAG_READ_WRITE ) ) goto error;
967−//
968−// // add FLAG_READONLY
969−// if( !type_engine_import_svar( env, "int", "READ",
970−// TRUE, (t_CKUINT)&Chuck_IO_File::FLAG_READONLY ) ) goto error;
971−//
972−// // add FLAG_WRITEONLY
973−// if( !type_engine_import_svar( env, "int", "WRITE",
974−// TRUE, (t_CKUINT)&Chuck_IO_File::FLAG_WRITEONLY ) ) goto error;
975−//
976−// // add FLAG_APPEND
977−// if( !type_engine_import_svar( env, "int", "APPEND",
978−// TRUE, (t_CKUINT)&Chuck_IO_File::FLAG_APPEND ) ) goto error;
979−//
980−// // add TYPE_ASCII
981−// if( !type_engine_import_svar( env, "int", "ASCII",
982−// TRUE, (t_CKUINT)&Chuck_IO_File::TYPE_ASCII ) ) goto error;
983−//
984−// // add TYPE_BINARY
985−// if( !type_engine_import_svar( env, "int", "BINARY",
986−// TRUE, (t_CKUINT)&Chuck_IO_File::TYPE_BINARY ) ) goto error;
987−//
988−// // end the class import
989−// type_engine_import_class_end( env );
990−//
991−// return TRUE;
992−//
993−//error:
994−//
995−// // end the class import
996−// type_engine_import_class_end( env );
997−//
998−// return FALSE;
999−//}
854+t_CKBOOL init_class_fileio( Chuck_Env * env, Chuck_Type * type )
855+{
856+ // init as base class
857+ Chuck_DL_Func * func = NULL;
858+
859+ // log
860+ EM_log( CK_LOG_SEVERE, "class 'fileio'" );
861+
862+ // init as base class
863+ // TODO: ctor/dtor?
864+ // TODO: replace dummy with pure function
865+ if( !type_engine_import_class_begin( env, type, env->global(), fileio_ctor, fileio_dtor ) )
866+ return FALSE;
867+
868+ // add open(string)
869+ func = make_new_mfun( "int", "open", fileio_open );
870+ func->add_arg( "string", "path" );
871+ if( !type_engine_import_mfun( env, func ) ) goto error;
872+
873+ // add open(string, flags)
874+ func = make_new_mfun( "int", "open", fileio_openflags );
875+ func->add_arg( "string", "path" );
876+ func->add_arg( "int", "flags" );
877+ if( !type_engine_import_mfun( env, func ) ) goto error;
878+
879+ // add good()
880+ func = make_new_mfun( "int", "good", fileio_good );
881+ if( !type_engine_import_mfun( env, func ) ) goto error;
882+
883+ // add close()
884+ func = make_new_mfun( "void", "close", fileio_close );
885+ if( !type_engine_import_mfun( env, func ) ) goto error;
886+
887+ // add flush()
888+ func = make_new_mfun( "void", "flush", fileio_flush );
889+ if( !type_engine_import_mfun( env, func ) ) goto error;
890+
891+ // add mode()
892+ func = make_new_mfun( "int", "mode", fileio_getmode );
893+ if( !type_engine_import_mfun( env, func ) ) goto error;
894+
895+ // add mode(int)
896+ func = make_new_mfun( "int", "mode", fileio_setmode );
897+ func->add_arg( "int", "flag" );
898+ if( !type_engine_import_mfun( env, func ) ) goto error;
899+
900+ // add size()
901+ func = make_new_mfun( "int", "size", fileio_size );
902+ if( !type_engine_import_mfun( env, func ) ) goto error;
903+
904+ // add seek(int)
905+ func = make_new_mfun( "void", "seek", fileio_seek );
906+ func->add_arg( "int", "pos" );
907+ if( !type_engine_import_mfun( env, func ) ) goto error;
908+
909+ // add tell()
910+ func = make_new_mfun( "int", "tell", fileio_tell );
911+ if( !type_engine_import_mfun( env, func ) ) goto error;
912+
913+ // add isDir()
914+ func = make_new_mfun( "int", "isDir", fileio_isdir );
915+ if( !type_engine_import_mfun( env, func ) ) goto error;
916+
917+ // add dirList()
918+ func = make_new_mfun( "string[]", "dirList", fileio_dirlist );
919+ if( !type_engine_import_mfun( env, func ) ) goto error;
920+
921+ // add read()
922+ // func = make_new_mfun( "string", "read", fileio_read );
923+ // func->add_arg( "int", "length" );
924+ // if( !type_engine_import_mfun( env, func ) ) goto error;
925+
926+ // add readLine()
927+ func = make_new_mfun( "string", "readLine", fileio_readline );
928+ if( !type_engine_import_mfun( env, func ) ) goto error;
929+
930+ // add readInt()
931+ // func = make_new_mfun( "int", "readInt", fileio_readint );
932+ // if( !type_engine_import_mfun( env, func ) ) goto error;
933+
934+ // add readInt(int)
935+ func = make_new_mfun( "int", "readInt", fileio_readintflags );
936+ func->add_arg( "int", "flags" );
937+ if( !type_engine_import_mfun( env, func ) ) goto error;
938+
939+ // add readFloat()
940+ // func = make_new_mfun( "float", "readFloat", fileio_readfloat );
941+ // if( !type_engine_import_mfun( env, func ) ) goto error;
942+
943+ // add eof()
944+ func = make_new_mfun( "int", "eof", fileio_eof );
945+ if( !type_engine_import_mfun( env, func ) ) goto error;
946+
947+ // add more()
948+ func = make_new_mfun( "int", "more", fileio_more );
949+ if( !type_engine_import_mfun( env, func ) ) goto error;
950+
951+ // add write(string)
952+ func = make_new_mfun( "void", "write", fileio_writestring );
953+ func->add_arg( "string", "val" );
954+ if( !type_engine_import_mfun( env, func ) ) goto error;
955+
956+ // add write(int)
957+ func = make_new_mfun( "void", "write", fileio_writeint );
958+ func->add_arg( "int", "val" );
959+ if( !type_engine_import_mfun( env, func ) ) goto error;
960+
961+ // add write(int,flags)
962+ func = make_new_mfun( "void", "write", fileio_writeintflags );
963+ func->add_arg( "int", "val" );
964+ func->add_arg( "int", "flags" );
965+ if( !type_engine_import_mfun( env, func ) ) goto error;
966+
967+ // add write(float)
968+ func = make_new_mfun( "void", "write", fileio_writefloat );
969+ func->add_arg( "float", "val" );
970+ if( !type_engine_import_mfun( env, func ) ) goto error;
971+
972+ // add FLAG_READ_WRITE
973+ if( !type_engine_import_svar( env, "int", "READ_WRITE",
974+ TRUE, (t_CKUINT)&Chuck_IO_File::FLAG_READ_WRITE ) ) goto error;
975+
976+ // add FLAG_READONLY
977+ if( !type_engine_import_svar( env, "int", "READ",
978+ TRUE, (t_CKUINT)&Chuck_IO_File::FLAG_READONLY ) ) goto error;
979+
980+ // add FLAG_WRITEONLY
981+ if( !type_engine_import_svar( env, "int", "WRITE",
982+ TRUE, (t_CKUINT)&Chuck_IO_File::FLAG_WRITEONLY ) ) goto error;
983+
984+ // add FLAG_APPEND
985+ if( !type_engine_import_svar( env, "int", "APPEND",
986+ TRUE, (t_CKUINT)&Chuck_IO_File::FLAG_APPEND ) ) goto error;
987+
988+ // add TYPE_ASCII
989+ if( !type_engine_import_svar( env, "int", "ASCII",
990+ TRUE, (t_CKUINT)&Chuck_IO_File::TYPE_ASCII ) ) goto error;
991+
992+ // add TYPE_BINARY
993+ if( !type_engine_import_svar( env, "int", "BINARY",
994+ TRUE, (t_CKUINT)&Chuck_IO_File::TYPE_BINARY ) ) goto error;
995+
996+ // end the class import
997+ type_engine_import_class_end( env );
998+
999+ return TRUE;
1000+
1001+error:
1002+
1003+ // end the class import
1004+ type_engine_import_class_end( env );
1005+
1006+ return FALSE;
1007+}
1008+#endif
10001009
10011010
10021011
@@ -1633,442 +1642,443 @@ error: · 630 unmodified lines
16331642
16341643
16351644
1636−//// static
1637−//static t_CKUINT HidIn_offset_data = 0;
1638−//
1639−//static t_CKUINT HidMsg_offset_device_type = 0;
1640−//static t_CKUINT HidMsg_offset_device_num = 0;
1641−//static t_CKUINT HidMsg_offset_type = 0;
1642−//static t_CKUINT HidMsg_offset_which = 0;
1643−//static t_CKUINT HidMsg_offset_idata = 0;
1644−//static t_CKUINT HidMsg_offset_fdata = 0;
1645−//static t_CKUINT HidMsg_offset_when = 0;
1646−//static t_CKUINT HidMsg_offset_deltax = 0;
1647−//static t_CKUINT HidMsg_offset_deltay = 0;
1648−//static t_CKUINT HidMsg_offset_axis_position = 0; // deprecated
1649−//static t_CKUINT HidMsg_offset_axis_position2 = 0;
1650−//static t_CKUINT HidMsg_offset_scaled_axis_position = 0; // deprecated
1651−//static t_CKUINT HidMsg_offset_hat_position = 0;
1652−//static t_CKUINT HidMsg_offset_cursorx = 0;
1653−//static t_CKUINT HidMsg_offset_cursory = 0;
1654−//static t_CKUINT HidMsg_offset_scaledcursorx = 0;
1655−//static t_CKUINT HidMsg_offset_scaledcursory = 0;
1656−//static t_CKUINT HidMsg_offset_x = 0;
1657−//static t_CKUINT HidMsg_offset_y = 0;
1658−//static t_CKUINT HidMsg_offset_z = 0;
1659−//static t_CKUINT HidMsg_offset_touchx = 0; // added 1.3.0.0
1660−//static t_CKUINT HidMsg_offset_touchy = 0; // added 1.3.0.0
1661−//static t_CKUINT HidMsg_offset_touchsize = 0; // added 1.3.0.0
1662−//static t_CKUINT HidMsg_offset_ascii = 0;
1663−//static t_CKUINT HidMsg_offset_key = 0;
1664−//
1665−//static t_CKUINT HidOut_offset_data = 0;
1666−
1667−////-----------------------------------------------------------------------------
1668−//// name: init_class_HID()
1669−//// desc: ...
1670−////-----------------------------------------------------------------------------
1671−//t_CKBOOL init_class_HID( Chuck_Env * env )
1672−//{
1673−// Chuck_DL_Func * func = NULL;
1674−//
1675−// // init base class
1676−// if( !type_engine_import_class_begin( env, "HidMsg", "Object",
1677−// env->global(), NULL, NULL ) )
1678−// return FALSE;
1679−//
1680−// // add member variable
1681−// HidMsg_offset_device_type = type_engine_import_mvar( env, "int", "deviceType", FALSE );
1682−// if( HidMsg_offset_device_type == CK_INVALID_OFFSET ) goto error;
1683−//
1684−// // add member variable
1685−// HidMsg_offset_device_num = type_engine_import_mvar( env, "int", "deviceNum", FALSE );
1686−// if( HidMsg_offset_device_num == CK_INVALID_OFFSET ) goto error;
1687−//
1688−// // add member variable
1689−// HidMsg_offset_type = type_engine_import_mvar( env, "int", "type", FALSE );
1690−// if( HidMsg_offset_type == CK_INVALID_OFFSET ) goto error;
1691−//
1692−// // add member variable
1693−// HidMsg_offset_which = type_engine_import_mvar( env, "int", "which", FALSE );
1694−// if( HidMsg_offset_which == CK_INVALID_OFFSET ) goto error;
1695−//
1696−// // add member variable
1697−// HidMsg_offset_idata = type_engine_import_mvar( env, "int", "idata", FALSE );
1698−// if( HidMsg_offset_idata == CK_INVALID_OFFSET ) goto error;
1699−//
1700−// // add member variable
1701−// HidMsg_offset_fdata = type_engine_import_mvar( env, "float", "fdata", FALSE );
1702−// if( HidMsg_offset_fdata == CK_INVALID_OFFSET ) goto error;
1703−//
1704−// // add member variable
1705−// HidMsg_offset_when = type_engine_import_mvar( env, "time", "when", FALSE );
1706−// if( HidMsg_offset_when == CK_INVALID_OFFSET ) goto error;
1707−//
1708−// // add member variable
1709−// HidMsg_offset_deltax = type_engine_import_mvar( env, "int", "deltaX", FALSE );
1710−// if( HidMsg_offset_deltax == CK_INVALID_OFFSET ) goto error;
1711−//
1712−// // add member variable
1713−// HidMsg_offset_deltay = type_engine_import_mvar( env, "int", "deltaY", FALSE );
1714−// if( HidMsg_offset_deltay == CK_INVALID_OFFSET ) goto error;
1715−//
1716−// // add member variable
1717−// HidMsg_offset_cursorx = type_engine_import_mvar( env, "int", "cursorX", FALSE );
1718−// if( HidMsg_offset_cursorx == CK_INVALID_OFFSET ) goto error;
1719−//
1720−// // add member variable
1721−// HidMsg_offset_cursory = type_engine_import_mvar( env, "int", "cursorY", FALSE );
1722−// if( HidMsg_offset_cursory == CK_INVALID_OFFSET ) goto error;
1723−//
1724−// // add member variable
1725−// HidMsg_offset_scaledcursorx = type_engine_import_mvar( env, "float", "scaledCursorX", FALSE );
1726−// if( HidMsg_offset_scaledcursorx == CK_INVALID_OFFSET ) goto error;
1727−//
1728−// // add member variable
1729−// HidMsg_offset_scaledcursory = type_engine_import_mvar( env, "float", "scaledCursorY", FALSE );
1730−// if( HidMsg_offset_scaledcursory == CK_INVALID_OFFSET ) goto error;
1731−//
1732−// // add member variable
1733−// HidMsg_offset_x = type_engine_import_mvar( env, "int", "x", FALSE );
1734−// if( HidMsg_offset_x == CK_INVALID_OFFSET ) goto error;
1735−//
1736−// // add member variable
1737−// HidMsg_offset_y = type_engine_import_mvar( env, "int", "y", FALSE );
1738−// if( HidMsg_offset_y == CK_INVALID_OFFSET ) goto error;
1739−//
1740−// // add member variable
1741−// HidMsg_offset_z = type_engine_import_mvar( env, "int", "z", FALSE );
1742−// if( HidMsg_offset_z == CK_INVALID_OFFSET ) goto error;
1743−//
1744−// // add member variable (added 1.3.0.0)
1745−// HidMsg_offset_touchx = type_engine_import_mvar( env, "float", "touchX", FALSE );
1746−// if( HidMsg_offset_touchx == CK_INVALID_OFFSET ) goto error;
1747−//
1748−// // add member variable (added 1.3.0.0)
1749−// HidMsg_offset_touchy = type_engine_import_mvar( env, "float", "touchY", FALSE );
1750−// if( HidMsg_offset_touchy == CK_INVALID_OFFSET ) goto error;
1751−//
1752−// // add member variable (added 1.3.0.0)
1753−// HidMsg_offset_touchsize = type_engine_import_mvar( env, "float", "touchSize", FALSE );
1754−// if( HidMsg_offset_touchsize == CK_INVALID_OFFSET ) goto error;
1755−//
1756−// // add member variable
1757−// HidMsg_offset_axis_position = type_engine_import_mvar( env, "int", "axis_position", FALSE );
1758−// if( HidMsg_offset_axis_position == CK_INVALID_OFFSET ) goto error;
1759−//
1760−// // add member variable
1761−// HidMsg_offset_axis_position2 = type_engine_import_mvar( env, "float", "axisPosition", FALSE );
1762−// if( HidMsg_offset_axis_position2 == CK_INVALID_OFFSET ) goto error;
1763−//
1764−// // add member variable
1765−// HidMsg_offset_hat_position = type_engine_import_mvar( env, "int", "hatPosition", FALSE );
1766−// if( HidMsg_offset_hat_position == CK_INVALID_OFFSET ) goto error;
1767−//
1768−// // add member variable
1769−// HidMsg_offset_ascii = type_engine_import_mvar( env, "int", "ascii", FALSE );
1770−// if( HidMsg_offset_ascii == CK_INVALID_OFFSET ) goto error;
1771−//
1772−// // add member variable
1773−// HidMsg_offset_key = type_engine_import_mvar( env, "int", "key", FALSE );
1774−// if( HidMsg_offset_key == CK_INVALID_OFFSET ) goto error;
1775−//
1776−// // add member variable
1777−// HidMsg_offset_scaled_axis_position = type_engine_import_mvar( env, "float", "scaled_axis_position", FALSE );
1778−// if( HidMsg_offset_scaled_axis_position == CK_INVALID_OFFSET ) goto error;
1779−//
1780−// // add is_axis_motion()
1781−// func = make_new_mfun( "int", "is_axis_motion", HidMsg_is_axis_motion ); // deprecated
1782−// if( !type_engine_import_mfun( env, func ) ) goto error;
1783−//
1784−// // add isAxisMotion()
1785−// func = make_new_mfun( "int", "isAxisMotion", HidMsg_is_axis_motion );
1786−// if( !type_engine_import_mfun( env, func ) ) goto error;
1787−//
1788−// // add is_button_down()
1789−// func = make_new_mfun( "int", "is_button_down", HidMsg_is_button_down ); // deprecated
1790−// if( !type_engine_import_mfun( env, func ) ) goto error;
1791−//
1792−// // add isButtonDown()
1793−// func = make_new_mfun( "int", "isButtonDown", HidMsg_is_button_down );
1794−// if( !type_engine_import_mfun( env, func ) ) goto error;
1795−//
1796−// // add is_button_up()
1797−// func = make_new_mfun( "int", "is_button_up", HidMsg_is_button_up ); // deprecated
1798−// if( !type_engine_import_mfun( env, func ) ) goto error;
1799−//
1800−// // add isButtonUp()
1801−// func = make_new_mfun( "int", "isButtonUp", HidMsg_is_button_up );
1802−// if( !type_engine_import_mfun( env, func ) ) goto error;
1803−//
1804−// // add is_mouse_motion()
1805−// func = make_new_mfun( "int", "is_mouse_motion", HidMsg_is_mouse_motion ); // deprecated
1806−// if( !type_engine_import_mfun( env, func ) ) goto error;
1807−//
1808−// // add isMouseMotion()
1809−// func = make_new_mfun( "int", "isMouseMotion", HidMsg_is_mouse_motion );
1810−// if( !type_engine_import_mfun( env, func ) ) goto error;
1811−//
1812−// // add is_hat_motion()
1813−// func = make_new_mfun( "int", "is_hat_motion", HidMsg_is_hat_motion ); // deprecated
1814−// if( !type_engine_import_mfun( env, func ) ) goto error;
1815−//
1816−// // add isHatMotion()
1817−// func = make_new_mfun( "int", "isHatMotion", HidMsg_is_hat_motion );
1818−// if( !type_engine_import_mfun( env, func ) ) goto error;
1819−//
1820−// // add isWheelMotion()
1821−// func = make_new_mfun( "int", "isWheelMotion", HidMsg_is_wheel_motion );
1822−// if( !type_engine_import_mfun( env, func ) ) goto error;
1823−//
1824−// // end the class import
1825−// type_engine_import_class_end( env );
1826−//
1827−//
1828−// // register deprecate
1829−// type_engine_register_deprecate( env, "HidIn", "Hid" );
1830−//
1831−// // init base class Hid (copy of HidIn + constants)
1832−// if( !type_engine_import_class_begin( env, "Hid", "Event",
1833−// env->global(), HidIn_ctor, HidIn_dtor ) )
1834−// return FALSE;
1835−//
1836−// // add open()
1837−// func = make_new_mfun( "int", "open", HidIn_open );
1838−// func->add_arg( "int", "type" );
1839−// func->add_arg( "int", "num" );
1840−// if( !type_engine_import_mfun( env, func ) ) goto error;
1841−//
1842−// // add open()
1843−// func = make_new_mfun( "int", "open", HidIn_open_named );
1844−// func->add_arg( "string", "name" );
1845−// if( !type_engine_import_mfun( env, func ) ) goto error;
1846−//
1847−// // add openJoystick()
1848−// func = make_new_mfun( "int", "openJoystick", HidIn_open_joystick );
1849−// func->add_arg( "int", "num" );
1850−// if( !type_engine_import_mfun( env, func ) ) goto error;
1851−//
1852−// // add openMouse()
1853−// func = make_new_mfun( "int", "openMouse", HidIn_open_mouse );
1854−// func->add_arg( "int", "num" );
1855−// if( !type_engine_import_mfun( env, func ) ) goto error;
1856−//
1857−// // add openKeyboard()
1858−// func = make_new_mfun( "int", "openKeyboard", HidIn_open_keyboard );
1859−// func->add_arg( "int", "num" );
1860−// if( !type_engine_import_mfun( env, func ) ) goto error;
1861−//
1862−// // add openTiltSensor()
1863−// func = make_new_mfun( "int", "openTiltSensor", HidIn_open_tiltsensor );
1864−// if( !type_engine_import_mfun( env, func ) ) goto error;
1865−//
1866−// // add good()
1867−// func = make_new_mfun( "int", "good", HidIn_good );
1868−// if( !type_engine_import_mfun( env, func ) ) goto error;
1869−//
1870−// // add num()
1871−// func = make_new_mfun( "int", "num", HidIn_num );
1872−// if( !type_engine_import_mfun( env, func ) ) goto error;
1873−//
1874−// // add name()
1875−// func = make_new_mfun( "string", "name", HidIn_name );
1876−// if( !type_engine_import_mfun( env, func ) ) goto error;
1877−//
1878−// // add printerr()
1879−// func = make_new_mfun( "void", "printerr", HidIn_printerr );
1880−// func->add_arg( "int", "print_or_not" );
1881−// if( !type_engine_import_mfun( env, func ) ) goto error;
1882−//
1883−// // add recv()
1884−// func = make_new_mfun( "int", "recv", HidIn_recv );
1885−// func->add_arg( "HidMsg", "msg" );
1886−// if( !type_engine_import_mfun( env, func ) ) goto error;
1887−//
1888−// // add read()
1889−// func = make_new_mfun( "int", "read", HidIn_read );
1890−// func->add_arg( "int", "type" );
1891−// func->add_arg( "int", "which" );
1892−// func->add_arg( "HidMsg", "msg" );
1893−// if( !type_engine_import_mfun( env, func ) ) goto error;
1894−//
1895−// // add send()
1896−// func = make_new_mfun( "int", "send", HidIn_send );
1897−// func->add_arg( "HidMsg", "msg" );
1898−// if( !type_engine_import_mfun( env, func ) ) goto error;
1899−//
1900−// // add can_wait()
1901−// func = make_new_mfun( "int", "can_wait", HidIn_can_wait );
1902−// if( !type_engine_import_mfun( env, func ) ) goto error;
1903−//
1904−// // add readTiltSensor()
1905−// func = make_new_sfun( "int[]", "readTiltSensor", HidIn_read_tilt_sensor );
1906−// if( !type_engine_import_sfun( env, func ) ) goto error;
1907−//
1908−// // add globalTiltPollRate()
1909−// func = make_new_sfun( "dur", "globalTiltPollRate", HidIn_ctrl_tiltPollRate );
1910−// func->add_arg( "dur", "d" );
1911−// if( !type_engine_import_sfun( env, func ) ) goto error;
1912−//
1913−// // add globalTiltPollRate()
1914−// func = make_new_sfun( "dur", "globalTiltPollRate", HidIn_cget_tiltPollRate );
1915−// if( !type_engine_import_sfun( env, func ) ) goto error;
1916−//
1917−// // add startCursorTrack()
1918−// func = make_new_sfun( "int", "startCursorTrack", HidIn_start_cursor_track );
1919−// if( !type_engine_import_sfun( env, func ) ) goto error;
1920−//
1921−// // add stopCursorTrack()
1922−// func = make_new_sfun( "int", "stopCursorTrack", HidIn_stop_cursor_track );
1923−// if( !type_engine_import_sfun( env, func ) ) goto error;
1924−//
1925−// // add member variable
1926−// HidIn_offset_data = type_engine_import_mvar( env, "int", "@Hid_data", FALSE );
1927−// if( HidIn_offset_data == CK_INVALID_OFFSET ) goto error;
1928−//
1929−// // add static member variable joystick
1930−// if( type_engine_import_svar( env, "int", "JOYSTICK", TRUE,
1931−// ( t_CKUINT ) &CK_HID_DEV_JOYSTICK ) == FALSE )
1932−// goto error;
1933−//
1934−// // add static member variable keyboard
1935−// if( type_engine_import_svar( env, "int", "KEYBOARD", TRUE,
1936−// ( t_CKUINT ) &CK_HID_DEV_KEYBOARD ) == FALSE )
1937−// goto error;
1938−//
1939−// // add static member variable mouse
1940−// if( type_engine_import_svar( env, "int", "MOUSE", TRUE,
1941−// ( t_CKUINT ) &CK_HID_DEV_MOUSE ) == FALSE )
1942−// goto error;
1943−//
1944−// // add static member variable wii_remote
1945−// if( type_engine_import_svar( env, "int", "WII_REMOTE", TRUE,
1946−// ( t_CKUINT ) &CK_HID_DEV_WIIREMOTE ) == FALSE )
1947−// goto error;
1948−//
1949−// // add static member variable wii_remote
1950−// if( type_engine_import_svar( env, "int", "TILT_SENSOR", TRUE,
1951−// ( t_CKUINT ) &CK_HID_DEV_TILTSENSOR ) == FALSE )
1952−// goto error;
1953−//
1954−// // add static member variable tablet
1955−// if( type_engine_import_svar( env, "int", "TABLET", TRUE,
1956−// ( t_CKUINT ) &CK_HID_DEV_TABLET ) == FALSE )
1957−// goto error;
1958−//
1959−// // add static member variable axisMotion
1960−// if( type_engine_import_svar( env, "int", "AXIS_MOTION", TRUE,
1961−// ( t_CKUINT ) &CK_HID_JOYSTICK_AXIS ) == FALSE )
1962−// goto error;
1963−//
1964−// // add static member variable buttonDown
1965−// if( type_engine_import_svar( env, "int", "BUTTON_DOWN", TRUE,
1966−// ( t_CKUINT ) &CK_HID_BUTTON_DOWN ) == FALSE )
1967−// goto error;
1968−//
1969−// // add static member variable buttonUp
1970−// if( type_engine_import_svar( env, "int", "BUTTON_UP", TRUE,
1971−// ( t_CKUINT ) &CK_HID_BUTTON_UP ) == FALSE )
1972−// goto error;
1973−//
1974−// // add static member variable joystickHat
1975−// if( type_engine_import_svar( env, "int", "JOYSTICK_HAT", TRUE,
1976−// ( t_CKUINT ) &CK_HID_JOYSTICK_HAT ) == FALSE )
1977−// goto error;
1978−//
1979−// // add static member variable JOYSTICK_BALL
1980−// if( type_engine_import_svar( env, "int", "JOYSTICK_BALL", TRUE,
1981−// ( t_CKUINT ) &CK_HID_JOYSTICK_BALL ) == FALSE )
1982−// goto error;
1983−//
1984−// // add static member variable mouseMotion
1985−// if( type_engine_import_svar( env, "int", "MOUSE_MOTION", TRUE,
1986−// ( t_CKUINT ) &CK_HID_MOUSE_MOTION ) == FALSE )
1987−// goto error;
1988−//
1989−// // add static member variable mouseWheel
1990−// if( type_engine_import_svar( env, "int", "MOUSE_WHEEL", TRUE,
1991−// ( t_CKUINT ) &CK_HID_MOUSE_WHEEL ) == FALSE )
1992−// goto error;
1993−//
1994−// // add static member variable DEVICE_CONNECTED
1995−// if( type_engine_import_svar( env, "int", "DEVICE_CONNECTED", TRUE,
1996−// ( t_CKUINT ) &CK_HID_DEVICE_CONNECTED ) == FALSE )
1997−// goto error;
1998−//
1999−// // add static member variable DEVICE_DISCONNECTED
2000−// if( type_engine_import_svar( env, "int", "DEVICE_DISCONNECTED", TRUE,
2001−// ( t_CKUINT ) &CK_HID_DEVICE_DISCONNECTED ) == FALSE )
2002−// goto error;
2003−//
2004−// // add static member variable ACCELEROMETER
2005−// if( type_engine_import_svar( env, "int", "ACCELEROMETER", TRUE,
2006−// ( t_CKUINT ) &CK_HID_ACCELEROMETER ) == FALSE )
2007−// goto error;
2008−//
2009−// // add static member variable LED
2010−// if( type_engine_import_svar( env, "int", "LED", TRUE,
2011−// ( t_CKUINT ) &CK_HID_LED ) == FALSE )
2012−// goto error;
2013−//
2014−// // add static member variable LED
2015−// if( type_engine_import_svar( env, "int", "FORCE_FEEDBACK", TRUE,
2016−// ( t_CKUINT ) &CK_HID_FORCE_FEEDBACK ) == FALSE )
2017−// goto error;
2018−//
2019−// // end the class import
2020−// type_engine_import_class_end( env );
2021−//
2022−// /*
2023−// // init base class
2024−// if( !type_engine_import_class_begin( env, "HidOut", "Object",
2025−// env->global(), HidOut_ctor ) )
2026−// return FALSE;
2027−//
2028−// // add open()
2029−// func = make_new_mfun( "int", "open", HidOut_open );
2030−// func->add_arg( "int", "port" );
2031−// if( !type_engine_import_mfun( env, func ) ) goto error;
2032−//
2033−// // add good()
2034−// func = make_new_mfun( "int", "good", HidOut_good );
2035−// if( !type_engine_import_mfun( env, func ) ) goto error;
2036−//
2037−// // add num()
2038−// func = make_new_mfun( "int", "num", HidOut_num );
2039−// if( !type_engine_import_mfun( env, func ) ) goto error;
2040−//
2041−// // add name()
2042−// func = make_new_mfun( "string", "name", HidOut_name );
2043−// if( !type_engine_import_mfun( env, func ) ) goto error;
2044−//
2045−// // add printerr()
2046−// func = make_new_mfun( "void", "printerr", HidOut_printerr );
2047−// func->add_arg( "int", "print_or_not" );
2048−// if( !type_engine_import_mfun( env, func ) ) goto error;
2049−//
2050−// // add send()
2051−// func = make_new_mfun( "int", "send", HidOut_send );
2052−// func->add_arg( "HidMsg", "msg" );
2053−// if( !type_engine_import_mfun( env, func ) ) goto error;
2054−//
2055−// // add member variable
2056−// HidOut_offset_data = type_engine_import_mvar( env, "int", "@HidOut_data", FALSE );
2057−// if( HidOut_offset_data == CK_INVALID_OFFSET ) goto error;
2058−//
2059−// // end the class import
2060−// type_engine_import_class_end( env );
2061−// */
2062−// return TRUE;
2063−//
2064−//error:
2065−//
2066−// // end the class import
2067−// type_engine_import_class_end( env );
2068−//
2069−// return FALSE;
2070−//}
1645+#ifndef __DISABLE_HID__
1646+// static
1647+static t_CKUINT HidIn_offset_data = 0;
1648+
1649+static t_CKUINT HidMsg_offset_device_type = 0;
1650+static t_CKUINT HidMsg_offset_device_num = 0;
1651+static t_CKUINT HidMsg_offset_type = 0;
1652+static t_CKUINT HidMsg_offset_which = 0;
1653+static t_CKUINT HidMsg_offset_idata = 0;
1654+static t_CKUINT HidMsg_offset_fdata = 0;
1655+static t_CKUINT HidMsg_offset_when = 0;
1656+static t_CKUINT HidMsg_offset_deltax = 0;
1657+static t_CKUINT HidMsg_offset_deltay = 0;
1658+static t_CKUINT HidMsg_offset_axis_position = 0; // deprecated
1659+static t_CKUINT HidMsg_offset_axis_position2 = 0;
1660+static t_CKUINT HidMsg_offset_scaled_axis_position = 0; // deprecated
1661+static t_CKUINT HidMsg_offset_hat_position = 0;
1662+static t_CKUINT HidMsg_offset_cursorx = 0;
1663+static t_CKUINT HidMsg_offset_cursory = 0;
1664+static t_CKUINT HidMsg_offset_scaledcursorx = 0;
1665+static t_CKUINT HidMsg_offset_scaledcursory = 0;
1666+static t_CKUINT HidMsg_offset_x = 0;
1667+static t_CKUINT HidMsg_offset_y = 0;
1668+static t_CKUINT HidMsg_offset_z = 0;
1669+static t_CKUINT HidMsg_offset_touchx = 0; // added 1.3.0.0
1670+static t_CKUINT HidMsg_offset_touchy = 0; // added 1.3.0.0
1671+static t_CKUINT HidMsg_offset_touchsize = 0; // added 1.3.0.0
1672+static t_CKUINT HidMsg_offset_ascii = 0;
1673+static t_CKUINT HidMsg_offset_key = 0;
1674+
1675+static t_CKUINT HidOut_offset_data = 0;
1676+
1677+//-----------------------------------------------------------------------------
1678+// name: init_class_HID()
1679+// desc: ...
1680+//-----------------------------------------------------------------------------
1681+t_CKBOOL init_class_HID( Chuck_Env * env )
1682+{
1683+ Chuck_DL_Func * func = NULL;
1684+
1685+ // init base class
1686+ if( !type_engine_import_class_begin( env, "HidMsg", "Object",
1687+ env->global(), NULL, NULL ) )
1688+ return FALSE;
1689+
1690+ // add member variable
1691+ HidMsg_offset_device_type = type_engine_import_mvar( env, "int", "deviceType", FALSE );
1692+ if( HidMsg_offset_device_type == CK_INVALID_OFFSET ) goto error;
1693+
1694+ // add member variable
1695+ HidMsg_offset_device_num = type_engine_import_mvar( env, "int", "deviceNum", FALSE );
1696+ if( HidMsg_offset_device_num == CK_INVALID_OFFSET ) goto error;
1697+
1698+ // add member variable
1699+ HidMsg_offset_type = type_engine_import_mvar( env, "int", "type", FALSE );
1700+ if( HidMsg_offset_type == CK_INVALID_OFFSET ) goto error;
1701+
1702+ // add member variable
1703+ HidMsg_offset_which = type_engine_import_mvar( env, "int", "which", FALSE );
1704+ if( HidMsg_offset_which == CK_INVALID_OFFSET ) goto error;
1705+
1706+ // add member variable
1707+ HidMsg_offset_idata = type_engine_import_mvar( env, "int", "idata", FALSE );
1708+ if( HidMsg_offset_idata == CK_INVALID_OFFSET ) goto error;
1709+
1710+ // add member variable
1711+ HidMsg_offset_fdata = type_engine_import_mvar( env, "float", "fdata", FALSE );
1712+ if( HidMsg_offset_fdata == CK_INVALID_OFFSET ) goto error;
1713+
1714+ // add member variable
1715+ HidMsg_offset_when = type_engine_import_mvar( env, "time", "when", FALSE );
1716+ if( HidMsg_offset_when == CK_INVALID_OFFSET ) goto error;
1717+
1718+ // add member variable
1719+ HidMsg_offset_deltax = type_engine_import_mvar( env, "int", "deltaX", FALSE );
1720+ if( HidMsg_offset_deltax == CK_INVALID_OFFSET ) goto error;
1721+
1722+ // add member variable
1723+ HidMsg_offset_deltay = type_engine_import_mvar( env, "int", "deltaY", FALSE );
1724+ if( HidMsg_offset_deltay == CK_INVALID_OFFSET ) goto error;
1725+
1726+ // add member variable
1727+ HidMsg_offset_cursorx = type_engine_import_mvar( env, "int", "cursorX", FALSE );
1728+ if( HidMsg_offset_cursorx == CK_INVALID_OFFSET ) goto error;
1729+
1730+ // add member variable
1731+ HidMsg_offset_cursory = type_engine_import_mvar( env, "int", "cursorY", FALSE );
1732+ if( HidMsg_offset_cursory == CK_INVALID_OFFSET ) goto error;
1733+
1734+ // add member variable
1735+ HidMsg_offset_scaledcursorx = type_engine_import_mvar( env, "float", "scaledCursorX", FALSE );
1736+ if( HidMsg_offset_scaledcursorx == CK_INVALID_OFFSET ) goto error;
1737+
1738+ // add member variable
1739+ HidMsg_offset_scaledcursory = type_engine_import_mvar( env, "float", "scaledCursorY", FALSE );
1740+ if( HidMsg_offset_scaledcursory == CK_INVALID_OFFSET ) goto error;
1741+
1742+ // add member variable
1743+ HidMsg_offset_x = type_engine_import_mvar( env, "int", "x", FALSE );
1744+ if( HidMsg_offset_x == CK_INVALID_OFFSET ) goto error;
1745+
1746+ // add member variable
1747+ HidMsg_offset_y = type_engine_import_mvar( env, "int", "y", FALSE );
1748+ if( HidMsg_offset_y == CK_INVALID_OFFSET ) goto error;
1749+
1750+ // add member variable
1751+ HidMsg_offset_z = type_engine_import_mvar( env, "int", "z", FALSE );
1752+ if( HidMsg_offset_z == CK_INVALID_OFFSET ) goto error;
1753+
1754+ // add member variable (added 1.3.0.0)
1755+ HidMsg_offset_touchx = type_engine_import_mvar( env, "float", "touchX", FALSE );
1756+ if( HidMsg_offset_touchx == CK_INVALID_OFFSET ) goto error;
1757+
1758+ // add member variable (added 1.3.0.0)
1759+ HidMsg_offset_touchy = type_engine_import_mvar( env, "float", "touchY", FALSE );
1760+ if( HidMsg_offset_touchy == CK_INVALID_OFFSET ) goto error;
1761+
1762+ // add member variable (added 1.3.0.0)
1763+ HidMsg_offset_touchsize = type_engine_import_mvar( env, "float", "touchSize", FALSE );
1764+ if( HidMsg_offset_touchsize == CK_INVALID_OFFSET ) goto error;
1765+
1766+ // add member variable
1767+ HidMsg_offset_axis_position = type_engine_import_mvar( env, "int", "axis_position", FALSE );
1768+ if( HidMsg_offset_axis_position == CK_INVALID_OFFSET ) goto error;
1769+
1770+ // add member variable
1771+ HidMsg_offset_axis_position2 = type_engine_import_mvar( env, "float", "axisPosition", FALSE );
1772+ if( HidMsg_offset_axis_position2 == CK_INVALID_OFFSET ) goto error;
1773+
1774+ // add member variable
1775+ HidMsg_offset_hat_position = type_engine_import_mvar( env, "int", "hatPosition", FALSE );
1776+ if( HidMsg_offset_hat_position == CK_INVALID_OFFSET ) goto error;
1777+
1778+ // add member variable
1779+ HidMsg_offset_ascii = type_engine_import_mvar( env, "int", "ascii", FALSE );
1780+ if( HidMsg_offset_ascii == CK_INVALID_OFFSET ) goto error;
1781+
1782+ // add member variable
1783+ HidMsg_offset_key = type_engine_import_mvar( env, "int", "key", FALSE );
1784+ if( HidMsg_offset_key == CK_INVALID_OFFSET ) goto error;
1785+
1786+ // add member variable
1787+ HidMsg_offset_scaled_axis_position = type_engine_import_mvar( env, "float", "scaled_axis_position", FALSE );
1788+ if( HidMsg_offset_scaled_axis_position == CK_INVALID_OFFSET ) goto error;
1789+
1790+ // add is_axis_motion()
1791+ func = make_new_mfun( "int", "is_axis_motion", HidMsg_is_axis_motion ); // deprecated
1792+ if( !type_engine_import_mfun( env, func ) ) goto error;
1793+
1794+ // add isAxisMotion()
1795+ func = make_new_mfun( "int", "isAxisMotion", HidMsg_is_axis_motion );
1796+ if( !type_engine_import_mfun( env, func ) ) goto error;
1797+
1798+ // add is_button_down()
1799+ func = make_new_mfun( "int", "is_button_down", HidMsg_is_button_down ); // deprecated
1800+ if( !type_engine_import_mfun( env, func ) ) goto error;
1801+
1802+ // add isButtonDown()
1803+ func = make_new_mfun( "int", "isButtonDown", HidMsg_is_button_down );
1804+ if( !type_engine_import_mfun( env, func ) ) goto error;
1805+
1806+ // add is_button_up()
1807+ func = make_new_mfun( "int", "is_button_up", HidMsg_is_button_up ); // deprecated
1808+ if( !type_engine_import_mfun( env, func ) ) goto error;
1809+
1810+ // add isButtonUp()
1811+ func = make_new_mfun( "int", "isButtonUp", HidMsg_is_button_up );
1812+ if( !type_engine_import_mfun( env, func ) ) goto error;
1813+
1814+ // add is_mouse_motion()
1815+ func = make_new_mfun( "int", "is_mouse_motion", HidMsg_is_mouse_motion ); // deprecated
1816+ if( !type_engine_import_mfun( env, func ) ) goto error;
1817+
1818+ // add isMouseMotion()
1819+ func = make_new_mfun( "int", "isMouseMotion", HidMsg_is_mouse_motion );
1820+ if( !type_engine_import_mfun( env, func ) ) goto error;
1821+
1822+ // add is_hat_motion()
1823+ func = make_new_mfun( "int", "is_hat_motion", HidMsg_is_hat_motion ); // deprecated
1824+ if( !type_engine_import_mfun( env, func ) ) goto error;
1825+
1826+ // add isHatMotion()
1827+ func = make_new_mfun( "int", "isHatMotion", HidMsg_is_hat_motion );
1828+ if( !type_engine_import_mfun( env, func ) ) goto error;
1829+
1830+ // add isWheelMotion()
1831+ func = make_new_mfun( "int", "isWheelMotion", HidMsg_is_wheel_motion );
1832+ if( !type_engine_import_mfun( env, func ) ) goto error;
1833+
1834+ // end the class import
1835+ type_engine_import_class_end( env );
1836+
1837+
1838+ // register deprecate
1839+ type_engine_register_deprecate( env, "HidIn", "Hid" );
1840+
1841+ // init base class Hid (copy of HidIn + constants)
1842+ if( !type_engine_import_class_begin( env, "Hid", "Event",
1843+ env->global(), HidIn_ctor, HidIn_dtor ) )
1844+ return FALSE;
1845+
1846+ // add open()
1847+ func = make_new_mfun( "int", "open", HidIn_open );
1848+ func->add_arg( "int", "type" );
1849+ func->add_arg( "int", "num" );
1850+ if( !type_engine_import_mfun( env, func ) ) goto error;
1851+
1852+ // add open()
1853+ func = make_new_mfun( "int", "open", HidIn_open_named );
1854+ func->add_arg( "string", "name" );
1855+ if( !type_engine_import_mfun( env, func ) ) goto error;
1856+
1857+ // add openJoystick()
1858+ func = make_new_mfun( "int", "openJoystick", HidIn_open_joystick );
1859+ func->add_arg( "int", "num" );
1860+ if( !type_engine_import_mfun( env, func ) ) goto error;
20711861
1862+ // add openMouse()
1863+ func = make_new_mfun( "int", "openMouse", HidIn_open_mouse );
1864+ func->add_arg( "int", "num" );
1865+ if( !type_engine_import_mfun( env, func ) ) goto error;
1866+
1867+ // add openKeyboard()
1868+ func = make_new_mfun( "int", "openKeyboard", HidIn_open_keyboard );
1869+ func->add_arg( "int", "num" );
1870+ if( !type_engine_import_mfun( env, func ) ) goto error;
1871+
1872+ // add openTiltSensor()
1873+ func = make_new_mfun( "int", "openTiltSensor", HidIn_open_tiltsensor );
1874+ if( !type_engine_import_mfun( env, func ) ) goto error;
1875+
1876+ // add good()
1877+ func = make_new_mfun( "int", "good", HidIn_good );
1878+ if( !type_engine_import_mfun( env, func ) ) goto error;
1879+
1880+ // add num()
1881+ func = make_new_mfun( "int", "num", HidIn_num );
1882+ if( !type_engine_import_mfun( env, func ) ) goto error;
1883+
1884+ // add name()
1885+ func = make_new_mfun( "string", "name", HidIn_name );
1886+ if( !type_engine_import_mfun( env, func ) ) goto error;
1887+
1888+ // add printerr()
1889+ func = make_new_mfun( "void", "printerr", HidIn_printerr );
1890+ func->add_arg( "int", "print_or_not" );
1891+ if( !type_engine_import_mfun( env, func ) ) goto error;
1892+
1893+ // add recv()
1894+ func = make_new_mfun( "int", "recv", HidIn_recv );
1895+ func->add_arg( "HidMsg", "msg" );
1896+ if( !type_engine_import_mfun( env, func ) ) goto error;
1897+
1898+ // add read()
1899+ func = make_new_mfun( "int", "read", HidIn_read );
1900+ func->add_arg( "int", "type" );
1901+ func->add_arg( "int", "which" );
1902+ func->add_arg( "HidMsg", "msg" );
1903+ if( !type_engine_import_mfun( env, func ) ) goto error;
1904+
1905+ // add send()
1906+ func = make_new_mfun( "int", "send", HidIn_send );
1907+ func->add_arg( "HidMsg", "msg" );
1908+ if( !type_engine_import_mfun( env, func ) ) goto error;
1909+
1910+ // add can_wait()
1911+ func = make_new_mfun( "int", "can_wait", HidIn_can_wait );
1912+ if( !type_engine_import_mfun( env, func ) ) goto error;
1913+
1914+ // add readTiltSensor()
1915+ func = make_new_sfun( "int[]", "readTiltSensor", HidIn_read_tilt_sensor );
1916+ if( !type_engine_import_sfun( env, func ) ) goto error;
1917+
1918+ // add globalTiltPollRate()
1919+ func = make_new_sfun( "dur", "globalTiltPollRate", HidIn_ctrl_tiltPollRate );
1920+ func->add_arg( "dur", "d" );
1921+ if( !type_engine_import_sfun( env, func ) ) goto error;
1922+
1923+ // add globalTiltPollRate()
1924+ func = make_new_sfun( "dur", "globalTiltPollRate", HidIn_cget_tiltPollRate );
1925+ if( !type_engine_import_sfun( env, func ) ) goto error;
1926+
1927+ // add startCursorTrack()
1928+ func = make_new_sfun( "int", "startCursorTrack", HidIn_start_cursor_track );
1929+ if( !type_engine_import_sfun( env, func ) ) goto error;
1930+
1931+ // add stopCursorTrack()
1932+ func = make_new_sfun( "int", "stopCursorTrack", HidIn_stop_cursor_track );
1933+ if( !type_engine_import_sfun( env, func ) ) goto error;
1934+
1935+ // add member variable
1936+ HidIn_offset_data = type_engine_import_mvar( env, "int", "@Hid_data", FALSE );
1937+ if( HidIn_offset_data == CK_INVALID_OFFSET ) goto error;
1938+
1939+ // add static member variable joystick
1940+ if( type_engine_import_svar( env, "int", "JOYSTICK", TRUE,
1941+ ( t_CKUINT ) &CK_HID_DEV_JOYSTICK ) == FALSE )
1942+ goto error;
1943+
1944+ // add static member variable keyboard
1945+ if( type_engine_import_svar( env, "int", "KEYBOARD", TRUE,
1946+ ( t_CKUINT ) &CK_HID_DEV_KEYBOARD ) == FALSE )
1947+ goto error;
1948+
1949+ // add static member variable mouse
1950+ if( type_engine_import_svar( env, "int", "MOUSE", TRUE,
1951+ ( t_CKUINT ) &CK_HID_DEV_MOUSE ) == FALSE )
1952+ goto error;
1953+
1954+ // add static member variable wii_remote
1955+ if( type_engine_import_svar( env, "int", "WII_REMOTE", TRUE,
1956+ ( t_CKUINT ) &CK_HID_DEV_WIIREMOTE ) == FALSE )
1957+ goto error;
1958+
1959+ // add static member variable wii_remote
1960+ if( type_engine_import_svar( env, "int", "TILT_SENSOR", TRUE,
1961+ ( t_CKUINT ) &CK_HID_DEV_TILTSENSOR ) == FALSE )
1962+ goto error;
1963+
1964+ // add static member variable tablet
1965+ if( type_engine_import_svar( env, "int", "TABLET", TRUE,
1966+ ( t_CKUINT ) &CK_HID_DEV_TABLET ) == FALSE )
1967+ goto error;
1968+
1969+ // add static member variable axisMotion
1970+ if( type_engine_import_svar( env, "int", "AXIS_MOTION", TRUE,
1971+ ( t_CKUINT ) &CK_HID_JOYSTICK_AXIS ) == FALSE )
1972+ goto error;
1973+
1974+ // add static member variable buttonDown
1975+ if( type_engine_import_svar( env, "int", "BUTTON_DOWN", TRUE,
1976+ ( t_CKUINT ) &CK_HID_BUTTON_DOWN ) == FALSE )
1977+ goto error;
1978+
1979+ // add static member variable buttonUp
1980+ if( type_engine_import_svar( env, "int", "BUTTON_UP", TRUE,
1981+ ( t_CKUINT ) &CK_HID_BUTTON_UP ) == FALSE )
1982+ goto error;
1983+
1984+ // add static member variable joystickHat
1985+ if( type_engine_import_svar( env, "int", "JOYSTICK_HAT", TRUE,
1986+ ( t_CKUINT ) &CK_HID_JOYSTICK_HAT ) == FALSE )
1987+ goto error;
1988+
1989+ // add static member variable JOYSTICK_BALL
1990+ if( type_engine_import_svar( env, "int", "JOYSTICK_BALL", TRUE,
1991+ ( t_CKUINT ) &CK_HID_JOYSTICK_BALL ) == FALSE )
1992+ goto error;
1993+
1994+ // add static member variable mouseMotion
1995+ if( type_engine_import_svar( env, "int", "MOUSE_MOTION", TRUE,
1996+ ( t_CKUINT ) &CK_HID_MOUSE_MOTION ) == FALSE )
1997+ goto error;
1998+
1999+ // add static member variable mouseWheel
2000+ if( type_engine_import_svar( env, "int", "MOUSE_WHEEL", TRUE,
2001+ ( t_CKUINT ) &CK_HID_MOUSE_WHEEL ) == FALSE )
2002+ goto error;
2003+
2004+ // add static member variable DEVICE_CONNECTED
2005+ if( type_engine_import_svar( env, "int", "DEVICE_CONNECTED", TRUE,
2006+ ( t_CKUINT ) &CK_HID_DEVICE_CONNECTED ) == FALSE )
2007+ goto error;
2008+
2009+ // add static member variable DEVICE_DISCONNECTED
2010+ if( type_engine_import_svar( env, "int", "DEVICE_DISCONNECTED", TRUE,
2011+ ( t_CKUINT ) &CK_HID_DEVICE_DISCONNECTED ) == FALSE )
2012+ goto error;
2013+
2014+ // add static member variable ACCELEROMETER
2015+ if( type_engine_import_svar( env, "int", "ACCELEROMETER", TRUE,
2016+ ( t_CKUINT ) &CK_HID_ACCELEROMETER ) == FALSE )
2017+ goto error;
2018+
2019+ // add static member variable LED
2020+ if( type_engine_import_svar( env, "int", "LED", TRUE,
2021+ ( t_CKUINT ) &CK_HID_LED ) == FALSE )
2022+ goto error;
2023+
2024+ // add static member variable LED
2025+ if( type_engine_import_svar( env, "int", "FORCE_FEEDBACK", TRUE,
2026+ ( t_CKUINT ) &CK_HID_FORCE_FEEDBACK ) == FALSE )
2027+ goto error;
2028+
2029+ // end the class import
2030+ type_engine_import_class_end( env );
2031+
2032+ /*
2033+ // init base class
2034+ if( !type_engine_import_class_begin( env, "HidOut", "Object",
2035+ env->global(), HidOut_ctor ) )
2036+ return FALSE;
2037+
2038+ // add open()
2039+ func = make_new_mfun( "int", "open", HidOut_open );
2040+ func->add_arg( "int", "port" );
2041+ if( !type_engine_import_mfun( env, func ) ) goto error;
2042+
2043+ // add good()
2044+ func = make_new_mfun( "int", "good", HidOut_good );
2045+ if( !type_engine_import_mfun( env, func ) ) goto error;
2046+
2047+ // add num()
2048+ func = make_new_mfun( "int", "num", HidOut_num );
2049+ if( !type_engine_import_mfun( env, func ) ) goto error;
2050+
2051+ // add name()
2052+ func = make_new_mfun( "string", "name", HidOut_name );
2053+ if( !type_engine_import_mfun( env, func ) ) goto error;
2054+
2055+ // add printerr()
2056+ func = make_new_mfun( "void", "printerr", HidOut_printerr );
2057+ func->add_arg( "int", "print_or_not" );
2058+ if( !type_engine_import_mfun( env, func ) ) goto error;
2059+
2060+ // add send()
2061+ func = make_new_mfun( "int", "send", HidOut_send );
2062+ func->add_arg( "HidMsg", "msg" );
2063+ if( !type_engine_import_mfun( env, func ) ) goto error;
2064+
2065+ // add member variable
2066+ HidOut_offset_data = type_engine_import_mvar( env, "int", "@HidOut_data", FALSE );
2067+ if( HidOut_offset_data == CK_INVALID_OFFSET ) goto error;
2068+
2069+ // end the class import
2070+ type_engine_import_class_end( env );
2071+ */
2072+ return TRUE;
2073+
2074+error:
2075+
2076+ // end the class import
2077+ type_engine_import_class_end( env );
2078+
2079+ return FALSE;
2080+}
2081+#endif
20722082
20732083
20742084
@@ -2962,313 +2972,319 @@ CK_DLL_SFUN( io_newline ) · 887 unmodified lines
29622972 }
29632973
29642974
2975+
2976+
2977+#ifndef __DISABLE_FILEIO__
29652978 //-----------------------------------------------------------------------------
29662979 // FileIO API
29672980 //-----------------------------------------------------------------------------
2968−//CK_DLL_CTOR( fileio_ctor )
2969−//{ }
2970−//
2971−//CK_DLL_DTOR( fileio_dtor )
2972−//{ }
2973−//
2974−//CK_DLL_MFUN( fileio_open )
2975−//{
2976−// std::string filename = GET_NEXT_STRING(ARGS)->str();
2977−// Chuck_IO_File * f = (Chuck_IO_File *)SELF;
2978−// t_CKINT default_flags =
2979−// Chuck_IO_File::FLAG_READ_WRITE | Chuck_IO_File::TYPE_ASCII;
2980−//
2981−// RETURN->v_int = f->open(filename, default_flags);
2982−//}
2983−//
2984−//CK_DLL_MFUN( fileio_openflags )
2985−//{
2986−// Chuck_IO_File * f = (Chuck_IO_File *)SELF;
2987−// std::string filename = GET_NEXT_STRING(ARGS)->str();
2988−// t_CKINT flags = GET_NEXT_INT(ARGS);
2989−//
2990−// RETURN->v_int = f->open(filename, flags);
2991−//}
2992−//
2993−//CK_DLL_MFUN( fileio_close )
2994−//{
2995−// Chuck_IO_File * f = (Chuck_IO_File *)SELF;
2996−// f->close();
2997−//}
2998−//
2999−//CK_DLL_MFUN( fileio_good )
3000−//{
3001−// Chuck_IO_File * f = (Chuck_IO_File *)SELF;
3002−// RETURN->v_int = f->good();
3003−//}
3004−//
3005−//CK_DLL_MFUN( fileio_flush )
3006−//{
3007−// Chuck_IO_File * f = (Chuck_IO_File *)SELF;
3008−// f->flush();
3009−//}
3010−//
3011−//CK_DLL_MFUN( fileio_getmode )
3012−//{
3013−// Chuck_IO_File * f = (Chuck_IO_File *)SELF;
3014−// RETURN->v_int = f->mode();
3015−//}
3016−//
3017−//CK_DLL_MFUN( fileio_setmode )
3018−//{
3019−// t_CKINT flag = GET_NEXT_INT(ARGS);
3020−//
3021−// Chuck_IO_File * f = (Chuck_IO_File *)SELF;
3022−// f->mode( flag );
3023−// RETURN->v_int = 0;
3024−//}
3025−//
3026−//CK_DLL_MFUN( fileio_size )
3027−//{
3028−// Chuck_IO_File * f = (Chuck_IO_File *)SELF;
3029−// RETURN->v_int = f->size();
3030−//}
3031−//
3032−//CK_DLL_MFUN( fileio_seek )
3033−//{
3034−// t_CKINT pos = GET_NEXT_INT(ARGS);
3035−//
3036−// Chuck_IO_File * f = (Chuck_IO_File *)SELF;
3037−// f->seek(pos);
3038−//}
3039−//
3040−//CK_DLL_MFUN( fileio_tell )
3041−//{
3042−// Chuck_IO_File * f = (Chuck_IO_File *)SELF;
3043−// RETURN->v_int = f->tell();
3044−//}
3045−//
3046−//CK_DLL_MFUN( fileio_isdir )
3047−//{
3048−// Chuck_IO_File * f = (Chuck_IO_File *)SELF;
3049−// RETURN->v_int = f->isDir();
3050−//}
3051−//
3052−//CK_DLL_MFUN( fileio_dirlist )
3053−//{
3054−// Chuck_IO_File * f = (Chuck_IO_File *)SELF;
3055−// Chuck_Array4 * a = f->dirList();
3056−// RETURN->v_object = a;
3057−//}
3058−//
3059−///*
3060−//CK_DLL_MFUN( fileio_read )
3061−//{
3062−// t_CKINT len = GET_NEXT_INT(ARGS);
3063−// Chuck_IO_File * f = (Chuck_IO_File *)SELF;
3064−//
3065−// Chuck_String * s = f->read( len );
3066−// RETURN->v_object = s;
3067−//}
3068−//*/
3069−//
3070−//CK_DLL_MFUN( fileio_readline )
3071−//{
3072−// Chuck_IO_File * f = (Chuck_IO_File *)SELF;
3073−// Chuck_String * ret = f->readLine();
3074−// RETURN->v_object = ret;
3075−//}
3076−//
3077−//CK_DLL_MFUN( fileio_readint )
3078−//{
3079−// Chuck_IO_File * f = (Chuck_IO_File *)SELF;
3080−// t_CKINT defaultflags = Chuck_IO::INT32;
3081−//
3082−// /* (ATODO: doesn't look like asynchronous reading will work)
3083−// if (f->mode() == Chuck_IO::MODE_ASYNC)
3084−// {
3085−// // set up arguments
3086−// Chuck_IO::async_args *args = new Chuck_IO::async_args;
3087−// args->RETURN = (void *)RETURN;
3088−// args->fileio_obj = f;
3089−// args->intArg = defaultflags;
3090−// // set shred to wait for I/O completion
3091−// f->m_asyncEvent->wait( SHRED, SHRED->vm_ref );
3092−// // start thread
3093−// bool ret = f->m_thread->start( f->readInt_thread, (void *)args );
3094−// if (!ret) {
3095−// cerr << "m_thread->start failed; recreating m_thread" << endl;
3096−// delete f->m_thread;
3097−// f->m_thread = new XThread;
3098−// ret = f->m_thread->start( f->readInt_thread, (void *)args );
3099−// if (!ret) {
3100−// EM_error3( "(FileIO): failed to start thread for asynchronous mode I/O" );
3101−// }
3102−// }
3103−// } else {*/
3104−// t_CKINT ret = f->readInt( defaultflags );
3105−// RETURN->v_int = ret;
3106−// //}
3107−// // ATODO: Debug
3108−// //sleep(1);
3109−// //cerr << "fileio_readint exiting" << endl;
3110−//}
3111−//
3112−//CK_DLL_MFUN( fileio_readintflags )
3113−//{
3114−// t_CKINT flags = GET_NEXT_INT(ARGS);
3115−//
3116−// Chuck_IO_File * f = (Chuck_IO_File *)SELF;
3117−// t_CKINT ret = f->readInt( flags );
3118−//
3119−// RETURN->v_int = ret;
3120−//}
3121−//
3122−//CK_DLL_MFUN( fileio_readfloat )
3123−//{
3124−// Chuck_IO_File * f = (Chuck_IO_File *)SELF;
3125−// t_CKFLOAT ret = f->readFloat();
3126−// RETURN->v_float = ret;
3127−//}
3128−//
3129−//CK_DLL_MFUN( fileio_eof )
3130−//{
3131−// Chuck_IO_File * f = (Chuck_IO_File *)SELF;
3132−// t_CKBOOL ret = f->eof();
3133−// RETURN->v_int = ret;
3134−//}
3135−//
3136−//CK_DLL_MFUN( fileio_more )
3137−//{
3138−// Chuck_IO_File * f = (Chuck_IO_File *)SELF;
3139−// t_CKBOOL ret = !f->eof();
3140−// RETURN->v_int = ret;
3141−//}
3142−//
3143−//CK_DLL_MFUN( fileio_writestring )
3144−//{
3145−// std::string val = GET_NEXT_STRING(ARGS)->str();
3146−//
3147−// Chuck_IO_File * f = (Chuck_IO_File *)SELF;
3148−// if (f->mode() == Chuck_IO::MODE_ASYNC)
3149−// {
3150−// // set up arguments
3151−// Chuck_IO::async_args *args = new Chuck_IO::async_args;
3152−// args->RETURN = (void *)RETURN;
3153−// args->fileio_obj = f;
3154−// args->stringArg = std::string(val);
3155−// // set shred to wait for I/O completion
3156−// assert( SHRED != NULL );
3157−// f->m_asyncEvent->wait( SHRED, SHRED->vm_ref );
3158−// // start thread
3159−// bool ret = f->m_thread->start( f->writeStr_thread, (void *)args );
3160−// if (!ret) {
3161−// // for some reason, the XThread object needs to be
3162−// // deleted and reconstructed every time after call #375
3163−// delete f->m_thread;
3164−// f->m_thread = new XThread;
3165−// ret = f->m_thread->start( f->writeStr_thread, (void *)args );
3166−// if (!ret) {
3167−// EM_error3( "(FileIO): failed to start thread for asynchronous mode I/O" );
3168−// }
3169−// }
3170−// } else {
3171−// f->write(val);
3172−// }
3173−//}
3174−//
3175−//CK_DLL_MFUN( fileio_writeint )
3176−//{
3177−// t_CKINT val = GET_NEXT_INT(ARGS);
3178−//
3179−// Chuck_IO_File * f = (Chuck_IO_File *)SELF;
3180−// if (f->mode() == Chuck_IO::MODE_ASYNC)
3181−// {
3182−// // set up arguments
3183−// Chuck_IO::async_args *args = new Chuck_IO::async_args;
3184−// args->RETURN = (void *)RETURN;
3185−// args->fileio_obj = f;
3186−// args->intArg = val;
3187−// // set shred to wait for I/O completion
3188−// assert( SHRED != NULL );
3189−// f->m_asyncEvent->wait( SHRED, SHRED->vm_ref );
3190−// // start thread
3191−// bool ret = f->m_thread->start( f->writeInt_thread, (void *)args );
3192−// if (!ret) {
3193−// // for some reason, the XThread object needs to be
3194−// // deleted and reconstructed every time after call #375
3195−// delete f->m_thread;
3196−// f->m_thread = new XThread;
3197−// ret = f->m_thread->start( f->writeInt_thread, (void *)args );
3198−// if (!ret) {
3199−// EM_error3( "(FileIO): failed to start thread for asynchronous mode I/O" );
3200−// }
3201−// }
3202−// } else {
3203−// f->write(val);
3204−// }
3205−//}
3206−//
3207−//CK_DLL_MFUN( fileio_writeintflags )
3208−//{
3209−// t_CKINT val = GET_NEXT_INT(ARGS);
3210−// t_CKINT flags = GET_NEXT_INT(ARGS);
3211−//
3212−// Chuck_IO_File * f = (Chuck_IO_File *)SELF;
3213−// if (f->mode() == Chuck_IO::MODE_ASYNC)
3214−// {
3215−// // TODO: pass flags in args
3216−// // set up arguments
3217−// Chuck_IO::async_args *args = new Chuck_IO::async_args;
3218−// args->RETURN = (void *)RETURN;
3219−// args->fileio_obj = f;
3220−// args->intArg = val;
3221−// // set shred to wait for I/O completion
3222−// assert( SHRED != NULL );
3223−// f->m_asyncEvent->wait( SHRED, SHRED->vm_ref );
3224−// // start thread
3225−// bool ret = f->m_thread->start( f->writeInt_thread, (void *)args );
3226−// if (!ret) {
3227−// // for some reason, the XThread object needs to be
3228−// // deleted and reconstructed every time after call #375
3229−// delete f->m_thread;
3230−// f->m_thread = new XThread;
3231−// ret = f->m_thread->start( f->writeInt_thread, (void *)args );
3232−// if (!ret) {
3233−// EM_error3( "(FileIO): failed to start thread for asynchronous mode I/O" );
3234−// }
3235−// }
3236−// } else {
3237−// f->write(val, flags);
3238−// }
3239−//}
3240−//
3241−//CK_DLL_MFUN( fileio_writefloat )
3242−//{
3243−// t_CKFLOAT val = GET_NEXT_FLOAT(ARGS);
3244−//
3245−// Chuck_IO_File * f = (Chuck_IO_File *)SELF;
3246−// if (f->mode() == Chuck_IO::MODE_ASYNC)
3247−// {
3248−// // set up arguments
3249−// Chuck_IO::async_args *args = new Chuck_IO::async_args;
3250−// args->RETURN = (void *)RETURN;
3251−// args->fileio_obj = f;
3252−// args->floatArg = val;
3253−// // set shred to wait for I/O completion
3254−// assert( SHRED != NULL );
3255−// f->m_asyncEvent->wait( SHRED, SHRED->vm_ref );
3256−// // start thread
3257−// bool ret = f->m_thread->start( f->writeFloat_thread, (void *)args );
3258−// if (!ret) {
3259−// // for some reason, the XThread object needs to be
3260−// // deleted and reconstructed every time after call #375
3261−// delete f->m_thread;
3262−// f->m_thread = new XThread;
3263−// ret = f->m_thread->start( f->writeFloat_thread, (void *)args );
3264−// if (!ret) {
3265−// EM_error3( "(FileIO): failed to start thread for asynchronous mode I/O" );
3266−// }
3267−// }
3268−// } else {
3269−// f->write(val);
3270−// }
3271−//}
2981+CK_DLL_CTOR( fileio_ctor )
2982+{ }
2983+
2984+CK_DLL_DTOR( fileio_dtor )
2985+{ }
2986+
2987+CK_DLL_MFUN( fileio_open )
2988+{
2989+ std::string filename = GET_NEXT_STRING(ARGS)->str();
2990+ Chuck_IO_File * f = (Chuck_IO_File *)SELF;
2991+ t_CKINT default_flags =
2992+ Chuck_IO_File::FLAG_READ_WRITE | Chuck_IO_File::TYPE_ASCII;
2993+
2994+ RETURN->v_int = f->open(filename, default_flags);
2995+}
2996+
2997+CK_DLL_MFUN( fileio_openflags )
2998+{
2999+ Chuck_IO_File * f = (Chuck_IO_File *)SELF;
3000+ std::string filename = GET_NEXT_STRING(ARGS)->str();
3001+ t_CKINT flags = GET_NEXT_INT(ARGS);
3002+
3003+ RETURN->v_int = f->open(filename, flags);
3004+}
3005+
3006+CK_DLL_MFUN( fileio_close )
3007+{
3008+ Chuck_IO_File * f = (Chuck_IO_File *)SELF;
3009+ f->close();
3010+}
3011+
3012+CK_DLL_MFUN( fileio_good )
3013+{
3014+ Chuck_IO_File * f = (Chuck_IO_File *)SELF;
3015+ RETURN->v_int = f->good();
3016+}
3017+
3018+CK_DLL_MFUN( fileio_flush )
3019+{
3020+ Chuck_IO_File * f = (Chuck_IO_File *)SELF;
3021+ f->flush();
3022+}
3023+
3024+CK_DLL_MFUN( fileio_getmode )
3025+{
3026+ Chuck_IO_File * f = (Chuck_IO_File *)SELF;
3027+ RETURN->v_int = f->mode();
3028+}
3029+
3030+CK_DLL_MFUN( fileio_setmode )
3031+{
3032+ t_CKINT flag = GET_NEXT_INT(ARGS);
3033+
3034+ Chuck_IO_File * f = (Chuck_IO_File *)SELF;
3035+ f->mode( flag );
3036+ RETURN->v_int = 0;
3037+}
3038+
3039+CK_DLL_MFUN( fileio_size )
3040+{
3041+ Chuck_IO_File * f = (Chuck_IO_File *)SELF;
3042+ RETURN->v_int = f->size();
3043+}
3044+
3045+CK_DLL_MFUN( fileio_seek )
3046+{
3047+ t_CKINT pos = GET_NEXT_INT(ARGS);
3048+
3049+ Chuck_IO_File * f = (Chuck_IO_File *)SELF;
3050+ f->seek(pos);
3051+}
3052+
3053+CK_DLL_MFUN( fileio_tell )
3054+{
3055+ Chuck_IO_File * f = (Chuck_IO_File *)SELF;
3056+ RETURN->v_int = f->tell();
3057+}
3058+
3059+CK_DLL_MFUN( fileio_isdir )
3060+{
3061+ Chuck_IO_File * f = (Chuck_IO_File *)SELF;
3062+ RETURN->v_int = f->isDir();
3063+}
3064+
3065+CK_DLL_MFUN( fileio_dirlist )
3066+{
3067+ Chuck_IO_File * f = (Chuck_IO_File *)SELF;
3068+ Chuck_Array4 * a = f->dirList();
3069+ RETURN->v_object = a;
3070+}
3071+
3072+/*
3073+CK_DLL_MFUN( fileio_read )
3074+{
3075+ t_CKINT len = GET_NEXT_INT(ARGS);
3076+ Chuck_IO_File * f = (Chuck_IO_File *)SELF;
3077+
3078+ Chuck_String * s = f->read( len );
3079+ RETURN->v_object = s;
3080+}
3081+*/
3082+
3083+CK_DLL_MFUN( fileio_readline )
3084+{
3085+ Chuck_IO_File * f = (Chuck_IO_File *)SELF;
3086+ Chuck_String * ret = f->readLine();
3087+ RETURN->v_object = ret;
3088+}
3089+
3090+CK_DLL_MFUN( fileio_readint )
3091+{
3092+ Chuck_IO_File * f = (Chuck_IO_File *)SELF;
3093+ t_CKINT defaultflags = Chuck_IO::INT32;
3094+
3095+ /* (ATODO: doesn't look like asynchronous reading will work)
3096+ if (f->mode() == Chuck_IO::MODE_ASYNC)
3097+ {
3098+ // set up arguments
3099+ Chuck_IO::async_args *args = new Chuck_IO::async_args;
3100+ args->RETURN = (void *)RETURN;
3101+ args->fileio_obj = f;
3102+ args->intArg = defaultflags;
3103+ // set shred to wait for I/O completion
3104+ f->m_asyncEvent->wait( SHRED, SHRED->vm_ref );
3105+ // start thread
3106+ bool ret = f->m_thread->start( f->readInt_thread, (void *)args );
3107+ if (!ret) {
3108+ cerr << "m_thread->start failed; recreating m_thread" << endl;
3109+ delete f->m_thread;
3110+ f->m_thread = new XThread;
3111+ ret = f->m_thread->start( f->readInt_thread, (void *)args );
3112+ if (!ret) {
3113+ EM_error3( "(FileIO): failed to start thread for asynchronous mode I/O" );
3114+ }
3115+ }
3116+ } else {*/
3117+ t_CKINT ret = f->readInt( defaultflags );
3118+ RETURN->v_int = ret;
3119+ //}
3120+ // ATODO: Debug
3121+ //sleep(1);
3122+ //cerr << "fileio_readint exiting" << endl;
3123+}
3124+
3125+CK_DLL_MFUN( fileio_readintflags )
3126+{
3127+ t_CKINT flags = GET_NEXT_INT(ARGS);
3128+
3129+ Chuck_IO_File * f = (Chuck_IO_File *)SELF;
3130+ t_CKINT ret = f->readInt( flags );
3131+
3132+ RETURN->v_int = ret;
3133+}
3134+
3135+CK_DLL_MFUN( fileio_readfloat )
3136+{
3137+ Chuck_IO_File * f = (Chuck_IO_File *)SELF;
3138+ t_CKFLOAT ret = f->readFloat();
3139+ RETURN->v_float = ret;
3140+}
3141+
3142+CK_DLL_MFUN( fileio_eof )
3143+{
3144+ Chuck_IO_File * f = (Chuck_IO_File *)SELF;
3145+ t_CKBOOL ret = f->eof();
3146+ RETURN->v_int = ret;
3147+}
3148+
3149+CK_DLL_MFUN( fileio_more )
3150+{
3151+ Chuck_IO_File * f = (Chuck_IO_File *)SELF;
3152+ t_CKBOOL ret = !f->eof();
3153+ RETURN->v_int = ret;
3154+}
3155+
3156+CK_DLL_MFUN( fileio_writestring )
3157+{
3158+ std::string val = GET_NEXT_STRING(ARGS)->str();
3159+
3160+ Chuck_IO_File * f = (Chuck_IO_File *)SELF;
3161+ if (f->mode() == Chuck_IO::MODE_ASYNC)
3162+ {
3163+ // set up arguments
3164+ Chuck_IO::async_args *args = new Chuck_IO::async_args;
3165+ args->RETURN = (void *)RETURN;
3166+ args->fileio_obj = f;
3167+ args->stringArg = std::string(val);
3168+ // set shred to wait for I/O completion
3169+ assert( SHRED != NULL );
3170+ f->m_asyncEvent->wait( SHRED, SHRED->vm_ref );
3171+ // start thread
3172+ bool ret = f->m_thread->start( f->writeStr_thread, (void *)args );
3173+ if (!ret) {
3174+ // for some reason, the XThread object needs to be
3175+ // deleted and reconstructed every time after call #375
3176+ delete f->m_thread;
3177+ f->m_thread = new XThread;
3178+ ret = f->m_thread->start( f->writeStr_thread, (void *)args );
3179+ if (!ret) {
3180+ EM_error3( "(FileIO): failed to start thread for asynchronous mode I/O" );
3181+ }
3182+ }
3183+ } else {
3184+ f->write(val);
3185+ }
3186+}
3187+
3188+CK_DLL_MFUN( fileio_writeint )
3189+{
3190+ t_CKINT val = GET_NEXT_INT(ARGS);
3191+
3192+ Chuck_IO_File * f = (Chuck_IO_File *)SELF;
3193+ if (f->mode() == Chuck_IO::MODE_ASYNC)
3194+ {
3195+ // set up arguments
3196+ Chuck_IO::async_args *args = new Chuck_IO::async_args;
3197+ args->RETURN = (void *)RETURN;
3198+ args->fileio_obj = f;
3199+ args->intArg = val;
3200+ // set shred to wait for I/O completion
3201+ assert( SHRED != NULL );
3202+ f->m_asyncEvent->wait( SHRED, SHRED->vm_ref );
3203+ // start thread
3204+ bool ret = f->m_thread->start( f->writeInt_thread, (void *)args );
3205+ if (!ret) {
3206+ // for some reason, the XThread object needs to be
3207+ // deleted and reconstructed every time after call #375
3208+ delete f->m_thread;
3209+ f->m_thread = new XThread;
3210+ ret = f->m_thread->start( f->writeInt_thread, (void *)args );
3211+ if (!ret) {
3212+ EM_error3( "(FileIO): failed to start thread for asynchronous mode I/O" );
3213+ }
3214+ }
3215+ } else {
3216+ f->write(val);
3217+ }
3218+}
3219+
3220+CK_DLL_MFUN( fileio_writeintflags )
3221+{
3222+ t_CKINT val = GET_NEXT_INT(ARGS);
3223+ t_CKINT flags = GET_NEXT_INT(ARGS);
3224+
3225+ Chuck_IO_File * f = (Chuck_IO_File *)SELF;
3226+ if (f->mode() == Chuck_IO::MODE_ASYNC)
3227+ {
3228+ // TODO: pass flags in args
3229+ // set up arguments
3230+ Chuck_IO::async_args *args = new Chuck_IO::async_args;
3231+ args->RETURN = (void *)RETURN;
3232+ args->fileio_obj = f;
3233+ args->intArg = val;
3234+ // set shred to wait for I/O completion
3235+ assert( SHRED != NULL );
3236+ f->m_asyncEvent->wait( SHRED, SHRED->vm_ref );
3237+ // start thread
3238+ bool ret = f->m_thread->start( f->writeInt_thread, (void *)args );
3239+ if (!ret) {
3240+ // for some reason, the XThread object needs to be
3241+ // deleted and reconstructed every time after call #375
3242+ delete f->m_thread;
3243+ f->m_thread = new XThread;
3244+ ret = f->m_thread->start( f->writeInt_thread, (void *)args );
3245+ if (!ret) {
3246+ EM_error3( "(FileIO): failed to start thread for asynchronous mode I/O" );
3247+ }
3248+ }
3249+ } else {
3250+ f->write(val, flags);
3251+ }
3252+}
3253+
3254+CK_DLL_MFUN( fileio_writefloat )
3255+{
3256+ t_CKFLOAT val = GET_NEXT_FLOAT(ARGS);
3257+
3258+ Chuck_IO_File * f = (Chuck_IO_File *)SELF;
3259+ if (f->mode() == Chuck_IO::MODE_ASYNC)
3260+ {
3261+ // set up arguments
3262+ Chuck_IO::async_args *args = new Chuck_IO::async_args;
3263+ args->RETURN = (void *)RETURN;
3264+ args->fileio_obj = f;
3265+ args->floatArg = val;
3266+ // set shred to wait for I/O completion
3267+ assert( SHRED != NULL );
3268+ f->m_asyncEvent->wait( SHRED, SHRED->vm_ref );
3269+ // start thread
3270+ bool ret = f->m_thread->start( f->writeFloat_thread, (void *)args );
3271+ if (!ret) {
3272+ // for some reason, the XThread object needs to be
3273+ // deleted and reconstructed every time after call #375
3274+ delete f->m_thread;
3275+ f->m_thread = new XThread;
3276+ ret = f->m_thread->start( f->writeFloat_thread, (void *)args );
3277+ if (!ret) {
3278+ EM_error3( "(FileIO): failed to start thread for asynchronous mode I/O" );
3279+ }
3280+ }
3281+ } else {
3282+ f->write(val);
3283+ }
3284+}
3285+#endif
3286+
3287+
32723288
32733289
32743290 //-----------------------------------------------------------------------------
@@ -4336,403 +4352,409 @@ CK_DLL_MFUN( MidiOut_send ) · 1061 unmodified lines
43364352 #endif // __DISABLE_MIDI__
43374353
43384354
4339−////-----------------------------------------------------------------------------
4340−//// HidMsg API
4341−////-----------------------------------------------------------------------------
4342−//CK_DLL_MFUN( HidMsg_is_axis_motion )
4343−//{
4344−// RETURN->v_int = ( ( t_CKINT ) OBJ_MEMBER_INT( SELF, HidMsg_offset_type ) ==
4345−// CK_HID_JOYSTICK_AXIS ? 1 : 0 );
4346−//}
4347−//
4348−//CK_DLL_MFUN( HidMsg_is_button_down )
4349−//{
4350−// RETURN->v_int = ( ( t_CKINT ) OBJ_MEMBER_INT( SELF, HidMsg_offset_type ) ==
4351−// CK_HID_BUTTON_DOWN ? 1 : 0 );
4352−//}
4353−//
4354−//CK_DLL_MFUN( HidMsg_is_button_up )
4355−//{
4356−// RETURN->v_int = ( ( t_CKINT ) OBJ_MEMBER_INT( SELF, HidMsg_offset_type ) ==
4357−// CK_HID_BUTTON_UP ? 1 : 0 );
4358−//}
4359−//
4360−//CK_DLL_MFUN( HidMsg_is_mouse_motion )
4361−//{
4362−// RETURN->v_int = ( ( t_CKINT ) OBJ_MEMBER_INT( SELF, HidMsg_offset_type ) ==
4363−// CK_HID_MOUSE_MOTION ? 1 : 0 );
4364−//}
4365−//
4366−//CK_DLL_MFUN( HidMsg_is_hat_motion )
4367−//{
4368−// RETURN->v_int = ( ( t_CKINT ) OBJ_MEMBER_INT( SELF, HidMsg_offset_type ) ==
4369−// CK_HID_JOYSTICK_HAT ? 1 : 0 );
4370−//}
4371−//
4372−//CK_DLL_MFUN( HidMsg_is_wheel_motion )
4373−//{
4374−// RETURN->v_int = ( ( t_CKINT ) OBJ_MEMBER_INT( SELF, HidMsg_offset_type ) ==
4375−// CK_HID_MOUSE_WHEEL ? 1 : 0 );
4376−//}
4377−//
4378−////-----------------------------------------------------------------------------
4379−//// HidIn API
4380−////-----------------------------------------------------------------------------
4381−//CK_DLL_CTOR( HidIn_ctor )
4382−//{
4383−// HidIn * min = new HidIn;
4384−// min->SELF = SELF;
4385−// OBJ_MEMBER_INT(SELF, HidIn_offset_data) = (t_CKINT)min;
4386−//}
4387−//
4388−//CK_DLL_DTOR( HidIn_dtor )
4389−//{
4390−// delete (HidIn *)OBJ_MEMBER_INT(SELF, HidIn_offset_data);
4391−// OBJ_MEMBER_INT(SELF, HidIn_offset_data) = 0;
4392−//}
4393−//
4394−//CK_DLL_MFUN( HidIn_open )
4395−//{
4396−// HidIn * min = (HidIn *)OBJ_MEMBER_INT(SELF, HidIn_offset_data);
4397−// t_CKINT type = GET_NEXT_INT(ARGS);
4398−// t_CKINT num = GET_NEXT_INT(ARGS);
4399−// // CK_FPRINTF_STDERR( "HidIn_open %li %li\n", type, num );
4400−// RETURN->v_int = min->open( SHRED->vm_ref, type, num );
4401−//}
4402−//
4403−//CK_DLL_MFUN( HidIn_open_named )
4404−//{
4405−// HidIn * min = (HidIn *)OBJ_MEMBER_INT(SELF, HidIn_offset_data);
4406−// Chuck_String * name = GET_NEXT_STRING(ARGS);
4407−// std::string s = name->str();
4408−// RETURN->v_int = min->open( SHRED->vm_ref, s );
4409−//}
4410−//
4411−//CK_DLL_MFUN( HidIn_open_joystick )
4412−//{
4413−// HidIn * min = (HidIn *)OBJ_MEMBER_INT(SELF, HidIn_offset_data);
4414−// t_CKINT num = GET_NEXT_INT(ARGS);
4415−// RETURN->v_int = min->open( SHRED->vm_ref, CK_HID_DEV_JOYSTICK, num );
4416−//}
4417−//
4418−//CK_DLL_MFUN( HidIn_open_mouse )
4419−//{
4420−// HidIn * min = (HidIn *)OBJ_MEMBER_INT(SELF, HidIn_offset_data);
4421−// t_CKINT num = GET_NEXT_INT(ARGS);
4422−// RETURN->v_int = min->open( SHRED->vm_ref, CK_HID_DEV_MOUSE, num );
4423−//}
4424−//
4425−//CK_DLL_MFUN( HidIn_open_keyboard )
4426−//{
4427−// HidIn * min = (HidIn *)OBJ_MEMBER_INT(SELF, HidIn_offset_data);
4428−// t_CKINT num = GET_NEXT_INT(ARGS);
4429−// RETURN->v_int = min->open( SHRED->vm_ref, CK_HID_DEV_KEYBOARD, num );
4430−//}
4431−//
4432−//CK_DLL_MFUN( HidIn_open_tiltsensor )
4433−//{
4434−// HidIn * min = (HidIn *)OBJ_MEMBER_INT(SELF, HidIn_offset_data);
4435−// RETURN->v_int = min->open( SHRED->vm_ref, CK_HID_DEV_TILTSENSOR, 0 );
4436−//}
4437−//
4438−//CK_DLL_MFUN( HidIn_good )
4439−//{
4440−// HidIn * min = (HidIn *)OBJ_MEMBER_INT(SELF, HidIn_offset_data);
4441−// RETURN->v_int = (t_CKINT)min->good();
4442−//}
4443−//
4444−//CK_DLL_MFUN( HidIn_num )
4445−//{
4446−// HidIn * min = (HidIn *)OBJ_MEMBER_INT(SELF, HidIn_offset_data);
4447−// RETURN->v_int = min->num();
4448−//}
4449−//
4450−//CK_DLL_MFUN( HidIn_printerr )
4451−//{
4452−// HidIn * min = (HidIn *)OBJ_MEMBER_INT(SELF, HidIn_offset_data);
4453−// t_CKINT print_or_not = GET_CK_INT(ARGS);
4454−// min->set_suppress( !print_or_not );
4455−//}
4456−//
4457−//CK_DLL_MFUN( HidIn_name )
4458−//{
4459−// HidIn * min = (HidIn *)OBJ_MEMBER_INT(SELF, HidIn_offset_data);
4460−// // TODO: memory leak, please fix, Thanks.
4461−// // Chuck_String * a = (Chuck_String *)instantiate_and_initialize_object( SHRED->vm_ref->env()->t_string, SHRED );
4462−// // only if valid
4463−// // if( min->good() )
4464−// // a->str = min->phin->getPortName( min->num() );
4465−// // TODO: is null problem?
4466−// RETURN->v_string = (Chuck_String *)instantiate_and_initialize_object( SHRED->vm_ref->env()->t_string, SHRED );
4467−// RETURN->v_string->set( min->name() );
4468−//}
4469−//
4470−//CK_DLL_MFUN( HidIn_recv )
4471−//{
4472−// HidIn * min = (HidIn *)OBJ_MEMBER_INT(SELF, HidIn_offset_data);
4473−// Chuck_Object * fake_msg = GET_CK_OBJECT(ARGS);
4474−// HidMsg the_msg;
4475−// RETURN->v_int = min->recv( &the_msg );
4476−// if( RETURN->v_int )
4477−// {
4478−// OBJ_MEMBER_INT(fake_msg, HidMsg_offset_device_type) = the_msg.device_type;
4479−// OBJ_MEMBER_INT(fake_msg, HidMsg_offset_device_num) = the_msg.device_num;
4480−// OBJ_MEMBER_INT(fake_msg, HidMsg_offset_type) = the_msg.type;
4481−// OBJ_MEMBER_INT(fake_msg, HidMsg_offset_which) = the_msg.eid;
4482−// OBJ_MEMBER_INT(fake_msg, HidMsg_offset_idata) = the_msg.idata[0];
4483−// OBJ_MEMBER_FLOAT(fake_msg, HidMsg_offset_fdata) = the_msg.fdata[0];
4484−//
4485−// // mouse motion specific member variables
4486−// OBJ_MEMBER_INT(fake_msg, HidMsg_offset_deltax) = the_msg.idata[0];
4487−// OBJ_MEMBER_INT(fake_msg, HidMsg_offset_deltay) = the_msg.idata[1];
4488−// OBJ_MEMBER_INT(fake_msg, HidMsg_offset_cursorx) = the_msg.idata[2];
4489−// OBJ_MEMBER_INT(fake_msg, HidMsg_offset_cursory) = the_msg.idata[3];
4490−// OBJ_MEMBER_FLOAT(fake_msg, HidMsg_offset_scaledcursorx) = the_msg.fdata[0];
4491−// OBJ_MEMBER_FLOAT(fake_msg, HidMsg_offset_scaledcursory) = the_msg.fdata[1];
4492−//
4493−// // axis motion specific member variables
4494−// OBJ_MEMBER_INT(fake_msg, HidMsg_offset_axis_position) = the_msg.idata[0];
4495−// OBJ_MEMBER_FLOAT(fake_msg, HidMsg_offset_scaled_axis_position) = the_msg.fdata[0];
4496−// OBJ_MEMBER_FLOAT(fake_msg, HidMsg_offset_axis_position2) = the_msg.fdata[0];
4497−//
4498−// // hat motion specific variables
4499−// OBJ_MEMBER_INT(fake_msg, HidMsg_offset_hat_position) = the_msg.idata[0];
4500−//
4501−// // keyboard specific variables
4502−// OBJ_MEMBER_INT(fake_msg, HidMsg_offset_key) = the_msg.idata[1];
4503−// OBJ_MEMBER_INT(fake_msg, HidMsg_offset_ascii) = the_msg.idata[2];
4504−//
4505−// // accelerometer (tilt sensor, wii remote) specific members
4506−// OBJ_MEMBER_INT(fake_msg, HidMsg_offset_x) = the_msg.idata[0];
4507−// OBJ_MEMBER_INT(fake_msg, HidMsg_offset_y) = the_msg.idata[1];
4508−// OBJ_MEMBER_INT(fake_msg, HidMsg_offset_z) = the_msg.idata[2];
4509−//
4510−// // multitouch stuff - added 1.3.0.0
4511−// OBJ_MEMBER_FLOAT(fake_msg, HidMsg_offset_touchx) = the_msg.fdata[0];
4512−// OBJ_MEMBER_FLOAT(fake_msg, HidMsg_offset_touchy) = the_msg.fdata[1];
4513−// OBJ_MEMBER_FLOAT(fake_msg, HidMsg_offset_touchsize) = the_msg.fdata[2];
4514−// }
4515−//}
4516−//
4517−//CK_DLL_MFUN( HidIn_read )
4518−//{
4519−// HidIn * min = (HidIn *)OBJ_MEMBER_INT(SELF, HidIn_offset_data);
4520−// t_CKINT type = GET_NEXT_INT(ARGS);
4521−// t_CKINT num = GET_NEXT_INT(ARGS);
4522−// Chuck_Object * fake_msg = GET_NEXT_OBJECT(ARGS);
4523−//
4524−// HidMsg the_msg;
4525−//
4526−// RETURN->v_int = min->read( type, num, &the_msg );
4527−//
4528−// if( RETURN->v_int )
4529−// {
4530−// OBJ_MEMBER_INT(fake_msg, HidMsg_offset_device_type) = the_msg.device_type;
4531−// OBJ_MEMBER_INT(fake_msg, HidMsg_offset_device_num) = the_msg.device_num;
4532−// OBJ_MEMBER_INT(fake_msg, HidMsg_offset_type) = the_msg.type;
4533−// OBJ_MEMBER_INT(fake_msg, HidMsg_offset_which) = the_msg.eid;
4534−//
4535−// OBJ_MEMBER_INT(fake_msg, HidMsg_offset_idata) = the_msg.idata[0];
4536−// OBJ_MEMBER_FLOAT(fake_msg, HidMsg_offset_fdata) = the_msg.fdata[0];
4537−//
4538−// // mouse motion specific member members
4539−// OBJ_MEMBER_INT(fake_msg, HidMsg_offset_deltax) = the_msg.idata[0];
4540−// OBJ_MEMBER_INT(fake_msg, HidMsg_offset_deltay) = the_msg.idata[1];
4541−// OBJ_MEMBER_INT(fake_msg, HidMsg_offset_cursorx) = the_msg.idata[2];
4542−// OBJ_MEMBER_INT(fake_msg, HidMsg_offset_cursory) = the_msg.idata[3];
4543−// OBJ_MEMBER_FLOAT(fake_msg, HidMsg_offset_scaledcursorx) = the_msg.fdata[0];
4544−// OBJ_MEMBER_FLOAT(fake_msg, HidMsg_offset_scaledcursory) = the_msg.fdata[1];
4545−//
4546−// // joystick axis specific member members
4547−// OBJ_MEMBER_INT(fake_msg, HidMsg_offset_axis_position) = the_msg.idata[0];
4548−// OBJ_MEMBER_FLOAT(fake_msg, HidMsg_offset_scaled_axis_position) = the_msg.fdata[0];
4549−// OBJ_MEMBER_FLOAT(fake_msg, HidMsg_offset_axis_position2) = the_msg.fdata[0];
4550−//
4551−// // joystick hat specific member members
4552−// OBJ_MEMBER_INT(fake_msg, HidMsg_offset_hat_position) = the_msg.idata[0];
4553−//
4554−// // keyboard specific members
4555−// OBJ_MEMBER_INT(fake_msg, HidMsg_offset_key) = the_msg.idata[1];
4556−// OBJ_MEMBER_INT(fake_msg, HidMsg_offset_ascii) = the_msg.idata[2];
4557−//
4558−// // accelerometer (tilt sensor, wii remote) specific members
4559−// OBJ_MEMBER_INT(fake_msg, HidMsg_offset_x) = the_msg.idata[0];
4560−// OBJ_MEMBER_INT(fake_msg, HidMsg_offset_y) = the_msg.idata[1];
4561−// OBJ_MEMBER_INT(fake_msg, HidMsg_offset_z) = the_msg.idata[2];
4562−// }
4563−//}
4564−//
4565−//CK_DLL_MFUN( HidIn_send )
4566−//{
4567−// HidIn * min = (HidIn *)OBJ_MEMBER_INT(SELF, HidIn_offset_data);
4568−// Chuck_Object * fake_msg = GET_NEXT_OBJECT(ARGS);
4569−//
4570−// HidMsg the_msg;
4571−// the_msg.device_type = OBJ_MEMBER_INT( fake_msg, HidMsg_offset_device_type );
4572−// the_msg.device_num = OBJ_MEMBER_INT( fake_msg, HidMsg_offset_device_num );
4573−// the_msg.type = OBJ_MEMBER_INT( fake_msg, HidMsg_offset_type );
4574−// the_msg.eid = OBJ_MEMBER_INT( fake_msg, HidMsg_offset_which );
4575−// the_msg.idata[0] = OBJ_MEMBER_INT( fake_msg, HidMsg_offset_idata );
4576−//
4577−// RETURN->v_int = min->send( &the_msg );
4578−//}
4579−//
4580−//CK_DLL_MFUN( HidIn_can_wait )
4581−//{
4582−// HidIn * min = (HidIn *)OBJ_MEMBER_INT(SELF, HidIn_offset_data);
4583−// RETURN->v_int = min->empty();
4584−//}
4585−//
4586−//CK_DLL_SFUN( HidIn_read_tilt_sensor )
4587−//{
4588−// static HidIn * hi;
4589−// static t_CKBOOL hi_good = TRUE;
4590−//
4591−// Chuck_Array4 * array = new Chuck_Array4( FALSE, 3 );
4592−// array->set( 0, 0 );
4593−// array->set( 1, 0 );
4594−// array->set( 2, 0 );
4595−//
4596−// // TODO: reference count?
4597−// array->add_ref();
4598−// RETURN->v_object = array;
4599−//
4600−// if( hi_good == FALSE )
4601−// return;
4602−//
4603−// if( !hi )
4604−// {
4605−// hi = new HidIn;
4606−// if( !hi->open( SHRED->vm_ref, CK_HID_DEV_TILTSENSOR, 0 ) )
4607−// {
4608−// hi_good = FALSE;
4609−// return;
4610−// }
4611−// }
4612−//
4613−// HidMsg msg;
4614−//
4615−// if( !hi->read( CK_HID_ACCELEROMETER, 0, &msg ) )
4616−// {
4617−// return;
4618−// }
4619−//
4620−// array->set( 0, msg.idata[0] );
4621−// array->set( 1, msg.idata[1] );
4622−// array->set( 2, msg.idata[2] );
4623−//}
4624−//
4625−//CK_DLL_SFUN( HidIn_ctrl_tiltPollRate )
4626−//{
4627−// // get srate
4628−// if( !SHRED || !SHRED->vm_ref )
4629−// {
4630−// // problem
4631−// CK_FPRINTF_STDERR( "[chuck](via HID): can't set tiltPollRate on NULL shred/VM...\n" );
4632−// RETURN->v_dur = 0;
4633−// return;
4634−// }
4635−// t_CKFLOAT srate = SHRED->vm_ref->srate();
4636−//
4637−// // get arg
4638−// t_CKDUR v = GET_NEXT_DUR( ARGS );
4639−//
4640−// // get in microseconds
4641−// t_CKINT usec = (t_CKINT)( v / srate * 1000000 );
4642−//
4643−// // make sure it's nonnegative
4644−// if( usec < 0 ) usec = 0;
4645−//
4646−// // go
4647−// RETURN->v_dur = TiltSensor_setPollRate( usec ) * srate / 1000000;
4648−//}
4649−//
4650−//CK_DLL_SFUN( HidIn_cget_tiltPollRate )
4651−//{
4652−// // get srate
4653−// if( !SHRED || !SHRED->vm_ref )
4654−// {
4655−// // problem
4656−// CK_FPRINTF_STDERR( "[chuck](via HID): can't get tiltPollRate on NULL shred/VM...\n" );
4657−// RETURN->v_dur = 0;
4658−// return;
4659−// }
4660−// t_CKFLOAT srate = SHRED->vm_ref->srate();
4661−//
4662−// RETURN->v_dur = TiltSensor_getPollRate() * srate / 1000000;
4663−//}
4664−//
4665−//CK_DLL_SFUN( HidIn_start_cursor_track )
4666−//{
4667−// RETURN->v_int = !Mouse_start_cursor_track();
4668−//}
4669−//
4670−//CK_DLL_SFUN( HidIn_stop_cursor_track )
4671−//{
4672−// RETURN->v_int = !Mouse_stop_cursor_track();
4673−//}
4674−//
4675−////-----------------------------------------------------------------------------
4676−//// HidOut API
4677−////-----------------------------------------------------------------------------
4678−//CK_DLL_CTOR( HidOut_ctor )
4679−//{
4680−// OBJ_MEMBER_INT(SELF, HidOut_offset_data) = (t_CKUINT)new HidOut;
4681−//}
4682−//
4683−//CK_DLL_DTOR( HidOut_dtor )
4684−//{
4685−// delete (HidOut *)OBJ_MEMBER_INT(SELF, HidOut_offset_data);
4686−// OBJ_MEMBER_INT(SELF, HidOut_offset_data) = 0;
4687−//}
4688−//
4689−//CK_DLL_MFUN( HidOut_open )
4690−//{
4691−// HidOut * mout = (HidOut *)OBJ_MEMBER_INT(SELF, HidOut_offset_data);
4692−// t_CKINT num = GET_CK_INT(ARGS);
4693−// RETURN->v_int = mout->open( num );
4694−//}
4695−//
4696−//CK_DLL_MFUN( HidOut_good )
4697−//{
4698−// HidOut * mout = (HidOut *)OBJ_MEMBER_INT(SELF, HidOut_offset_data);
4699−// RETURN->v_int = (t_CKINT)mout->good();
4700−//}
4701−//
4702−//CK_DLL_MFUN( HidOut_num )
4703−//{
4704−// HidOut * mout = (HidOut *)OBJ_MEMBER_INT(SELF, HidOut_offset_data);
4705−// RETURN->v_int = mout->num();
4706−//}
4707−//
4708−//CK_DLL_MFUN( HidOut_name )
4709−//{
4710−// // HidOut * mout = (HidOut *)OBJ_MEMBER_INT(SELF, HidOut_offset_data);
4711−// // TODO: memory leak, please fix, Thanks.
4712−// Chuck_String * a = (Chuck_String *)instantiate_and_initialize_object( SHRED->vm_ref->env()->t_string, SHRED );
4713−// // only if valid
4714−// // if( mout->good() )
4715−// // a->str = mout->mout->getPortName( mout->num() );
4716−// RETURN->v_string = a;
4717−//}
4718−//
4719−//CK_DLL_MFUN( HidOut_printerr )
4720−//{
4721−// HidOut * mout = (HidOut *)OBJ_MEMBER_INT(SELF, HidOut_offset_data);
4722−// t_CKINT print_or_not = GET_CK_INT(ARGS);
4723−// mout->set_suppress( !print_or_not );
4724−//}
4725−//
4726−//CK_DLL_MFUN( HidOut_send )
4727−//{
4728−// HidOut * mout = (HidOut *)OBJ_MEMBER_INT(SELF, HidOut_offset_data);
4729−// // Chuck_Object * fake_msg = GET_CK_OBJECT(ARGS);
4730−// HidMsg the_msg;
4731−// // the_msg.data[0] = (t_CKBYTE)OBJ_MEMBER_INT(fake_msg, HidMsg_offset_data1);
4732−// // the_msg.data[1] = (t_CKBYTE)OBJ_MEMBER_INT(fake_msg, HidMsg_offset_data2);
4733−// // the_msg.data[2] = (t_CKBYTE)OBJ_MEMBER_INT(fake_msg, HidMsg_offset_data3);
4734−// RETURN->v_int = mout->send( &the_msg );
4735−//}
4355+
4356+
4357+#ifndef __DISABLE_HID__
4358+//-----------------------------------------------------------------------------
4359+// HidMsg API
4360+//-----------------------------------------------------------------------------
4361+CK_DLL_MFUN( HidMsg_is_axis_motion )
4362+{
4363+ RETURN->v_int = ( ( t_CKINT ) OBJ_MEMBER_INT( SELF, HidMsg_offset_type ) ==
4364+ CK_HID_JOYSTICK_AXIS ? 1 : 0 );
4365+}
4366+
4367+CK_DLL_MFUN( HidMsg_is_button_down )
4368+{
4369+ RETURN->v_int = ( ( t_CKINT ) OBJ_MEMBER_INT( SELF, HidMsg_offset_type ) ==
4370+ CK_HID_BUTTON_DOWN ? 1 : 0 );
4371+}
4372+
4373+CK_DLL_MFUN( HidMsg_is_button_up )
4374+{
4375+ RETURN->v_int = ( ( t_CKINT ) OBJ_MEMBER_INT( SELF, HidMsg_offset_type ) ==
4376+ CK_HID_BUTTON_UP ? 1 : 0 );
4377+}
4378+
4379+CK_DLL_MFUN( HidMsg_is_mouse_motion )
4380+{
4381+ RETURN->v_int = ( ( t_CKINT ) OBJ_MEMBER_INT( SELF, HidMsg_offset_type ) ==
4382+ CK_HID_MOUSE_MOTION ? 1 : 0 );
4383+}
4384+
4385+CK_DLL_MFUN( HidMsg_is_hat_motion )
4386+{
4387+ RETURN->v_int = ( ( t_CKINT ) OBJ_MEMBER_INT( SELF, HidMsg_offset_type ) ==
4388+ CK_HID_JOYSTICK_HAT ? 1 : 0 );
4389+}
4390+
4391+CK_DLL_MFUN( HidMsg_is_wheel_motion )
4392+{
4393+ RETURN->v_int = ( ( t_CKINT ) OBJ_MEMBER_INT( SELF, HidMsg_offset_type ) ==
4394+ CK_HID_MOUSE_WHEEL ? 1 : 0 );
4395+}
4396+
4397+//-----------------------------------------------------------------------------
4398+// HidIn API
4399+//-----------------------------------------------------------------------------
4400+CK_DLL_CTOR( HidIn_ctor )
4401+{
4402+ HidIn * min = new HidIn;
4403+ min->SELF = SELF;
4404+ OBJ_MEMBER_INT(SELF, HidIn_offset_data) = (t_CKINT)min;
4405+}
4406+
4407+CK_DLL_DTOR( HidIn_dtor )
4408+{
4409+ delete (HidIn *)OBJ_MEMBER_INT(SELF, HidIn_offset_data);
4410+ OBJ_MEMBER_INT(SELF, HidIn_offset_data) = 0;
4411+}
4412+
4413+CK_DLL_MFUN( HidIn_open )
4414+{
4415+ HidIn * min = (HidIn *)OBJ_MEMBER_INT(SELF, HidIn_offset_data);
4416+ t_CKINT type = GET_NEXT_INT(ARGS);
4417+ t_CKINT num = GET_NEXT_INT(ARGS);
4418+ // CK_FPRINTF_STDERR( "HidIn_open %li %li\n", type, num );
4419+ RETURN->v_int = min->open( SHRED->vm_ref, type, num );
4420+}
4421+
4422+CK_DLL_MFUN( HidIn_open_named )
4423+{
4424+ HidIn * min = (HidIn *)OBJ_MEMBER_INT(SELF, HidIn_offset_data);
4425+ Chuck_String * name = GET_NEXT_STRING(ARGS);
4426+ std::string s = name->str();
4427+ RETURN->v_int = min->open( SHRED->vm_ref, s );
4428+}
4429+
4430+CK_DLL_MFUN( HidIn_open_joystick )
4431+{
4432+ HidIn * min = (HidIn *)OBJ_MEMBER_INT(SELF, HidIn_offset_data);
4433+ t_CKINT num = GET_NEXT_INT(ARGS);
4434+ RETURN->v_int = min->open( SHRED->vm_ref, CK_HID_DEV_JOYSTICK, num );
4435+}
4436+
4437+CK_DLL_MFUN( HidIn_open_mouse )
4438+{
4439+ HidIn * min = (HidIn *)OBJ_MEMBER_INT(SELF, HidIn_offset_data);
4440+ t_CKINT num = GET_NEXT_INT(ARGS);
4441+ RETURN->v_int = min->open( SHRED->vm_ref, CK_HID_DEV_MOUSE, num );
4442+}
4443+
4444+CK_DLL_MFUN( HidIn_open_keyboard )
4445+{
4446+ HidIn * min = (HidIn *)OBJ_MEMBER_INT(SELF, HidIn_offset_data);
4447+ t_CKINT num = GET_NEXT_INT(ARGS);
4448+ RETURN->v_int = min->open( SHRED->vm_ref, CK_HID_DEV_KEYBOARD, num );
4449+}
4450+
4451+CK_DLL_MFUN( HidIn_open_tiltsensor )
4452+{
4453+ HidIn * min = (HidIn *)OBJ_MEMBER_INT(SELF, HidIn_offset_data);
4454+ RETURN->v_int = min->open( SHRED->vm_ref, CK_HID_DEV_TILTSENSOR, 0 );
4455+}
4456+
4457+CK_DLL_MFUN( HidIn_good )
4458+{
4459+ HidIn * min = (HidIn *)OBJ_MEMBER_INT(SELF, HidIn_offset_data);
4460+ RETURN->v_int = (t_CKINT)min->good();
4461+}
4462+
4463+CK_DLL_MFUN( HidIn_num )
4464+{
4465+ HidIn * min = (HidIn *)OBJ_MEMBER_INT(SELF, HidIn_offset_data);
4466+ RETURN->v_int = min->num();
4467+}
4468+
4469+CK_DLL_MFUN( HidIn_printerr )
4470+{
4471+ HidIn * min = (HidIn *)OBJ_MEMBER_INT(SELF, HidIn_offset_data);
4472+ t_CKINT print_or_not = GET_CK_INT(ARGS);
4473+ min->set_suppress( !print_or_not );
4474+}
4475+
4476+CK_DLL_MFUN( HidIn_name )
4477+{
4478+ HidIn * min = (HidIn *)OBJ_MEMBER_INT(SELF, HidIn_offset_data);
4479+ // TODO: memory leak, please fix, Thanks.
4480+ // Chuck_String * a = (Chuck_String *)instantiate_and_initialize_object( SHRED->vm_ref->env()->t_string, SHRED );
4481+ // only if valid
4482+ // if( min->good() )
4483+ // a->str = min->phin->getPortName( min->num() );
4484+ // TODO: is null problem?
4485+ RETURN->v_string = (Chuck_String *)instantiate_and_initialize_object( SHRED->vm_ref->env()->t_string, SHRED );
4486+ RETURN->v_string->set( min->name() );
4487+}
4488+
4489+CK_DLL_MFUN( HidIn_recv )
4490+{
4491+ HidIn * min = (HidIn *)OBJ_MEMBER_INT(SELF, HidIn_offset_data);
4492+ Chuck_Object * fake_msg = GET_CK_OBJECT(ARGS);
4493+ HidMsg the_msg;
4494+ RETURN->v_int = min->recv( &the_msg );
4495+ if( RETURN->v_int )
4496+ {
4497+ OBJ_MEMBER_INT(fake_msg, HidMsg_offset_device_type) = the_msg.device_type;
4498+ OBJ_MEMBER_INT(fake_msg, HidMsg_offset_device_num) = the_msg.device_num;
4499+ OBJ_MEMBER_INT(fake_msg, HidMsg_offset_type) = the_msg.type;
4500+ OBJ_MEMBER_INT(fake_msg, HidMsg_offset_which) = the_msg.eid;
4501+ OBJ_MEMBER_INT(fake_msg, HidMsg_offset_idata) = the_msg.idata[0];
4502+ OBJ_MEMBER_FLOAT(fake_msg, HidMsg_offset_fdata) = the_msg.fdata[0];
4503+
4504+ // mouse motion specific member variables
4505+ OBJ_MEMBER_INT(fake_msg, HidMsg_offset_deltax) = the_msg.idata[0];
4506+ OBJ_MEMBER_INT(fake_msg, HidMsg_offset_deltay) = the_msg.idata[1];
4507+ OBJ_MEMBER_INT(fake_msg, HidMsg_offset_cursorx) = the_msg.idata[2];
4508+ OBJ_MEMBER_INT(fake_msg, HidMsg_offset_cursory) = the_msg.idata[3];
4509+ OBJ_MEMBER_FLOAT(fake_msg, HidMsg_offset_scaledcursorx) = the_msg.fdata[0];
4510+ OBJ_MEMBER_FLOAT(fake_msg, HidMsg_offset_scaledcursory) = the_msg.fdata[1];
4511+
4512+ // axis motion specific member variables
4513+ OBJ_MEMBER_INT(fake_msg, HidMsg_offset_axis_position) = the_msg.idata[0];
4514+ OBJ_MEMBER_FLOAT(fake_msg, HidMsg_offset_scaled_axis_position) = the_msg.fdata[0];
4515+ OBJ_MEMBER_FLOAT(fake_msg, HidMsg_offset_axis_position2) = the_msg.fdata[0];
4516+
4517+ // hat motion specific variables
4518+ OBJ_MEMBER_INT(fake_msg, HidMsg_offset_hat_position) = the_msg.idata[0];
4519+
4520+ // keyboard specific variables
4521+ OBJ_MEMBER_INT(fake_msg, HidMsg_offset_key) = the_msg.idata[1];
4522+ OBJ_MEMBER_INT(fake_msg, HidMsg_offset_ascii) = the_msg.idata[2];
4523+
4524+ // accelerometer (tilt sensor, wii remote) specific members
4525+ OBJ_MEMBER_INT(fake_msg, HidMsg_offset_x) = the_msg.idata[0];
4526+ OBJ_MEMBER_INT(fake_msg, HidMsg_offset_y) = the_msg.idata[1];
4527+ OBJ_MEMBER_INT(fake_msg, HidMsg_offset_z) = the_msg.idata[2];
4528+
4529+ // multitouch stuff - added 1.3.0.0
4530+ OBJ_MEMBER_FLOAT(fake_msg, HidMsg_offset_touchx) = the_msg.fdata[0];
4531+ OBJ_MEMBER_FLOAT(fake_msg, HidMsg_offset_touchy) = the_msg.fdata[1];
4532+ OBJ_MEMBER_FLOAT(fake_msg, HidMsg_offset_touchsize) = the_msg.fdata[2];
4533+ }
4534+}
4535+
4536+CK_DLL_MFUN( HidIn_read )
4537+{
4538+ HidIn * min = (HidIn *)OBJ_MEMBER_INT(SELF, HidIn_offset_data);
4539+ t_CKINT type = GET_NEXT_INT(ARGS);
4540+ t_CKINT num = GET_NEXT_INT(ARGS);
4541+ Chuck_Object * fake_msg = GET_NEXT_OBJECT(ARGS);
4542+
4543+ HidMsg the_msg;
4544+
4545+ RETURN->v_int = min->read( type, num, &the_msg );
4546+
4547+ if( RETURN->v_int )
4548+ {
4549+ OBJ_MEMBER_INT(fake_msg, HidMsg_offset_device_type) = the_msg.device_type;
4550+ OBJ_MEMBER_INT(fake_msg, HidMsg_offset_device_num) = the_msg.device_num;
4551+ OBJ_MEMBER_INT(fake_msg, HidMsg_offset_type) = the_msg.type;
4552+ OBJ_MEMBER_INT(fake_msg, HidMsg_offset_which) = the_msg.eid;
4553+
4554+ OBJ_MEMBER_INT(fake_msg, HidMsg_offset_idata) = the_msg.idata[0];
4555+ OBJ_MEMBER_FLOAT(fake_msg, HidMsg_offset_fdata) = the_msg.fdata[0];
4556+
4557+ // mouse motion specific member members
4558+ OBJ_MEMBER_INT(fake_msg, HidMsg_offset_deltax) = the_msg.idata[0];
4559+ OBJ_MEMBER_INT(fake_msg, HidMsg_offset_deltay) = the_msg.idata[1];
4560+ OBJ_MEMBER_INT(fake_msg, HidMsg_offset_cursorx) = the_msg.idata[2];
4561+ OBJ_MEMBER_INT(fake_msg, HidMsg_offset_cursory) = the_msg.idata[3];
4562+ OBJ_MEMBER_FLOAT(fake_msg, HidMsg_offset_scaledcursorx) = the_msg.fdata[0];
4563+ OBJ_MEMBER_FLOAT(fake_msg, HidMsg_offset_scaledcursory) = the_msg.fdata[1];
4564+
4565+ // joystick axis specific member members
4566+ OBJ_MEMBER_INT(fake_msg, HidMsg_offset_axis_position) = the_msg.idata[0];
4567+ OBJ_MEMBER_FLOAT(fake_msg, HidMsg_offset_scaled_axis_position) = the_msg.fdata[0];
4568+ OBJ_MEMBER_FLOAT(fake_msg, HidMsg_offset_axis_position2) = the_msg.fdata[0];
4569+
4570+ // joystick hat specific member members
4571+ OBJ_MEMBER_INT(fake_msg, HidMsg_offset_hat_position) = the_msg.idata[0];
4572+
4573+ // keyboard specific members
4574+ OBJ_MEMBER_INT(fake_msg, HidMsg_offset_key) = the_msg.idata[1];
4575+ OBJ_MEMBER_INT(fake_msg, HidMsg_offset_ascii) = the_msg.idata[2];
4576+
4577+ // accelerometer (tilt sensor, wii remote) specific members
4578+ OBJ_MEMBER_INT(fake_msg, HidMsg_offset_x) = the_msg.idata[0];
4579+ OBJ_MEMBER_INT(fake_msg, HidMsg_offset_y) = the_msg.idata[1];
4580+ OBJ_MEMBER_INT(fake_msg, HidMsg_offset_z) = the_msg.idata[2];
4581+ }
4582+}
4583+
4584+CK_DLL_MFUN( HidIn_send )
4585+{
4586+ HidIn * min = (HidIn *)OBJ_MEMBER_INT(SELF, HidIn_offset_data);
4587+ Chuck_Object * fake_msg = GET_NEXT_OBJECT(ARGS);
4588+
4589+ HidMsg the_msg;
4590+ the_msg.device_type = OBJ_MEMBER_INT( fake_msg, HidMsg_offset_device_type );
4591+ the_msg.device_num = OBJ_MEMBER_INT( fake_msg, HidMsg_offset_device_num );
4592+ the_msg.type = OBJ_MEMBER_INT( fake_msg, HidMsg_offset_type );
4593+ the_msg.eid = OBJ_MEMBER_INT( fake_msg, HidMsg_offset_which );
4594+ the_msg.idata[0] = OBJ_MEMBER_INT( fake_msg, HidMsg_offset_idata );
4595+
4596+ RETURN->v_int = min->send( &the_msg );
4597+}
4598+
4599+CK_DLL_MFUN( HidIn_can_wait )
4600+{
4601+ HidIn * min = (HidIn *)OBJ_MEMBER_INT(SELF, HidIn_offset_data);
4602+ RETURN->v_int = min->empty();
4603+}
4604+
4605+CK_DLL_SFUN( HidIn_read_tilt_sensor )
4606+{
4607+ static HidIn * hi;
4608+ static t_CKBOOL hi_good = TRUE;
4609+
4610+ Chuck_Array4 * array = new Chuck_Array4( FALSE, 3 );
4611+ array->set( 0, 0 );
4612+ array->set( 1, 0 );
4613+ array->set( 2, 0 );
4614+
4615+ // TODO: reference count?
4616+ array->add_ref();
4617+ RETURN->v_object = array;
4618+
4619+ if( hi_good == FALSE )
4620+ return;
4621+
4622+ if( !hi )
4623+ {
4624+ hi = new HidIn;
4625+ if( !hi->open( SHRED->vm_ref, CK_HID_DEV_TILTSENSOR, 0 ) )
4626+ {
4627+ hi_good = FALSE;
4628+ return;
4629+ }
4630+ }
4631+
4632+ HidMsg msg;
4633+
4634+ if( !hi->read( CK_HID_ACCELEROMETER, 0, &msg ) )
4635+ {
4636+ return;
4637+ }
4638+
4639+ array->set( 0, msg.idata[0] );
4640+ array->set( 1, msg.idata[1] );
4641+ array->set( 2, msg.idata[2] );
4642+}
4643+
4644+CK_DLL_SFUN( HidIn_ctrl_tiltPollRate )
4645+{
4646+ // get srate
4647+ if( !SHRED || !SHRED->vm_ref )
4648+ {
4649+ // problem
4650+ CK_FPRINTF_STDERR( "[chuck](via HID): can't set tiltPollRate on NULL shred/VM...\n" );
4651+ RETURN->v_dur = 0;
4652+ return;
4653+ }
4654+ t_CKFLOAT srate = SHRED->vm_ref->srate();
4655+
4656+ // get arg
4657+ t_CKDUR v = GET_NEXT_DUR( ARGS );
4658+
4659+ // get in microseconds
4660+ t_CKINT usec = (t_CKINT)( v / srate * 1000000 );
4661+
4662+ // make sure it's nonnegative
4663+ if( usec < 0 ) usec = 0;
4664+
4665+ // go
4666+ RETURN->v_dur = TiltSensor_setPollRate( usec ) * srate / 1000000;
4667+}
4668+
4669+CK_DLL_SFUN( HidIn_cget_tiltPollRate )
4670+{
4671+ // get srate
4672+ if( !SHRED || !SHRED->vm_ref )
4673+ {
4674+ // problem
4675+ CK_FPRINTF_STDERR( "[chuck](via HID): can't get tiltPollRate on NULL shred/VM...\n" );
4676+ RETURN->v_dur = 0;
4677+ return;
4678+ }
4679+ t_CKFLOAT srate = SHRED->vm_ref->srate();
4680+
4681+ RETURN->v_dur = TiltSensor_getPollRate() * srate / 1000000;
4682+}
4683+
4684+CK_DLL_SFUN( HidIn_start_cursor_track )
4685+{
4686+ RETURN->v_int = !Mouse_start_cursor_track();
4687+}
4688+
4689+CK_DLL_SFUN( HidIn_stop_cursor_track )
4690+{
4691+ RETURN->v_int = !Mouse_stop_cursor_track();
4692+}
4693+
4694+//-----------------------------------------------------------------------------
4695+// HidOut API
4696+//-----------------------------------------------------------------------------
4697+CK_DLL_CTOR( HidOut_ctor )
4698+{
4699+ OBJ_MEMBER_INT(SELF, HidOut_offset_data) = (t_CKUINT)new HidOut;
4700+}
4701+
4702+CK_DLL_DTOR( HidOut_dtor )
4703+{
4704+ delete (HidOut *)OBJ_MEMBER_INT(SELF, HidOut_offset_data);
4705+ OBJ_MEMBER_INT(SELF, HidOut_offset_data) = 0;
4706+}
4707+
4708+CK_DLL_MFUN( HidOut_open )
4709+{
4710+ HidOut * mout = (HidOut *)OBJ_MEMBER_INT(SELF, HidOut_offset_data);
4711+ t_CKINT num = GET_CK_INT(ARGS);
4712+ RETURN->v_int = mout->open( num );
4713+}
4714+
4715+CK_DLL_MFUN( HidOut_good )
4716+{
4717+ HidOut * mout = (HidOut *)OBJ_MEMBER_INT(SELF, HidOut_offset_data);
4718+ RETURN->v_int = (t_CKINT)mout->good();
4719+}
4720+
4721+CK_DLL_MFUN( HidOut_num )
4722+{
4723+ HidOut * mout = (HidOut *)OBJ_MEMBER_INT(SELF, HidOut_offset_data);
4724+ RETURN->v_int = mout->num();
4725+}
4726+
4727+CK_DLL_MFUN( HidOut_name )
4728+{
4729+ // HidOut * mout = (HidOut *)OBJ_MEMBER_INT(SELF, HidOut_offset_data);
4730+ // TODO: memory leak, please fix, Thanks.
4731+ Chuck_String * a = (Chuck_String *)instantiate_and_initialize_object( SHRED->vm_ref->env()->t_string, SHRED );
4732+ // only if valid
4733+ // if( mout->good() )
4734+ // a->str = mout->mout->getPortName( mout->num() );
4735+ RETURN->v_string = a;
4736+}
4737+
4738+CK_DLL_MFUN( HidOut_printerr )
4739+{
4740+ HidOut * mout = (HidOut *)OBJ_MEMBER_INT(SELF, HidOut_offset_data);
4741+ t_CKINT print_or_not = GET_CK_INT(ARGS);
4742+ mout->set_suppress( !print_or_not );
4743+}
4744+
4745+CK_DLL_MFUN( HidOut_send )
4746+{
4747+ HidOut * mout = (HidOut *)OBJ_MEMBER_INT(SELF, HidOut_offset_data);
4748+ // Chuck_Object * fake_msg = GET_CK_OBJECT(ARGS);
4749+ HidMsg the_msg;
4750+ // the_msg.data[0] = (t_CKBYTE)OBJ_MEMBER_INT(fake_msg, HidMsg_offset_data1);
4751+ // the_msg.data[1] = (t_CKBYTE)OBJ_MEMBER_INT(fake_msg, HidMsg_offset_data2);
4752+ // the_msg.data[2] = (t_CKBYTE)OBJ_MEMBER_INT(fake_msg, HidMsg_offset_data3);
4753+ RETURN->v_int = mout->send( &the_msg );
4754+}
4755+#endif //__DISABLE_HID__
4756+
4757+
47364758
47374759
47384760 //-----------------------------------------------------------------------------
src/core/chuck_lang.h+83−77
@@ -63,7 +63,9 @@ t_CKBOOL init_class_Midi( Chuck_Env * env ); · 62 unmodified lines
6363 t_CKBOOL init_class_MidiRW( Chuck_Env * env );
6464 t_CKBOOL init_class_HID( Chuck_Env * env );
6565 t_CKBOOL init_class_io( Chuck_Env * env, Chuck_Type * type );
66−//t_CKBOOL init_class_fileio( Chuck_Env * env, Chuck_Type * type );
66+#ifndef __DISABLE_FILEIO__
67+t_CKBOOL init_class_fileio( Chuck_Env * env, Chuck_Type * type );
68+#endif
6769 // added 1.3.0.0 -- moved to be full-fledged class
6870 t_CKBOOL init_class_chout( Chuck_Env * env, Chuck_Type * type );
6971 // added 1.3.0.0 -- moved to be full-fledged class
@@ -214,34 +216,36 @@ CK_DLL_SFUN( io_newline ); · 144 unmodified lines
214216 CK_DLL_SFUN( io_openfile );
215217
216218
217−////-----------------------------------------------------------------------------
218−//// fileio API
219−////-----------------------------------------------------------------------------
220−//CK_DLL_CTOR( fileio_ctor );
221−//CK_DLL_DTOR( fileio_dtor );
222−//CK_DLL_MFUN( fileio_open );
223−//CK_DLL_MFUN( fileio_openflags );
224−//CK_DLL_MFUN( fileio_good );
225−//CK_DLL_MFUN( fileio_close );
226−//CK_DLL_MFUN( fileio_flush );
227−//CK_DLL_MFUN( fileio_getmode );
228−//CK_DLL_MFUN( fileio_setmode );
229−//CK_DLL_MFUN( fileio_size );
230−//CK_DLL_MFUN( fileio_seek );
231−//CK_DLL_MFUN( fileio_tell );
232−//CK_DLL_MFUN( fileio_isdir );
233−//CK_DLL_MFUN( fileio_dirlist );
234−//CK_DLL_MFUN( fileio_read );
235−//CK_DLL_MFUN( fileio_readline );
236−//CK_DLL_MFUN( fileio_readint );
237−//CK_DLL_MFUN( fileio_readintflags );
238−//CK_DLL_MFUN( fileio_readfloat );
239−//CK_DLL_MFUN( fileio_eof );
240−//CK_DLL_MFUN( fileio_more );
241−//CK_DLL_MFUN( fileio_writestring );
242−//CK_DLL_MFUN( fileio_writeint );
243−//CK_DLL_MFUN( fileio_writeintflags );
244−//CK_DLL_MFUN( fileio_writefloat );
219+#ifndef __DISABLE_FILEIO__
220+//-----------------------------------------------------------------------------
221+// fileio API
222+//-----------------------------------------------------------------------------
223+CK_DLL_CTOR( fileio_ctor );
224+CK_DLL_DTOR( fileio_dtor );
225+CK_DLL_MFUN( fileio_open );
226+CK_DLL_MFUN( fileio_openflags );
227+CK_DLL_MFUN( fileio_good );
228+CK_DLL_MFUN( fileio_close );
229+CK_DLL_MFUN( fileio_flush );
230+CK_DLL_MFUN( fileio_getmode );
231+CK_DLL_MFUN( fileio_setmode );
232+CK_DLL_MFUN( fileio_size );
233+CK_DLL_MFUN( fileio_seek );
234+CK_DLL_MFUN( fileio_tell );
235+CK_DLL_MFUN( fileio_isdir );
236+CK_DLL_MFUN( fileio_dirlist );
237+CK_DLL_MFUN( fileio_read );
238+CK_DLL_MFUN( fileio_readline );
239+CK_DLL_MFUN( fileio_readint );
240+CK_DLL_MFUN( fileio_readintflags );
241+CK_DLL_MFUN( fileio_readfloat );
242+CK_DLL_MFUN( fileio_eof );
243+CK_DLL_MFUN( fileio_more );
244+CK_DLL_MFUN( fileio_writestring );
245+CK_DLL_MFUN( fileio_writeint );
246+CK_DLL_MFUN( fileio_writeintflags );
247+CK_DLL_MFUN( fileio_writefloat );
248+#endif
245249
246250
247251 //-----------------------------------------------------------------------------
@@ -428,54 +432,56 @@ CK_DLL_MFUN( MidiOut_printerr ); · 180 unmodified lines
428432 CK_DLL_MFUN( MidiOut_send );
429433
430434
431−////-----------------------------------------------------------------------------
432−//// HidMsg API
433−////-----------------------------------------------------------------------------
434−//CK_DLL_MFUN( HidMsg_is_axis_motion );
435−//CK_DLL_MFUN( HidMsg_is_button_down );
436−//CK_DLL_MFUN( HidMsg_is_button_up );
437−//CK_DLL_MFUN( HidMsg_is_mouse_motion );
438−//CK_DLL_MFUN( HidMsg_is_hat_motion );
439−//CK_DLL_MFUN( HidMsg_is_wheel_motion );
440−//
441−////-----------------------------------------------------------------------------
442−//// HidIn API
443−////-----------------------------------------------------------------------------
444−//CK_DLL_CTOR( HidIn_ctor );
445−//CK_DLL_DTOR( HidIn_dtor );
446−//CK_DLL_MFUN( HidIn_open );
447−//CK_DLL_MFUN( HidIn_open_named );
448−//CK_DLL_MFUN( HidIn_open_named_i ); // added 1.3.0.0
449−//CK_DLL_MFUN( HidIn_open_joystick );
450−//CK_DLL_MFUN( HidIn_open_mouse );
451−//CK_DLL_MFUN( HidIn_open_keyboard );
452−//CK_DLL_MFUN( HidIn_open_tiltsensor );
453−//CK_DLL_MFUN( HidIn_good );
454−//CK_DLL_MFUN( HidIn_num );
455−//CK_DLL_MFUN( HidIn_name );
456−//CK_DLL_MFUN( HidIn_printerr );
457−//CK_DLL_MFUN( HidIn_recv );
458−//CK_DLL_MFUN( HidIn_read );
459−//CK_DLL_MFUN( HidIn_send );
460−//CK_DLL_MFUN( HidIn_can_wait );
461−//CK_DLL_SFUN( HidIn_read_tilt_sensor );
462−//CK_DLL_SFUN( HidIn_ctrl_tiltPollRate );
463−//CK_DLL_SFUN( HidIn_cget_tiltPollRate );
464−//CK_DLL_SFUN( HidIn_start_cursor_track );
465−//CK_DLL_SFUN( HidIn_stop_cursor_track );
466−//
467−//
468−////-----------------------------------------------------------------------------
469−//// HidOut API
470−////-----------------------------------------------------------------------------
471−//CK_DLL_CTOR( HidOut_ctor );
472−//CK_DLL_DTOR( HidOut_dtor );
473−//CK_DLL_MFUN( HidOut_open );
474−//CK_DLL_MFUN( HidOut_good );
475−//CK_DLL_MFUN( HidOut_num );
476−//CK_DLL_MFUN( HidOut_name );
477−//CK_DLL_MFUN( HidOut_printerr );
478−//CK_DLL_MFUN( HidOut_send );
435+#ifndef __DISABLE_HID__
436+//-----------------------------------------------------------------------------
437+// HidMsg API
438+//-----------------------------------------------------------------------------
439+CK_DLL_MFUN( HidMsg_is_axis_motion );
440+CK_DLL_MFUN( HidMsg_is_button_down );
441+CK_DLL_MFUN( HidMsg_is_button_up );
442+CK_DLL_MFUN( HidMsg_is_mouse_motion );
443+CK_DLL_MFUN( HidMsg_is_hat_motion );
444+CK_DLL_MFUN( HidMsg_is_wheel_motion );
445+
446+//-----------------------------------------------------------------------------
447+// HidIn API
448+//-----------------------------------------------------------------------------
449+CK_DLL_CTOR( HidIn_ctor );
450+CK_DLL_DTOR( HidIn_dtor );
451+CK_DLL_MFUN( HidIn_open );
452+CK_DLL_MFUN( HidIn_open_named );
453+CK_DLL_MFUN( HidIn_open_named_i ); // added 1.3.0.0
454+CK_DLL_MFUN( HidIn_open_joystick );
455+CK_DLL_MFUN( HidIn_open_mouse );
456+CK_DLL_MFUN( HidIn_open_keyboard );
457+CK_DLL_MFUN( HidIn_open_tiltsensor );
458+CK_DLL_MFUN( HidIn_good );
459+CK_DLL_MFUN( HidIn_num );
460+CK_DLL_MFUN( HidIn_name );
461+CK_DLL_MFUN( HidIn_printerr );
462+CK_DLL_MFUN( HidIn_recv );
463+CK_DLL_MFUN( HidIn_read );
464+CK_DLL_MFUN( HidIn_send );
465+CK_DLL_MFUN( HidIn_can_wait );
466+CK_DLL_SFUN( HidIn_read_tilt_sensor );
467+CK_DLL_SFUN( HidIn_ctrl_tiltPollRate );
468+CK_DLL_SFUN( HidIn_cget_tiltPollRate );
469+CK_DLL_SFUN( HidIn_start_cursor_track );
470+CK_DLL_SFUN( HidIn_stop_cursor_track );
471+
472+
473+//-----------------------------------------------------------------------------
474+// HidOut API
475+//-----------------------------------------------------------------------------
476+CK_DLL_CTOR( HidOut_ctor );
477+CK_DLL_DTOR( HidOut_dtor );
478+CK_DLL_MFUN( HidOut_open );
479+CK_DLL_MFUN( HidOut_good );
480+CK_DLL_MFUN( HidOut_num );
481+CK_DLL_MFUN( HidOut_name );
482+CK_DLL_MFUN( HidOut_printerr );
483+CK_DLL_MFUN( HidOut_send );
484+#endif
479485
480486
481487
src/core/chuck_oo.cpp+943−896
@@ -56,12 +56,14 @@ const t_CKINT Chuck_IO::INT16 = 0x2; · 55 unmodified lines
5656 const t_CKINT Chuck_IO::INT8 = 0x4;
5757 const t_CKINT Chuck_IO::MODE_SYNC = 0;
5858 const t_CKINT Chuck_IO::MODE_ASYNC = 1;
59−//const t_CKINT Chuck_IO_File::FLAG_READ_WRITE = 0x8;
60−//const t_CKINT Chuck_IO_File::FLAG_READONLY = 0x10;
61−//const t_CKINT Chuck_IO_File::FLAG_WRITEONLY = 0x20;
62−//const t_CKINT Chuck_IO_File::FLAG_APPEND = 0x40;
63−//const t_CKINT Chuck_IO_File::TYPE_ASCII = 0x80;
64−//const t_CKINT Chuck_IO_File::TYPE_BINARY = 0x100;
59+#ifndef __DISABLE_FILEIO__
60+const t_CKINT Chuck_IO_File::FLAG_READ_WRITE = 0x8;
61+const t_CKINT Chuck_IO_File::FLAG_READONLY = 0x10;
62+const t_CKINT Chuck_IO_File::FLAG_WRITEONLY = 0x20;
63+const t_CKINT Chuck_IO_File::FLAG_APPEND = 0x40;
64+const t_CKINT Chuck_IO_File::TYPE_ASCII = 0x80;
65+const t_CKINT Chuck_IO_File::TYPE_BINARY = 0x100;
66+#endif
6567
6668
6769
@@ -1967,7 +1969,9 @@ t_CKUINT Chuck_Event::our_can_wait = 0; · 1899 unmodified lines
19671969 //-----------------------------------------------------------------------------
19681970 void Chuck_Event::signal()
19691971 {
1970−// m_queue_lock.acquire();
1972+ #ifndef __DISABLE_THREADS__
1973+ m_queue_lock.acquire();
1974+ #endif
19711975 if( !m_queue.empty() )
19721976 {
19731977 // get the shred on top of the queue
@@ -1975,7 +1979,9 @@ void Chuck_Event::signal() · 1 unmodified line
19751979 // pop the top
19761980 m_queue.pop();
19771981 // release it!
1978−// m_queue_lock.release();
1982+ #ifndef __DISABLE_THREADS__
1983+ m_queue_lock.release();
1984+ #endif
19791985 // REFACTOR-2017: BUG-FIX
19801986 // release the extra ref we added when we started waiting for this event
19811987 SAFE_RELEASE( shred->event );
@@ -1991,7 +1997,9 @@ void Chuck_Event::signal() · 9 unmodified lines
19911997 }
19921998 else
19931999 {
1994−// m_queue_lock.release();
2000+ #ifndef __DISABLE_THREADS__
2001+ m_queue_lock.release();
2002+ #endif
19952003 }
19962004 }
19972005
@@ -2008,7 +2016,9 @@ t_CKBOOL Chuck_Event::remove( Chuck_VM_Shred * shred ) · 10 unmodified lines
20082016 t_CKBOOL removed = FALSE;
20092017
20102018 // lock
2011−// m_queue_lock.acquire();
2019+ #ifndef __DISABLE_THREADS__
2020+ m_queue_lock.acquire();
2021+ #endif
20122022 // while something in queue
20132023 while( !m_queue.empty() )
20142024 {
@@ -2038,7 +2048,9 @@ t_CKBOOL Chuck_Event::remove( Chuck_VM_Shred * shred ) · 23 unmodified lines
20382048 // copy temp back to queue
20392049 m_queue = temp;
20402050 // release lock
2041−// m_queue_lock.release();
2051+ #ifndef __DISABLE_THREADS__
2052+ m_queue_lock.release();
2053+ #endif
20422054
20432055 return removed;
20442056 }
@@ -2077,7 +2089,9 @@ t_CKBOOL Chuck_Event::remove_listen( void (* cb)(void) ) · 32 unmodified lines
20772089 t_CKBOOL removed = FALSE;
20782090
20792091 // lock
2080−// m_queue_lock.acquire();
2092+ #ifndef __DISABLE_THREADS__
2093+ m_queue_lock.acquire();
2094+ #endif
20812095 // while something in queue
20822096 while( !m_global_queue.empty() )
20832097 {
@@ -2100,7 +2114,9 @@ t_CKBOOL Chuck_Event::remove_listen( void (* cb)(void) ) · 16 unmodified lines
21002114 // copy temp back to queue
21012115 m_global_queue = temp;
21022116 // release lock
2103−// m_queue_lock.release();
2117+ #ifndef __DISABLE_THREADS__
2118+ m_queue_lock.release();
2119+ #endif
21042120
21052121 return removed;
21062122 }
@@ -2114,7 +2130,9 @@ t_CKBOOL Chuck_Event::remove_listen( void (* cb)(void) ) · 7 unmodified lines
21142130 //-----------------------------------------------------------------------------
21152131 void Chuck_Event::signal_global()
21162132 {
2117−// m_queue_lock.acquire();
2133+ #ifndef __DISABLE_THREADS__
2134+ m_queue_lock.acquire();
2135+ #endif
21182136
21192137 if( !m_global_queue.empty() )
21202138 {
@@ -2134,7 +2152,9 @@ void Chuck_Event::signal_global() · 13 unmodified lines
21342152 }
21352153 }
21362154
2137−// m_queue_lock.release();
2155+ #ifndef __DISABLE_THREADS__
2156+ m_queue_lock.release();
2157+ #endif
21382158 }
21392159
21402160
@@ -2146,7 +2166,9 @@ void Chuck_Event::signal_global() · 5 unmodified lines
21462166 //-----------------------------------------------------------------------------
21472167 void Chuck_Event::broadcast_global()
21482168 {
2149−// m_queue_lock.acquire();
2169+ #ifndef __DISABLE_THREADS__
2170+ m_queue_lock.acquire();
2171+ #endif
21502172 std::queue< Chuck_Global_Event_Listener > call_again;
21512173
21522174 while( !m_global_queue.empty() )
@@ -2169,8 +2191,10 @@ void Chuck_Event::broadcast_global() · 16 unmodified lines
21692191
21702192 // for those that should be called again, store them again
21712193 m_global_queue = call_again;
2172−
2173−// m_queue_lock.release();
2194+
2195+ #ifndef __DISABLE_THREADS__
2196+ m_queue_lock.release();
2197+ #endif
21742198 }
21752199
21762200
@@ -2185,19 +2209,25 @@ void Chuck_Event::broadcast_global() · 8 unmodified lines
21852209 void Chuck_Event::queue_broadcast( CBufferSimple * event_buffer )
21862210 {
21872211 // TODO: handle multiple VM
2188−// m_queue_lock.acquire();
2212+ #ifndef __DISABLE_THREADS__
2213+ m_queue_lock.acquire();
2214+ #endif
21892215 if( !m_queue.empty() )
21902216 {
21912217 // get shred (only to get the VM ref)
21922218 Chuck_VM_Shred * shred = m_queue.front();
21932219 // release lock
2194−// m_queue_lock.release();
2220+ #ifndef __DISABLE_THREADS__
2221+ m_queue_lock.release();
2222+ #endif
21952223 // queue the event on the vm (added 1.3.0.0: event_buffer)
21962224 shred->vm_ref->queue_event( this, 1, event_buffer );
21972225 }
21982226 else
21992227 {
2200−// m_queue_lock.release();
2228+ #ifndef __DISABLE_THREADS__
2229+ m_queue_lock.release();
2230+ #endif
22012231 }
22022232 }
22032233
@@ -2211,19 +2241,27 @@ void Chuck_Event::queue_broadcast( CBufferSimple * event_buffer ) · 7 unmodified lines
22112241 void Chuck_Event::broadcast()
22122242 {
22132243 // lock queue
2214−// m_queue_lock.acquire();
2244+ #ifndef __DISABLE_THREADS__
2245+ m_queue_lock.acquire();
2246+ #endif
22152247 // while not empty
22162248 while( !m_queue.empty() )
22172249 {
22182250 // release first
2219−// m_queue_lock.release();
2251+ #ifndef __DISABLE_THREADS__
2252+ m_queue_lock.release();
2253+ #endif
22202254 // signal the next shred
22212255 this->signal();
22222256 // lock again
2223−// m_queue_lock.acquire();
2257+ #ifndef __DISABLE_THREADS__
2258+ m_queue_lock.acquire();
2259+ #endif
22242260 }
22252261 // release
2226−// m_queue_lock.release();
2262+ #ifndef __DISABLE_THREADS__
2263+ m_queue_lock.release();
2264+ #endif
22272265 }
22282266
22292267
@@ -2255,9 +2293,13 @@ void Chuck_Event::wait( Chuck_VM_Shred * shred, Chuck_VM * vm ) · 25 unmodified lines
22552293 shred->is_running = FALSE;
22562294
22572295 // add to waiting list
2258−// m_queue_lock.acquire();
2296+ #ifndef __DISABLE_THREADS__
2297+ m_queue_lock.acquire();
2298+ #endif
22592299 m_queue.push( shred );
2260−// m_queue_lock.release();
2300+ #ifndef __DISABLE_THREADS__
2301+ m_queue_lock.release();
2302+ #endif
22612303
22622304 // add event to shred
22632305 assert( shred->event == NULL );
@@ -2302,677 +2344,678 @@ Chuck_IO::~Chuck_IO() · 38 unmodified lines
23022344
23032345
23042346
2305−////-----------------------------------------------------------------------------
2306−//// name: Chuck_IO_File()
2307−//// desc: constructor
2308−////-----------------------------------------------------------------------------
2309−//Chuck_IO_File::Chuck_IO_File( Chuck_VM * vm )
2310−//{
2311−// m_vmRef = vm;
2312−// // zero things out
2313−// m_flags = 0;
2314−// m_iomode = MODE_SYNC;
2315−// m_path = "";
2316−// m_dir = NULL;
2317−// m_dir_start = 0;
2318−// m_asyncEvent = new Chuck_Event;
2319−// initialize_object( m_asyncEvent, vm->env()->t_event );
2320−// m_thread = new XThread;
2321−//}
2322−//
2323−//
2324−//
2325−//
2326−////-----------------------------------------------------------------------------
2327−//// name: ~Chuck_IO_File()
2328−//// desc: destructor
2329−////-----------------------------------------------------------------------------
2330−//Chuck_IO_File::~Chuck_IO_File()
2331−//{
2332−// // clean up
2333−// this->close();
2334−// delete m_asyncEvent;
2335−// delete m_thread;
2336−//}
2337−//
2338−//
2339−//
2340−//
2341−////-----------------------------------------------------------------------------
2342−//// name: open
2343−//// desc: open file from disk
2344−////-----------------------------------------------------------------------------
2345−//t_CKBOOL Chuck_IO_File::open( const string & path, t_CKINT flags )
2346−//{
2347−// // log
2348−// EM_log( CK_LOG_INFO, "FileIO: opening file from disk..." );
2349−// EM_log( CK_LOG_INFO, "FileIO: path: %s", path.c_str() );
2350−// EM_pushlog();
2351−//
2352−// // if no flag specified, make it READ by default
2353−// if( !(flags & FLAG_READ_WRITE) &&
2354−// !(flags & FLAG_READONLY) &&
2355−// !(flags & FLAG_WRITEONLY) &&
2356−// !(flags & FLAG_APPEND) )
2357−// {
2358−// flags |= FLAG_READONLY;
2359−// }
2360−//
2361−// // if both read and write, enable read and write
2362−// if( flags & FLAG_READONLY && flags & FLAG_WRITEONLY )
2363−// {
2364−// flags ^= FLAG_READONLY;
2365−// flags ^= FLAG_WRITEONLY;
2366−// flags |= FLAG_READ_WRITE;
2367−// }
2368−//
2369−// // check flags for errors
2370−// if ((flags & TYPE_ASCII) &&
2371−// (flags & TYPE_BINARY))
2372−// {
2373−// EM_error3( "[chuck](via FileIO): cannot open file in both ASCII and binary mode" );
2374−// goto error;
2375−// }
2376−//
2377−// if ((flags & FLAG_READ_WRITE) &&
2378−// (flags & FLAG_READONLY))
2379−// {
2380−// EM_error3( "[chuck](via FileIO): conflicting flags: READ_WRITE and READ" );
2381−// goto error;
2382−// }
2383−//
2384−// if ((flags & FLAG_READ_WRITE) &&
2385−// (flags & FLAG_WRITEONLY))
2386−// {
2387−// EM_error3( "[chuck](via FileIO): conflicting flags: READ_WRITE and WRITE" );
2388−// goto error;
2389−// }
2390−//
2391−// if ((flags & FLAG_READ_WRITE) &&
2392−// (flags & FLAG_APPEND))
2393−// {
2394−// EM_error3( "[chuck](via FileIO): conflicting flags: READ_WRITE and APPEND" );
2395−// goto error;
2396−// }
2397−//
2398−// if ((flags & FLAG_WRITEONLY) &&
2399−// (flags & FLAG_READONLY))
2400−// {
2401−// EM_error3( "[chuck](via FileIO): conflicting flags: WRITE and READ" );
2402−// goto error;
2403−// }
2404−//
2405−// if ((flags & FLAG_APPEND) &&
2406−// (flags & FLAG_READONLY))
2407−// {
2408−// EM_error3( "[chuck](via FileIO): conflicting flags: APPEND and FLAG_READ" );
2409−// goto error;
2410−// }
2411−//
2412−// // set open flags
2413−// ios_base::openmode mode;
2414−//
2415−// if (flags & FLAG_READ_WRITE)
2416−// mode = ios_base::in | ios_base::out;
2417−// else if (flags & FLAG_READONLY)
2418−// mode = ios_base::in;
2419−// else if (flags & FLAG_APPEND)
2420−// mode = ios_base::out | ios_base::app;
2421−// else if (flags & FLAG_WRITEONLY)
2422−// mode = ios_base::out | ios_base::trunc;
2423−//
2424−// if (flags & TYPE_BINARY)
2425−// mode |= ios_base::binary;
2426−//
2427−// // close first
2428−// if (m_io.is_open())
2429−// this->close();
2430−//
2431−// // try to open as a dir first (fixed 1.3.0.0 removed warning)
2432−// if( (m_dir = opendir( path.c_str() )) )
2433−// {
2434−// EM_poplog();
2435−// return TRUE;
2436−// }
2437−//
2438−// // not a dir, create file if it does not exist unless flag is
2439−// // readonly
2440−// if ( !(flags & FLAG_READONLY) )
2441−// {
2442−// m_io.open( path.c_str(), ios_base::in );
2443−// if ( m_io.fail() )
2444−// {
2445−// m_io.clear();
2446−// m_io.open( path.c_str(), ios_base::out | ios_base::trunc );
2447−// m_io.close();
2448−// }
2449−// else
2450−// m_io.close();
2451−// }
2452−//
2453−// //open file
2454−// m_io.open( path.c_str(), mode );
2455−//
2456−// // seek to beginning if necessary
2457−// if (flags & FLAG_READ_WRITE)
2458−// {
2459−// m_io.seekp(0);
2460−// m_io.seekg(0);
2461−// }
2462−//
2463−// /* ATODO: Ge's code
2464−// // windows sucks for being creative in the wrong places
2465−// #ifdef __PLATFORM_WIN32__
2466−// // if( flags ^ Chuck_IO::TRUNCATE && flags | Chuck_IO::READ ) nMode |= ios::nocreate;
2467−// m_io.open( path.c_str(), nMode );
2468−// #else
2469−// m_io.open( path.c_str(), (_Ios_Openmode)nMode );
2470−// #endif
2471−// */
2472−//
2473−// // check for error
2474−// if( !(m_io.is_open()) )
2475−// {
2476−// // EM_error3( "[chuck](via FileIO): cannot open file: '%s'", path.c_str() );
2477−// goto error;
2478−// }
2479−//
2480−// // set path
2481−// m_path = path;
2482−// // set flags
2483−// m_flags = flags;
2484−// if (!(flags & TYPE_BINARY))
2485−// m_flags |= Chuck_IO_File::TYPE_ASCII; // ASCII is default
2486−// // set mode
2487−// m_iomode = MODE_SYNC;
2488−//
2489−// // pop
2490−// EM_poplog();
2491−//
2492−// return TRUE;
2493−//
2494−//error:
2495−//
2496−// // pop
2497−// EM_poplog();
2498−//
2499−// // reset
2500−// m_path = "";
2501−// m_flags = 0;
2502−// m_iomode = MODE_SYNC;
2503−// m_io.clear();
2504−// m_io.close();
2505−//
2506−// return FALSE;
2507−//}
2508−//
2509−//
2510−//
2511−//
2512−////-----------------------------------------------------------------------------
2513−//// name: close
2514−//// desc: close file
2515−////-----------------------------------------------------------------------------
2516−//void Chuck_IO_File::close()
2517−//{
2518−// // log
2519−// EM_log( CK_LOG_INFO, "FileIO: closing file '%s'...", m_path.c_str() );
2520−// // close it
2521−// m_io.close();
2522−// m_flags = 0;
2523−// m_path = "";
2524−// m_iomode = Chuck_IO::MODE_SYNC;
2525−// if ( m_dir ) {
2526−// closedir( m_dir );
2527−// m_dir = NULL;
2528−// m_dir_start = 0;
2529−// }
2530−//}
2531−//
2532−//
2533−//
2534−//
2535−////-----------------------------------------------------------------------------
2536−//// name: good()
2537−//// desc: ...
2538−////-----------------------------------------------------------------------------
2539−//t_CKBOOL Chuck_IO_File::good()
2540−//{
2541−// return m_dir || m_io.is_open();
2542−// // return (!m_dir) && (!m_io.is_open());
2543−//}
2544−//
2545−//
2546−//
2547−//
2548−////-----------------------------------------------------------------------------
2549−//// name: flush()
2550−//// desc: ...
2551−////-----------------------------------------------------------------------------
2552−//void Chuck_IO_File::flush()
2553−//{
2554−// // sanity
2555−// if ( m_dir )
2556−// {
2557−// EM_error3( "[chuck](via FileIO): cannot flush on directory" );
2558−// return;
2559−// }
2560−// m_io.flush();
2561−//}
2562−//
2563−//
2564−//
2565−//
2566−////-----------------------------------------------------------------------------
2567−//// name: mode()
2568−//// desc: ...
2569−////-----------------------------------------------------------------------------
2570−//t_CKINT Chuck_IO_File::mode()
2571−//{
2572−// // sanity
2573−// if ( m_dir )
2574−// {
2575−// EM_error3( "[chuck](via FileIO): cannot get mode on directory" );
2576−// return -1;
2577−// }
2578−// return m_iomode;
2579−//}
2580−//
2581−//
2582−//
2583−//
2584−////-----------------------------------------------------------------------------
2585−//// name: mode( t_CKINT flag )
2586−//// desc: ...
2587−////-----------------------------------------------------------------------------
2588−//void Chuck_IO_File::mode( t_CKINT flag )
2589−//{
2590−// // sanity
2591−// if ( m_dir )
2592−// {
2593−// EM_error3( "[chuck](via FileIO): cannot set mode on directory" );
2594−// return;
2595−// }
2596−// if ( (flag != Chuck_IO::MODE_ASYNC) && (flag != Chuck_IO::MODE_SYNC) )
2597−// {
2598−// EM_error3( "[chuck](via FileIO): invalid mode flag" );
2599−// return;
2600−// }
2601−//
2602−// m_iomode = flag;
2603−//}
2604−//
2605−//
2606−//
2607−//
2608−////-----------------------------------------------------------------------------
2609−//// name: size()
2610−//// desc: Returns the size of the file in bytes, or -1 if no file is opened or
2611−//// if a directory is opened.
2612−////-----------------------------------------------------------------------------
2613−//t_CKINT Chuck_IO_File::size()
2614−//{
2615−// if (!(m_io.is_open())) return -1;
2616−// if ( m_dir )
2617−// {
2618−// EM_error3( "[chuck](via FileIO): cannot get size on a directory" );
2619−// return -1;
2620−// }
2621−//
2622−// // no easy way to find file size in C++
2623−// // have to seek to end, report position
2624−// FILE * stream = fopen( m_path.c_str(), "r" );
2625−// fseek( stream, 0L, SEEK_END );
2626−// int endPos = ftell( stream );
2627−// fclose( stream );
2628−// return endPos;
2629−//}
2630−//
2631−//
2632−//
2633−//
2634−////-----------------------------------------------------------------------------
2635−//// name: seek( t_CKINT pos )
2636−//// desc: Seeks to the specified byte offset in the file.
2637−////-----------------------------------------------------------------------------
2638−//void Chuck_IO_File::seek( t_CKINT pos )
2639−//{
2640−// if ( !(m_io.is_open()) )
2641−// {
2642−// EM_error3( "[chuck](via FileIO): cannot seek: no file is open" );
2643−// return;
2644−// }
2645−// if ( m_dir )
2646−// {
2647−// EM_error3( "[chuck](via FileIO): cannot seek on a directory" );
2648−// return;
2649−// }
2650−// m_io.seekg( pos );
2651−// m_io.seekp( pos );
2652−//}
2653−//
2654−//
2655−//
2656−//
2657−////-----------------------------------------------------------------------------
2658−//// name: tell()
2659−//// desc: Returns the byte offset into the file, or -1 if no file is opened.
2660−////-----------------------------------------------------------------------------
2661−//t_CKINT Chuck_IO_File::tell()
2662−//{
2663−// if (!(m_io.is_open()))
2664−// return -1;
2665−// if ( m_dir )
2666−// {
2667−// EM_error3( "[chuck](via FileIO): cannot tell on directory" );
2668−// return -1;
2669−// }
2670−//
2671−// return m_io.tellg();
2672−//}
2673−//
2674−//
2675−//
2676−//
2677−////-----------------------------------------------------------------------------
2678−//// name: isDir()
2679−//// desc: ...
2680−////-----------------------------------------------------------------------------
2681−//t_CKINT Chuck_IO_File::isDir()
2682−//{
2683−// return m_dir != NULL;
2684−//}
2685−//
2686−//
2687−//
2688−//
2689−////-----------------------------------------------------------------------------
2690−//// name: dirList()
2691−//// desc: ...
2692−////-----------------------------------------------------------------------------
2693−//Chuck_Array4 * Chuck_IO_File::dirList()
2694−//{
2695−// // sanity
2696−// if ( !m_dir )
2697−// {
2698−// EM_error3( "[chuck](via FileIO): cannot get list: no directory open" );
2699−// Chuck_Array4 *ret = new Chuck_Array4( TRUE, 0 );
2700−// initialize_object( ret, m_vmRef->env()->t_array );
2701−// return ret;
2702−// }
2703−//
2704−// // fill vector with entry names
2705−// rewinddir( m_dir );
2706−// std::vector<Chuck_String *> entrylist;
2707−// struct dirent *ent;
2708−// while( (ent = readdir( m_dir )) ) // fixed 1.3.0.0: removed warning
2709−// {
2710−// // pass NULL as shred ref
2711−// Chuck_String *s = (Chuck_String *)instantiate_and_initialize_object( m_vmRef->env()->t_string, NULL, m_vmRef );
2712−// s->set( std::string( ent->d_name ) );
2713−// if ( s->str() != ".." && s->str() != "." )
2714−// {
2715−// // don't include .. and . in the list
2716−// entrylist.push_back( s );
2717−// }
2718−// }
2719−//
2720−// // make array
2721−// Chuck_Array4 *array = new Chuck_Array4( true, entrylist.size() );
2722−// initialize_object( array, m_vmRef->env()->t_array );
2723−// for ( int i = 0; i < entrylist.size(); i++ )
2724−// array->set( i, (t_CKUINT) entrylist[i] );
2725−// return array;
2726−//}
2347+#ifndef __DISABLE_FILEIO__
2348+//-----------------------------------------------------------------------------
2349+// name: Chuck_IO_File()
2350+// desc: constructor
2351+//-----------------------------------------------------------------------------
2352+Chuck_IO_File::Chuck_IO_File( Chuck_VM * vm )
2353+{
2354+ m_vmRef = vm;
2355+ // zero things out
2356+ m_flags = 0;
2357+ m_iomode = MODE_SYNC;
2358+ m_path = "";
2359+ m_dir = NULL;
2360+ m_dir_start = 0;
2361+ m_asyncEvent = new Chuck_Event;
2362+ initialize_object( m_asyncEvent, vm->env()->t_event );
2363+ m_thread = new XThread;
2364+}
27272365
27282366
27292367
27302368
27312369 //-----------------------------------------------------------------------------
2732−// name: read( t_CKINT length )
2733−// desc: ...
2370+// name: ~Chuck_IO_File()
2371+// desc: destructor
27342372 //-----------------------------------------------------------------------------
2735−/*Chuck_String * Chuck_IO_File::read( t_CKINT length )
2373+Chuck_IO_File::~Chuck_IO_File()
27362374 {
2737− // sanity
2738− if (!(m_io.is_open())) {
2739− EM_error3( "[chuck](via FileIO): cannot read: no file open" );
2740− return new Chuck_String( "" );
2375+ // clean up
2376+ this->close();
2377+ delete m_asyncEvent;
2378+ delete m_thread;
2379+}
2380+
2381+
2382+
2383+
2384+//-----------------------------------------------------------------------------
2385+// name: open
2386+// desc: open file from disk
2387+//-----------------------------------------------------------------------------
2388+t_CKBOOL Chuck_IO_File::open( const string & path, t_CKINT flags )
2389+{
2390+ // log
2391+ EM_log( CK_LOG_INFO, "FileIO: opening file from disk..." );
2392+ EM_log( CK_LOG_INFO, "FileIO: path: %s", path.c_str() );
2393+ EM_pushlog();
2394+
2395+ // if no flag specified, make it READ by default
2396+ if( !(flags & FLAG_READ_WRITE) &&
2397+ !(flags & FLAG_READONLY) &&
2398+ !(flags & FLAG_WRITEONLY) &&
2399+ !(flags & FLAG_APPEND) )
2400+ {
2401+ flags |= FLAG_READONLY;
27412402 }
2742−
2743− if (m_io.fail()) {
2744− EM_error3( "[chuck](via FileIO): cannot read: I/O stream failed" );
2745− return new Chuck_String( "" );
2403+
2404+ // if both read and write, enable read and write
2405+ if( flags & FLAG_READONLY && flags & FLAG_WRITEONLY )
2406+ {
2407+ flags ^= FLAG_READONLY;
2408+ flags ^= FLAG_WRITEONLY;
2409+ flags |= FLAG_READ_WRITE;
27462410 }
2747−
2748− if ( m_dir )
2411+
2412+ // check flags for errors
2413+ if ((flags & TYPE_ASCII) &&
2414+ (flags & TYPE_BINARY))
27492415 {
2750− EM_error3( "[chuck](via FileIO): cannot read on a directory" );
2751− return new Chuck_String( "" );
2416+ EM_error3( "[chuck](via FileIO): cannot open file in both ASCII and binary mode" );
2417+ goto error;
27522418 }
2753−
2754− char buf[length+1];
2755− m_io.read( buf, length );
2756− buf[m_io.gcount()] = '\0';
2757− string s( buf );
2758− return new Chuck_String( s );
2759−}*/
27602419
2420+ if ((flags & FLAG_READ_WRITE) &&
2421+ (flags & FLAG_READONLY))
2422+ {
2423+ EM_error3( "[chuck](via FileIO): conflicting flags: READ_WRITE and READ" );
2424+ goto error;
2425+ }
27612426
2427+ if ((flags & FLAG_READ_WRITE) &&
2428+ (flags & FLAG_WRITEONLY))
2429+ {
2430+ EM_error3( "[chuck](via FileIO): conflicting flags: READ_WRITE and WRITE" );
2431+ goto error;
2432+ }
27622433
2434+ if ((flags & FLAG_READ_WRITE) &&
2435+ (flags & FLAG_APPEND))
2436+ {
2437+ EM_error3( "[chuck](via FileIO): conflicting flags: READ_WRITE and APPEND" );
2438+ goto error;
2439+ }
27632440
2764−//-----------------------------------------------------------------------------
2765−// name: readLine()
2766−// desc: read line
2767−//-----------------------------------------------------------------------------
2768−//Chuck_String * Chuck_IO_File::readLine()
2769−//{
2770−// // sanity
2771−// if (!(m_io.is_open())) {
2772−// EM_error3( "[chuck](via FileIO): cannot readLine: no file open" );
2773−// return new Chuck_String( "" );
2774−// }
2775−//
2776−// if (m_io.fail()) {
2777−// EM_error3( "[chuck](via FileIO): cannot readLine: I/O stream failed" );
2778−// return new Chuck_String( "" );
2779−// }
2780−//
2781−// if ( m_dir )
2782−// {
2783−// EM_error3( "[chuck](via FileIO): cannot readLine on directory" );
2784−// return new Chuck_String( "" );
2785−// }
2786−//
2787−// string s;
2788−// getline( m_io, s );
2789−// return new Chuck_String( s );
2790−//}
2791−//
2792−//
2793−//
2794−//
2795−////-----------------------------------------------------------------------------
2796−//// name: readInt( t_CKINT flags )
2797−//// desc: ...
2798−////-----------------------------------------------------------------------------
2799−//t_CKINT Chuck_IO_File::readInt( t_CKINT flags )
2800−//{
2801−// // sanity
2802−// if (!(m_io.is_open())) {
2803−// EM_error3( "[chuck](via FileIO): cannot readInt: no file open" );
2804−// return 0;
2805−// }
2806−//
2807−// if (m_io.eof()) {
2808−// EM_error3( "[chuck](via FileIO): cannot readInt: EOF reached" );
2809−// return 0;
2810−// }
2811−//
2812−// if ( m_dir )
2813−// {
2814−// EM_error3( "[chuck](via FileIO): cannot read on directory" );
2815−// return 0;
2816−// }
2817−//
2818−// if (m_io.fail()) {
2819−// EM_error3( "[chuck](via FileIO): cannot readInt: I/O stream failed" );
2820−// return 0;
2821−// }
2822−//
2823−// if (m_flags & TYPE_ASCII) {
2824−// // ASCII
2825−// t_CKINT val = 0;
2826−// m_io >> val;
2827−// // if (m_io.fail())
2828−// // EM_error3( "[chuck](via FileIO): cannot readInt: I/O stream failed" );
2829−// return val;
2830−//
2831−// } else if (m_flags & TYPE_BINARY) {
2832−// // binary
2833−// if (flags & Chuck_IO::INT32) {
2834−// // 32-bit
2835−// t_CKINT i;
2836−// m_io.read( (char *)&i, 4 );
2837−// if (m_io.gcount() != 4)
2838−// EM_error3( "[chuck](via FileIO): cannot readInt: not enough bytes left" );
2839−// else if (m_io.fail())
2840−// EM_error3( "[chuck](via FileIO): cannot readInt: I/O stream failed" );
2841−// return i;
2842−// } else if (flags & Chuck_IO::INT16) {
2843−// // 16-bit
2844−// // int16_t i;
2845−// // issue: 64-bit
2846−// short i;
2847−// m_io.read( (char *)&i, 2 );
2848−// if (m_io.gcount() != 2)
2849−// EM_error3( "[chuck](via FileIO): cannot readInt: not enough bytes left" );
2850−// else if (m_io.fail())
2851−// EM_error3( "[chuck](via FileIO): cannot readInt: I/O stream failed" );
2852−// return (t_CKINT) i;
2853−// } else if (flags & Chuck_IO::INT8) {
2854−// // 8-bit
2855−// // int8_t i;
2856−// // issue: 64-bit
2857−// char i;
2858−// m_io.read( (char *)&i, 1 );
2859−// if (m_io.gcount() != 1)
2860−// EM_error3( "[chuck](via FileIO): cannot readInt: not enough bytes left" );
2861−// else if (m_io.fail())
2862−// EM_error3( "[chuck](via FileIO): cannot readInt: I/O stream failed" );
2863−// return (t_CKINT) i;
2864−// } else {
2865−// EM_error3( "[chuck](via FileIO): readInt error: invalid int size flag" );
2866−// return 0;
2867−// }
2868−//
2869−// } else {
2870−// EM_error3( "[chuck](via FileIO): readInt error: invalid ASCII/binary flag" );
2871−// return 0;
2872−// }
2873−//}
2874−//
2875−//
2876−//
2877−//
2878−////-----------------------------------------------------------------------------
2879−//// name: readFloat()
2880−//// desc: read next as (ascii) floating point value
2881−////-----------------------------------------------------------------------------
2882−//t_CKFLOAT Chuck_IO_File::readFloat()
2883−//{
2884−// // sanity
2885−// if (!(m_io.is_open())) {
2886−// EM_error3( "[chuck](via FileIO): cannot readFloat: no file open" );
2887−// return 0;
2888−// }
2889−//
2890−// if (m_io.eof()) {
2891−// EM_error3( "[chuck](via FileIO): cannot readFloat: EOF reached" );
2892−// return 0;
2893−// }
2894−//
2895−// if (m_io.fail()) {
2896−// EM_error3( "[chuck](via FileIO): cannot readFloat: I/O stream failed" );
2897−// return 0;
2898−// }
2899−//
2900−// if ( m_dir )
2901−// {
2902−// EM_error3( "[chuck](via FileIO): cannot read a directory" );
2903−// return 0;
2904−// }
2905−//
2906−// if (m_flags & TYPE_ASCII) {
2907−// // ASCII
2908−// t_CKFLOAT val = 0;
2909−// m_io >> val;
2910−// // if (m_io.fail())
2911−// // EM_error3( "[chuck](via FileIO): cannot readFloat: I/O stream failed" );
2912−// return val;
2913−//
2914−// } else if (m_flags & TYPE_BINARY) {
2915−// // binary
2916−// t_CKFLOAT i;
2917−// m_io.read( (char *)&i, sizeof(t_CKFLOAT) );
2918−// if (m_io.gcount() != sizeof(t_CKFLOAT) )
2919−// EM_error3( "[chuck](via FileIO): cannot readFloat: not enough bytes left" );
2920−// else if (m_io.fail())
2921−// EM_error3( "[chuck](via FileIO): cannot readInt: I/O stream failed" );
2922−// return i;
2923−//
2924−// } else {
2925−// EM_error3( "[chuck](via FileIO): readFloat error: invalid ASCII/binary flag" );
2926−// return 0;
2927−// }
2928−//}
2929−//
2930−//
2931−//
2932−//
2933−////-----------------------------------------------------------------------------
2934−//// name: readString()
2935−//// desc: ...
2936−////-----------------------------------------------------------------------------
2937−//t_CKBOOL Chuck_IO_File::readString( std::string & str )
2938−//{
2939−// // set
2940−// str = "";
2941−//
2942−// // sanity
2943−// if (!(m_io.is_open())) {
2944−// EM_error3( "[chuck](via FileIO): cannot readString: no file open" );
2945−// return FALSE;
2946−// }
2947−//
2948−// if (m_io.eof()) {
2949−// EM_error3( "[chuck](via FileIO): cannot readString: EOF reached" );
2950−// return FALSE;
2951−// }
2952−//
2953−// if ( m_dir )
2954−// {
2955−// EM_error3( "[chuck](via FileIO): cannot read on directory" );
2956−// return FALSE;
2957−// }
2958−//
2959−// if (m_io.fail()) {
2960−// EM_error3( "[chuck](via FileIO): cannot readString: I/O stream failed" );
2961−// return FALSE;
2962−// }
2963−//
2964−// if (m_flags & TYPE_ASCII) {
2965−// // ASCII
2966−// m_io >> str;
2967−// return TRUE;
2968−// } else if (m_flags & TYPE_BINARY) {
2969−// EM_error3( "[chuck](via FileIO): readString not supported for binary mode" );
2970−// return FALSE;
2971−// } else {
2972−// EM_error3( "[chuck](via FileIO): readInt error: invalid ASCII/binary flag" );
2973−// return FALSE;
2974−// }
2975−//}
2441+ if ((flags & FLAG_WRITEONLY) &&
2442+ (flags & FLAG_READONLY))
2443+ {
2444+ EM_error3( "[chuck](via FileIO): conflicting flags: WRITE and READ" );
2445+ goto error;
2446+ }
2447+
2448+ if ((flags & FLAG_APPEND) &&
2449+ (flags & FLAG_READONLY))
2450+ {
2451+ EM_error3( "[chuck](via FileIO): conflicting flags: APPEND and FLAG_READ" );
2452+ goto error;
2453+ }
2454+
2455+ // set open flags
2456+ ios_base::openmode mode;
2457+
2458+ if (flags & FLAG_READ_WRITE)
2459+ mode = ios_base::in | ios_base::out;
2460+ else if (flags & FLAG_READONLY)
2461+ mode = ios_base::in;
2462+ else if (flags & FLAG_APPEND)
2463+ mode = ios_base::out | ios_base::app;
2464+ else if (flags & FLAG_WRITEONLY)
2465+ mode = ios_base::out | ios_base::trunc;
2466+
2467+ if (flags & TYPE_BINARY)
2468+ mode |= ios_base::binary;
2469+
2470+ // close first
2471+ if (m_io.is_open())
2472+ this->close();
2473+
2474+ // try to open as a dir first (fixed 1.3.0.0 removed warning)
2475+ if( (m_dir = opendir( path.c_str() )) )
2476+ {
2477+ EM_poplog();
2478+ return TRUE;
2479+ }
2480+
2481+ // not a dir, create file if it does not exist unless flag is
2482+ // readonly
2483+ if ( !(flags & FLAG_READONLY) )
2484+ {
2485+ m_io.open( path.c_str(), ios_base::in );
2486+ if ( m_io.fail() )
2487+ {
2488+ m_io.clear();
2489+ m_io.open( path.c_str(), ios_base::out | ios_base::trunc );
2490+ m_io.close();
2491+ }
2492+ else
2493+ m_io.close();
2494+ }
2495+
2496+ //open file
2497+ m_io.open( path.c_str(), mode );
2498+
2499+ // seek to beginning if necessary
2500+ if (flags & FLAG_READ_WRITE)
2501+ {
2502+ m_io.seekp(0);
2503+ m_io.seekg(0);
2504+ }
2505+
2506+ /* ATODO: Ge's code
2507+ // windows sucks for being creative in the wrong places
2508+ #ifdef __PLATFORM_WIN32__
2509+ // if( flags ^ Chuck_IO::TRUNCATE && flags | Chuck_IO::READ ) nMode |= ios::nocreate;
2510+ m_io.open( path.c_str(), nMode );
2511+ #else
2512+ m_io.open( path.c_str(), (_Ios_Openmode)nMode );
2513+ #endif
2514+ */
2515+
2516+ // check for error
2517+ if( !(m_io.is_open()) )
2518+ {
2519+ // EM_error3( "[chuck](via FileIO): cannot open file: '%s'", path.c_str() );
2520+ goto error;
2521+ }
2522+
2523+ // set path
2524+ m_path = path;
2525+ // set flags
2526+ m_flags = flags;
2527+ if (!(flags & TYPE_BINARY))
2528+ m_flags |= Chuck_IO_File::TYPE_ASCII; // ASCII is default
2529+ // set mode
2530+ m_iomode = MODE_SYNC;
2531+
2532+ // pop
2533+ EM_poplog();
2534+
2535+ return TRUE;
2536+
2537+error:
2538+
2539+ // pop
2540+ EM_poplog();
2541+
2542+ // reset
2543+ m_path = "";
2544+ m_flags = 0;
2545+ m_iomode = MODE_SYNC;
2546+ m_io.clear();
2547+ m_io.close();
2548+
2549+ return FALSE;
2550+}
2551+
2552+
2553+
2554+
2555+//-----------------------------------------------------------------------------
2556+// name: close
2557+// desc: close file
2558+//-----------------------------------------------------------------------------
2559+void Chuck_IO_File::close()
2560+{
2561+ // log
2562+ EM_log( CK_LOG_INFO, "FileIO: closing file '%s'...", m_path.c_str() );
2563+ // close it
2564+ m_io.close();
2565+ m_flags = 0;
2566+ m_path = "";
2567+ m_iomode = Chuck_IO::MODE_SYNC;
2568+ if ( m_dir ) {
2569+ closedir( m_dir );
2570+ m_dir = NULL;
2571+ m_dir_start = 0;
2572+ }
2573+}
2574+
2575+
2576+
2577+
2578+//-----------------------------------------------------------------------------
2579+// name: good()
2580+// desc: ...
2581+//-----------------------------------------------------------------------------
2582+t_CKBOOL Chuck_IO_File::good()
2583+{
2584+ return m_dir || m_io.is_open();
2585+ // return (!m_dir) && (!m_io.is_open());
2586+}
2587+
2588+
2589+
2590+
2591+//-----------------------------------------------------------------------------
2592+// name: flush()
2593+// desc: ...
2594+//-----------------------------------------------------------------------------
2595+void Chuck_IO_File::flush()
2596+{
2597+ // sanity
2598+ if ( m_dir )
2599+ {
2600+ EM_error3( "[chuck](via FileIO): cannot flush on directory" );
2601+ return;
2602+ }
2603+ m_io.flush();
2604+}
2605+
2606+
2607+
2608+
2609+//-----------------------------------------------------------------------------
2610+// name: mode()
2611+// desc: ...
2612+//-----------------------------------------------------------------------------
2613+t_CKINT Chuck_IO_File::mode()
2614+{
2615+ // sanity
2616+ if ( m_dir )
2617+ {
2618+ EM_error3( "[chuck](via FileIO): cannot get mode on directory" );
2619+ return -1;
2620+ }
2621+ return m_iomode;
2622+}
2623+
2624+
2625+
2626+
2627+//-----------------------------------------------------------------------------
2628+// name: mode( t_CKINT flag )
2629+// desc: ...
2630+//-----------------------------------------------------------------------------
2631+void Chuck_IO_File::mode( t_CKINT flag )
2632+{
2633+ // sanity
2634+ if ( m_dir )
2635+ {
2636+ EM_error3( "[chuck](via FileIO): cannot set mode on directory" );
2637+ return;
2638+ }
2639+ if ( (flag != Chuck_IO::MODE_ASYNC) && (flag != Chuck_IO::MODE_SYNC) )
2640+ {
2641+ EM_error3( "[chuck](via FileIO): invalid mode flag" );
2642+ return;
2643+ }
2644+
2645+ m_iomode = flag;
2646+}
2647+
2648+
2649+
2650+
2651+//-----------------------------------------------------------------------------
2652+// name: size()
2653+// desc: Returns the size of the file in bytes, or -1 if no file is opened or
2654+// if a directory is opened.
2655+//-----------------------------------------------------------------------------
2656+t_CKINT Chuck_IO_File::size()
2657+{
2658+ if (!(m_io.is_open())) return -1;
2659+ if ( m_dir )
2660+ {
2661+ EM_error3( "[chuck](via FileIO): cannot get size on a directory" );
2662+ return -1;
2663+ }
2664+
2665+ // no easy way to find file size in C++
2666+ // have to seek to end, report position
2667+ FILE * stream = fopen( m_path.c_str(), "r" );
2668+ fseek( stream, 0L, SEEK_END );
2669+ int endPos = ftell( stream );
2670+ fclose( stream );
2671+ return endPos;
2672+}
2673+
2674+
2675+
2676+
2677+//-----------------------------------------------------------------------------
2678+// name: seek( t_CKINT pos )
2679+// desc: Seeks to the specified byte offset in the file.
2680+//-----------------------------------------------------------------------------
2681+void Chuck_IO_File::seek( t_CKINT pos )
2682+{
2683+ if ( !(m_io.is_open()) )
2684+ {
2685+ EM_error3( "[chuck](via FileIO): cannot seek: no file is open" );
2686+ return;
2687+ }
2688+ if ( m_dir )
2689+ {
2690+ EM_error3( "[chuck](via FileIO): cannot seek on a directory" );
2691+ return;
2692+ }
2693+ m_io.seekg( pos );
2694+ m_io.seekp( pos );
2695+}
2696+
2697+
2698+
2699+
2700+//-----------------------------------------------------------------------------
2701+// name: tell()
2702+// desc: Returns the byte offset into the file, or -1 if no file is opened.
2703+//-----------------------------------------------------------------------------
2704+t_CKINT Chuck_IO_File::tell()
2705+{
2706+ if (!(m_io.is_open()))
2707+ return -1;
2708+ if ( m_dir )
2709+ {
2710+ EM_error3( "[chuck](via FileIO): cannot tell on directory" );
2711+ return -1;
2712+ }
2713+
2714+ return m_io.tellg();
2715+}
2716+
2717+
2718+
2719+
2720+//-----------------------------------------------------------------------------
2721+// name: isDir()
2722+// desc: ...
2723+//-----------------------------------------------------------------------------
2724+t_CKINT Chuck_IO_File::isDir()
2725+{
2726+ return m_dir != NULL;
2727+}
2728+
2729+
2730+
2731+
2732+//-----------------------------------------------------------------------------
2733+// name: dirList()
2734+// desc: ...
2735+//-----------------------------------------------------------------------------
2736+Chuck_Array4 * Chuck_IO_File::dirList()
2737+{
2738+ // sanity
2739+ if ( !m_dir )
2740+ {
2741+ EM_error3( "[chuck](via FileIO): cannot get list: no directory open" );
2742+ Chuck_Array4 *ret = new Chuck_Array4( TRUE, 0 );
2743+ initialize_object( ret, m_vmRef->env()->t_array );
2744+ return ret;
2745+ }
2746+
2747+ // fill vector with entry names
2748+ rewinddir( m_dir );
2749+ std::vector<Chuck_String *> entrylist;
2750+ struct dirent *ent;
2751+ while( (ent = readdir( m_dir )) ) // fixed 1.3.0.0: removed warning
2752+ {
2753+ // pass NULL as shred ref
2754+ Chuck_String *s = (Chuck_String *)instantiate_and_initialize_object( m_vmRef->env()->t_string, NULL, m_vmRef );
2755+ s->set( std::string( ent->d_name ) );
2756+ if ( s->str() != ".." && s->str() != "." )
2757+ {
2758+ // don't include .. and . in the list
2759+ entrylist.push_back( s );
2760+ }
2761+ }
2762+
2763+ // make array
2764+ Chuck_Array4 *array = new Chuck_Array4( true, entrylist.size() );
2765+ initialize_object( array, m_vmRef->env()->t_array );
2766+ for ( int i = 0; i < entrylist.size(); i++ )
2767+ array->set( i, (t_CKUINT) entrylist[i] );
2768+ return array;
2769+}
2770+
2771+
2772+
2773+
2774+//-----------------------------------------------------------------------------
2775+// name: read( t_CKINT length )
2776+// desc: ...
2777+//-----------------------------------------------------------------------------
2778+/*Chuck_String * Chuck_IO_File::read( t_CKINT length )
2779+{
2780+ // sanity
2781+ if (!(m_io.is_open())) {
2782+ EM_error3( "[chuck](via FileIO): cannot read: no file open" );
2783+ return new Chuck_String( "" );
2784+ }
2785+
2786+ if (m_io.fail()) {
2787+ EM_error3( "[chuck](via FileIO): cannot read: I/O stream failed" );
2788+ return new Chuck_String( "" );
2789+ }
2790+
2791+ if ( m_dir )
2792+ {
2793+ EM_error3( "[chuck](via FileIO): cannot read on a directory" );
2794+ return new Chuck_String( "" );
2795+ }
2796+
2797+ char buf[length+1];
2798+ m_io.read( buf, length );
2799+ buf[m_io.gcount()] = '\0';
2800+ string s( buf );
2801+ return new Chuck_String( s );
2802+}*/
2803+
2804+
2805+
2806+
2807+//-----------------------------------------------------------------------------
2808+// name: readLine()
2809+// desc: read line
2810+//-----------------------------------------------------------------------------
2811+Chuck_String * Chuck_IO_File::readLine()
2812+{
2813+ // sanity
2814+ if (!(m_io.is_open())) {
2815+ EM_error3( "[chuck](via FileIO): cannot readLine: no file open" );
2816+ return new Chuck_String( "" );
2817+ }
2818+
2819+ if (m_io.fail()) {
2820+ EM_error3( "[chuck](via FileIO): cannot readLine: I/O stream failed" );
2821+ return new Chuck_String( "" );
2822+ }
2823+
2824+ if ( m_dir )
2825+ {
2826+ EM_error3( "[chuck](via FileIO): cannot readLine on directory" );
2827+ return new Chuck_String( "" );
2828+ }
2829+
2830+ string s;
2831+ getline( m_io, s );
2832+ return new Chuck_String( s );
2833+}
2834+
2835+
2836+
2837+
2838+//-----------------------------------------------------------------------------
2839+// name: readInt( t_CKINT flags )
2840+// desc: ...
2841+//-----------------------------------------------------------------------------
2842+t_CKINT Chuck_IO_File::readInt( t_CKINT flags )
2843+{
2844+ // sanity
2845+ if (!(m_io.is_open())) {
2846+ EM_error3( "[chuck](via FileIO): cannot readInt: no file open" );
2847+ return 0;
2848+ }
2849+
2850+ if (m_io.eof()) {
2851+ EM_error3( "[chuck](via FileIO): cannot readInt: EOF reached" );
2852+ return 0;
2853+ }
2854+
2855+ if ( m_dir )
2856+ {
2857+ EM_error3( "[chuck](via FileIO): cannot read on directory" );
2858+ return 0;
2859+ }
2860+
2861+ if (m_io.fail()) {
2862+ EM_error3( "[chuck](via FileIO): cannot readInt: I/O stream failed" );
2863+ return 0;
2864+ }
2865+
2866+ if (m_flags & TYPE_ASCII) {
2867+ // ASCII
2868+ t_CKINT val = 0;
2869+ m_io >> val;
2870+ // if (m_io.fail())
2871+ // EM_error3( "[chuck](via FileIO): cannot readInt: I/O stream failed" );
2872+ return val;
2873+
2874+ } else if (m_flags & TYPE_BINARY) {
2875+ // binary
2876+ if (flags & Chuck_IO::INT32) {
2877+ // 32-bit
2878+ t_CKINT i;
2879+ m_io.read( (char *)&i, 4 );
2880+ if (m_io.gcount() != 4)
2881+ EM_error3( "[chuck](via FileIO): cannot readInt: not enough bytes left" );
2882+ else if (m_io.fail())
2883+ EM_error3( "[chuck](via FileIO): cannot readInt: I/O stream failed" );
2884+ return i;
2885+ } else if (flags & Chuck_IO::INT16) {
2886+ // 16-bit
2887+ // int16_t i;
2888+ // issue: 64-bit
2889+ short i;
2890+ m_io.read( (char *)&i, 2 );
2891+ if (m_io.gcount() != 2)
2892+ EM_error3( "[chuck](via FileIO): cannot readInt: not enough bytes left" );
2893+ else if (m_io.fail())
2894+ EM_error3( "[chuck](via FileIO): cannot readInt: I/O stream failed" );
2895+ return (t_CKINT) i;
2896+ } else if (flags & Chuck_IO::INT8) {
2897+ // 8-bit
2898+ // int8_t i;
2899+ // issue: 64-bit
2900+ char i;
2901+ m_io.read( (char *)&i, 1 );
2902+ if (m_io.gcount() != 1)
2903+ EM_error3( "[chuck](via FileIO): cannot readInt: not enough bytes left" );
2904+ else if (m_io.fail())
2905+ EM_error3( "[chuck](via FileIO): cannot readInt: I/O stream failed" );
2906+ return (t_CKINT) i;
2907+ } else {
2908+ EM_error3( "[chuck](via FileIO): readInt error: invalid int size flag" );
2909+ return 0;
2910+ }
2911+
2912+ } else {
2913+ EM_error3( "[chuck](via FileIO): readInt error: invalid ASCII/binary flag" );
2914+ return 0;
2915+ }
2916+}
2917+
2918+
2919+
2920+
2921+//-----------------------------------------------------------------------------
2922+// name: readFloat()
2923+// desc: read next as (ascii) floating point value
2924+//-----------------------------------------------------------------------------
2925+t_CKFLOAT Chuck_IO_File::readFloat()
2926+{
2927+ // sanity
2928+ if (!(m_io.is_open())) {
2929+ EM_error3( "[chuck](via FileIO): cannot readFloat: no file open" );
2930+ return 0;
2931+ }
2932+
2933+ if (m_io.eof()) {
2934+ EM_error3( "[chuck](via FileIO): cannot readFloat: EOF reached" );
2935+ return 0;
2936+ }
2937+
2938+ if (m_io.fail()) {
2939+ EM_error3( "[chuck](via FileIO): cannot readFloat: I/O stream failed" );
2940+ return 0;
2941+ }
2942+
2943+ if ( m_dir )
2944+ {
2945+ EM_error3( "[chuck](via FileIO): cannot read a directory" );
2946+ return 0;
2947+ }
2948+
2949+ if (m_flags & TYPE_ASCII) {
2950+ // ASCII
2951+ t_CKFLOAT val = 0;
2952+ m_io >> val;
2953+ // if (m_io.fail())
2954+ // EM_error3( "[chuck](via FileIO): cannot readFloat: I/O stream failed" );
2955+ return val;
2956+
2957+ } else if (m_flags & TYPE_BINARY) {
2958+ // binary
2959+ t_CKFLOAT i;
2960+ m_io.read( (char *)&i, sizeof(t_CKFLOAT) );
2961+ if (m_io.gcount() != sizeof(t_CKFLOAT) )
2962+ EM_error3( "[chuck](via FileIO): cannot readFloat: not enough bytes left" );
2963+ else if (m_io.fail())
2964+ EM_error3( "[chuck](via FileIO): cannot readInt: I/O stream failed" );
2965+ return i;
2966+
2967+ } else {
2968+ EM_error3( "[chuck](via FileIO): readFloat error: invalid ASCII/binary flag" );
2969+ return 0;
2970+ }
2971+}
2972+
2973+
2974+
2975+
2976+//-----------------------------------------------------------------------------
2977+// name: readString()
2978+// desc: ...
2979+//-----------------------------------------------------------------------------
2980+t_CKBOOL Chuck_IO_File::readString( std::string & str )
2981+{
2982+ // set
2983+ str = "";
2984+
2985+ // sanity
2986+ if (!(m_io.is_open())) {
2987+ EM_error3( "[chuck](via FileIO): cannot readString: no file open" );
2988+ return FALSE;
2989+ }
2990+
2991+ if (m_io.eof()) {
2992+ EM_error3( "[chuck](via FileIO): cannot readString: EOF reached" );
2993+ return FALSE;
2994+ }
2995+
2996+ if ( m_dir )
2997+ {
2998+ EM_error3( "[chuck](via FileIO): cannot read on directory" );
2999+ return FALSE;
3000+ }
3001+
3002+ if (m_io.fail()) {
3003+ EM_error3( "[chuck](via FileIO): cannot readString: I/O stream failed" );
3004+ return FALSE;
3005+ }
3006+
3007+ if (m_flags & TYPE_ASCII) {
3008+ // ASCII
3009+ m_io >> str;
3010+ return TRUE;
3011+ } else if (m_flags & TYPE_BINARY) {
3012+ EM_error3( "[chuck](via FileIO): readString not supported for binary mode" );
3013+ return FALSE;
3014+ } else {
3015+ EM_error3( "[chuck](via FileIO): readInt error: invalid ASCII/binary flag" );
3016+ return FALSE;
3017+ }
3018+}
29763019
29773020
29783021
@@ -2981,13 +3024,13 @@ Chuck_IO::~Chuck_IO() · 2 unmodified lines
29813024
29823025 THREAD_RETURN ( THREAD_TYPE Chuck_IO_File::read_thread ) ( void *data )
29833026 {
2984− // (ATODO: test this)
3027+ (ATODO: test this)
29853028 cerr << "In thread" << endl;
29863029 async_args *args = (async_args *)data;
29873030 Chuck_String *ret = (Chuck_String *)(args->RETURN);
29883031 ret = args->fileio_obj->read( args->intArg );
29893032 cerr << "Called FileIO.read(int)" << endl;
2990− args->fileio_obj->m_asyncEvent->broadcast(); // wake up
3033+ args->fileio_obj->m_asyncEvent->broadcast(); wake up
29913034 cerr << "Broadcasted on event" << endl;
29923035 cerr << "Sleeping" << endl;
29933036 sleep(5);
@@ -3000,18 +3043,18 @@ Chuck_IO::~Chuck_IO() · 6 unmodified lines
30003043
30013044 THREAD_RETURN ( THREAD_TYPE Chuck_IO_File::readLine_thread ) ( void *data )
30023045 {
3003− // not yet implemented
3046+ not yet implemented
30043047 return NULL;
30053048 }
30063049
30073050 THREAD_RETURN ( THREAD_TYPE Chuck_IO_File::readInt_thread ) ( void *data )
30083051 {
3009− // (ATODO: test this)
3052+ (ATODO: test this)
30103053 async_args *args = (async_args *)data;
30113054 Chuck_DL_Return *ret = (Chuck_DL_Return *)(args->RETURN);
30123055 ret->v_int = args->fileio_obj->readInt( args->intArg );
30133056 cerr << "Called readInt, set ret->v_int to " << ret->v_int << endl;
3014− args->fileio_obj->m_asyncEvent->broadcast(); // wake up
3057+ args->fileio_obj->m_asyncEvent->broadcast(); wake up
30153058 cerr << "Called broadcast" << endl;
30163059 delete args;
30173060
@@ -3020,7 +3063,7 @@ Chuck_IO::~Chuck_IO() · 2 unmodified lines
30203063
30213064 THREAD_RETURN ( THREAD_TYPE Chuck_IO_File::readFloat_thread ) ( void *data )
30223065 {
3023− // not yet implemented
3066+ not yet implemented
30243067 return NULL;
30253068 }
30263069 */
@@ -3029,213 +3072,217 @@ Chuck_IO::~Chuck_IO() · 2 unmodified lines
30293072 // name: eof()
30303073 // desc: end of file?
30313074 //-----------------------------------------------------------------------------
3032−//t_CKBOOL Chuck_IO_File::eof()
3033−//{
3034−// if( !m_io.is_open() )
3035−// {
3036−// // EM_error3( "[chuck](via FileIO): cannot check eof: no file open" );
3037−// return TRUE;
3038−// }
3039−// if( m_dir )
3040−// {
3041−// EM_error3( "[chuck](via FileIO): cannot check eof on directory" );
3042−// return TRUE;
3043−// }
3044−//
3045−// return m_io.eof() || m_io.fail();
3046−//}
3047−//
3048−//
3049−//
3050−//
3051−////-----------------------------------------------------------------------------
3052−//// name: write( const std::string & val )
3053−//// desc: ...
3054−////-----------------------------------------------------------------------------
3055−//void Chuck_IO_File::write( const std::string & val )
3056−//{
3057−// // sanity
3058−// if (!(m_io.is_open())) {
3059−// EM_error3( "[chuck](via FileIO): cannot write: no file open" );
3060−// return;
3061−// }
3062−//
3063−// if (m_io.fail()) {
3064−// EM_error3( "[chuck](via FileIO): cannot write: I/O stream failed" );
3065−// return;
3066−// }
3067−//
3068−// if ( m_dir )
3069−// {
3070−// EM_error3( "[chuck](via FileIO): cannot write to a directory" );
3071−// return;
3072−// }
3073−//
3074−// m_io.write( val.c_str(), val.size() );
3075−//
3076−// if (m_io.fail()) { // check both before and after write if stream is ok
3077−// EM_error3( "[chuck](via FileIO): cannot write: I/O stream failed" );
3078−// }
3079−//}
3080−//
3081−//
3082−//
3083−//
3084−////-----------------------------------------------------------------------------
3085−//// name: write( t_CKINT val )
3086−//// desc: ...
3087−////-----------------------------------------------------------------------------
3088−//void Chuck_IO_File::write( t_CKINT val )
3089−//{
3090−// // sanity
3091−// if (!(m_io.is_open())) {
3092−// EM_error3( "[chuck](via FileIO): cannot write: no file open" );
3093−// return;
3094−// }
3095−//
3096−// if (m_io.fail()) {
3097−// EM_error3( "[chuck](via FileIO): cannot write: I/O stream failed" );
3098−// return;
3099−// }
3100−//
3101−// if ( m_dir )
3102−// {
3103−// EM_error3( "[chuck](via FileIO): cannot write on directory" );
3104−// return;
3105−// }
3106−//
3107−// if (m_flags & TYPE_ASCII) {
3108−// m_io << val;
3109−// } else if (m_flags & TYPE_BINARY) {
3110−// m_io.write( (char *)&val, sizeof(t_CKINT) );
3111−// } else {
3112−// EM_error3( "[chuck](via FileIO): write error: invalid ASCII/binary flag" );
3113−// }
3114−//
3115−// if (m_io.fail()) { // check both before and after write if stream is ok
3116−// EM_error3( "[chuck](via FileIO): cannot write: I/O stream failed" );
3117−// }
3118−//}
3119−//
3120−//
3121−//
3122−//
3123−////-----------------------------------------------------------------------------
3124−//// name: write( t_CKINT val )
3125−//// desc: ...
3126−////-----------------------------------------------------------------------------
3127−//void Chuck_IO_File::write( t_CKINT val, t_CKINT flags )
3128−//{
3129−// // sanity
3130−// if (!(m_io.is_open())) {
3131−// EM_error3( "[chuck](via FileIO): cannot write: no file open" );
3132−// return;
3133−// }
3134−//
3135−// if (m_io.fail()) {
3136−// EM_error3( "[chuck](via FileIO): cannot write: I/O stream failed" );
3137−// return;
3138−// }
3139−//
3140−// if ( m_dir )
3141−// {
3142−// EM_error3( "[chuck](via FileIO): cannot write on directory" );
3143−// return;
3144−// }
3145−//
3146−// if (m_flags & TYPE_ASCII) {
3147−// m_io << val;
3148−// } else if (m_flags & TYPE_BINARY) {
3149−// int nBytes = 4;
3150−// if(flags & INT8) nBytes = 1;
3151−// else if(flags & INT16) nBytes = 2;
3152−// else if(flags & INT32) nBytes = 4;
3153−// m_io.write( (char *)&val, nBytes );
3154−// } else {
3155−// EM_error3( "[chuck](via FileIO): write error: invalid ASCII/binary flag" );
3156−// }
3157−//
3158−// if (m_io.fail()) { // check both before and after write if stream is ok
3159−// EM_error3( "[chuck](via FileIO): cannot write: I/O stream failed" );
3160−// }
3161−//}
3162−//
3163−//
3164−//
3165−//
3166−////-----------------------------------------------------------------------------
3167−//// name: write( t_CKFLOAT val )
3168−//// desc: ...
3169−////-----------------------------------------------------------------------------
3170−//void Chuck_IO_File::write( t_CKFLOAT val )
3171−//{
3172−// // sanity
3173−// if (!(m_io.is_open())) {
3174−// EM_error3( "[chuck](via FileIO): cannot write: no file open" );
3175−// return;
3176−// }
3177−//
3178−// if (m_io.fail()) {
3179−// EM_error3( "[chuck](via FileIO): cannot write: I/O stream failed" );
3180−// return;
3181−// }
3182−//
3183−// if ( m_dir )
3184−// {
3185−// EM_error3( "[chuck](via FileIO): cannot write to a directory" );
3186−// return;
3187−// }
3188−//
3189−// if (m_flags & TYPE_ASCII) {
3190−// m_io << val;
3191−// } else if (m_flags & TYPE_BINARY) {
3192−// m_io.write( (char *)&val, sizeof(t_CKFLOAT) );
3193−// } else {
3194−// EM_error3( "[chuck](via FileIO): write error: invalid ASCII/binary flag" );
3195−// }
3196−//
3197−// if (m_io.fail()) { // check both before and after write if stream is ok
3198−// EM_error3( "[chuck](via FileIO): cannot write: I/O stream failed" );
3199−// }
3200−//}
3201−//
3202−//
3203−//
3204−//
3205−//// static helper functions for writing asynchronously
3206−//THREAD_RETURN ( THREAD_TYPE Chuck_IO_File::writeStr_thread ) ( void *data )
3207−//{
3208−// async_args *args = (async_args *)data;
3209−// args->fileio_obj->write ( args->stringArg );
3210−// Chuck_Event *e = args->fileio_obj->m_asyncEvent;
3211−// delete args;
3212−// e->broadcast(); // wake up
3213−// e->broadcast_global();
3214−//
3215−// return (THREAD_RETURN)0;
3216−//}
3217−//
3218−//THREAD_RETURN ( THREAD_TYPE Chuck_IO_File::writeInt_thread ) ( void *data )
3219−//{
3220−// async_args *args = (async_args *)data;
3221−// args->fileio_obj->write ( args->intArg );
3222−// args->fileio_obj->m_asyncEvent->broadcast(); // wake up
3223−// args->fileio_obj->m_asyncEvent->broadcast_global();
3224−// delete args;
3225−//
3226−// return (THREAD_RETURN)0;
3227−//}
3228−//
3229−//THREAD_RETURN ( THREAD_TYPE Chuck_IO_File::writeFloat_thread ) ( void *data )
3230−//{
3231−// async_args *args = (async_args *)data;
3232−// args->fileio_obj->write ( args->floatArg );
3233−// args->fileio_obj->m_asyncEvent->broadcast(); // wake up
3234−// args->fileio_obj->m_asyncEvent->broadcast_global();
3235−// delete args;
3236−//
3237−// return (THREAD_RETURN)0;
3238−//}
3075+t_CKBOOL Chuck_IO_File::eof()
3076+{
3077+ if( !m_io.is_open() )
3078+ {
3079+ // EM_error3( "[chuck](via FileIO): cannot check eof: no file open" );
3080+ return TRUE;
3081+ }
3082+ if( m_dir )
3083+ {
3084+ EM_error3( "[chuck](via FileIO): cannot check eof on directory" );
3085+ return TRUE;
3086+ }
3087+
3088+ return m_io.eof() || m_io.fail();
3089+}
3090+
3091+
3092+
3093+
3094+//-----------------------------------------------------------------------------
3095+// name: write( const std::string & val )
3096+// desc: ...
3097+//-----------------------------------------------------------------------------
3098+void Chuck_IO_File::write( const std::string & val )
3099+{
3100+ // sanity
3101+ if (!(m_io.is_open())) {
3102+ EM_error3( "[chuck](via FileIO): cannot write: no file open" );
3103+ return;
3104+ }
3105+
3106+ if (m_io.fail()) {
3107+ EM_error3( "[chuck](via FileIO): cannot write: I/O stream failed" );
3108+ return;
3109+ }
3110+
3111+ if ( m_dir )
3112+ {
3113+ EM_error3( "[chuck](via FileIO): cannot write to a directory" );
3114+ return;
3115+ }
3116+
3117+ m_io.write( val.c_str(), val.size() );
3118+
3119+ if (m_io.fail()) { // check both before and after write if stream is ok
3120+ EM_error3( "[chuck](via FileIO): cannot write: I/O stream failed" );
3121+ }
3122+}
3123+
3124+
3125+
3126+
3127+//-----------------------------------------------------------------------------
3128+// name: write( t_CKINT val )
3129+// desc: ...
3130+//-----------------------------------------------------------------------------
3131+void Chuck_IO_File::write( t_CKINT val )
3132+{
3133+ // sanity
3134+ if (!(m_io.is_open())) {
3135+ EM_error3( "[chuck](via FileIO): cannot write: no file open" );
3136+ return;
3137+ }
3138+
3139+ if (m_io.fail()) {
3140+ EM_error3( "[chuck](via FileIO): cannot write: I/O stream failed" );
3141+ return;
3142+ }
3143+
3144+ if ( m_dir )
3145+ {
3146+ EM_error3( "[chuck](via FileIO): cannot write on directory" );
3147+ return;
3148+ }
3149+
3150+ if (m_flags & TYPE_ASCII) {
3151+ m_io << val;
3152+ } else if (m_flags & TYPE_BINARY) {
3153+ m_io.write( (char *)&val, sizeof(t_CKINT) );
3154+ } else {
3155+ EM_error3( "[chuck](via FileIO): write error: invalid ASCII/binary flag" );
3156+ }
3157+
3158+ if (m_io.fail()) { // check both before and after write if stream is ok
3159+ EM_error3( "[chuck](via FileIO): cannot write: I/O stream failed" );
3160+ }
3161+}
3162+
3163+
3164+
3165+
3166+//-----------------------------------------------------------------------------
3167+// name: write( t_CKINT val )
3168+// desc: ...
3169+//-----------------------------------------------------------------------------
3170+void Chuck_IO_File::write( t_CKINT val, t_CKINT flags )
3171+{
3172+ // sanity
3173+ if (!(m_io.is_open())) {
3174+ EM_error3( "[chuck](via FileIO): cannot write: no file open" );
3175+ return;
3176+ }
3177+
3178+ if (m_io.fail()) {
3179+ EM_error3( "[chuck](via FileIO): cannot write: I/O stream failed" );
3180+ return;
3181+ }
3182+
3183+ if ( m_dir )
3184+ {
3185+ EM_error3( "[chuck](via FileIO): cannot write on directory" );
3186+ return;
3187+ }
3188+
3189+ if (m_flags & TYPE_ASCII) {
3190+ m_io << val;
3191+ } else if (m_flags & TYPE_BINARY) {
3192+ int nBytes = 4;
3193+ if(flags & INT8) nBytes = 1;
3194+ else if(flags & INT16) nBytes = 2;
3195+ else if(flags & INT32) nBytes = 4;
3196+ m_io.write( (char *)&val, nBytes );
3197+ } else {
3198+ EM_error3( "[chuck](via FileIO): write error: invalid ASCII/binary flag" );
3199+ }
3200+
3201+ if (m_io.fail()) { // check both before and after write if stream is ok
3202+ EM_error3( "[chuck](via FileIO): cannot write: I/O stream failed" );
3203+ }
3204+}
3205+
3206+
3207+
3208+
3209+//-----------------------------------------------------------------------------
3210+// name: write( t_CKFLOAT val )
3211+// desc: ...
3212+//-----------------------------------------------------------------------------
3213+void Chuck_IO_File::write( t_CKFLOAT val )
3214+{
3215+ // sanity
3216+ if (!(m_io.is_open())) {
3217+ EM_error3( "[chuck](via FileIO): cannot write: no file open" );
3218+ return;
3219+ }
3220+
3221+ if (m_io.fail()) {
3222+ EM_error3( "[chuck](via FileIO): cannot write: I/O stream failed" );
3223+ return;
3224+ }
3225+
3226+ if ( m_dir )
3227+ {
3228+ EM_error3( "[chuck](via FileIO): cannot write to a directory" );
3229+ return;
3230+ }
3231+
3232+ if (m_flags & TYPE_ASCII) {
3233+ m_io << val;
3234+ } else if (m_flags & TYPE_BINARY) {
3235+ m_io.write( (char *)&val, sizeof(t_CKFLOAT) );
3236+ } else {
3237+ EM_error3( "[chuck](via FileIO): write error: invalid ASCII/binary flag" );
3238+ }
3239+
3240+ if (m_io.fail()) { // check both before and after write if stream is ok
3241+ EM_error3( "[chuck](via FileIO): cannot write: I/O stream failed" );
3242+ }
3243+}
3244+
3245+
3246+
3247+
3248+// static helper functions for writing asynchronously
3249+THREAD_RETURN ( THREAD_TYPE Chuck_IO_File::writeStr_thread ) ( void *data )
3250+{
3251+ async_args *args = (async_args *)data;
3252+ args->fileio_obj->write ( args->stringArg );
3253+ Chuck_Event *e = args->fileio_obj->m_asyncEvent;
3254+ delete args;
3255+ e->broadcast(); // wake up
3256+ e->broadcast_global();
3257+
3258+ return (THREAD_RETURN)0;
3259+}
3260+
3261+THREAD_RETURN ( THREAD_TYPE Chuck_IO_File::writeInt_thread ) ( void *data )
3262+{
3263+ async_args *args = (async_args *)data;
3264+ args->fileio_obj->write ( args->intArg );
3265+ args->fileio_obj->m_asyncEvent->broadcast(); // wake up
3266+ args->fileio_obj->m_asyncEvent->broadcast_global();
3267+ delete args;
3268+
3269+ return (THREAD_RETURN)0;
3270+}
3271+
3272+THREAD_RETURN ( THREAD_TYPE Chuck_IO_File::writeFloat_thread ) ( void *data )
3273+{
3274+ async_args *args = (async_args *)data;
3275+ args->fileio_obj->write ( args->floatArg );
3276+ args->fileio_obj->m_asyncEvent->broadcast(); // wake up
3277+ args->fileio_obj->m_asyncEvent->broadcast_global();
3278+ delete args;
3279+
3280+ return (THREAD_RETURN)0;
3281+}
3282+#endif // __DISABLE_FILEIO__
3283+
3284+
3285+
32393286
32403287 Chuck_IO_Chout::Chuck_IO_Chout( Chuck_Carrier * carrier ) {
32413288 // store
src/core/chuck_oo.h+90−81
@@ -42,7 +42,9 @@ · 41 unmodified lines
4242 #include <queue>
4343 #include <fstream>
4444 #include <sstream> // REFACTOR-2017: for custom output
45−//#include "util_thread.h" // added 1.3.0.0
45+#ifndef __DISABLE_THREADS__
46+#include "util_thread.h" // added 1.3.0.0
47+#endif
4648
4749
4850
@@ -460,7 +462,9 @@ public: · 411 unmodified lines
460462
461463 protected:
462464 std::queue<Chuck_VM_Shred *> m_queue;
463−// XMutex m_queue_lock;
465+ #ifndef __DISABLE_THREADS__
466+ XMutex m_queue_lock;
467+ #endif
464468 std::queue<Chuck_Global_Event_Listener> m_global_queue;
465469 };
466470
@@ -537,7 +541,9 @@ public: · 70 unmodified lines
537541 static const t_CKINT MODE_SYNC;
538542 static const t_CKINT MODE_ASYNC;
539543 Chuck_Event * m_asyncEvent;
540−// XThread * m_thread;
544+ #ifndef __DISABLE_THREADS__
545+ XThread * m_thread;
546+ #endif
541547 struct async_args
542548 {
543549 Chuck_IO_File * fileio_obj;
@@ -549,88 +555,91 @@ public: · 5 unmodified lines
549555 };
550556
551557
558+
559+#ifndef __DISABLE_FILEIO__
552560 //-----------------------------------------------------------------------------
553561 // name: Chuck_IO_File
554562 // desc: Chuck File IO class
555563 //-----------------------------------------------------------------------------
556−//struct Chuck_IO_File : Chuck_IO
557−//{
558−//public:
559−// // REFACTOR-2017
560−// Chuck_IO_File( Chuck_VM * vm );
561−// virtual ~Chuck_IO_File();
562−//
563−//public:
564−// // meta
565−// virtual t_CKBOOL open( const std::string & path, t_CKINT flags );
566−// virtual t_CKBOOL good();
567−// virtual void close();
568−// virtual void flush();
569−// virtual t_CKINT mode();
570−// virtual void mode( t_CKINT flag );
571−// virtual t_CKINT size();
572−//
573−// // seeking
574−// virtual void seek( t_CKINT pos );
575−// virtual t_CKINT tell();
576−//
577−// // directories
578−// virtual t_CKINT isDir();
579−// virtual Chuck_Array4 * dirList();
580−//
581−// // reading
582−// // virtual Chuck_String * read( t_CKINT length );
583−// virtual Chuck_String * readLine();
584−// virtual t_CKINT readInt( t_CKINT flags );
585−// virtual t_CKFLOAT readFloat();
586−// virtual t_CKBOOL readString( std::string & str );
587−// virtual t_CKBOOL eof();
588−//
589−// // reading -- async
590−// /* TODO: doesn't look like asynchronous reads will work
591−// static THREAD_RETURN ( THREAD_TYPE read_thread ) ( void *data );
592−// static THREAD_RETURN ( THREAD_TYPE readLine_thread ) ( void *data );
593−// static THREAD_RETURN ( THREAD_TYPE readInt_thread ) ( void *data );
594−// static THREAD_RETURN ( THREAD_TYPE readFloat_thread ) ( void *data );
595−// */
596−//
597−// // writing
598−// virtual void write( const std::string & val );
599−// virtual void write( t_CKINT val );
600−// virtual void write( t_CKINT val, t_CKINT flags );
601−// virtual void write( t_CKFLOAT val );
602−//
603−// // writing -- async
604−// static THREAD_RETURN ( THREAD_TYPE writeStr_thread ) ( void *data );
605−// static THREAD_RETURN ( THREAD_TYPE writeInt_thread ) ( void *data );
606−// static THREAD_RETURN ( THREAD_TYPE writeFloat_thread ) ( void *data );
607−//
608−//public:
609−// // constants
610−// static const t_CKINT FLAG_READ_WRITE;
611−// static const t_CKINT FLAG_READONLY;
612−// static const t_CKINT FLAG_WRITEONLY;
613−// static const t_CKINT FLAG_APPEND;
614−// static const t_CKINT TYPE_ASCII;
615−// static const t_CKINT TYPE_BINARY;
616−//
617−//protected:
618−// // open flags
619−// t_CKINT m_flags;
620−// // I/O mode
621−// t_CKINT m_iomode;
622−// // file stream
623−// std::fstream m_io;
624−// // directory pointer
625−// DIR * m_dir;
626−// // directory location
627−// long m_dir_start;
628−// // path
629−// std::string m_path;
630−// // vm and shred
631−// Chuck_VM * m_vmRef;
632−//};
633−//
564+struct Chuck_IO_File : Chuck_IO
565+{
566+public:
567+ // REFACTOR-2017
568+ Chuck_IO_File( Chuck_VM * vm );
569+ virtual ~Chuck_IO_File();
570+
571+public:
572+ // meta
573+ virtual t_CKBOOL open( const std::string & path, t_CKINT flags );
574+ virtual t_CKBOOL good();
575+ virtual void close();
576+ virtual void flush();
577+ virtual t_CKINT mode();
578+ virtual void mode( t_CKINT flag );
579+ virtual t_CKINT size();
580+
581+ // seeking
582+ virtual void seek( t_CKINT pos );
583+ virtual t_CKINT tell();
584+
585+ // directories
586+ virtual t_CKINT isDir();
587+ virtual Chuck_Array4 * dirList();
588+
589+ // reading
590+ // virtual Chuck_String * read( t_CKINT length );
591+ virtual Chuck_String * readLine();
592+ virtual t_CKINT readInt( t_CKINT flags );
593+ virtual t_CKFLOAT readFloat();
594+ virtual t_CKBOOL readString( std::string & str );
595+ virtual t_CKBOOL eof();
596+
597+ // reading -- async
598+ /* TODO: doesn't look like asynchronous reads will work
599+ static THREAD_RETURN ( THREAD_TYPE read_thread ) ( void *data );
600+ static THREAD_RETURN ( THREAD_TYPE readLine_thread ) ( void *data );
601+ static THREAD_RETURN ( THREAD_TYPE readInt_thread ) ( void *data );
602+ static THREAD_RETURN ( THREAD_TYPE readFloat_thread ) ( void *data );
603+ */
604+
605+ // writing
606+ virtual void write( const std::string & val );
607+ virtual void write( t_CKINT val );
608+ virtual void write( t_CKINT val, t_CKINT flags );
609+ virtual void write( t_CKFLOAT val );
610+
611+ // writing -- async
612+ static THREAD_RETURN ( THREAD_TYPE writeStr_thread ) ( void *data );
613+ static THREAD_RETURN ( THREAD_TYPE writeInt_thread ) ( void *data );
614+ static THREAD_RETURN ( THREAD_TYPE writeFloat_thread ) ( void *data );
615+
616+public:
617+ // constants
618+ static const t_CKINT FLAG_READ_WRITE;
619+ static const t_CKINT FLAG_READONLY;
620+ static const t_CKINT FLAG_WRITEONLY;
621+ static const t_CKINT FLAG_APPEND;
622+ static const t_CKINT TYPE_ASCII;
623+ static const t_CKINT TYPE_BINARY;
624+
625+protected:
626+ // open flags
627+ t_CKINT m_flags;
628+ // I/O mode
629+ t_CKINT m_iomode;
630+ // file stream
631+ std::fstream m_io;
632+ // directory pointer
633+ DIR * m_dir;
634+ // directory location
635+ long m_dir_start;
636+ // path
637+ std::string m_path;
638+ // vm and shred
639+ Chuck_VM * m_vmRef;
640+};
641+#endif // __DISABLE_FILEIO__
642+
634643
635644
636645
src/core/chuck_type.cpp+15−5
@@ -186,7 +186,9 @@ Chuck_Env::Chuck_Env( ) · 185 unmodified lines
186186 t_uanablob = new Chuck_Type( this, te_uanablob, "UAnaBlob", t_object, sizeof(void *) );
187187 t_shred = new Chuck_Type( this, te_shred, "Shred", t_object, sizeof(void *) );
188188 t_io = new Chuck_Type( this, te_io, "IO", t_event, sizeof(void *) );
189−// t_fileio = new Chuck_Type( this, te_fileio, "FileIO", t_io, sizeof(void *) );
189+ #ifndef __DISABLE_FILEIO__
190+ t_fileio = new Chuck_Type( this, te_fileio, "FileIO", t_io, sizeof(void *) );
191+ #endif
190192 t_chout = new Chuck_Type( this, te_chout, "StdOut", t_io, sizeof(void *) );
191193 t_cherr = new Chuck_Type( this, te_cherr, "StdErr", t_io, sizeof(void *) );
192194 t_thread = new Chuck_Type( this, te_thread, "Thread", t_object, sizeof(void *) );
@@ -217,7 +219,9 @@ Chuck_Env::~Chuck_Env() · 24 unmodified lines
217219 SAFE_RELEASE( t_class->info );
218220 SAFE_RELEASE( t_thread->info );
219221 SAFE_RELEASE( t_io->info );
220−// SAFE_RELEASE( t_fileio->info );
222+ #ifndef __DISABLE_FILEIO__
223+ SAFE_RELEASE( t_fileio->info );
224+ #endif
221225 SAFE_RELEASE( t_chout->info ); // added 1.3.0.0
222226 SAFE_RELEASE( t_cherr->info ); // added 1.3.0.0
223227 SAFE_RELEASE( t_vec3->info ); // added 1.3.5.3
@@ -236,7 +240,9 @@ Chuck_Env::~Chuck_Env() · 12 unmodified lines
236240 SAFE_DELETE( t_class );
237241 SAFE_DELETE( t_thread );
238242 SAFE_DELETE( t_io );
239−// SAFE_DELETE( t_fileio );
243+ #ifndef __DISABLE_FILEIO__
244+ SAFE_DELETE( t_fileio );
245+ #endif
240246 SAFE_DELETE( t_chout ); // added 1.3.0.0
241247 SAFE_DELETE( t_cherr ); // added 1.3.0.0
242248 SAFE_DELETE( t_vec3 ); // added 1.3.5.3
@@ -293,7 +299,9 @@ Chuck_Env * type_engine_init( Chuck_Carrier * carrier ) · 50 unmodified lines
293299 env->global()->type.add( env->t_array->name, env->t_array ); env->t_array->lock();
294300 env->global()->type.add( env->t_event->name, env->t_event ); env->t_event->lock();
295301 env->global()->type.add( env->t_io->name, env->t_io ); env->t_io->lock();
296−// env->global()->type.add( env->t_fileio->name, env->t_fileio ); env->t_fileio->lock();
302+ #ifndef __DISABLE_FILEIO__
303+ env->global()->type.add( env->t_fileio->name, env->t_fileio ); env->t_fileio->lock();
304+ #endif
297305 env->global()->type.add( env->t_chout->name, env->t_chout ); env->t_chout->lock();
298306 env->global()->type.add( env->t_cherr->name, env->t_cherr ); env->t_cherr->lock();
299307
@@ -320,7 +328,9 @@ Chuck_Env * type_engine_init( Chuck_Carrier * carrier ) · 20 unmodified lines
320328 init_class_shred( env, env->t_shred );
321329 init_class_event( env, env->t_event );
322330 init_class_io( env, env->t_io );
323−// init_class_fileio( env, env->t_fileio );
331+ #ifndef __DISABLE_FILEIO__
332+ init_class_fileio( env, env->t_fileio );
333+ #endif
324334 init_class_chout( env, env->t_chout ); // 1.3.0.0
325335 init_class_cherr( env, env->t_cherr ); // 1.3.0.0
326336 init_class_vec3( env, env->t_vec3 ); // 1.3.5.3
src/core/chuck_type.h+3−1
@@ -533,7 +533,9 @@ public: · 532 unmodified lines
533533 Chuck_Type * t_uanablob;
534534 Chuck_Type * t_shred;
535535 Chuck_Type * t_io;
536−// Chuck_Type * t_fileio;
536+ #ifndef __DISABLE_FILEIO__
537+ Chuck_Type * t_fileio;
538+ #endif
537539 Chuck_Type * t_chout;
538540 Chuck_Type * t_cherr;
539541 Chuck_Type * t_thread;
src/core/chuck_vm.cpp+59−42
@@ -34,10 +34,18 @@ · 33 unmodified lines
3434 #include "chuck_lang.h"
3535 #include "chuck_type.h"
3636 #include "chuck_dl.h"
37−//#include "chuck_io.h"
37+
38+#ifndef __DISABLE_SERIAL__
39+#include "chuck_io.h"
40+#endif
41+
3842 #include "chuck_errmsg.h"
3943 #include "ugen_xxx.h"
40−//#include "hidio_sdl.h" // 1.4.0.0
44+
45+#ifndef __DISABLE_HID__
46+#include "hidio_sdl.h" // 1.4.0.0
47+#endif
48+
4149 #ifndef __DISABLE_MIDI__
4250 #include "midiio_rtmidi.h" // 1.4.0.1
4351 #endif
@@ -341,14 +349,17 @@ t_CKBOOL Chuck_VM::shutdown() · 297 unmodified lines
341349 // free the shreduler
342350 SAFE_DELETE( m_shreduler );
343351
352+ #ifndef __DISABLE_HID__
344353 // log
345354 EM_log( CK_LOG_SYSTEM, "unregistering VM from HID manager..." );
346355 // clean up this vm
347−// HidInManager::cleanup_buffer( this );
356+ HidInManager::cleanup_buffer( this );
357+ #endif
358+
359+ #ifndef __DISABLE_MIDI__
348360 EM_log( CK_LOG_SYSTEM, "unregistering VM from MIDI manager..." );
349−#ifndef __DISABLE_MIDI__
350361 MidiInManager::cleanup_buffer( this );
351−#endif
362+ #endif
352363
353364 // log
354365 EM_log( CK_LOG_SYSTEM, "freeing msg/reply/event buffers..." );
@@ -3559,7 +3570,9 @@ Chuck_VM_Shred::Chuck_VM_Shred() · 3204 unmodified lines
35593570 vm_ref = NULL;
35603571 event = NULL;
35613572 xid = 0;
3562−// m_serials = NULL;
3573+ #ifndef __DISABLE_SERIAL__
3574+ m_serials = NULL;
3575+ #endif
35633576
35643577 // set
35653578 CK_TRACK( stat = NULL );
@@ -3692,18 +3705,20 @@ t_CKBOOL Chuck_VM_Shred::shutdown() · 126 unmodified lines
36923705 // clear it
36933706 code_orig = code = NULL;
36943707
3708+ #ifndef __DISABLE_SERIAL__
36953709 // HACK (added 1.3.2.0): close serial devices
3696−// if(m_serials != NULL)
3697−// {
3698−// for(list<Chuck_IO_Serial *>::iterator i = m_serials->begin(); i != m_serials->end(); i++)
3699−// {
3700−// (*i)->release();
3701−// (*i)->close();
3702−// }
3703−//
3704−// m_serials->clear();
3705−// SAFE_DELETE(m_serials);
3706−// }
3710+ if(m_serials != NULL)
3711+ {
3712+ for(list<Chuck_IO_Serial *>::iterator i = m_serials->begin(); i != m_serials->end(); i++)
3713+ {
3714+ (*i)->release();
3715+ (*i)->close();
3716+ }
3717+
3718+ m_serials->clear();
3719+ SAFE_DELETE(m_serials);
3720+ }
3721+ #endif
37073722
37083723 // 1.3.5.3 pop all loop counters
37093724 while( this->popLoopCounter() );
@@ -3835,31 +3850,33 @@ CK_VM_DEBUG(CK_FPRINTF_STDERR( "CK_VM_DEBUG reg sp in: 0x%08lx out: 0x%08lx\n", · 125 unmodified lines
38353850
38363851
38373852
3838−////-----------------------------------------------------------------------------
3839−//// name: add_serialio()
3840−//// desc: ...
3841−////-----------------------------------------------------------------------------
3842−//t_CKVOID Chuck_VM_Shred::add_serialio( Chuck_IO_Serial * serial )
3843−//{
3844−// if(m_serials == NULL)
3845−// m_serials = new list<Chuck_IO_Serial *>;
3846−// serial->add_ref();
3847−// m_serials->push_back( serial );
3848−//}
3849−//
3850−//
3851−//
3852−////-----------------------------------------------------------------------------
3853−//// name: add_serialio()
3854−//// desc: ...
3855−////-----------------------------------------------------------------------------
3856−//t_CKVOID Chuck_VM_Shred::remove_serialio( Chuck_IO_Serial * serial )
3857−//{
3858−// if(m_serials == NULL)
3859−// return;
3860−// m_serials->remove( serial );
3861−// serial->release();
3862−//}
3853+#ifndef __DISABLE_SERIAL__
3854+//-----------------------------------------------------------------------------
3855+// name: add_serialio()
3856+// desc: ...
3857+//-----------------------------------------------------------------------------
3858+t_CKVOID Chuck_VM_Shred::add_serialio( Chuck_IO_Serial * serial )
3859+{
3860+ if(m_serials == NULL)
3861+ m_serials = new list<Chuck_IO_Serial *>;
3862+ serial->add_ref();
3863+ m_serials->push_back( serial );
3864+}
3865+
3866+
3867+
3868+//-----------------------------------------------------------------------------
3869+// name: add_serialio()
3870+// desc: ...
3871+//-----------------------------------------------------------------------------
3872+t_CKVOID Chuck_VM_Shred::remove_serialio( Chuck_IO_Serial * serial )
3873+{
3874+ if(m_serials == NULL)
3875+ return;
3876+ m_serials->remove( serial );
3877+ serial->release();
3878+}
3879+#endif
38633880
38643881
38653882
src/core/chuck_vm.h+10−4
@@ -72,8 +72,10 @@ struct Chuck_VM; · 71 unmodified lines
7272 struct Chuck_VM_Func;
7373 struct Chuck_VM_FTable;
7474 struct Chuck_Msg;
75+#ifndef __DISABLE_SERIAL__
7576 // hack: spencer?
76−//struct Chuck_IO_Serial;
77+struct Chuck_IO_Serial;
78+#endif
7779
7880 class CBufferSimple;
7981 //XXXclass BBQ;
@@ -179,11 +181,13 @@ public: · 99 unmodified lines
179181 // add parent object reference (added 1.3.1.2)
180182 t_CKVOID add_parent_ref( Chuck_Object * obj );
181183
184+ #ifndef __DISABLE_SERIAL__
182185 // HACK - spencer (added 1.3.2.0)
183186 // add/remove SerialIO devices to close on shred exit
184187 // REFACTOR-2017: TODO -- remove
185−// t_CKVOID add_serialio( Chuck_IO_Serial * serial );
186−// t_CKVOID remove_serialio( Chuck_IO_Serial * serial );
188+ t_CKVOID add_serialio( Chuck_IO_Serial * serial );
189+ t_CKVOID remove_serialio( Chuck_IO_Serial * serial );
190+ #endif
187191
188192 //-----------------------------------------------------------------------------
189193 // data
@@ -250,8 +254,10 @@ public: // ge: 1.3.5.3 · 60 unmodified lines
250254 // loop counter pointer stack
251255 std::vector<t_CKUINT *> m_loopCounters;
252256
257+#ifndef __DISABLE_SERIAL__
253258 private:
254−// std::list<Chuck_IO_Serial *> * m_serials;
259+ std::list<Chuck_IO_Serial *> * m_serials;
260+#endif
255261 };
256262
257263
src/core/chuck_win32.c+510−508
@@ -1,8 +1,8 @@
1−/* A Bison parser, made by GNU Bison 3.0.4. */
1+/* A Bison parser, made by GNU Bison 3.1. */
22
33 /* Bison implementation for Yacc-like parsers in C
44
5− Copyright (C) 1984, 1989-1990, 2000-2015 Free Software Foundation, Inc.
5+ Copyright (C) 1984, 1989-1990, 2000-2015, 2018 Free Software Foundation, Inc.
66
77 This program is free software: you can redistribute it and/or modify
88 it under the terms of the GNU General Public License as published by
@@ -44,7 +44,7 @@ · 35 unmodified lines
4444 #define YYBISON 1
4545
4646 /* Bison version. */
47−#define YYBISON_VERSION "3.0.4"
47+#define YYBISON_VERSION "3.1"
4848
4949 /* Skeleton name. */
5050 #define YYSKELETON_NAME "yacc.c"
@@ -119,7 +119,7 @@ void yyerror( char *s ) · 68 unmodified lines
119119 a_Program g_program = NULL;
120120
121121
122−#line 122 "chuck.tab.c" /* yacc.c:339 */
122+#line 123 "chuck.tab.c" /* yacc.c:339 */
123123
124124 # ifndef YY_NULLPTR
125125 # if defined __cplusplus && 201103L <= __cplusplus
@@ -271,7 +271,7 @@ extern int yydebug; · 145 unmodified lines
271271
272272 union YYSTYPE
273273 {
274−#line 59 "chuck.y" /* yacc.c:355 */
274+#line 60 "chuck.y" /* yacc.c:355 */
275275
276276 int pos;
277277 int ival;
@@ -297,7 +297,7 @@ union YYSTYPE · 19 unmodified lines
297297 a_Polar polar_exp;
298298 a_Vec vec_exp; // ge: added 1.3.5.3
299299
300−#line 300 "chuck.tab.c" /* yacc.c:355 */
300+#line 301 "chuck.tab.c" /* yacc.c:355 */
301301 };
302302
303303 typedef union YYSTYPE YYSTYPE;
@@ -314,7 +314,7 @@ int yyparse (void); · 10 unmodified lines
314314
315315 /* Copy the second part of user declarations. */
316316
317−#line 317 "chuck.tab.c" /* yacc.c:358 */
317+#line 318 "chuck.tab.c" /* yacc.c:358 */
318318
319319 #ifdef short
320320 # undef short
@@ -335,13 +335,13 @@ typedef signed char yytype_int8; · 14 unmodified lines
335335 #ifdef YYTYPE_UINT16
336336 typedef YYTYPE_UINT16 yytype_uint16;
337337 #else
338−typedef unsigned short int yytype_uint16;
338+typedef unsigned short yytype_uint16;
339339 #endif
340340
341341 #ifdef YYTYPE_INT16
342342 typedef YYTYPE_INT16 yytype_int16;
343343 #else
344−typedef short int yytype_int16;
344+typedef short yytype_int16;
345345 #endif
346346
347347 #ifndef YYSIZE_T
@@ -353,7 +353,7 @@ typedef short int yytype_int16; · 5 unmodified lines
353353 # include <stddef.h> /* INFRINGES ON USER NAME SPACE */
354354 # define YYSIZE_T size_t
355355 # else
356−# define YYSIZE_T unsigned int
356+# define YYSIZE_T unsigned
357357 # endif
358358 #endif
359359
@@ -405,7 +405,7 @@ typedef short int yytype_int16; · 45 unmodified lines
405405 # define YYUSE(E) /* empty */
406406 #endif
407407
408−#if defined __GNUC__ && 407 <= __GNUC__ * 100 + __GNUC_MINOR__
408+#if defined __GNUC__ && ! defined __ICC && 407 <= __GNUC__ * 100 + __GNUC_MINOR__
409409 /* Suppress an incorrect diagnostic about yylval being uninitialized. */
410410 # define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \
411411 _Pragma ("GCC diagnostic push") \
@@ -573,7 +573,7 @@ union yyalloc · 161 unmodified lines
573573 #define YYMAXUTOK 366
574574
575575 #define YYTRANSLATE(YYX) \
576− ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
576+ ((unsigned) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
577577
578578 /* YYTRANSLATE[TOKEN-NUM] -- Symbol number corresponding to TOKEN-NUM
579579 as returned by yylex, without out-of-bounds checking. */
@@ -622,25 +622,25 @@ static const yytype_uint8 yytranslate[] = · 42 unmodified lines
622622 /* YYRLINE[YYN] -- Source line where rule number YYN was defined. */
623623 static const yytype_uint16 yyrline[] =
624624 {
625− 0, 183, 183, 184, 188, 189, 190, 194, 196, 198,
626− 200, 205, 206, 207, 208, 212, 213, 217, 218, 223,
627− 224, 225, 229, 233, 234, 238, 239, 243, 245, 247,
628− 249, 254, 255, 256, 260, 261, 262, 263, 267, 268,
629− 269, 273, 274, 278, 279, 288, 289, 294, 295, 299,
630− 300, 304, 305, 309, 310, 311, 312, 314, 318, 319,
631− 320, 321, 325, 327, 332, 334, 336, 338, 340, 342,
632− 344, 349, 350, 354, 355, 359, 360, 364, 365, 370,
633− 371, 376, 377, 382, 383, 387, 388, 389, 390, 391,
634− 392, 393, 397, 398, 402, 403, 404, 408, 413, 418,
635− 423, 424, 425, 426, 427, 428, 429, 430, 431, 432,
636− 433, 434, 435, 436, 440, 441, 445, 446, 451, 452,
637− 457, 458, 463, 464, 469, 470, 475, 476, 481, 482,
638− 484, 489, 490, 492, 494, 496, 501, 502, 504, 509,
639− 510, 512, 517, 518, 520, 522, 527, 528, 533, 534,
640− 539, 540, 542, 544, 546, 548, 550, 552, 559, 560,
641− 561, 562, 563, 564, 569, 570, 575, 576, 578, 580,
642− 582, 584, 586, 592, 593, 594, 595, 596, 597, 598,
643− 599, 600, 601, 602, 603
625+ 0, 184, 184, 185, 189, 190, 191, 195, 197, 199,
626+ 201, 206, 207, 208, 209, 213, 214, 218, 219, 224,
627+ 225, 226, 230, 234, 235, 239, 240, 244, 246, 248,
628+ 250, 255, 256, 257, 261, 262, 263, 264, 268, 269,
629+ 270, 274, 275, 279, 280, 289, 290, 295, 296, 300,
630+ 301, 305, 306, 310, 311, 312, 313, 315, 319, 320,
631+ 321, 322, 326, 328, 333, 335, 337, 339, 341, 343,
632+ 345, 350, 351, 355, 356, 360, 361, 365, 366, 371,
633+ 372, 377, 378, 383, 384, 388, 389, 390, 391, 392,
634+ 393, 394, 398, 399, 403, 404, 405, 409, 414, 419,
635+ 424, 425, 426, 427, 428, 429, 430, 431, 432, 433,
636+ 434, 435, 436, 437, 441, 442, 446, 447, 452, 453,
637+ 458, 459, 464, 465, 470, 471, 476, 477, 482, 483,
638+ 485, 490, 491, 493, 495, 497, 502, 503, 505, 510,
639+ 511, 513, 518, 519, 521, 523, 528, 529, 534, 535,
640+ 540, 541, 543, 545, 547, 549, 551, 553, 560, 561,
641+ 562, 563, 564, 565, 570, 571, 576, 577, 579, 581,
642+ 583, 585, 587, 593, 594, 595, 596, 597, 598, 599,
643+ 600, 601, 602, 603, 604
644644 };
645645 #endif
646646
@@ -1281,7 +1281,7 @@ do { \ · 634 unmodified lines
12811281 static void
12821282 yy_reduce_print (yytype_int16 *yyssp, YYSTYPE *yyvsp, int yyrule)
12831283 {
1284− unsigned long int yylno = yyrline[yyrule];
1284+ unsigned long yylno = yyrline[yyrule];
12851285 int yynrhs = yyr2[yyrule];
12861286 int yyi;
12871287 YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n",
@@ -1507,6 +1507,7 @@ yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg, · 219 unmodified lines
15071507 case N: \
15081508 yyformat = S; \
15091509 break
1510+ default: /* Avoid compiler warnings. */
15101511 YYCASE_(0, YY_("syntax error"));
15111512 YYCASE_(1, YY_("syntax error, unexpected %s"));
15121513 YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s"));
@@ -1712,7 +1713,7 @@ yyparse (void) · 199 unmodified lines
17121713 yyvsp = yyvs + yysize - 1;
17131714
17141715 YYDPRINTF ((stderr, "Stack size increased to %lu\n",
1715− (unsigned long int) yystacksize));
1716+ (unsigned long) yystacksize));
17161717
17171718 if (yyss + yystacksize - 1 <= yyssp)
17181719 YYABORT;
@@ -1823,1099 +1824,1099 @@ yyreduce: · 104 unmodified lines
18231824 switch (yyn)
18241825 {
18251826 case 2:
1826−#line 183 "chuck.y" /* yacc.c:1646 */
1827+#line 184 "chuck.y" /* yacc.c:1651 */
18271828 { (yyval.program) = g_program = new_program( (yyvsp[0].program_section), EM_lineNum ); }
1828−#line 1828 "chuck.tab.c" /* yacc.c:1646 */
1829+#line 1830 "chuck.tab.c" /* yacc.c:1651 */
18291830 break;
18301831
18311832 case 3:
1832−#line 184 "chuck.y" /* yacc.c:1646 */
1833+#line 185 "chuck.y" /* yacc.c:1651 */
18331834 { (yyval.program) = g_program = prepend_program( (yyvsp[-1].program_section), (yyvsp[0].program), EM_lineNum ); }
1834−#line 1834 "chuck.tab.c" /* yacc.c:1646 */
1835+#line 1836 "chuck.tab.c" /* yacc.c:1651 */
18351836 break;
18361837
18371838 case 4:
1838−#line 188 "chuck.y" /* yacc.c:1646 */
1839+#line 189 "chuck.y" /* yacc.c:1651 */
18391840 { (yyval.program_section) = new_section_stmt( (yyvsp[0].stmt_list), EM_lineNum ); }
1840−#line 1840 "chuck.tab.c" /* yacc.c:1646 */
1841+#line 1842 "chuck.tab.c" /* yacc.c:1651 */
18411842 break;
18421843
18431844 case 5:
1844−#line 189 "chuck.y" /* yacc.c:1646 */
1845+#line 190 "chuck.y" /* yacc.c:1651 */
18451846 { (yyval.program_section) = new_section_func_def( (yyvsp[0].func_def), EM_lineNum ); }
1846−#line 1846 "chuck.tab.c" /* yacc.c:1646 */
1847+#line 1848 "chuck.tab.c" /* yacc.c:1651 */
18471848 break;
18481849
18491850 case 6:
1850−#line 190 "chuck.y" /* yacc.c:1646 */
1851+#line 191 "chuck.y" /* yacc.c:1651 */
18511852 { (yyval.program_section) = new_section_class_def( (yyvsp[0].class_def), EM_lineNum ); }
1852−#line 1852 "chuck.tab.c" /* yacc.c:1646 */
1853+#line 1854 "chuck.tab.c" /* yacc.c:1651 */
18531854 break;
18541855
18551856 case 7:
1856−#line 195 "chuck.y" /* yacc.c:1646 */
1857+#line 196 "chuck.y" /* yacc.c:1651 */
18571858 { (yyval.class_def) = new_class_def( (yyvsp[-5].ival), (yyvsp[-3].id_list), NULL, (yyvsp[-1].class_body), EM_lineNum ); }
1858−#line 1858 "chuck.tab.c" /* yacc.c:1646 */
1859+#line 1860 "chuck.tab.c" /* yacc.c:1651 */
18591860 break;
18601861
18611862 case 8:
1862−#line 197 "chuck.y" /* yacc.c:1646 */
1863+#line 198 "chuck.y" /* yacc.c:1651 */
18631864 { (yyval.class_def) = new_class_def( (yyvsp[-6].ival), (yyvsp[-4].id_list), (yyvsp[-3].class_ext), (yyvsp[-1].class_body), EM_lineNum ); }
1864−#line 1864 "chuck.tab.c" /* yacc.c:1646 */
1865+#line 1866 "chuck.tab.c" /* yacc.c:1651 */
18651866 break;
18661867
18671868 case 9:
1868−#line 199 "chuck.y" /* yacc.c:1646 */
1869+#line 200 "chuck.y" /* yacc.c:1651 */
18691870 { (yyval.class_def) = new_iface_def( (yyvsp[-5].ival), (yyvsp[-3].id_list), NULL, (yyvsp[-1].class_body), EM_lineNum ); }
1870−#line 1870 "chuck.tab.c" /* yacc.c:1646 */
1871+#line 1872 "chuck.tab.c" /* yacc.c:1651 */
18711872 break;
18721873
18731874 case 10:
1874−#line 201 "chuck.y" /* yacc.c:1646 */
1875+#line 202 "chuck.y" /* yacc.c:1651 */
18751876 { (yyval.class_def) = new_iface_def( (yyvsp[-6].ival), (yyvsp[-4].id_list), (yyvsp[-3].class_ext), (yyvsp[-1].class_body), EM_lineNum ); }
1876−#line 1876 "chuck.tab.c" /* yacc.c:1646 */
1877+#line 1878 "chuck.tab.c" /* yacc.c:1651 */
18771878 break;
18781879
18791880 case 11:
1880−#line 205 "chuck.y" /* yacc.c:1646 */
1881+#line 206 "chuck.y" /* yacc.c:1651 */
18811882 { (yyval.class_ext) = new_class_ext( NULL, (yyvsp[0].id_list), EM_lineNum ); }
1882−#line 1882 "chuck.tab.c" /* yacc.c:1646 */
1883+#line 1884 "chuck.tab.c" /* yacc.c:1651 */
18831884 break;
18841885
18851886 case 12:
1886−#line 206 "chuck.y" /* yacc.c:1646 */
1887+#line 207 "chuck.y" /* yacc.c:1651 */
18871888 { (yyval.class_ext) = new_class_ext( (yyvsp[0].id_list), (yyvsp[-2].id_list), EM_lineNum ); }
1888−#line 1888 "chuck.tab.c" /* yacc.c:1646 */
1889+#line 1890 "chuck.tab.c" /* yacc.c:1651 */
18891890 break;
18901891
18911892 case 13:
1892−#line 207 "chuck.y" /* yacc.c:1646 */
1893+#line 208 "chuck.y" /* yacc.c:1651 */
18931894 { (yyval.class_ext) = new_class_ext( (yyvsp[0].id_list), NULL, EM_lineNum ); }
1894−#line 1894 "chuck.tab.c" /* yacc.c:1646 */
1895+#line 1896 "chuck.tab.c" /* yacc.c:1651 */
18951896 break;
18961897
18971898 case 14:
1898−#line 208 "chuck.y" /* yacc.c:1646 */
1899+#line 209 "chuck.y" /* yacc.c:1651 */
18991900 { (yyval.class_ext) = new_class_ext( (yyvsp[-2].id_list), (yyvsp[0].id_list), EM_lineNum ); }
1900−#line 1900 "chuck.tab.c" /* yacc.c:1646 */
1901+#line 1902 "chuck.tab.c" /* yacc.c:1651 */
19011902 break;
19021903
19031904 case 15:
1904−#line 212 "chuck.y" /* yacc.c:1646 */
1905+#line 213 "chuck.y" /* yacc.c:1651 */
19051906 { (yyval.class_body) = (yyvsp[0].class_body); }
1906−#line 1906 "chuck.tab.c" /* yacc.c:1646 */
1907+#line 1908 "chuck.tab.c" /* yacc.c:1651 */
19071908 break;
19081909
19091910 case 16:
1910−#line 213 "chuck.y" /* yacc.c:1646 */
1911+#line 214 "chuck.y" /* yacc.c:1651 */
19111912 { (yyval.class_body) = NULL; }
1912−#line 1912 "chuck.tab.c" /* yacc.c:1646 */
1913+#line 1914 "chuck.tab.c" /* yacc.c:1651 */
19131914 break;
19141915
19151916 case 17:
1916−#line 217 "chuck.y" /* yacc.c:1646 */
1917+#line 218 "chuck.y" /* yacc.c:1651 */
19171918 { (yyval.class_body) = new_class_body( (yyvsp[0].program_section), EM_lineNum ); }
1918−#line 1918 "chuck.tab.c" /* yacc.c:1646 */
1919+#line 1920 "chuck.tab.c" /* yacc.c:1651 */
19191920 break;
19201921
19211922 case 18:
1922−#line 218 "chuck.y" /* yacc.c:1646 */
1923+#line 219 "chuck.y" /* yacc.c:1651 */
19231924 { (yyval.class_body) = prepend_class_body( (yyvsp[-1].program_section), (yyvsp[0].class_body), EM_lineNum ); }
1924−#line 1924 "chuck.tab.c" /* yacc.c:1646 */
1925+#line 1926 "chuck.tab.c" /* yacc.c:1651 */
19251926 break;
19261927
19271928 case 19:
1928−#line 223 "chuck.y" /* yacc.c:1646 */
1929+#line 224 "chuck.y" /* yacc.c:1651 */
19291930 { (yyval.program_section) = new_section_stmt( (yyvsp[0].stmt_list), EM_lineNum ); }
1930−#line 1930 "chuck.tab.c" /* yacc.c:1646 */
1931+#line 1932 "chuck.tab.c" /* yacc.c:1651 */
19311932 break;
19321933
19331934 case 20:
1934−#line 224 "chuck.y" /* yacc.c:1646 */
1935+#line 225 "chuck.y" /* yacc.c:1651 */
19351936 { (yyval.program_section) = new_section_func_def( (yyvsp[0].func_def), EM_lineNum ); }
1936−#line 1936 "chuck.tab.c" /* yacc.c:1646 */
1937+#line 1938 "chuck.tab.c" /* yacc.c:1651 */
19371938 break;
19381939
19391940 case 21:
1940−#line 225 "chuck.y" /* yacc.c:1646 */
1941+#line 226 "chuck.y" /* yacc.c:1651 */
19411942 { (yyval.program_section) = new_section_class_def( (yyvsp[0].class_def), EM_lineNum ); }
1942−#line 1942 "chuck.tab.c" /* yacc.c:1646 */
1943+#line 1944 "chuck.tab.c" /* yacc.c:1651 */
19431944 break;
19441945
19451946 case 22:
1946−#line 229 "chuck.y" /* yacc.c:1646 */
1947+#line 230 "chuck.y" /* yacc.c:1651 */
19471948 { (yyval.class_ext) = new_class_ext( NULL, (yyvsp[0].id_list), EM_lineNum ); }
1948−#line 1948 "chuck.tab.c" /* yacc.c:1646 */
1949+#line 1950 "chuck.tab.c" /* yacc.c:1651 */
19491950 break;
19501951
19511952 case 23:
1952−#line 233 "chuck.y" /* yacc.c:1646 */
1953+#line 234 "chuck.y" /* yacc.c:1651 */
19531954 { (yyval.id_list) = new_id_list( (yyvsp[0].sval), EM_lineNum ); }
1954−#line 1954 "chuck.tab.c" /* yacc.c:1646 */
1955+#line 1956 "chuck.tab.c" /* yacc.c:1651 */
19551956 break;
19561957
19571958 case 24:
1958−#line 234 "chuck.y" /* yacc.c:1646 */
1959+#line 235 "chuck.y" /* yacc.c:1651 */
19591960 { (yyval.id_list) = prepend_id_list( (yyvsp[-2].sval), (yyvsp[0].id_list), EM_lineNum ); }
1960−#line 1960 "chuck.tab.c" /* yacc.c:1646 */
1961+#line 1962 "chuck.tab.c" /* yacc.c:1651 */
19611962 break;
19621963
19631964 case 25:
1964−#line 238 "chuck.y" /* yacc.c:1646 */
1965+#line 239 "chuck.y" /* yacc.c:1651 */
19651966 { (yyval.id_list) = new_id_list( (yyvsp[0].sval), EM_lineNum ); }
1966−#line 1966 "chuck.tab.c" /* yacc.c:1646 */
1967+#line 1968 "chuck.tab.c" /* yacc.c:1651 */
19671968 break;
19681969
19691970 case 26:
1970−#line 239 "chuck.y" /* yacc.c:1646 */
1971+#line 240 "chuck.y" /* yacc.c:1651 */
19711972 { (yyval.id_list) = prepend_id_list( (yyvsp[-2].sval), (yyvsp[0].id_list), EM_lineNum ); }
1972−#line 1972 "chuck.tab.c" /* yacc.c:1646 */
1973+#line 1974 "chuck.tab.c" /* yacc.c:1651 */
19731974 break;
19741975
19751976 case 27:
1976−#line 244 "chuck.y" /* yacc.c:1646 */
1977+#line 245 "chuck.y" /* yacc.c:1651 */
19771978 { (yyval.func_def) = new_func_def( (yyvsp[-7].ival), (yyvsp[-6].ival), (yyvsp[-5].type_decl), (yyvsp[-4].sval), (yyvsp[-2].arg_list), (yyvsp[0].stmt), EM_lineNum ); }
1978−#line 1978 "chuck.tab.c" /* yacc.c:1646 */
1979+#line 1980 "chuck.tab.c" /* yacc.c:1651 */
19791980 break;
19801981
19811982 case 28:
1982−#line 246 "chuck.y" /* yacc.c:1646 */
1983+#line 247 "chuck.y" /* yacc.c:1651 */
19831984 { (yyval.func_def) = new_func_def( (yyvsp[-6].ival), (yyvsp[-5].ival), (yyvsp[-4].type_decl), (yyvsp[-3].sval), NULL, (yyvsp[0].stmt), EM_lineNum ); }
1984−#line 1984 "chuck.tab.c" /* yacc.c:1646 */
1985+#line 1986 "chuck.tab.c" /* yacc.c:1651 */
19851986 break;
19861987
19871988 case 29:
1988−#line 248 "chuck.y" /* yacc.c:1646 */
1989+#line 249 "chuck.y" /* yacc.c:1651 */
19891990 { (yyval.func_def) = new_func_def( (yyvsp[-7].ival), (yyvsp[-6].ival), (yyvsp[-5].type_decl), (yyvsp[-4].sval), (yyvsp[-2].arg_list), NULL, EM_lineNum ); }
1990−#line 1990 "chuck.tab.c" /* yacc.c:1646 */
1991+#line 1992 "chuck.tab.c" /* yacc.c:1651 */
19911992 break;
19921993
19931994 case 30:
1994−#line 250 "chuck.y" /* yacc.c:1646 */
1995+#line 251 "chuck.y" /* yacc.c:1651 */
19951996 { (yyval.func_def) = new_func_def( (yyvsp[-6].ival), (yyvsp[-5].ival), (yyvsp[-4].type_decl), (yyvsp[-3].sval), NULL, NULL, EM_lineNum ); }
1996−#line 1996 "chuck.tab.c" /* yacc.c:1646 */
1997+#line 1998 "chuck.tab.c" /* yacc.c:1651 */
19971998 break;
19981999
19992000 case 31:
2000−#line 254 "chuck.y" /* yacc.c:1646 */
2001+#line 255 "chuck.y" /* yacc.c:1651 */
20012002 { (yyval.ival) = ae_key_public; }
2002−#line 2002 "chuck.tab.c" /* yacc.c:1646 */
2003+#line 2004 "chuck.tab.c" /* yacc.c:1651 */
20032004 break;
20042005
20052006 case 32:
2006−#line 255 "chuck.y" /* yacc.c:1646 */
2007+#line 256 "chuck.y" /* yacc.c:1651 */
20072008 { (yyval.ival) = ae_key_private; }
2008−#line 2008 "chuck.tab.c" /* yacc.c:1646 */
2009+#line 2010 "chuck.tab.c" /* yacc.c:1651 */
20092010 break;
20102011
20112012 case 33:
2012−#line 256 "chuck.y" /* yacc.c:1646 */
2013+#line 257 "chuck.y" /* yacc.c:1651 */
20132014 { (yyval.ival) = ae_key_private; }
2014−#line 2014 "chuck.tab.c" /* yacc.c:1646 */
2015+#line 2016 "chuck.tab.c" /* yacc.c:1651 */
20152016 break;
20162017
20172018 case 34:
2018−#line 260 "chuck.y" /* yacc.c:1646 */
2019+#line 261 "chuck.y" /* yacc.c:1651 */
20192020 { (yyval.ival) = ae_key_func; }
2020−#line 2020 "chuck.tab.c" /* yacc.c:1646 */
2021+#line 2022 "chuck.tab.c" /* yacc.c:1651 */
20212022 break;
20222023
20232024 case 35:
2024−#line 261 "chuck.y" /* yacc.c:1646 */
2025+#line 262 "chuck.y" /* yacc.c:1651 */
20252026 { (yyval.ival) = ae_key_public; }
2026−#line 2026 "chuck.tab.c" /* yacc.c:1646 */
2027+#line 2028 "chuck.tab.c" /* yacc.c:1651 */
20272028 break;
20282029
20292030 case 36:
2030−#line 262 "chuck.y" /* yacc.c:1646 */
2031+#line 263 "chuck.y" /* yacc.c:1651 */
20312032 { (yyval.ival) = ae_key_protected; }
2032−#line 2032 "chuck.tab.c" /* yacc.c:1646 */
2033+#line 2034 "chuck.tab.c" /* yacc.c:1651 */
20332034 break;
20342035
20352036 case 37:
2036−#line 263 "chuck.y" /* yacc.c:1646 */
2037+#line 264 "chuck.y" /* yacc.c:1651 */
20372038 { (yyval.ival) = ae_key_private; }
2038−#line 2038 "chuck.tab.c" /* yacc.c:1646 */
2039+#line 2040 "chuck.tab.c" /* yacc.c:1651 */
20392040 break;
20402041
20412042 case 38:
2042−#line 267 "chuck.y" /* yacc.c:1646 */
2043+#line 268 "chuck.y" /* yacc.c:1651 */
20432044 { (yyval.ival) = ae_key_static; }
2044−#line 2044 "chuck.tab.c" /* yacc.c:1646 */
2045+#line 2046 "chuck.tab.c" /* yacc.c:1651 */
20452046 break;
20462047
20472048 case 39:
2048−#line 268 "chuck.y" /* yacc.c:1646 */
2049+#line 269 "chuck.y" /* yacc.c:1651 */
20492050 { (yyval.ival) = ae_key_abstract; }
2050−#line 2050 "chuck.tab.c" /* yacc.c:1646 */
2051+#line 2052 "chuck.tab.c" /* yacc.c:1651 */
20512052 break;
20522053
20532054 case 40:
2054−#line 269 "chuck.y" /* yacc.c:1646 */
2055+#line 270 "chuck.y" /* yacc.c:1651 */
20552056 { (yyval.ival) = ae_key_instance; }
2056−#line 2056 "chuck.tab.c" /* yacc.c:1646 */
2057+#line 2058 "chuck.tab.c" /* yacc.c:1651 */
20572058 break;
20582059
20592060 case 41:
2060−#line 273 "chuck.y" /* yacc.c:1646 */
2061+#line 274 "chuck.y" /* yacc.c:1651 */
20612062 { (yyval.type_decl) = new_type_decl( new_id_list( (yyvsp[0].sval), EM_lineNum ), 0, EM_lineNum ); }
2062−#line 2062 "chuck.tab.c" /* yacc.c:1646 */
2063+#line 2064 "chuck.tab.c" /* yacc.c:1651 */
20632064 break;
20642065
20652066 case 42:
2066−#line 274 "chuck.y" /* yacc.c:1646 */
2067+#line 275 "chuck.y" /* yacc.c:1651 */
20672068 { (yyval.type_decl) = new_type_decl( new_id_list( (yyvsp[-1].sval), EM_lineNum ), 1, EM_lineNum ); }
2068−#line 2068 "chuck.tab.c" /* yacc.c:1646 */
2069+#line 2070 "chuck.tab.c" /* yacc.c:1651 */
20692070 break;
20702071
20712072 case 43:
2072−#line 278 "chuck.y" /* yacc.c:1646 */
2073+#line 279 "chuck.y" /* yacc.c:1651 */
20732074 { (yyval.type_decl) = new_type_decl( (yyvsp[-1].id_list), 0, EM_lineNum ); }
2074−#line 2074 "chuck.tab.c" /* yacc.c:1646 */
2075+#line 2076 "chuck.tab.c" /* yacc.c:1651 */
20752076 break;
20762077
20772078 case 44:
2078−#line 279 "chuck.y" /* yacc.c:1646 */
2079+#line 280 "chuck.y" /* yacc.c:1651 */
20792080 { (yyval.type_decl) = new_type_decl( (yyvsp[-2].id_list), 1, EM_lineNum ); }
2080−#line 2080 "chuck.tab.c" /* yacc.c:1646 */
2081+#line 2082 "chuck.tab.c" /* yacc.c:1651 */
20812082 break;
20822083
20832084 case 45:
2084−#line 288 "chuck.y" /* yacc.c:1646 */
2085+#line 289 "chuck.y" /* yacc.c:1651 */
20852086 { (yyval.type_decl) = (yyvsp[0].type_decl); }
2086−#line 2086 "chuck.tab.c" /* yacc.c:1646 */
2087+#line 2088 "chuck.tab.c" /* yacc.c:1651 */
20872088 break;
20882089
20892090 case 46:
2090−#line 289 "chuck.y" /* yacc.c:1646 */
2091+#line 290 "chuck.y" /* yacc.c:1651 */
20912092 { (yyval.type_decl) = (yyvsp[0].type_decl); }
2092−#line 2092 "chuck.tab.c" /* yacc.c:1646 */
2093+#line 2094 "chuck.tab.c" /* yacc.c:1651 */
20932094 break;
20942095
20952096 case 47:
2096−#line 294 "chuck.y" /* yacc.c:1646 */
2097+#line 295 "chuck.y" /* yacc.c:1651 */
20972098 { (yyval.type_decl) = (yyvsp[0].type_decl); }
2098−#line 2098 "chuck.tab.c" /* yacc.c:1646 */
2099+#line 2100 "chuck.tab.c" /* yacc.c:1651 */
20992100 break;
21002101
21012102 case 48:
2102−#line 295 "chuck.y" /* yacc.c:1646 */
2103+#line 296 "chuck.y" /* yacc.c:1651 */
21032104 { (yyval.type_decl) = add_type_decl_array( (yyvsp[-1].type_decl), (yyvsp[0].array_sub), EM_lineNum ); }
2104−#line 2104 "chuck.tab.c" /* yacc.c:1646 */
2105+#line 2106 "chuck.tab.c" /* yacc.c:1651 */
21052106 break;
21062107
21072108 case 49:
2108−#line 299 "chuck.y" /* yacc.c:1646 */
2109+#line 300 "chuck.y" /* yacc.c:1651 */
21092110 { (yyval.arg_list) = new_arg_list( (yyvsp[-1].type_decl), (yyvsp[0].var_decl), EM_lineNum ); }
2110−#line 2110 "chuck.tab.c" /* yacc.c:1646 */
2111+#line 2112 "chuck.tab.c" /* yacc.c:1651 */
21112112 break;
21122113
21132114 case 50:
2114−#line 300 "chuck.y" /* yacc.c:1646 */
2115+#line 301 "chuck.y" /* yacc.c:1651 */
21152116 { (yyval.arg_list) = prepend_arg_list( (yyvsp[-3].type_decl), (yyvsp[-2].var_decl), (yyvsp[0].arg_list), EM_lineNum ); }
2116−#line 2116 "chuck.tab.c" /* yacc.c:1646 */
2117+#line 2118 "chuck.tab.c" /* yacc.c:1651 */
21172118 break;
21182119
21192120 case 51:
2120−#line 304 "chuck.y" /* yacc.c:1646 */
2121+#line 305 "chuck.y" /* yacc.c:1651 */
21212122 { (yyval.stmt_list) = new_stmt_list( (yyvsp[0].stmt), EM_lineNum ); }
2122−#line 2122 "chuck.tab.c" /* yacc.c:1646 */
2123+#line 2124 "chuck.tab.c" /* yacc.c:1651 */
21232124 break;
21242125
21252126 case 52:
2126−#line 305 "chuck.y" /* yacc.c:1646 */
2127+#line 306 "chuck.y" /* yacc.c:1651 */
21272128 { (yyval.stmt_list) = prepend_stmt_list( (yyvsp[-1].stmt), (yyvsp[0].stmt_list), EM_lineNum ); }
2128−#line 2128 "chuck.tab.c" /* yacc.c:1646 */
2129+#line 2130 "chuck.tab.c" /* yacc.c:1651 */
21292130 break;
21302131
21312132 case 53:
2132−#line 309 "chuck.y" /* yacc.c:1646 */
2133+#line 310 "chuck.y" /* yacc.c:1651 */
21332134 { (yyval.stmt) = (yyvsp[0].stmt); }
2134−#line 2134 "chuck.tab.c" /* yacc.c:1646 */
2135+#line 2136 "chuck.tab.c" /* yacc.c:1651 */
21352136 break;
21362137
21372138 case 54:
2138−#line 310 "chuck.y" /* yacc.c:1646 */
2139+#line 311 "chuck.y" /* yacc.c:1651 */
21392140 { (yyval.stmt) = (yyvsp[0].stmt); }
2140−#line 2140 "chuck.tab.c" /* yacc.c:1646 */
2141+#line 2142 "chuck.tab.c" /* yacc.c:1651 */
21412142 break;
21422143
21432144 case 55:
2144−#line 311 "chuck.y" /* yacc.c:1646 */
2145+#line 312 "chuck.y" /* yacc.c:1651 */
21452146 { (yyval.stmt) = (yyvsp[0].stmt); }
2146−#line 2146 "chuck.tab.c" /* yacc.c:1646 */
2147+#line 2148 "chuck.tab.c" /* yacc.c:1651 */
21472148 break;
21482149
21492150 case 56:
2150−#line 312 "chuck.y" /* yacc.c:1646 */
2151+#line 313 "chuck.y" /* yacc.c:1651 */
21512152 { (yyval.stmt) = (yyvsp[0].stmt); }
2152−#line 2152 "chuck.tab.c" /* yacc.c:1646 */
2153+#line 2154 "chuck.tab.c" /* yacc.c:1651 */
21532154 break;
21542155
21552156 case 57:
2156−#line 314 "chuck.y" /* yacc.c:1646 */
2157+#line 315 "chuck.y" /* yacc.c:1651 */
21572158 { (yyval.stmt) = (yyvsp[0].stmt); }
2158−#line 2158 "chuck.tab.c" /* yacc.c:1646 */
2159+#line 2160 "chuck.tab.c" /* yacc.c:1651 */
21592160 break;
21602161
21612162 case 58:
2162−#line 318 "chuck.y" /* yacc.c:1646 */
2163+#line 319 "chuck.y" /* yacc.c:1651 */
21632164 { (yyval.stmt) = new_stmt_from_return( NULL, EM_lineNum ); }
2164−#line 2164 "chuck.tab.c" /* yacc.c:1646 */
2165+#line 2166 "chuck.tab.c" /* yacc.c:1651 */
21652166 break;
21662167
21672168 case 59:
2168−#line 319 "chuck.y" /* yacc.c:1646 */
2169+#line 320 "chuck.y" /* yacc.c:1651 */
21692170 { (yyval.stmt) = new_stmt_from_return( (yyvsp[-1].exp), EM_lineNum ); }
2170−#line 2170 "chuck.tab.c" /* yacc.c:1646 */
2171+#line 2172 "chuck.tab.c" /* yacc.c:1651 */
21712172 break;
21722173
21732174 case 60:
2174−#line 320 "chuck.y" /* yacc.c:1646 */
2175+#line 321 "chuck.y" /* yacc.c:1651 */
21752176 { (yyval.stmt) = new_stmt_from_break( EM_lineNum ); }
2176−#line 2176 "chuck.tab.c" /* yacc.c:1646 */
2177+#line 2178 "chuck.tab.c" /* yacc.c:1651 */
21772178 break;
21782179
21792180 case 61:
2180−#line 321 "chuck.y" /* yacc.c:1646 */
2181+#line 322 "chuck.y" /* yacc.c:1651 */
21812182 { (yyval.stmt) = new_stmt_from_continue( EM_lineNum ); }
2182−#line 2182 "chuck.tab.c" /* yacc.c:1646 */
2183+#line 2184 "chuck.tab.c" /* yacc.c:1651 */
21832184 break;
21842185
21852186 case 62:
2186−#line 326 "chuck.y" /* yacc.c:1646 */
2187+#line 327 "chuck.y" /* yacc.c:1651 */
21872188 { (yyval.stmt) = new_stmt_from_if( (yyvsp[-2].exp), (yyvsp[0].stmt), NULL, EM_lineNum ); }
2188−#line 2188 "chuck.tab.c" /* yacc.c:1646 */
2189+#line 2190 "chuck.tab.c" /* yacc.c:1651 */
21892190 break;
21902191
21912192 case 63:
2192−#line 328 "chuck.y" /* yacc.c:1646 */
2193+#line 329 "chuck.y" /* yacc.c:1651 */
21932194 { (yyval.stmt) = new_stmt_from_if( (yyvsp[-4].exp), (yyvsp[-2].stmt), (yyvsp[0].stmt), EM_lineNum ); }
2194−#line 2194 "chuck.tab.c" /* yacc.c:1646 */
2195+#line 2196 "chuck.tab.c" /* yacc.c:1651 */
21952196 break;
21962197
21972198 case 64:
2198−#line 333 "chuck.y" /* yacc.c:1646 */
2199+#line 334 "chuck.y" /* yacc.c:1651 */
21992200 { (yyval.stmt) = new_stmt_from_while( (yyvsp[-2].exp), (yyvsp[0].stmt), EM_lineNum ); }
2200−#line 2200 "chuck.tab.c" /* yacc.c:1646 */
2201+#line 2202 "chuck.tab.c" /* yacc.c:1651 */
22012202 break;
22022203
22032204 case 65:
2204−#line 335 "chuck.y" /* yacc.c:1646 */
2205+#line 336 "chuck.y" /* yacc.c:1651 */
22052206 { (yyval.stmt) = new_stmt_from_do_while( (yyvsp[-2].exp), (yyvsp[-5].stmt), EM_lineNum ); }
2206−#line 2206 "chuck.tab.c" /* yacc.c:1646 */
2207+#line 2208 "chuck.tab.c" /* yacc.c:1651 */
22072208 break;
22082209
22092210 case 66:
2210−#line 337 "chuck.y" /* yacc.c:1646 */
2211+#line 338 "chuck.y" /* yacc.c:1651 */
22112212 { (yyval.stmt) = new_stmt_from_for( (yyvsp[-3].stmt), (yyvsp[-2].stmt), NULL, (yyvsp[0].stmt), EM_lineNum ); }
2212−#line 2212 "chuck.tab.c" /* yacc.c:1646 */
2213+#line 2214 "chuck.tab.c" /* yacc.c:1651 */
22132214 break;
22142215
22152216 case 67:
2216−#line 339 "chuck.y" /* yacc.c:1646 */
2217+#line 340 "chuck.y" /* yacc.c:1651 */
22172218 { (yyval.stmt) = new_stmt_from_for( (yyvsp[-4].stmt), (yyvsp[-3].stmt), (yyvsp[-2].exp), (yyvsp[0].stmt), EM_lineNum ); }
2218−#line 2218 "chuck.tab.c" /* yacc.c:1646 */
2219+#line 2220 "chuck.tab.c" /* yacc.c:1651 */
22192220 break;
22202221
22212222 case 68:
2222−#line 341 "chuck.y" /* yacc.c:1646 */
2223+#line 342 "chuck.y" /* yacc.c:1651 */
22232224 { (yyval.stmt) = new_stmt_from_until( (yyvsp[-2].exp), (yyvsp[0].stmt), EM_lineNum ); }
2224−#line 2224 "chuck.tab.c" /* yacc.c:1646 */
2225+#line 2226 "chuck.tab.c" /* yacc.c:1651 */
22252226 break;
22262227
22272228 case 69:
2228−#line 343 "chuck.y" /* yacc.c:1646 */
2229+#line 344 "chuck.y" /* yacc.c:1651 */
22292230 { (yyval.stmt) = new_stmt_from_do_until( (yyvsp[-2].exp), (yyvsp[-5].stmt), EM_lineNum ); }
2230−#line 2230 "chuck.tab.c" /* yacc.c:1646 */
2231+#line 2232 "chuck.tab.c" /* yacc.c:1651 */
22312232 break;
22322233
22332234 case 70:
2234−#line 345 "chuck.y" /* yacc.c:1646 */
2235+#line 346 "chuck.y" /* yacc.c:1651 */
22352236 { (yyval.stmt) = new_stmt_from_loop( (yyvsp[-2].exp), (yyvsp[0].stmt), EM_lineNum ); }
2236−#line 2236 "chuck.tab.c" /* yacc.c:1646 */
2237+#line 2238 "chuck.tab.c" /* yacc.c:1651 */
22372238 break;
22382239
22392240 case 71:
2240−#line 349 "chuck.y" /* yacc.c:1646 */
2241+#line 350 "chuck.y" /* yacc.c:1651 */
22412242 { (yyval.stmt) = new_stmt_from_code( NULL, EM_lineNum ); }
2242−#line 2242 "chuck.tab.c" /* yacc.c:1646 */
2243+#line 2244 "chuck.tab.c" /* yacc.c:1651 */
22432244 break;
22442245
22452246 case 72:
2246−#line 350 "chuck.y" /* yacc.c:1646 */
2247+#line 351 "chuck.y" /* yacc.c:1651 */
22472248 { (yyval.stmt) = new_stmt_from_code( (yyvsp[-1].stmt_list), EM_lineNum ); }
2248−#line 2248 "chuck.tab.c" /* yacc.c:1646 */
2249+#line 2250 "chuck.tab.c" /* yacc.c:1651 */
22492250 break;
22502251
22512252 case 73:
2252−#line 354 "chuck.y" /* yacc.c:1646 */
2253+#line 355 "chuck.y" /* yacc.c:1651 */
22532254 { (yyval.stmt) = NULL; }
2254−#line 2254 "chuck.tab.c" /* yacc.c:1646 */
2255+#line 2256 "chuck.tab.c" /* yacc.c:1651 */
22552256 break;
22562257
22572258 case 74:
2258−#line 355 "chuck.y" /* yacc.c:1646 */
2259+#line 356 "chuck.y" /* yacc.c:1651 */
22592260 { (yyval.stmt) = new_stmt_from_expression( (yyvsp[-1].exp), EM_lineNum ); }
2260−#line 2260 "chuck.tab.c" /* yacc.c:1646 */
2261+#line 2262 "chuck.tab.c" /* yacc.c:1651 */
22612262 break;
22622263
22632264 case 75:
2264−#line 359 "chuck.y" /* yacc.c:1646 */
2265+#line 360 "chuck.y" /* yacc.c:1651 */
22652266 { (yyval.exp) = (yyvsp[0].exp); }
2266−#line 2266 "chuck.tab.c" /* yacc.c:1646 */
2267+#line 2268 "chuck.tab.c" /* yacc.c:1651 */
22672268 break;
22682269
22692270 case 76:
2270−#line 360 "chuck.y" /* yacc.c:1646 */
2271+#line 361 "chuck.y" /* yacc.c:1651 */
22712272 { (yyval.exp) = prepend_expression( (yyvsp[-2].exp), (yyvsp[0].exp), EM_lineNum ); }
2272−#line 2272 "chuck.tab.c" /* yacc.c:1646 */
2273+#line 2274 "chuck.tab.c" /* yacc.c:1651 */
22732274 break;
22742275
22752276 case 77:
2276−#line 364 "chuck.y" /* yacc.c:1646 */
2277+#line 365 "chuck.y" /* yacc.c:1651 */
22772278 { (yyval.exp) = (yyvsp[0].exp); }
2278−#line 2278 "chuck.tab.c" /* yacc.c:1646 */
2279+#line 2280 "chuck.tab.c" /* yacc.c:1651 */
22792280 break;
22802281
22812282 case 78:
2282−#line 366 "chuck.y" /* yacc.c:1646 */
2283+#line 367 "chuck.y" /* yacc.c:1651 */
22832284 { (yyval.exp) = new_exp_from_binary( (yyvsp[-2].exp), (yyvsp[-1].ival), (yyvsp[0].exp), EM_lineNum ); }
2284−#line 2284 "chuck.tab.c" /* yacc.c:1646 */
2285+#line 2286 "chuck.tab.c" /* yacc.c:1651 */
22852286 break;
22862287
22872288 case 79:
2288−#line 370 "chuck.y" /* yacc.c:1646 */
2289+#line 371 "chuck.y" /* yacc.c:1651 */
22892290 { (yyval.exp) = (yyvsp[0].exp); }
2290−#line 2290 "chuck.tab.c" /* yacc.c:1646 */
2291+#line 2292 "chuck.tab.c" /* yacc.c:1651 */
22912292 break;
22922293
22932294 case 80:
2294−#line 372 "chuck.y" /* yacc.c:1646 */
2295+#line 373 "chuck.y" /* yacc.c:1651 */
22952296 { (yyval.exp) = new_exp_from_binary( (yyvsp[-2].exp), (yyvsp[-1].ival), (yyvsp[0].exp), EM_lineNum ); }
2296−#line 2296 "chuck.tab.c" /* yacc.c:1646 */
2297+#line 2298 "chuck.tab.c" /* yacc.c:1651 */
22972298 break;
22982299
22992300 case 81:
2300−#line 376 "chuck.y" /* yacc.c:1646 */
2301+#line 377 "chuck.y" /* yacc.c:1651 */
23012302 { (yyval.array_sub) = new_array_sub( (yyvsp[-1].exp), EM_lineNum ); }
2302−#line 2302 "chuck.tab.c" /* yacc.c:1646 */
2303+#line 2304 "chuck.tab.c" /* yacc.c:1651 */
23032304 break;
23042305
23052306 case 82:
2306−#line 378 "chuck.y" /* yacc.c:1646 */
2307+#line 379 "chuck.y" /* yacc.c:1651 */
23072308 { (yyval.array_sub) = prepend_array_sub( (yyvsp[0].array_sub), (yyvsp[-2].exp), EM_lineNum ); }
2308−#line 2308 "chuck.tab.c" /* yacc.c:1646 */
2309+#line 2310 "chuck.tab.c" /* yacc.c:1651 */
23092310 break;
23102311
23112312 case 83:
2312−#line 382 "chuck.y" /* yacc.c:1646 */
2313+#line 383 "chuck.y" /* yacc.c:1651 */
23132314 { (yyval.array_sub) = new_array_sub( NULL, EM_lineNum ); }
2314−#line 2314 "chuck.tab.c" /* yacc.c:1646 */
2315+#line 2316 "chuck.tab.c" /* yacc.c:1651 */
23152316 break;
23162317
23172318 case 84:
2318−#line 383 "chuck.y" /* yacc.c:1646 */
2319+#line 384 "chuck.y" /* yacc.c:1651 */
23192320 { (yyval.array_sub) = prepend_array_sub( (yyvsp[-2].array_sub), NULL, EM_lineNum ); }
2320−#line 2320 "chuck.tab.c" /* yacc.c:1646 */
2321+#line 2322 "chuck.tab.c" /* yacc.c:1651 */
23212322 break;
23222323
23232324 case 85:
2324−#line 387 "chuck.y" /* yacc.c:1646 */
2325+#line 388 "chuck.y" /* yacc.c:1651 */
23252326 { (yyval.exp) = (yyvsp[0].exp); }
2326−#line 2326 "chuck.tab.c" /* yacc.c:1646 */
2327+#line 2328 "chuck.tab.c" /* yacc.c:1651 */
23272328 break;
23282329
23292330 case 86:
2330−#line 388 "chuck.y" /* yacc.c:1646 */
2331+#line 389 "chuck.y" /* yacc.c:1651 */
23312332 { (yyval.exp) = new_exp_decl( (yyvsp[-1].type_decl), (yyvsp[0].var_decl_list), 0, EM_lineNum ); }
2332−#line 2332 "chuck.tab.c" /* yacc.c:1646 */
2333+#line 2334 "chuck.tab.c" /* yacc.c:1651 */
23332334 break;
23342335
23352336 case 87:
2336−#line 389 "chuck.y" /* yacc.c:1646 */
2337+#line 390 "chuck.y" /* yacc.c:1651 */
23372338 { (yyval.exp) = new_exp_decl_external( (yyvsp[-1].type_decl), (yyvsp[0].var_decl_list), 0, EM_lineNum ); }
2338−#line 2338 "chuck.tab.c" /* yacc.c:1646 */
2339+#line 2340 "chuck.tab.c" /* yacc.c:1651 */
23392340 break;
23402341
23412342 case 88:
2342−#line 390 "chuck.y" /* yacc.c:1646 */
2343+#line 391 "chuck.y" /* yacc.c:1651 */
23432344 { (yyval.exp) = new_exp_decl_global( (yyvsp[-1].type_decl), (yyvsp[0].var_decl_list), 0, EM_lineNum ); }
2344−#line 2344 "chuck.tab.c" /* yacc.c:1646 */
2345+#line 2346 "chuck.tab.c" /* yacc.c:1651 */
23452346 break;
23462347
23472348 case 89:
2348−#line 391 "chuck.y" /* yacc.c:1646 */
2349+#line 392 "chuck.y" /* yacc.c:1651 */
23492350 { (yyval.exp) = new_exp_decl( (yyvsp[-1].type_decl), (yyvsp[0].var_decl_list), 1, EM_lineNum ); }
2350−#line 2350 "chuck.tab.c" /* yacc.c:1646 */
2351+#line 2352 "chuck.tab.c" /* yacc.c:1651 */
23512352 break;
23522353
23532354 case 90:
2354−#line 392 "chuck.y" /* yacc.c:1646 */
2355+#line 393 "chuck.y" /* yacc.c:1651 */
23552356 { (yyval.exp) = new_exp_decl( NULL, (yyvsp[0].var_decl_list), 0, EM_lineNum ); }
2356−#line 2356 "chuck.tab.c" /* yacc.c:1646 */
2357+#line 2358 "chuck.tab.c" /* yacc.c:1651 */
23572358 break;
23582359
23592360 case 91:
2360−#line 393 "chuck.y" /* yacc.c:1646 */
2361+#line 394 "chuck.y" /* yacc.c:1651 */
23612362 { (yyval.exp) = new_exp_decl( NULL, (yyvsp[0].var_decl_list), 1, EM_lineNum ); }
2362−#line 2362 "chuck.tab.c" /* yacc.c:1646 */
2363+#line 2364 "chuck.tab.c" /* yacc.c:1651 */
23632364 break;
23642365
23652366 case 92:
2366−#line 397 "chuck.y" /* yacc.c:1646 */
2367+#line 398 "chuck.y" /* yacc.c:1651 */
23672368 { (yyval.var_decl_list) = new_var_decl_list( (yyvsp[0].var_decl), EM_lineNum ); }
2368−#line 2368 "chuck.tab.c" /* yacc.c:1646 */
2369+#line 2370 "chuck.tab.c" /* yacc.c:1651 */
23692370 break;
23702371
23712372 case 93:
2372−#line 398 "chuck.y" /* yacc.c:1646 */
2373+#line 399 "chuck.y" /* yacc.c:1651 */
23732374 { (yyval.var_decl_list) = prepend_var_decl_list( (yyvsp[-2].var_decl), (yyvsp[0].var_decl_list), EM_lineNum ); }
2374−#line 2374 "chuck.tab.c" /* yacc.c:1646 */
2375+#line 2376 "chuck.tab.c" /* yacc.c:1651 */
23752376 break;
23762377
23772378 case 94:
2378−#line 402 "chuck.y" /* yacc.c:1646 */
2379+#line 403 "chuck.y" /* yacc.c:1651 */
23792380 { (yyval.var_decl) = new_var_decl( (yyvsp[0].sval), NULL, EM_lineNum ); }
2380−#line 2380 "chuck.tab.c" /* yacc.c:1646 */
2381+#line 2382 "chuck.tab.c" /* yacc.c:1651 */
23812382 break;
23822383
23832384 case 95:
2384−#line 403 "chuck.y" /* yacc.c:1646 */
2385+#line 404 "chuck.y" /* yacc.c:1651 */
23852386 { (yyval.var_decl) = new_var_decl( (yyvsp[-1].sval), (yyvsp[0].array_sub), EM_lineNum ); }
2386−#line 2386 "chuck.tab.c" /* yacc.c:1646 */
2387+#line 2388 "chuck.tab.c" /* yacc.c:1651 */
23872388 break;
23882389
23892390 case 96:
2390−#line 404 "chuck.y" /* yacc.c:1646 */
2391+#line 405 "chuck.y" /* yacc.c:1651 */
23912392 { (yyval.var_decl) = new_var_decl( (yyvsp[-1].sval), (yyvsp[0].array_sub), EM_lineNum ); }
2392−#line 2392 "chuck.tab.c" /* yacc.c:1646 */
2393+#line 2394 "chuck.tab.c" /* yacc.c:1651 */
23932394 break;
23942395
23952396 case 97:
2396−#line 409 "chuck.y" /* yacc.c:1646 */
2397+#line 410 "chuck.y" /* yacc.c:1651 */
23972398 { (yyval.complex_exp) = new_complex( (yyvsp[-1].exp), EM_lineNum ); }
2398−#line 2398 "chuck.tab.c" /* yacc.c:1646 */
2399+#line 2400 "chuck.tab.c" /* yacc.c:1651 */
23992400 break;
24002401
24012402 case 98:
2402−#line 414 "chuck.y" /* yacc.c:1646 */
2403+#line 415 "chuck.y" /* yacc.c:1651 */
24032404 { (yyval.polar_exp) = new_polar( (yyvsp[-1].exp), EM_lineNum ); }
2404−#line 2404 "chuck.tab.c" /* yacc.c:1646 */
2405+#line 2406 "chuck.tab.c" /* yacc.c:1651 */
24052406 break;
24062407
24072408 case 99:
2408−#line 419 "chuck.y" /* yacc.c:1646 */
2409+#line 420 "chuck.y" /* yacc.c:1651 */
24092410 { (yyval.vec_exp) = new_vec( (yyvsp[-1].exp), EM_lineNum ); }
2410−#line 2410 "chuck.tab.c" /* yacc.c:1646 */
2411+#line 2412 "chuck.tab.c" /* yacc.c:1651 */
24112412 break;
24122413
24132414 case 100:
2414−#line 423 "chuck.y" /* yacc.c:1646 */
2415+#line 424 "chuck.y" /* yacc.c:1651 */
24152416 { (yyval.ival) = ae_op_chuck; }
2416−#line 2416 "chuck.tab.c" /* yacc.c:1646 */
2417+#line 2418 "chuck.tab.c" /* yacc.c:1651 */
24172418 break;
24182419
24192420 case 101:
2420−#line 424 "chuck.y" /* yacc.c:1646 */
2421+#line 425 "chuck.y" /* yacc.c:1651 */
24212422 { (yyval.ival) = ae_op_at_chuck; }
2422−#line 2422 "chuck.tab.c" /* yacc.c:1646 */
2423+#line 2424 "chuck.tab.c" /* yacc.c:1651 */
24232424 break;
24242425
24252426 case 102:
2426−#line 425 "chuck.y" /* yacc.c:1646 */
2427+#line 426 "chuck.y" /* yacc.c:1651 */
24272428 { (yyval.ival) = ae_op_plus_chuck; }
2428−#line 2428 "chuck.tab.c" /* yacc.c:1646 */
2429+#line 2430 "chuck.tab.c" /* yacc.c:1651 */
24292430 break;
24302431
24312432 case 103:
2432−#line 426 "chuck.y" /* yacc.c:1646 */
2433+#line 427 "chuck.y" /* yacc.c:1651 */
24332434 { (yyval.ival) = ae_op_minus_chuck; }
2434−#line 2434 "chuck.tab.c" /* yacc.c:1646 */
2435+#line 2436 "chuck.tab.c" /* yacc.c:1651 */
24352436 break;
24362437
24372438 case 104:
2438−#line 427 "chuck.y" /* yacc.c:1646 */
2439+#line 428 "chuck.y" /* yacc.c:1651 */
24392440 { (yyval.ival) = ae_op_times_chuck; }
2440−#line 2440 "chuck.tab.c" /* yacc.c:1646 */
2441+#line 2442 "chuck.tab.c" /* yacc.c:1651 */
24412442 break;
24422443
24432444 case 105:
2444−#line 428 "chuck.y" /* yacc.c:1646 */
2445+#line 429 "chuck.y" /* yacc.c:1651 */
24452446 { (yyval.ival) = ae_op_divide_chuck; }
2446−#line 2446 "chuck.tab.c" /* yacc.c:1646 */
2447+#line 2448 "chuck.tab.c" /* yacc.c:1651 */
24472448 break;
24482449
24492450 case 106:
2450−#line 429 "chuck.y" /* yacc.c:1646 */
2451+#line 430 "chuck.y" /* yacc.c:1651 */
24512452 { (yyval.ival) = ae_op_shift_right_chuck; }
2452−#line 2452 "chuck.tab.c" /* yacc.c:1646 */
2453+#line 2454 "chuck.tab.c" /* yacc.c:1651 */
24532454 break;
24542455
24552456 case 107:
2456−#line 430 "chuck.y" /* yacc.c:1646 */
2457+#line 431 "chuck.y" /* yacc.c:1651 */
24572458 { (yyval.ival) = ae_op_shift_left_chuck; }
2458−#line 2458 "chuck.tab.c" /* yacc.c:1646 */
2459+#line 2460 "chuck.tab.c" /* yacc.c:1651 */
24592460 break;
24602461
24612462 case 108:
2462−#line 431 "chuck.y" /* yacc.c:1646 */
2463+#line 432 "chuck.y" /* yacc.c:1651 */
24632464 { (yyval.ival) = ae_op_percent_chuck; }
2464−#line 2464 "chuck.tab.c" /* yacc.c:1646 */
2465+#line 2466 "chuck.tab.c" /* yacc.c:1651 */
24652466 break;
24662467
24672468 case 109:
2468−#line 432 "chuck.y" /* yacc.c:1646 */
2469+#line 433 "chuck.y" /* yacc.c:1651 */
24692470 { (yyval.ival) = ae_op_unchuck; }
2470−#line 2470 "chuck.tab.c" /* yacc.c:1646 */
2471+#line 2472 "chuck.tab.c" /* yacc.c:1651 */
24712472 break;
24722473
24732474 case 110:
2474−#line 433 "chuck.y" /* yacc.c:1646 */
2475+#line 434 "chuck.y" /* yacc.c:1651 */
24752476 { (yyval.ival) = ae_op_upchuck; }
2476−#line 2476 "chuck.tab.c" /* yacc.c:1646 */
2477+#line 2478 "chuck.tab.c" /* yacc.c:1651 */
24772478 break;
24782479
24792480 case 111:
2480−#line 434 "chuck.y" /* yacc.c:1646 */
2481+#line 435 "chuck.y" /* yacc.c:1651 */
24812482 { (yyval.ival) = ae_op_s_and_chuck; }
2482−#line 2482 "chuck.tab.c" /* yacc.c:1646 */
2483+#line 2484 "chuck.tab.c" /* yacc.c:1651 */
24832484 break;
24842485
24852486 case 112:
2486−#line 435 "chuck.y" /* yacc.c:1646 */
2487+#line 436 "chuck.y" /* yacc.c:1651 */
24872488 { (yyval.ival) = ae_op_s_or_chuck; }
2488−#line 2488 "chuck.tab.c" /* yacc.c:1646 */
2489+#line 2490 "chuck.tab.c" /* yacc.c:1651 */
24892490 break;
24902491
24912492 case 113:
2492−#line 436 "chuck.y" /* yacc.c:1646 */
2493+#line 437 "chuck.y" /* yacc.c:1651 */
24932494 { (yyval.ival) = ae_op_s_xor_chuck; }
2494−#line 2494 "chuck.tab.c" /* yacc.c:1646 */
2495+#line 2496 "chuck.tab.c" /* yacc.c:1651 */
24952496 break;
24962497
24972498 case 114:
2498−#line 440 "chuck.y" /* yacc.c:1646 */
2499+#line 441 "chuck.y" /* yacc.c:1651 */
24992500 { (yyval.ival) = ae_op_arrow_left; }
2500−#line 2500 "chuck.tab.c" /* yacc.c:1646 */
2501+#line 2502 "chuck.tab.c" /* yacc.c:1651 */
25012502 break;
25022503
25032504 case 115:
2504−#line 441 "chuck.y" /* yacc.c:1646 */
2505+#line 442 "chuck.y" /* yacc.c:1651 */
25052506 { (yyval.ival) = ae_op_arrow_right; }
2506−#line 2506 "chuck.tab.c" /* yacc.c:1646 */
2507+#line 2508 "chuck.tab.c" /* yacc.c:1651 */
25072508 break;
25082509
25092510 case 116:
2510−#line 445 "chuck.y" /* yacc.c:1646 */
2511+#line 446 "chuck.y" /* yacc.c:1651 */
25112512 { (yyval.exp) = (yyvsp[0].exp); }
2512−#line 2512 "chuck.tab.c" /* yacc.c:1646 */
2513+#line 2514 "chuck.tab.c" /* yacc.c:1651 */
25132514 break;
25142515
25152516 case 117:
2516−#line 447 "chuck.y" /* yacc.c:1646 */
2517+#line 448 "chuck.y" /* yacc.c:1651 */
25172518 { (yyval.exp) = new_exp_from_if( (yyvsp[-4].exp), (yyvsp[-2].exp), (yyvsp[0].exp), EM_lineNum ); }
2518−#line 2518 "chuck.tab.c" /* yacc.c:1646 */
2519+#line 2520 "chuck.tab.c" /* yacc.c:1651 */
25192520 break;
25202521
25212522 case 118:
2522−#line 451 "chuck.y" /* yacc.c:1646 */
2523+#line 452 "chuck.y" /* yacc.c:1651 */
25232524 { (yyval.exp) = (yyvsp[0].exp); }
2524−#line 2524 "chuck.tab.c" /* yacc.c:1646 */
2525+#line 2526 "chuck.tab.c" /* yacc.c:1651 */
25252526 break;
25262527
25272528 case 119:
2528−#line 453 "chuck.y" /* yacc.c:1646 */
2529+#line 454 "chuck.y" /* yacc.c:1651 */
25292530 { (yyval.exp) = new_exp_from_binary( (yyvsp[-2].exp), ae_op_or, (yyvsp[0].exp), EM_lineNum ); }
2530−#line 2530 "chuck.tab.c" /* yacc.c:1646 */
2531+#line 2532 "chuck.tab.c" /* yacc.c:1651 */
25312532 break;
25322533
25332534 case 120:
2534−#line 457 "chuck.y" /* yacc.c:1646 */
2535+#line 458 "chuck.y" /* yacc.c:1651 */
25352536 { (yyval.exp) = (yyvsp[0].exp); }
2536−#line 2536 "chuck.tab.c" /* yacc.c:1646 */
2537+#line 2538 "chuck.tab.c" /* yacc.c:1651 */
25372538 break;
25382539
25392540 case 121:
2540−#line 459 "chuck.y" /* yacc.c:1646 */
2541+#line 460 "chuck.y" /* yacc.c:1651 */
25412542 { (yyval.exp) = new_exp_from_binary( (yyvsp[-2].exp), ae_op_and, (yyvsp[0].exp), EM_lineNum ); }
2542−#line 2542 "chuck.tab.c" /* yacc.c:1646 */
2543+#line 2544 "chuck.tab.c" /* yacc.c:1651 */
25432544 break;
25442545
25452546 case 122:
2546−#line 463 "chuck.y" /* yacc.c:1646 */
2547+#line 464 "chuck.y" /* yacc.c:1651 */
25472548 { (yyval.exp) = (yyvsp[0].exp); }
2548−#line 2548 "chuck.tab.c" /* yacc.c:1646 */
2549+#line 2550 "chuck.tab.c" /* yacc.c:1651 */
25492550 break;
25502551
25512552 case 123:
2552−#line 465 "chuck.y" /* yacc.c:1646 */
2553+#line 466 "chuck.y" /* yacc.c:1651 */
25532554 { (yyval.exp) = new_exp_from_binary( (yyvsp[-2].exp), ae_op_s_or, (yyvsp[0].exp), EM_lineNum ); }
2554−#line 2554 "chuck.tab.c" /* yacc.c:1646 */
2555+#line 2556 "chuck.tab.c" /* yacc.c:1651 */
25552556 break;
25562557
25572558 case 124:
2558−#line 469 "chuck.y" /* yacc.c:1646 */
2559+#line 470 "chuck.y" /* yacc.c:1651 */
25592560 { (yyval.exp) = (yyvsp[0].exp); }
2560−#line 2560 "chuck.tab.c" /* yacc.c:1646 */
2561+#line 2562 "chuck.tab.c" /* yacc.c:1651 */
25612562 break;
25622563
25632564 case 125:
2564−#line 471 "chuck.y" /* yacc.c:1646 */
2565+#line 472 "chuck.y" /* yacc.c:1651 */
25652566 { (yyval.exp) = new_exp_from_binary( (yyvsp[-2].exp), ae_op_s_xor, (yyvsp[0].exp), EM_lineNum ); }
2566−#line 2566 "chuck.tab.c" /* yacc.c:1646 */
2567+#line 2568 "chuck.tab.c" /* yacc.c:1651 */
25672568 break;
25682569
25692570 case 126:
2570−#line 475 "chuck.y" /* yacc.c:1646 */
2571+#line 476 "chuck.y" /* yacc.c:1651 */
25712572 { (yyval.exp) = (yyvsp[0].exp); }
2572−#line 2572 "chuck.tab.c" /* yacc.c:1646 */
2573+#line 2574 "chuck.tab.c" /* yacc.c:1651 */
25732574 break;
25742575
25752576 case 127:
2576−#line 477 "chuck.y" /* yacc.c:1646 */
2577+#line 478 "chuck.y" /* yacc.c:1651 */
25772578 { (yyval.exp) = new_exp_from_binary( (yyvsp[-2].exp), ae_op_s_and, (yyvsp[0].exp), EM_lineNum ); }
2578−#line 2578 "chuck.tab.c" /* yacc.c:1646 */
2579+#line 2580 "chuck.tab.c" /* yacc.c:1651 */
25792580 break;
25802581
25812582 case 128:
2582−#line 481 "chuck.y" /* yacc.c:1646 */
2583+#line 482 "chuck.y" /* yacc.c:1651 */
25832584 { (yyval.exp) = (yyvsp[0].exp); }
2584−#line 2584 "chuck.tab.c" /* yacc.c:1646 */
2585+#line 2586 "chuck.tab.c" /* yacc.c:1651 */
25852586 break;
25862587
25872588 case 129:
2588−#line 483 "chuck.y" /* yacc.c:1646 */
2589+#line 484 "chuck.y" /* yacc.c:1651 */
25892590 { (yyval.exp) = new_exp_from_binary( (yyvsp[-2].exp), ae_op_eq, (yyvsp[0].exp), EM_lineNum ); }
2590−#line 2590 "chuck.tab.c" /* yacc.c:1646 */
2591+#line 2592 "chuck.tab.c" /* yacc.c:1651 */
25912592 break;
25922593
25932594 case 130:
2594−#line 485 "chuck.y" /* yacc.c:1646 */
2595+#line 486 "chuck.y" /* yacc.c:1651 */
25952596 { (yyval.exp) = new_exp_from_binary( (yyvsp[-2].exp), ae_op_neq, (yyvsp[0].exp), EM_lineNum ); }
2596−#line 2596 "chuck.tab.c" /* yacc.c:1646 */
2597+#line 2598 "chuck.tab.c" /* yacc.c:1651 */
25972598 break;
25982599
25992600 case 131:
2600−#line 489 "chuck.y" /* yacc.c:1646 */
2601+#line 490 "chuck.y" /* yacc.c:1651 */
26012602 { (yyval.exp) = (yyvsp[0].exp); }
2602−#line 2602 "chuck.tab.c" /* yacc.c:1646 */
2603+#line 2604 "chuck.tab.c" /* yacc.c:1651 */
26032604 break;
26042605
26052606 case 132:
2606−#line 491 "chuck.y" /* yacc.c:1646 */
2607+#line 492 "chuck.y" /* yacc.c:1651 */
26072608 { (yyval.exp) = new_exp_from_binary( (yyvsp[-2].exp), ae_op_lt, (yyvsp[0].exp), EM_lineNum ); }
2608−#line 2608 "chuck.tab.c" /* yacc.c:1646 */
2609+#line 2610 "chuck.tab.c" /* yacc.c:1651 */
26092610 break;
26102611
26112612 case 133:
2612−#line 493 "chuck.y" /* yacc.c:1646 */
2613+#line 494 "chuck.y" /* yacc.c:1651 */
26132614 { (yyval.exp) = new_exp_from_binary( (yyvsp[-2].exp), ae_op_gt, (yyvsp[0].exp), EM_lineNum ); }
2614−#line 2614 "chuck.tab.c" /* yacc.c:1646 */
2615+#line 2616 "chuck.tab.c" /* yacc.c:1651 */
26152616 break;
26162617
26172618 case 134:
2618−#line 495 "chuck.y" /* yacc.c:1646 */
2619+#line 496 "chuck.y" /* yacc.c:1651 */
26192620 { (yyval.exp) = new_exp_from_binary( (yyvsp[-2].exp), ae_op_le, (yyvsp[0].exp), EM_lineNum ); }
2620−#line 2620 "chuck.tab.c" /* yacc.c:1646 */
2621+#line 2622 "chuck.tab.c" /* yacc.c:1651 */
26212622 break;
26222623
26232624 case 135:
2624−#line 497 "chuck.y" /* yacc.c:1646 */
2625+#line 498 "chuck.y" /* yacc.c:1651 */
26252626 { (yyval.exp) = new_exp_from_binary( (yyvsp[-2].exp), ae_op_ge, (yyvsp[0].exp), EM_lineNum ); }
2626−#line 2626 "chuck.tab.c" /* yacc.c:1646 */
2627+#line 2628 "chuck.tab.c" /* yacc.c:1651 */
26272628 break;
26282629
26292630 case 136:
2630−#line 501 "chuck.y" /* yacc.c:1646 */
2631+#line 502 "chuck.y" /* yacc.c:1651 */
26312632 { (yyval.exp) = (yyvsp[0].exp); }
2632−#line 2632 "chuck.tab.c" /* yacc.c:1646 */
2633+#line 2634 "chuck.tab.c" /* yacc.c:1651 */
26332634 break;
26342635
26352636 case 137:
2636−#line 503 "chuck.y" /* yacc.c:1646 */
2637+#line 504 "chuck.y" /* yacc.c:1651 */
26372638 { (yyval.exp) = new_exp_from_binary( (yyvsp[-2].exp), ae_op_shift_left, (yyvsp[0].exp), EM_lineNum ); }
2638−#line 2638 "chuck.tab.c" /* yacc.c:1646 */
2639+#line 2640 "chuck.tab.c" /* yacc.c:1651 */
26392640 break;
26402641
26412642 case 138:
2642−#line 505 "chuck.y" /* yacc.c:1646 */
2643+#line 506 "chuck.y" /* yacc.c:1651 */
26432644 { (yyval.exp) = new_exp_from_binary( (yyvsp[-2].exp), ae_op_shift_right, (yyvsp[0].exp), EM_lineNum ); }
2644−#line 2644 "chuck.tab.c" /* yacc.c:1646 */
2645+#line 2646 "chuck.tab.c" /* yacc.c:1651 */
26452646 break;
26462647
26472648 case 139:
2648−#line 509 "chuck.y" /* yacc.c:1646 */
2649+#line 510 "chuck.y" /* yacc.c:1651 */
26492650 { (yyval.exp) = (yyvsp[0].exp); }
2650−#line 2650 "chuck.tab.c" /* yacc.c:1646 */
2651+#line 2652 "chuck.tab.c" /* yacc.c:1651 */
26512652 break;
26522653
26532654 case 140:
2654−#line 511 "chuck.y" /* yacc.c:1646 */
2655+#line 512 "chuck.y" /* yacc.c:1651 */
26552656 { (yyval.exp) = new_exp_from_binary( (yyvsp[-2].exp), ae_op_plus, (yyvsp[0].exp), EM_lineNum ); }
2656−#line 2656 "chuck.tab.c" /* yacc.c:1646 */
2657+#line 2658 "chuck.tab.c" /* yacc.c:1651 */
26572658 break;
26582659
26592660 case 141:
2660−#line 513 "chuck.y" /* yacc.c:1646 */
2661+#line 514 "chuck.y" /* yacc.c:1651 */
26612662 { (yyval.exp) = new_exp_from_binary( (yyvsp[-2].exp), ae_op_minus, (yyvsp[0].exp), EM_lineNum ); }
2662−#line 2662 "chuck.tab.c" /* yacc.c:1646 */
2663+#line 2664 "chuck.tab.c" /* yacc.c:1651 */
26632664 break;
26642665
26652666 case 142:
2666−#line 517 "chuck.y" /* yacc.c:1646 */
2667+#line 518 "chuck.y" /* yacc.c:1651 */
26672668 { (yyval.exp) = (yyvsp[0].exp); }
2668−#line 2668 "chuck.tab.c" /* yacc.c:1646 */
2669+#line 2670 "chuck.tab.c" /* yacc.c:1651 */
26692670 break;
26702671
26712672 case 143:
2672−#line 519 "chuck.y" /* yacc.c:1646 */
2673+#line 520 "chuck.y" /* yacc.c:1651 */
26732674 { (yyval.exp) = new_exp_from_binary( (yyvsp[-2].exp), ae_op_times, (yyvsp[0].exp), EM_lineNum ); }
2674−#line 2674 "chuck.tab.c" /* yacc.c:1646 */
2675+#line 2676 "chuck.tab.c" /* yacc.c:1651 */
26752676 break;
26762677
26772678 case 144:
2678−#line 521 "chuck.y" /* yacc.c:1646 */
2679+#line 522 "chuck.y" /* yacc.c:1651 */
26792680 { (yyval.exp) = new_exp_from_binary( (yyvsp[-2].exp), ae_op_divide, (yyvsp[0].exp), EM_lineNum ); }
2680−#line 2680 "chuck.tab.c" /* yacc.c:1646 */
2681+#line 2682 "chuck.tab.c" /* yacc.c:1651 */
26812682 break;
26822683
26832684 case 145:
2684−#line 523 "chuck.y" /* yacc.c:1646 */
2685+#line 524 "chuck.y" /* yacc.c:1651 */
26852686 { (yyval.exp) = new_exp_from_binary( (yyvsp[-2].exp), ae_op_percent, (yyvsp[0].exp), EM_lineNum ); }
2686−#line 2686 "chuck.tab.c" /* yacc.c:1646 */
2687+#line 2688 "chuck.tab.c" /* yacc.c:1651 */
26872688 break;
26882689
26892690 case 146:
2690−#line 527 "chuck.y" /* yacc.c:1646 */
2691+#line 528 "chuck.y" /* yacc.c:1651 */
26912692 { (yyval.exp) = (yyvsp[0].exp); }
2692−#line 2692 "chuck.tab.c" /* yacc.c:1646 */
2693+#line 2694 "chuck.tab.c" /* yacc.c:1651 */
26932694 break;
26942695
26952696 case 147:
2696−#line 529 "chuck.y" /* yacc.c:1646 */
2697+#line 530 "chuck.y" /* yacc.c:1651 */
26972698 { (yyval.exp) = new_exp_from_binary( (yyvsp[-2].exp), ae_op_tilda, (yyvsp[0].exp), EM_lineNum ); }
2698−#line 2698 "chuck.tab.c" /* yacc.c:1646 */
2699+#line 2700 "chuck.tab.c" /* yacc.c:1651 */
26992700 break;
27002701
27012702 case 148:
2702−#line 533 "chuck.y" /* yacc.c:1646 */
2703+#line 534 "chuck.y" /* yacc.c:1651 */
27032704 { (yyval.exp) = (yyvsp[0].exp); }
2704−#line 2704 "chuck.tab.c" /* yacc.c:1646 */
2705+#line 2706 "chuck.tab.c" /* yacc.c:1651 */
27052706 break;
27062707
27072708 case 149:
2708−#line 535 "chuck.y" /* yacc.c:1646 */
2709+#line 536 "chuck.y" /* yacc.c:1651 */
27092710 { (yyval.exp) = new_exp_from_cast( (yyvsp[0].type_decl), (yyvsp[-2].exp), EM_lineNum ); }
2710−#line 2710 "chuck.tab.c" /* yacc.c:1646 */
2711+#line 2712 "chuck.tab.c" /* yacc.c:1651 */
27112712 break;
27122713
27132714 case 150:
2714−#line 539 "chuck.y" /* yacc.c:1646 */
2715+#line 540 "chuck.y" /* yacc.c:1651 */
27152716 { (yyval.exp) = (yyvsp[0].exp); }
2716−#line 2716 "chuck.tab.c" /* yacc.c:1646 */
2717+#line 2718 "chuck.tab.c" /* yacc.c:1651 */
27172718 break;
27182719
27192720 case 151:
2720−#line 541 "chuck.y" /* yacc.c:1646 */
2721+#line 542 "chuck.y" /* yacc.c:1651 */
27212722 { (yyval.exp) = new_exp_from_unary( ae_op_plusplus, (yyvsp[0].exp), EM_lineNum ); }
2722−#line 2722 "chuck.tab.c" /* yacc.c:1646 */
2723+#line 2724 "chuck.tab.c" /* yacc.c:1651 */
27232724 break;
27242725
27252726 case 152:
2726−#line 543 "chuck.y" /* yacc.c:1646 */
2727+#line 544 "chuck.y" /* yacc.c:1651 */
27272728 { (yyval.exp) = new_exp_from_unary( ae_op_minusminus, (yyvsp[0].exp), EM_lineNum ); }
2728−#line 2728 "chuck.tab.c" /* yacc.c:1646 */
2729+#line 2730 "chuck.tab.c" /* yacc.c:1651 */
27292730 break;
27302731
27312732 case 153:
2732−#line 545 "chuck.y" /* yacc.c:1646 */
2733+#line 546 "chuck.y" /* yacc.c:1651 */
27332734 { (yyval.exp) = new_exp_from_unary( (yyvsp[-1].ival), (yyvsp[0].exp), EM_lineNum ); }
2734−#line 2734 "chuck.tab.c" /* yacc.c:1646 */
2735+#line 2736 "chuck.tab.c" /* yacc.c:1651 */
27352736 break;
27362737
27372738 case 154:
2738−#line 547 "chuck.y" /* yacc.c:1646 */
2739+#line 548 "chuck.y" /* yacc.c:1651 */
27392740 { (yyval.exp) = new_exp_from_unary( ae_op_typeof, (yyvsp[0].exp), EM_lineNum ); }
2740−#line 2740 "chuck.tab.c" /* yacc.c:1646 */
2741+#line 2742 "chuck.tab.c" /* yacc.c:1651 */
27412742 break;
27422743
27432744 case 155:
2744−#line 549 "chuck.y" /* yacc.c:1646 */
2745+#line 550 "chuck.y" /* yacc.c:1651 */
27452746 { (yyval.exp) = new_exp_from_unary( ae_op_sizeof, (yyvsp[0].exp), EM_lineNum ); }
2746−#line 2746 "chuck.tab.c" /* yacc.c:1646 */
2747+#line 2748 "chuck.tab.c" /* yacc.c:1651 */
27472748 break;
27482749
27492750 case 156:
2750−#line 551 "chuck.y" /* yacc.c:1646 */
2751+#line 552 "chuck.y" /* yacc.c:1651 */
27512752 { (yyval.exp) = new_exp_from_unary2( ae_op_new, (yyvsp[0].type_decl), NULL, EM_lineNum ); }
2752−#line 2752 "chuck.tab.c" /* yacc.c:1646 */
2753+#line 2754 "chuck.tab.c" /* yacc.c:1651 */
27532754 break;
27542755
27552756 case 157:
2756−#line 553 "chuck.y" /* yacc.c:1646 */
2757+#line 554 "chuck.y" /* yacc.c:1651 */
27572758 { (yyval.exp) = new_exp_from_unary2( ae_op_new, (yyvsp[-1].type_decl), (yyvsp[0].array_sub), EM_lineNum ); }
2758−#line 2758 "chuck.tab.c" /* yacc.c:1646 */
2759+#line 2760 "chuck.tab.c" /* yacc.c:1651 */
27592760 break;
27602761
27612762 case 158:
2762−#line 559 "chuck.y" /* yacc.c:1646 */
2763+#line 560 "chuck.y" /* yacc.c:1651 */
27632764 { (yyval.ival) = ae_op_plus; }
2764−#line 2764 "chuck.tab.c" /* yacc.c:1646 */
2765+#line 2766 "chuck.tab.c" /* yacc.c:1651 */
27652766 break;
27662767
27672768 case 159:
2768−#line 560 "chuck.y" /* yacc.c:1646 */
2769+#line 561 "chuck.y" /* yacc.c:1651 */
27692770 { (yyval.ival) = ae_op_minus; }
2770−#line 2770 "chuck.tab.c" /* yacc.c:1646 */
2771+#line 2772 "chuck.tab.c" /* yacc.c:1651 */
27712772 break;
27722773
27732774 case 160:
2774−#line 561 "chuck.y" /* yacc.c:1646 */
2775+#line 562 "chuck.y" /* yacc.c:1651 */
27752776 { (yyval.ival) = ae_op_tilda; }
2776−#line 2776 "chuck.tab.c" /* yacc.c:1646 */
2777+#line 2778 "chuck.tab.c" /* yacc.c:1651 */
27772778 break;
27782779
27792780 case 161:
2780−#line 562 "chuck.y" /* yacc.c:1646 */
2781+#line 563 "chuck.y" /* yacc.c:1651 */
27812782 { (yyval.ival) = ae_op_exclamation; }
2782−#line 2782 "chuck.tab.c" /* yacc.c:1646 */
2783+#line 2784 "chuck.tab.c" /* yacc.c:1651 */
27832784 break;
27842785
27852786 case 162:
2786−#line 563 "chuck.y" /* yacc.c:1646 */
2787+#line 564 "chuck.y" /* yacc.c:1651 */
27872788 { (yyval.ival) = ae_op_times; }
2788−#line 2788 "chuck.tab.c" /* yacc.c:1646 */
2789+#line 2790 "chuck.tab.c" /* yacc.c:1651 */
27892790 break;
27902791
27912792 case 163:
2792−#line 564 "chuck.y" /* yacc.c:1646 */
2793+#line 565 "chuck.y" /* yacc.c:1651 */
27932794 { (yyval.ival) = ae_op_spork; }
2794−#line 2794 "chuck.tab.c" /* yacc.c:1646 */
2795+#line 2796 "chuck.tab.c" /* yacc.c:1651 */
27952796 break;
27962797
27972798 case 165:
2798−#line 571 "chuck.y" /* yacc.c:1646 */
2799+#line 572 "chuck.y" /* yacc.c:1651 */
27992800 { (yyval.exp) = new_exp_from_dur( (yyvsp[-2].exp), (yyvsp[0].exp), EM_lineNum ); }
2800−#line 2800 "chuck.tab.c" /* yacc.c:1646 */
2801+#line 2802 "chuck.tab.c" /* yacc.c:1651 */
28012802 break;
28022803
28032804 case 166:
2804−#line 575 "chuck.y" /* yacc.c:1646 */
2805+#line 576 "chuck.y" /* yacc.c:1651 */
28052806 { (yyval.exp) = (yyvsp[0].exp); }
2806−#line 2806 "chuck.tab.c" /* yacc.c:1646 */
2807+#line 2808 "chuck.tab.c" /* yacc.c:1651 */
28072808 break;
28082809
28092810 case 167:
2810−#line 577 "chuck.y" /* yacc.c:1646 */
2811+#line 578 "chuck.y" /* yacc.c:1651 */
28112812 { (yyval.exp) = new_exp_from_array( (yyvsp[-1].exp), (yyvsp[0].array_sub), EM_lineNum ); }
2812−#line 2812 "chuck.tab.c" /* yacc.c:1646 */
2813+#line 2814 "chuck.tab.c" /* yacc.c:1651 */
28132814 break;
28142815
28152816 case 168:
2816−#line 579 "chuck.y" /* yacc.c:1646 */
2817+#line 580 "chuck.y" /* yacc.c:1651 */
28172818 { (yyval.exp) = new_exp_from_func_call( (yyvsp[-2].exp), NULL, EM_lineNum ); }
2818−#line 2818 "chuck.tab.c" /* yacc.c:1646 */
2819+#line 2820 "chuck.tab.c" /* yacc.c:1651 */
28192820 break;
28202821
28212822 case 169:
2822−#line 581 "chuck.y" /* yacc.c:1646 */
2823+#line 582 "chuck.y" /* yacc.c:1651 */
28232824 { (yyval.exp) = new_exp_from_func_call( (yyvsp[-3].exp), (yyvsp[-1].exp), EM_lineNum ); }
2824−#line 2824 "chuck.tab.c" /* yacc.c:1646 */
2825+#line 2826 "chuck.tab.c" /* yacc.c:1651 */
28252826 break;
28262827
28272828 case 170:
2828−#line 583 "chuck.y" /* yacc.c:1646 */
2829+#line 584 "chuck.y" /* yacc.c:1651 */
28292830 { (yyval.exp) = new_exp_from_member_dot( (yyvsp[-2].exp), (yyvsp[0].sval), EM_lineNum ); }
2830−#line 2830 "chuck.tab.c" /* yacc.c:1646 */
2831+#line 2832 "chuck.tab.c" /* yacc.c:1651 */
28312832 break;
28322833
28332834 case 171:
2834−#line 585 "chuck.y" /* yacc.c:1646 */
2835+#line 586 "chuck.y" /* yacc.c:1651 */
28352836 { (yyval.exp) = new_exp_from_postfix( (yyvsp[-1].exp), ae_op_plusplus, EM_lineNum ); }
2836−#line 2836 "chuck.tab.c" /* yacc.c:1646 */
2837+#line 2838 "chuck.tab.c" /* yacc.c:1651 */
28372838 break;
28382839
28392840 case 172:
2840−#line 587 "chuck.y" /* yacc.c:1646 */
2841+#line 588 "chuck.y" /* yacc.c:1651 */
28412842 { (yyval.exp) = new_exp_from_postfix( (yyvsp[-1].exp), ae_op_minusminus, EM_lineNum ); }
2842−#line 2842 "chuck.tab.c" /* yacc.c:1646 */
2843+#line 2844 "chuck.tab.c" /* yacc.c:1651 */
28432844 break;
28442845
28452846 case 173:
2846−#line 592 "chuck.y" /* yacc.c:1646 */
2847+#line 593 "chuck.y" /* yacc.c:1651 */
28472848 { (yyval.exp) = new_exp_from_id( (yyvsp[0].sval), EM_lineNum ); }
2848−#line 2848 "chuck.tab.c" /* yacc.c:1646 */
2849+#line 2850 "chuck.tab.c" /* yacc.c:1651 */
28492850 break;
28502851
28512852 case 174:
2852−#line 593 "chuck.y" /* yacc.c:1646 */
2853+#line 594 "chuck.y" /* yacc.c:1651 */
28532854 { (yyval.exp) = new_exp_from_int( (yyvsp[0].ival), EM_lineNum ); }
2854−#line 2854 "chuck.tab.c" /* yacc.c:1646 */
2855+#line 2856 "chuck.tab.c" /* yacc.c:1651 */
28552856 break;
28562857
28572858 case 175:
2858−#line 594 "chuck.y" /* yacc.c:1646 */
2859+#line 595 "chuck.y" /* yacc.c:1651 */
28592860 { (yyval.exp) = new_exp_from_float( (yyvsp[0].fval), EM_lineNum ); }
2860−#line 2860 "chuck.tab.c" /* yacc.c:1646 */
2861+#line 2862 "chuck.tab.c" /* yacc.c:1651 */
28612862 break;
28622863
28632864 case 176:
2864−#line 595 "chuck.y" /* yacc.c:1646 */
2865+#line 596 "chuck.y" /* yacc.c:1651 */
28652866 { (yyval.exp) = new_exp_from_str( (yyvsp[0].sval), EM_lineNum ); }
2866−#line 2866 "chuck.tab.c" /* yacc.c:1646 */
2867+#line 2868 "chuck.tab.c" /* yacc.c:1651 */
28672868 break;
28682869
28692870 case 177:
2870−#line 596 "chuck.y" /* yacc.c:1646 */
2871+#line 597 "chuck.y" /* yacc.c:1651 */
28712872 { (yyval.exp) = new_exp_from_char( (yyvsp[0].sval), EM_lineNum ); }
2872−#line 2872 "chuck.tab.c" /* yacc.c:1646 */
2873+#line 2874 "chuck.tab.c" /* yacc.c:1651 */
28732874 break;
28742875
28752876 case 178:
2876−#line 597 "chuck.y" /* yacc.c:1646 */
2877+#line 598 "chuck.y" /* yacc.c:1651 */
28772878 { (yyval.exp) = new_exp_from_array_lit( (yyvsp[0].array_sub), EM_lineNum ); }
2878−#line 2878 "chuck.tab.c" /* yacc.c:1646 */
2879+#line 2880 "chuck.tab.c" /* yacc.c:1651 */
28792880 break;
28802881
28812882 case 179:
2882−#line 598 "chuck.y" /* yacc.c:1646 */
2883+#line 599 "chuck.y" /* yacc.c:1651 */
28832884 { (yyval.exp) = new_exp_from_complex( (yyvsp[0].complex_exp), EM_lineNum ); }
2884−#line 2884 "chuck.tab.c" /* yacc.c:1646 */
2885+#line 2886 "chuck.tab.c" /* yacc.c:1651 */
28852886 break;
28862887
28872888 case 180:
2888−#line 599 "chuck.y" /* yacc.c:1646 */
2889+#line 600 "chuck.y" /* yacc.c:1651 */
28892890 { (yyval.exp) = new_exp_from_polar( (yyvsp[0].polar_exp), EM_lineNum ); }
2890−#line 2890 "chuck.tab.c" /* yacc.c:1646 */
2891+#line 2892 "chuck.tab.c" /* yacc.c:1651 */
28912892 break;
28922893
28932894 case 181:
2894−#line 600 "chuck.y" /* yacc.c:1646 */
2895+#line 601 "chuck.y" /* yacc.c:1651 */
28952896 { (yyval.exp) = new_exp_from_vec( (yyvsp[0].vec_exp), EM_lineNum ); }
2896−#line 2896 "chuck.tab.c" /* yacc.c:1646 */
2897+#line 2898 "chuck.tab.c" /* yacc.c:1651 */
28972898 break;
28982899
28992900 case 182:
2900−#line 601 "chuck.y" /* yacc.c:1646 */
2901+#line 602 "chuck.y" /* yacc.c:1651 */
29012902 { (yyval.exp) = new_exp_from_hack( (yyvsp[-1].exp), EM_lineNum ); }
2902−#line 2902 "chuck.tab.c" /* yacc.c:1646 */
2903+#line 2904 "chuck.tab.c" /* yacc.c:1651 */
29032904 break;
29042905
29052906 case 183:
2906−#line 602 "chuck.y" /* yacc.c:1646 */
2907+#line 603 "chuck.y" /* yacc.c:1651 */
29072908 { (yyval.exp) = (yyvsp[-1].exp); }
2908−#line 2908 "chuck.tab.c" /* yacc.c:1646 */
2909+#line 2910 "chuck.tab.c" /* yacc.c:1651 */
29092910 break;
29102911
29112912 case 184:
2912−#line 603 "chuck.y" /* yacc.c:1646 */
2913+#line 604 "chuck.y" /* yacc.c:1651 */
29132914 { (yyval.exp) = new_exp_from_nil( EM_lineNum ); }
2914−#line 2914 "chuck.tab.c" /* yacc.c:1646 */
2915+#line 2916 "chuck.tab.c" /* yacc.c:1651 */
29152916 break;
29162917
29172918
2918−#line 2918 "chuck.tab.c" /* yacc.c:1646 */
2919+#line 2920 "chuck.tab.c" /* yacc.c:1651 */
29192920 default: break;
29202921 }
29212922 /* User semantic actions sometimes alter yychar, and that requires
@@ -3792,6 +3793,7 @@ char *yytext; · 870 unmodified lines
37923793
37933794 #include <stdlib.h>
37943795 #include <string.h>
3796+#include <unistd.h>
37953797 #include "chuck_utils.h"
37963798 #include "chuck_absyn.h"
37973799 #include "chuck_errmsg.h"
@@ -3913,8 +3915,8 @@ long htol( c_str str ) · 115 unmodified lines
39133915
39143916 // .*\-\-> { adjust(); continue; }
39153917
3916−#line 771 "core/chuck.yy.c"
39173918 #line 772 "core/chuck.yy.c"
3919+#line 773 "core/chuck.yy.c"
39183920
39193921 #define INITIAL 0
39203922
@@ -4123,10 +4125,10 @@ YY_DECL · 202 unmodified lines
41234125 }
41244126
41254127 {
4126−#line 172 "core/chuck.lex"
4128+#line 173 "core/chuck.lex"
41274129
41284130
4129−#line 984 "core/chuck.yy.c"
4131+#line 985 "core/chuck.yy.c"
41304132
41314133 while ( /*CONSTCOND*/1 ) /* loops until end-of-file is reached */
41324134 {
@@ -4185,535 +4187,535 @@ do_action: /* This label is used only to access EOF actions. */ · 52 unmodified lines
41854187
41864188 case 1:
41874189 YY_RULE_SETUP
4188−#line 174 "core/chuck.lex"
4190+#line 175 "core/chuck.lex"
41894191 { char c; adjust(); comment_hack; continue; }
41904192 YY_BREAK
41914193 case 2:
41924194 YY_RULE_SETUP
4193−#line 175 "core/chuck.lex"
4195+#line 176 "core/chuck.lex"
41944196 { char c; adjust(); comment_hack; continue; }
41954197 YY_BREAK
41964198 case 3:
41974199 YY_RULE_SETUP
4198−#line 176 "core/chuck.lex"
4200+#line 177 "core/chuck.lex"
41994201 { char c, c1; adjust(); block_comment_hack; continue; }
42004202 YY_BREAK
42014203 case 4:
42024204 YY_RULE_SETUP
4203−#line 177 "core/chuck.lex"
4205+#line 178 "core/chuck.lex"
42044206 { adjust(); continue; }
42054207 YY_BREAK
42064208 case 5:
42074209 YY_RULE_SETUP
4208−#line 178 "core/chuck.lex"
4210+#line 179 "core/chuck.lex"
42094211 { adjust(); continue; }
42104212 YY_BREAK
42114213 case 6:
42124214 /* rule 6 can match eol */
42134215 YY_RULE_SETUP
4214−#line 179 "core/chuck.lex"
4216+#line 180 "core/chuck.lex"
42154217 { adjust(); EM_newline(); continue; }
42164218 YY_BREAK
42174219 case 7:
42184220 /* rule 7 can match eol */
42194221 YY_RULE_SETUP
4220−#line 180 "core/chuck.lex"
4222+#line 181 "core/chuck.lex"
42214223 { adjust(); EM_newline(); continue; }
42224224 YY_BREAK
42234225 case 8:
42244226 YY_RULE_SETUP
4225−#line 182 "core/chuck.lex"
4227+#line 183 "core/chuck.lex"
42264228 { adjust(); return PLUSPLUS; }
42274229 YY_BREAK
42284230 case 9:
42294231 YY_RULE_SETUP
4230−#line 183 "core/chuck.lex"
4232+#line 184 "core/chuck.lex"
42314233 { adjust(); return MINUSMINUS; }
42324234 YY_BREAK
42334235 case 10:
42344236 YY_RULE_SETUP
4235−#line 184 "core/chuck.lex"
4237+#line 185 "core/chuck.lex"
42364238 { adjust(); return POUNDPAREN; }
42374239 YY_BREAK
42384240 case 11:
42394241 YY_RULE_SETUP
4240−#line 185 "core/chuck.lex"
4242+#line 186 "core/chuck.lex"
42414243 { adjust(); return PERCENTPAREN; }
42424244 YY_BREAK
42434245 case 12:
42444246 YY_RULE_SETUP
4245−#line 186 "core/chuck.lex"
4247+#line 187 "core/chuck.lex"
42464248 { adjust(); return ATPAREN; }
42474249 YY_BREAK
42484250 case 13:
42494251 YY_RULE_SETUP
4250−#line 188 "core/chuck.lex"
4252+#line 189 "core/chuck.lex"
42514253 { adjust(); return COMMA; }
42524254 YY_BREAK
42534255 case 14:
42544256 YY_RULE_SETUP
4255−#line 189 "core/chuck.lex"
4257+#line 190 "core/chuck.lex"
42564258 { adjust(); return COLON; }
42574259 YY_BREAK
42584260 case 15:
42594261 YY_RULE_SETUP
4260−#line 190 "core/chuck.lex"
4262+#line 191 "core/chuck.lex"
42614263 { adjust(); return DOT; }
42624264 YY_BREAK
42634265 case 16:
42644266 YY_RULE_SETUP
4265−#line 191 "core/chuck.lex"
4267+#line 192 "core/chuck.lex"
42664268 { adjust(); return PLUS; }
42674269 YY_BREAK
42684270 case 17:
42694271 YY_RULE_SETUP
4270−#line 192 "core/chuck.lex"
4272+#line 193 "core/chuck.lex"
42714273 { adjust(); return MINUS; }
42724274 YY_BREAK
42734275 case 18:
42744276 YY_RULE_SETUP
4275−#line 193 "core/chuck.lex"
4277+#line 194 "core/chuck.lex"
42764278 { adjust(); return TIMES; }
42774279 YY_BREAK
42784280 case 19:
42794281 YY_RULE_SETUP
4280−#line 194 "core/chuck.lex"
4282+#line 195 "core/chuck.lex"
42814283 { adjust(); return DIVIDE; }
42824284 YY_BREAK
42834285 case 20:
42844286 YY_RULE_SETUP
4285−#line 195 "core/chuck.lex"
4287+#line 196 "core/chuck.lex"
42864288 { adjust(); return PERCENT; }
42874289 YY_BREAK
42884290 case 21:
42894291 YY_RULE_SETUP
4290−#line 196 "core/chuck.lex"
4292+#line 197 "core/chuck.lex"
42914293 { adjust(); return POUND; }
42924294 YY_BREAK
42934295 case 22:
42944296 YY_RULE_SETUP
4295−#line 197 "core/chuck.lex"
4297+#line 198 "core/chuck.lex"
42964298 { adjust(); return DOLLAR; }
42974299 YY_BREAK
42984300 case 23:
42994301 YY_RULE_SETUP
4300−#line 199 "core/chuck.lex"
4302+#line 200 "core/chuck.lex"
43014303 { adjust(); return COLONCOLON; }
43024304 YY_BREAK
43034305 case 24:
43044306 YY_RULE_SETUP
4305−#line 200 "core/chuck.lex"
4307+#line 201 "core/chuck.lex"
43064308 { adjust(); return EQ; }
43074309 YY_BREAK
43084310 case 25:
43094311 YY_RULE_SETUP
4310−#line 201 "core/chuck.lex"
4312+#line 202 "core/chuck.lex"
43114313 { adjust(); return NEQ; }
43124314 YY_BREAK
43134315 case 26:
43144316 YY_RULE_SETUP
4315−#line 202 "core/chuck.lex"
4317+#line 203 "core/chuck.lex"
43164318 { adjust(); return LT; }
43174319 YY_BREAK
43184320 case 27:
43194321 YY_RULE_SETUP
4320−#line 203 "core/chuck.lex"
4322+#line 204 "core/chuck.lex"
43214323 { adjust(); return GT; }
43224324 YY_BREAK
43234325 case 28:
43244326 YY_RULE_SETUP
4325−#line 204 "core/chuck.lex"
4327+#line 205 "core/chuck.lex"
43264328 { adjust(); return LE; }
43274329 YY_BREAK
43284330 case 29:
43294331 YY_RULE_SETUP
4330−#line 205 "core/chuck.lex"
4332+#line 206 "core/chuck.lex"
43314333 { adjust(); return GE; }
43324334 YY_BREAK
43334335 case 30:
43344336 YY_RULE_SETUP
4335−#line 206 "core/chuck.lex"
4337+#line 207 "core/chuck.lex"
43364338 { adjust(); return AND; }
43374339 YY_BREAK
43384340 case 31:
43394341 YY_RULE_SETUP
4340−#line 207 "core/chuck.lex"
4342+#line 208 "core/chuck.lex"
43414343 { adjust(); return OR; }
43424344 YY_BREAK
43434345 case 32:
43444346 YY_RULE_SETUP
4345−#line 208 "core/chuck.lex"
4347+#line 209 "core/chuck.lex"
43464348 { adjust(); return S_AND; }
43474349 YY_BREAK
43484350 case 33:
43494351 YY_RULE_SETUP
4350−#line 209 "core/chuck.lex"
4352+#line 210 "core/chuck.lex"
43514353 { adjust(); return S_OR; }
43524354 YY_BREAK
43534355 case 34:
43544356 YY_RULE_SETUP
4355−#line 210 "core/chuck.lex"
4357+#line 211 "core/chuck.lex"
43564358 { adjust(); return S_XOR; }
43574359 YY_BREAK
43584360 case 35:
43594361 YY_RULE_SETUP
4360−#line 211 "core/chuck.lex"
4362+#line 212 "core/chuck.lex"
43614363 { adjust(); return SHIFT_RIGHT; }
43624364 YY_BREAK
43634365 case 36:
43644366 YY_RULE_SETUP
4365−#line 212 "core/chuck.lex"
4367+#line 213 "core/chuck.lex"
43664368 { adjust(); return SHIFT_LEFT; }
43674369 YY_BREAK
43684370 case 37:
43694371 YY_RULE_SETUP
4370−#line 213 "core/chuck.lex"
4372+#line 214 "core/chuck.lex"
43714373 { adjust(); return ASSIGN; }
43724374 YY_BREAK
43734375 case 38:
43744376 YY_RULE_SETUP
4375−#line 214 "core/chuck.lex"
4377+#line 215 "core/chuck.lex"
43764378 { adjust(); return LPAREN; }
43774379 YY_BREAK
43784380 case 39:
43794381 YY_RULE_SETUP
4380−#line 215 "core/chuck.lex"
4382+#line 216 "core/chuck.lex"
43814383 { adjust(); return RPAREN; }
43824384 YY_BREAK
43834385 case 40:
43844386 YY_RULE_SETUP
4385−#line 216 "core/chuck.lex"
4387+#line 217 "core/chuck.lex"
43864388 { adjust(); return LBRACK; }
43874389 YY_BREAK
43884390 case 41:
43894391 YY_RULE_SETUP
4390−#line 217 "core/chuck.lex"
4392+#line 218 "core/chuck.lex"
43914393 { adjust(); return RBRACK; }
43924394 YY_BREAK
43934395 case 42:
43944396 YY_RULE_SETUP
4395−#line 218 "core/chuck.lex"
4397+#line 219 "core/chuck.lex"
43964398 { adjust(); return LBRACE; }
43974399 YY_BREAK
43984400 case 43:
43994401 YY_RULE_SETUP
4400−#line 219 "core/chuck.lex"
4402+#line 220 "core/chuck.lex"
44014403 { adjust(); return RBRACE; }
44024404 YY_BREAK
44034405 case 44:
44044406 YY_RULE_SETUP
4405−#line 220 "core/chuck.lex"
4407+#line 221 "core/chuck.lex"
44064408 { adjust(); return SEMICOLON; }
44074409 YY_BREAK
44084410 case 45:
44094411 YY_RULE_SETUP
4410−#line 221 "core/chuck.lex"
4412+#line 222 "core/chuck.lex"
44114413 { adjust(); return QUESTION; }
44124414 YY_BREAK
44134415 case 46:
44144416 YY_RULE_SETUP
4415−#line 222 "core/chuck.lex"
4417+#line 223 "core/chuck.lex"
44164418 { adjust(); return EXCLAMATION; }
44174419 YY_BREAK
44184420 case 47:
44194421 YY_RULE_SETUP
4420−#line 223 "core/chuck.lex"
4422+#line 224 "core/chuck.lex"
44214423 { adjust(); return TILDA; }
44224424 YY_BREAK
44234425 case 48:
44244426 YY_RULE_SETUP
4425−#line 224 "core/chuck.lex"
4427+#line 225 "core/chuck.lex"
44264428 { adjust(); return FOR; }
44274429 YY_BREAK
44284430 case 49:
44294431 YY_RULE_SETUP
4430−#line 225 "core/chuck.lex"
4432+#line 226 "core/chuck.lex"
44314433 { adjust(); return WHILE; }
44324434 YY_BREAK
44334435 case 50:
44344436 YY_RULE_SETUP
4435−#line 226 "core/chuck.lex"
4437+#line 227 "core/chuck.lex"
44364438 { adjust(); return UNTIL; }
44374439 YY_BREAK
44384440 case 51:
44394441 YY_RULE_SETUP
4440−#line 227 "core/chuck.lex"
4442+#line 228 "core/chuck.lex"
44414443 { adjust(); return LOOP; }
44424444 YY_BREAK
44434445 case 52:
44444446 YY_RULE_SETUP
4445−#line 228 "core/chuck.lex"
4447+#line 229 "core/chuck.lex"
44464448 { adjust(); return CONTINUE; }
44474449 YY_BREAK
44484450 case 53:
44494451 YY_RULE_SETUP
4450−#line 229 "core/chuck.lex"
4452+#line 230 "core/chuck.lex"
44514453 { adjust(); return BREAK; }
44524454 YY_BREAK
44534455 case 54:
44544456 YY_RULE_SETUP
4455−#line 230 "core/chuck.lex"
4457+#line 231 "core/chuck.lex"
44564458 { adjust(); return IF; }
44574459 YY_BREAK
44584460 case 55:
44594461 YY_RULE_SETUP
4460−#line 231 "core/chuck.lex"
4462+#line 232 "core/chuck.lex"
44614463 { adjust(); return ELSE; }
44624464 YY_BREAK
44634465 case 56:
44644466 YY_RULE_SETUP
4465−#line 232 "core/chuck.lex"
4467+#line 233 "core/chuck.lex"
44664468 { adjust(); return DO; }
44674469 YY_BREAK
44684470 case 57:
44694471 YY_RULE_SETUP
4470−#line 233 "core/chuck.lex"
4472+#line 234 "core/chuck.lex"
44714473 { adjust(); return L_HACK; }
44724474 YY_BREAK
44734475 case 58:
44744476 YY_RULE_SETUP
4475−#line 234 "core/chuck.lex"
4477+#line 235 "core/chuck.lex"
44764478 { adjust(); return R_HACK; }
44774479 YY_BREAK
44784480 case 59:
44794481 YY_RULE_SETUP
4480−#line 236 "core/chuck.lex"
4482+#line 237 "core/chuck.lex"
44814483 { adjust(); return RETURN; }
44824484 YY_BREAK
44834485 case 60:
44844486 YY_RULE_SETUP
4485−#line 238 "core/chuck.lex"
4487+#line 239 "core/chuck.lex"
44864488 { adjust(); return FUNCTION; }
44874489 YY_BREAK
44884490 case 61:
44894491 YY_RULE_SETUP
4490−#line 239 "core/chuck.lex"
4492+#line 240 "core/chuck.lex"
44914493 { adjust(); return FUNCTION; }
44924494 YY_BREAK
44934495 case 62:
44944496 YY_RULE_SETUP
4495−#line 240 "core/chuck.lex"
4497+#line 241 "core/chuck.lex"
44964498 { adjust(); return NEW; }
44974499 YY_BREAK
44984500 case 63:
44994501 YY_RULE_SETUP
4500−#line 241 "core/chuck.lex"
4502+#line 242 "core/chuck.lex"
45014503 { adjust(); return CLASS; }
45024504 YY_BREAK
45034505 case 64:
45044506 YY_RULE_SETUP
4505−#line 242 "core/chuck.lex"
4507+#line 243 "core/chuck.lex"
45064508 { adjust(); return INTERFACE; }
45074509 YY_BREAK
45084510 case 65:
45094511 YY_RULE_SETUP
4510−#line 243 "core/chuck.lex"
4512+#line 244 "core/chuck.lex"
45114513 { adjust(); return EXTENDS; }
45124514 YY_BREAK
45134515 case 66:
45144516 YY_RULE_SETUP
4515−#line 244 "core/chuck.lex"
4517+#line 245 "core/chuck.lex"
45164518 { adjust(); return IMPLEMENTS; }
45174519 YY_BREAK
45184520 case 67:
45194521 YY_RULE_SETUP
4520−#line 245 "core/chuck.lex"
4522+#line 246 "core/chuck.lex"
45214523 { adjust(); return PUBLIC; }
45224524 YY_BREAK
45234525 case 68:
45244526 YY_RULE_SETUP
4525−#line 246 "core/chuck.lex"
4527+#line 247 "core/chuck.lex"
45264528 { adjust(); return PROTECTED; }
45274529 YY_BREAK
45284530 case 69:
45294531 YY_RULE_SETUP
4530−#line 247 "core/chuck.lex"
4532+#line 248 "core/chuck.lex"
45314533 { adjust(); return PRIVATE; }
45324534 YY_BREAK
45334535 case 70:
45344536 YY_RULE_SETUP
4535−#line 248 "core/chuck.lex"
4537+#line 249 "core/chuck.lex"
45364538 { adjust(); return STATIC; }
45374539 YY_BREAK
45384540 case 71:
45394541 YY_RULE_SETUP
4540−#line 249 "core/chuck.lex"
4542+#line 250 "core/chuck.lex"
45414543 { adjust(); return ABSTRACT; }
45424544 YY_BREAK
45434545 case 72:
45444546 YY_RULE_SETUP
4545−#line 250 "core/chuck.lex"
4547+#line 251 "core/chuck.lex"
45464548 { adjust(); return CONST; }
45474549 YY_BREAK
45484550 case 73:
45494551 YY_RULE_SETUP
4550−#line 251 "core/chuck.lex"
4552+#line 252 "core/chuck.lex"
45514553 { adjust(); return SPORK; }
45524554 YY_BREAK
45534555 case 74:
45544556 YY_RULE_SETUP
4555−#line 252 "core/chuck.lex"
4557+#line 253 "core/chuck.lex"
45564558 { adjust(); return TYPEOF; }
45574559 YY_BREAK
45584560 case 75:
45594561 YY_RULE_SETUP
4560−#line 253 "core/chuck.lex"
4562+#line 254 "core/chuck.lex"
45614563 { adjust(); return EXTERNAL; }
45624564 YY_BREAK
45634565 case 76:
45644566 YY_RULE_SETUP
4565−#line 254 "core/chuck.lex"
4567+#line 255 "core/chuck.lex"
45664568 { adjust(); return GLOBAL; }
45674569 YY_BREAK
45684570 case 77:
45694571 YY_RULE_SETUP
4570−#line 256 "core/chuck.lex"
4572+#line 257 "core/chuck.lex"
45714573 { adjust(); return CHUCK; }
45724574 YY_BREAK
45734575 case 78:
45744576 YY_RULE_SETUP
4575−#line 257 "core/chuck.lex"
4577+#line 258 "core/chuck.lex"
45764578 { adjust(); return UNCHUCK; }
45774579 YY_BREAK
45784580 case 79:
45794581 YY_RULE_SETUP
4580−#line 258 "core/chuck.lex"
4582+#line 259 "core/chuck.lex"
45814583 { adjust(); return UNCHUCK; }
45824584 YY_BREAK
45834585 case 80:
45844586 YY_RULE_SETUP
4585−#line 259 "core/chuck.lex"
4587+#line 260 "core/chuck.lex"
45864588 { adjust(); return UPCHUCK; }
45874589 YY_BREAK
45884590 case 81:
45894591 YY_RULE_SETUP
4590−#line 260 "core/chuck.lex"
4592+#line 261 "core/chuck.lex"
45914593 { adjust(); return AT_CHUCK; }
45924594 YY_BREAK
45934595 case 82:
45944596 YY_RULE_SETUP
4595−#line 261 "core/chuck.lex"
4597+#line 262 "core/chuck.lex"
45964598 { adjust(); return PLUS_CHUCK; }
45974599 YY_BREAK
45984600 case 83:
45994601 YY_RULE_SETUP
4600−#line 262 "core/chuck.lex"
4602+#line 263 "core/chuck.lex"
46014603 { adjust(); return MINUS_CHUCK; }
46024604 YY_BREAK
46034605 case 84:
46044606 YY_RULE_SETUP
4605−#line 263 "core/chuck.lex"
4607+#line 264 "core/chuck.lex"
46064608 { adjust(); return TIMES_CHUCK; }
46074609 YY_BREAK
46084610 case 85:
46094611 YY_RULE_SETUP
4610−#line 264 "core/chuck.lex"
4612+#line 265 "core/chuck.lex"
46114613 { adjust(); return DIVIDE_CHUCK; }
46124614 YY_BREAK
46134615 case 86:
46144616 YY_RULE_SETUP
4615−#line 265 "core/chuck.lex"
4617+#line 266 "core/chuck.lex"
46164618 { adjust(); return S_AND_CHUCK; }
46174619 YY_BREAK
46184620 case 87:
46194621 YY_RULE_SETUP
4620−#line 266 "core/chuck.lex"
4622+#line 267 "core/chuck.lex"
46214623 { adjust(); return S_OR_CHUCK; }
46224624 YY_BREAK
46234625 case 88:
46244626 YY_RULE_SETUP
4625−#line 267 "core/chuck.lex"
4627+#line 268 "core/chuck.lex"
46264628 { adjust(); return S_XOR_CHUCK; }
46274629 YY_BREAK
46284630 case 89:
46294631 YY_RULE_SETUP
4630−#line 268 "core/chuck.lex"
4632+#line 269 "core/chuck.lex"
46314633 { adjust(); return SHIFT_RIGHT_CHUCK; }
46324634 YY_BREAK
46334635 case 90:
46344636 YY_RULE_SETUP
4635−#line 269 "core/chuck.lex"
4637+#line 270 "core/chuck.lex"
46364638 { adjust(); return SHIFT_LEFT_CHUCK; }
46374639 YY_BREAK
46384640 case 91:
46394641 YY_RULE_SETUP
4640−#line 270 "core/chuck.lex"
4642+#line 271 "core/chuck.lex"
46414643 { adjust(); return PERCENT_CHUCK; }
46424644 YY_BREAK
46434645 case 92:
46444646 YY_RULE_SETUP
4645−#line 271 "core/chuck.lex"
4647+#line 272 "core/chuck.lex"
46464648 { adjust(); return AT_SYM; }
46474649 YY_BREAK
46484650 case 93:
46494651 YY_RULE_SETUP
4650−#line 272 "core/chuck.lex"
4652+#line 273 "core/chuck.lex"
46514653 { adjust(); return ATAT_SYM; }
46524654 YY_BREAK
46534655 case 94:
46544656 YY_RULE_SETUP
4655−#line 273 "core/chuck.lex"
4657+#line 274 "core/chuck.lex"
46564658 { adjust(); return ARROW_RIGHT; }
46574659 YY_BREAK
46584660 case 95:
46594661 YY_RULE_SETUP
4660−#line 274 "core/chuck.lex"
4662+#line 275 "core/chuck.lex"
46614663 { adjust(); return ARROW_LEFT; }
46624664 YY_BREAK
46634665 case 96:
46644666 YY_RULE_SETUP
4665−#line 276 "core/chuck.lex"
4667+#line 277 "core/chuck.lex"
46664668 { adjust(); yylval.ival=htol(yytext); return NUM; }
46674669 YY_BREAK
46684670 case 97:
46694671 YY_RULE_SETUP
4670−#line 277 "core/chuck.lex"
4672+#line 278 "core/chuck.lex"
46714673 { adjust(); yylval.ival=atoi(yytext); return NUM; }
46724674 YY_BREAK
46734675 case 98:
46744676 YY_RULE_SETUP
4675−#line 278 "core/chuck.lex"
4677+#line 279 "core/chuck.lex"
46764678 { adjust(); yylval.ival=atoi(yytext); return NUM; }
46774679 YY_BREAK
46784680 case 99:
46794681 YY_RULE_SETUP
4680−#line 279 "core/chuck.lex"
4682+#line 280 "core/chuck.lex"
46814683 { adjust(); yylval.fval=atof(yytext); return FLOAT; }
46824684 YY_BREAK
46834685 case 100:
46844686 YY_RULE_SETUP
4685−#line 280 "core/chuck.lex"
4687+#line 281 "core/chuck.lex"
46864688 { adjust(); yylval.sval=alloc_str(yytext); return ID; }
46874689 YY_BREAK
46884690 case 101:
46894691 /* rule 101 can match eol */
46904692 YY_RULE_SETUP
4691−#line 281 "core/chuck.lex"
4693+#line 282 "core/chuck.lex"
46924694 { adjust(); yylval.sval=alloc_str(strip_lit(yytext)); return STRING_LIT; }
46934695 YY_BREAK
46944696 case 102:
46954697 /* rule 102 can match eol */
46964698 YY_RULE_SETUP
4697−#line 282 "core/chuck.lex"
4699+#line 283 "core/chuck.lex"
46984700 { adjust(); yylval.sval=alloc_str(strip_lit(yytext)); return STRING_LIT; }
46994701 YY_BREAK
47004702 case 103:
47014703 /* rule 103 can match eol */
47024704 YY_RULE_SETUP
4703−#line 283 "core/chuck.lex"
4705+#line 284 "core/chuck.lex"
47044706 { adjust(); yylval.sval=alloc_str(strip_lit(yytext)); return CHAR_LIT; }
47054707 YY_BREAK
47064708 case 104:
47074709 YY_RULE_SETUP
4708−#line 285 "core/chuck.lex"
4710+#line 286 "core/chuck.lex"
47094711 { adjust(); EM_error( EM_tokPos, "illegal token" ); }
47104712 YY_BREAK
47114713 case 105:
47124714 YY_RULE_SETUP
4713−#line 287 "core/chuck.lex"
4715+#line 288 "core/chuck.lex"
47144716 ECHO;
47154717 YY_BREAK
4716−#line 1571 "core/chuck.yy.c"
4718+#line 1572 "core/chuck.yy.c"
47174719 case YY_STATE_EOF(INITIAL):
47184720 yyterminate();
47194721
@@ -5718,7 +5720,7 @@ void yyfree (void * ptr ) · 998 unmodified lines
57185720
57195721 #define YYTABLES_NAME "yytables"
57205722
5721−#line 287 "core/chuck.lex"
5723+#line 288 "core/chuck.lex"
57225724
57235725
57245726 /*
src/core/ugen_stk.cpp+4085−4070
@@ -443,31 +443,33 @@ CK_DLL_CTRL( WvIn_ctrl_path ); · 442 unmodified lines
443443 CK_DLL_CGET( WvIn_cget_rate );
444444 CK_DLL_CGET( WvIn_cget_path );
445445
446+#ifndef __DISABLE_WVOUT__
446447 // WvOut
447−//CK_DLL_CTOR( WvOut_ctor );
448−//CK_DLL_DTOR( WvOut_dtor );
449−//CK_DLL_TICK( WvOut_tick );
450−//CK_DLL_TICKF( WvOut2_tickf );
451−//CK_DLL_PMSG( WvOut_pmsg );
452−//CK_DLL_CTRL( WvOut_ctrl_filename );
453−//CK_DLL_CTRL( WvOut_ctrl_matFilename );
454−//CK_DLL_CTRL( WvOut2_ctrl_matFilename );
455−//CK_DLL_CTRL( WvOut_ctrl_sndFilename );
456−//CK_DLL_CTRL( WvOut2_ctrl_sndFilename );
457−//CK_DLL_CTRL( WvOut_ctrl_wavFilename );
458−//CK_DLL_CTRL( WvOut2_ctrl_wavFilename );
459−//CK_DLL_CTRL( WvOut_ctrl_rawFilename );
460−//CK_DLL_CTRL( WvOut2_ctrl_rawFilename );
461−//CK_DLL_CTRL( WvOut_ctrl_aifFilename );
462−//CK_DLL_CTRL( WvOut2_ctrl_aifFilename );
463−//CK_DLL_CTRL( WvOut_ctrl_closeFile );
464−//CK_DLL_CTRL( WvOut_ctrl_record );
465−//CK_DLL_CTRL( WvOut_ctrl_autoPrefix );
466−//CK_DLL_CGET( WvOut_cget_filename );
467−//CK_DLL_CGET( WvOut_cget_record );
468−//CK_DLL_CGET( WvOut_cget_autoPrefix );
469−//CK_DLL_CTRL( WvOut_ctrl_fileGain );
470−//CK_DLL_CGET( WvOut_cget_fileGain );
448+CK_DLL_CTOR( WvOut_ctor );
449+CK_DLL_DTOR( WvOut_dtor );
450+CK_DLL_TICK( WvOut_tick );
451+CK_DLL_TICKF( WvOut2_tickf );
452+CK_DLL_PMSG( WvOut_pmsg );
453+CK_DLL_CTRL( WvOut_ctrl_filename );
454+CK_DLL_CTRL( WvOut_ctrl_matFilename );
455+CK_DLL_CTRL( WvOut2_ctrl_matFilename );
456+CK_DLL_CTRL( WvOut_ctrl_sndFilename );
457+CK_DLL_CTRL( WvOut2_ctrl_sndFilename );
458+CK_DLL_CTRL( WvOut_ctrl_wavFilename );
459+CK_DLL_CTRL( WvOut2_ctrl_wavFilename );
460+CK_DLL_CTRL( WvOut_ctrl_rawFilename );
461+CK_DLL_CTRL( WvOut2_ctrl_rawFilename );
462+CK_DLL_CTRL( WvOut_ctrl_aifFilename );
463+CK_DLL_CTRL( WvOut2_ctrl_aifFilename );
464+CK_DLL_CTRL( WvOut_ctrl_closeFile );
465+CK_DLL_CTRL( WvOut_ctrl_record );
466+CK_DLL_CTRL( WvOut_ctrl_autoPrefix );
467+CK_DLL_CGET( WvOut_cget_filename );
468+CK_DLL_CGET( WvOut_cget_record );
469+CK_DLL_CGET( WvOut_cget_autoPrefix );
470+CK_DLL_CTRL( WvOut_ctrl_fileGain );
471+CK_DLL_CGET( WvOut_cget_fileGain );
472+#endif
471473
472474
473475 // FM
@@ -4375,125 +4377,127 @@ by Perry R. Cook and Gary P. Scavone, 1995 - 2002."; · 3901 unmodified lines
43754377 // end the class import
43764378 type_engine_import_class_end( env );
43774379
4378−
4380+
4381+ #ifndef __DISABLE_WVOUT__
43794382 //------------------------------------------------------------------------
43804383 // begin WvOut ugen
43814384 //------------------------------------------------------------------------
4382−//
4383−// doc = "This class provides output support for various audio file formats. It also serves as a base class for 'realtime' streaming subclasses.\n\
4384−//\n\
4385−//WvOut writes samples to an audio file. It supports multi-channel data in interleaved format. It is important to distinguish the `tick()` methods, which output single samples to all channels in a sample frame, from the `tickFrame()` method, which takes a pointer to multi-channel sample frame data.\n\
4386−//\n\
4387−//WvOut currently supports WAV, AIFF, AIFC, SND (AU), MAT-file (Matlab), and STK RAW file formats. Signed integer (8-, 16-, and 32-bit) and floating- point (32- and 64-bit) data types are supported. STK RAW files use 16-bit integers by definition. MAT-files will always be written as 64-bit floats. If a data type specification does not match the specified file type, the data type will automatically be modified. Uncompressed data types are not supported.\n\
4388−//\n\
4389−//Currently, WvOut is non-interpolating and the output rate is always `Stk::sampleRate()`.\n\
4390−//\n\
4391−//by Perry R. Cook and Gary P. Scavone, 1995 - 2002.";
4392−//
4393−// if( !type_engine_import_ugen_begin( env, "WvOut", "UGen", env->global(),
4394−// WvOut_ctor, WvOut_dtor,
4395−// WvOut_tick, WvOut_pmsg, doc.c_str() ) ) return FALSE;
4396−//
4397−// //member variable
4398−// WvOut_offset_data = type_engine_import_mvar ( env, "int", "@WvOut_data", FALSE );
4399−// if( WvOut_offset_data == CK_INVALID_OFFSET ) goto error;
4400−//
4401−// func = make_new_mfun( "string", "matFilename", WvOut_ctrl_matFilename ); //!open matlab file for writing
4402−// func->add_arg( "string", "value" );
4403−// func->doc = "Open MatLab file for writing.";
4404−// if( !type_engine_import_mfun( env, func ) ) goto error;
4405−//
4406−// func = make_new_mfun( "string", "sndFilename", WvOut_ctrl_sndFilename ); //!open snd file for writing
4407−// func->add_arg( "string", "value" );
4408−// func->doc = "Open SND file for writing.";
4409−// if( !type_engine_import_mfun( env, func ) ) goto error;
4410−//
4411−// func = make_new_mfun( "string", "wavFilename", WvOut_ctrl_wavFilename ); //!open WAVE file for writing
4412−// func->add_arg( "string", "value" );
4413−// func->doc = "Open WAVE file for writing.";
4414−// if( !type_engine_import_mfun( env, func ) ) goto error;
4415−//
4416−// func = make_new_mfun( "string", "rawFilename", WvOut_ctrl_rawFilename ); //!open raw file for writing
4417−// func->add_arg( "string", "value" );
4418−// func->doc = "Open a raw file for writing.";
4419−// if( !type_engine_import_mfun( env, func ) ) goto error;
4420−//
4421−// func = make_new_mfun( "string", "aifFilename", WvOut_ctrl_aifFilename ); //!open AIFF file for writing
4422−// func->add_arg( "string", "value" );
4423−// func->doc = "Open an AIFF file for writing.";
4424−// if( !type_engine_import_mfun( env, func ) ) goto error;
4425−//
4426−// func = make_new_mfun( "string", "filename", WvOut_cget_filename ); //!get filename
4427−// func->doc = "Get filename.";
4428−// if( !type_engine_import_mfun( env, func ) ) goto error;
4429−//
4430−// func = make_new_mfun( "int", "record", WvOut_ctrl_record ); // !start/stop output
4431−// func->add_arg( "int", "value" );
4432−// func->doc = "Start/stop output.";
4433−// if( !type_engine_import_mfun( env, func ) ) goto error;
4434−//
4435−// func = make_new_mfun( "int", "record", WvOut_cget_record ); // !start/stop output
4436−// func->doc = "Start/stop output.";
4437−// if( !type_engine_import_mfun( env, func ) ) goto error;
4438−//
4439−// func = make_new_mfun( "string", "closeFile", WvOut_ctrl_closeFile ); //! close file properly
4440−// func->add_arg( "string", "value" );
4441−// func->doc = "Close the file properly.";
4442−// if( !type_engine_import_mfun( env, func ) ) goto error;
4443−//
4444−// func = make_new_mfun( "string", "closeFile", WvOut_ctrl_closeFile ); //! close file properly
4445−// func->doc = "Close the file properly.";
4446−// if( !type_engine_import_mfun( env, func ) ) goto error;
4447−//
4448−// func = make_new_mfun( "string", "autoPrefix", WvOut_ctrl_autoPrefix ); //! set/get auto prefix string
4449−// func->add_arg( "string", "value" );
4450−// func->doc = "Set auto prefix string.";
4451−// if( !type_engine_import_mfun( env, func ) ) goto error;
4452−//
4453−// func = make_new_mfun( "string", "autoPrefix", WvOut_cget_autoPrefix ); //! set/get auto prefix string
4454−// func->doc = "Get auto prefix string.";
4455−// if( !type_engine_import_mfun( env, func ) ) goto error;
4456−//
4457−// func = make_new_mfun( "float", "fileGain", WvOut_ctrl_fileGain ); //! set/get auto prefix string
4458−// func->add_arg( "float", "value" );
4459−// func->doc = "Set file gain.";
4460−// if( !type_engine_import_mfun( env, func ) ) goto error;
4461−//
4462−// func = make_new_mfun( "float", "fileGain", WvOut_cget_fileGain ); //! set/get auto prefix string
4463−// func->doc = "Get file gain.";
4464−// if( !type_engine_import_mfun( env, func ) ) goto error;
4465−//
4466−// // end the class import
4467−// type_engine_import_class_end( env );
4468−//
4469−//
4470−// if( !type_engine_import_ugen_begin( env, "WvOut2", "WvOut", env->global(),
4471−// NULL, NULL,
4472−// NULL, WvOut2_tickf, WvOut_pmsg, 2, 2 ) ) return FALSE;
4473−//
4474−// func = make_new_mfun( "string", "matFilename", WvOut2_ctrl_matFilename ); //!open matlab file for writing
4475−// func->add_arg( "string", "value" );
4476−// if( !type_engine_import_mfun( env, func ) ) goto error;
4477−//
4478−// func = make_new_mfun( "string", "sndFilename", WvOut2_ctrl_sndFilename ); //!open snd file for writing
4479−// func->add_arg( "string", "value" );
4480−// if( !type_engine_import_mfun( env, func ) ) goto error;
4481−//
4482−// func = make_new_mfun( "string", "wavFilename", WvOut2_ctrl_wavFilename ); //!open WAVE file for writing
4483−// func->add_arg( "string", "value" );
4484−// if( !type_engine_import_mfun( env, func ) ) goto error;
4485−//
4486−// func = make_new_mfun( "string", "rawFilename", WvOut2_ctrl_rawFilename ); //!open raw file for writing
4487−// func->add_arg( "string", "value" );
4488−// if( !type_engine_import_mfun( env, func ) ) goto error;
4489−//
4490−// func = make_new_mfun( "string", "aifFilename", WvOut2_ctrl_aifFilename ); //!open AIFF file for writing
4491−// func->add_arg( "string", "value" );
4492−// if( !type_engine_import_mfun( env, func ) ) goto error;
4493−//
4494−// // end the class import
4495−// type_engine_import_class_end( env );
4385+
4386+ doc = "This class provides output support for various audio file formats. It also serves as a base class for 'realtime' streaming subclasses.\n\
4387+\n\
4388+WvOut writes samples to an audio file. It supports multi-channel data in interleaved format. It is important to distinguish the `tick()` methods, which output single samples to all channels in a sample frame, from the `tickFrame()` method, which takes a pointer to multi-channel sample frame data.\n\
4389+\n\
4390+WvOut currently supports WAV, AIFF, AIFC, SND (AU), MAT-file (Matlab), and STK RAW file formats. Signed integer (8-, 16-, and 32-bit) and floating- point (32- and 64-bit) data types are supported. STK RAW files use 16-bit integers by definition. MAT-files will always be written as 64-bit floats. If a data type specification does not match the specified file type, the data type will automatically be modified. Uncompressed data types are not supported.\n\
4391+\n\
4392+Currently, WvOut is non-interpolating and the output rate is always `Stk::sampleRate()`.\n\
4393+\n\
4394+by Perry R. Cook and Gary P. Scavone, 1995 - 2002.";
4395+
4396+ if( !type_engine_import_ugen_begin( env, "WvOut", "UGen", env->global(),
4397+ WvOut_ctor, WvOut_dtor,
4398+ WvOut_tick, WvOut_pmsg, doc.c_str() ) ) return FALSE;
4399+
4400+ //member variable
4401+ WvOut_offset_data = type_engine_import_mvar ( env, "int", "@WvOut_data", FALSE );
4402+ if( WvOut_offset_data == CK_INVALID_OFFSET ) goto error;
4403+
4404+ func = make_new_mfun( "string", "matFilename", WvOut_ctrl_matFilename ); //!open matlab file for writing
4405+ func->add_arg( "string", "value" );
4406+ func->doc = "Open MatLab file for writing.";
4407+ if( !type_engine_import_mfun( env, func ) ) goto error;
4408+
4409+ func = make_new_mfun( "string", "sndFilename", WvOut_ctrl_sndFilename ); //!open snd file for writing
4410+ func->add_arg( "string", "value" );
4411+ func->doc = "Open SND file for writing.";
4412+ if( !type_engine_import_mfun( env, func ) ) goto error;
4413+
4414+ func = make_new_mfun( "string", "wavFilename", WvOut_ctrl_wavFilename ); //!open WAVE file for writing
4415+ func->add_arg( "string", "value" );
4416+ func->doc = "Open WAVE file for writing.";
4417+ if( !type_engine_import_mfun( env, func ) ) goto error;
4418+
4419+ func = make_new_mfun( "string", "rawFilename", WvOut_ctrl_rawFilename ); //!open raw file for writing
4420+ func->add_arg( "string", "value" );
4421+ func->doc = "Open a raw file for writing.";
4422+ if( !type_engine_import_mfun( env, func ) ) goto error;
4423+
4424+ func = make_new_mfun( "string", "aifFilename", WvOut_ctrl_aifFilename ); //!open AIFF file for writing
4425+ func->add_arg( "string", "value" );
4426+ func->doc = "Open an AIFF file for writing.";
4427+ if( !type_engine_import_mfun( env, func ) ) goto error;
4428+
4429+ func = make_new_mfun( "string", "filename", WvOut_cget_filename ); //!get filename
4430+ func->doc = "Get filename.";
4431+ if( !type_engine_import_mfun( env, func ) ) goto error;
4432+
4433+ func = make_new_mfun( "int", "record", WvOut_ctrl_record ); // !start/stop output
4434+ func->add_arg( "int", "value" );
4435+ func->doc = "Start/stop output.";
4436+ if( !type_engine_import_mfun( env, func ) ) goto error;
4437+
4438+ func = make_new_mfun( "int", "record", WvOut_cget_record ); // !start/stop output
4439+ func->doc = "Start/stop output.";
4440+ if( !type_engine_import_mfun( env, func ) ) goto error;
4441+
4442+ func = make_new_mfun( "string", "closeFile", WvOut_ctrl_closeFile ); //! close file properly
4443+ func->add_arg( "string", "value" );
4444+ func->doc = "Close the file properly.";
4445+ if( !type_engine_import_mfun( env, func ) ) goto error;
4446+
4447+ func = make_new_mfun( "string", "closeFile", WvOut_ctrl_closeFile ); //! close file properly
4448+ func->doc = "Close the file properly.";
4449+ if( !type_engine_import_mfun( env, func ) ) goto error;
4450+
4451+ func = make_new_mfun( "string", "autoPrefix", WvOut_ctrl_autoPrefix ); //! set/get auto prefix string
4452+ func->add_arg( "string", "value" );
4453+ func->doc = "Set auto prefix string.";
4454+ if( !type_engine_import_mfun( env, func ) ) goto error;
4455+
4456+ func = make_new_mfun( "string", "autoPrefix", WvOut_cget_autoPrefix ); //! set/get auto prefix string
4457+ func->doc = "Get auto prefix string.";
4458+ if( !type_engine_import_mfun( env, func ) ) goto error;
4459+
4460+ func = make_new_mfun( "float", "fileGain", WvOut_ctrl_fileGain ); //! set/get auto prefix string
4461+ func->add_arg( "float", "value" );
4462+ func->doc = "Set file gain.";
4463+ if( !type_engine_import_mfun( env, func ) ) goto error;
4464+
4465+ func = make_new_mfun( "float", "fileGain", WvOut_cget_fileGain ); //! set/get auto prefix string
4466+ func->doc = "Get file gain.";
4467+ if( !type_engine_import_mfun( env, func ) ) goto error;
4468+
4469+ // end the class import
4470+ type_engine_import_class_end( env );
44964471
4472+
4473+ if( !type_engine_import_ugen_begin( env, "WvOut2", "WvOut", env->global(),
4474+ NULL, NULL,
4475+ NULL, WvOut2_tickf, WvOut_pmsg, 2, 2 ) ) return FALSE;
4476+
4477+ func = make_new_mfun( "string", "matFilename", WvOut2_ctrl_matFilename ); //!open matlab file for writing
4478+ func->add_arg( "string", "value" );
4479+ if( !type_engine_import_mfun( env, func ) ) goto error;
4480+
4481+ func = make_new_mfun( "string", "sndFilename", WvOut2_ctrl_sndFilename ); //!open snd file for writing
4482+ func->add_arg( "string", "value" );
4483+ if( !type_engine_import_mfun( env, func ) ) goto error;
4484+
4485+ func = make_new_mfun( "string", "wavFilename", WvOut2_ctrl_wavFilename ); //!open WAVE file for writing
4486+ func->add_arg( "string", "value" );
4487+ if( !type_engine_import_mfun( env, func ) ) goto error;
4488+
4489+ func = make_new_mfun( "string", "rawFilename", WvOut2_ctrl_rawFilename ); //!open raw file for writing
4490+ func->add_arg( "string", "value" );
4491+ if( !type_engine_import_mfun( env, func ) ) goto error;
4492+
4493+ func = make_new_mfun( "string", "aifFilename", WvOut2_ctrl_aifFilename ); //!open AIFF file for writing
4494+ func->add_arg( "string", "value" );
4495+ if( !type_engine_import_mfun( env, func ) ) goto error;
4496+
4497+ // end the class import
4498+ type_engine_import_class_end( env );
4499+ #endif //__DISABLE_WVOUT__
4500+
44974501
44984502 //------------------------------------------------------------------------
44994503 // begin BLT (BandLtd)
@@ -17820,11 +17824,13 @@ MY_FLOAT *WvIn :: tickFrame(MY_FLOAT *frameVector, unsigned int frames) · 13320 unmodified lines
1782017824 /***************************************************/
1782117825
1782217826
17823−//const WvOut::FILE_TYPE WvOut :: WVOUT_RAW = 1;
17824−//const WvOut::FILE_TYPE WvOut :: WVOUT_WAV = 2;
17825−//const WvOut::FILE_TYPE WvOut :: WVOUT_SND = 3;
17826−//const WvOut::FILE_TYPE WvOut :: WVOUT_AIF = 4;
17827−//const WvOut::FILE_TYPE WvOut :: WVOUT_MAT = 5;
17827+#ifndef __DISABLE_WVOUT__
17828+const WvOut::FILE_TYPE WvOut :: WVOUT_RAW = 1;
17829+const WvOut::FILE_TYPE WvOut :: WVOUT_WAV = 2;
17830+const WvOut::FILE_TYPE WvOut :: WVOUT_SND = 3;
17831+const WvOut::FILE_TYPE WvOut :: WVOUT_AIF = 4;
17832+const WvOut::FILE_TYPE WvOut :: WVOUT_MAT = 5;
17833+#endif
1782817834
1782917835 // WAV header structure. See ftp://ftp.isi.edu/in-notes/rfc2361.txt
1783017836 // for information regarding format codes.
@@ -17884,811 +17890,815 @@ struct mathdr { · 53 unmodified lines
1788417890 // There's more, but it's of variable length
1788517891 };
1788617892
17887−//size_t WvOut::fwrite(const void * ptr, size_t size, size_t nitems, FILE * stream)
17888−//{
17889−// if(asyncIO)
17890−// return asyncWriteThread->fwrite(ptr, size, nitems, stream);
17891−// else
17892−// return ::fwrite(ptr, size, nitems, stream);
17893−//}
17894−//
17895−//int WvOut::fseek(FILE *stream, long offset, int whence)
17896−//{
17897−// if(asyncIO)
17898−// return asyncWriteThread->fseek(stream, offset, whence);
17899−// else
17900−// return ::fseek(stream, offset, whence);
17901−//}
17902−//
17903−//int WvOut::fflush(FILE *stream)
17904−//{
17905−// if(asyncIO)
17906−// return asyncWriteThread->fflush(stream);
17907−// else
17908−// return ::fflush(stream);
17909−//}
17910−//
17911−//int WvOut::fclose(FILE *stream)
17912−//{
17913−// if(asyncIO)
17914−// return asyncWriteThread->fclose(stream);
17915−// else
17916−// return ::fclose(stream);
17917−//}
17918−//
17919−//size_t WvOut::fread(void *ptr, size_t size, size_t nitems, FILE *stream)
17920−//{
17921−// // can't read asynchronously (yet)
17922−// assert(0);
17923−// return 0;
17924−//}
17925−//
17926−//WvOut :: WvOut()
17927−//{
17928−// init();
17929−//}
17930−//
17931−//WvOut::WvOut( const char *fileName, unsigned int nChannels, FILE_TYPE type, Stk::STK_FORMAT format )
17932−//{
17933−// init();
17934−// openFile( fileName, nChannels, type, format );
17935−//}
17936−//
17937−//WvOut :: ~WvOut()
17938−//{
17939−// closeFile();
17940−//
17941−// if (data)
17942−// delete [] data;
17943−//}
17944−//
17945−//void WvOut :: init()
17946−//{
17947−// fd = 0;
17948−// data = 0;
17949−// fileType = 0;
17950−// dataType = 0;
17951−// channels = 0;
17952−// counter = 0;
17953−// totalCount = 0;
17954−// //m_filename[0] = '\0';
17955−// start = TRUE;
17956−// flush = 0;
17957−// fileGain = 1;
17958−//
17959−// // spencer: added as flag for off-thread write
17960−// asyncIO = FALSE;
17961−// asyncWriteThread = NULL;
17962−//}
17963−//
17964−//void WvOut :: closeFile( void )
17965−//{
17966−// if( fd ) {
17967−// // If there's an existing file, close it first.
17968−// writeData( counter );
17969−//
17970−// if ( fileType == WVOUT_RAW )
17971−// fclose( fd );
17972−// else if ( fileType == WVOUT_WAV )
17973−// closeWavFile();
17974−// else if ( fileType == WVOUT_SND )
17975−// closeSndFile();
17976−// else if ( fileType == WVOUT_AIF )
17977−// closeAifFile();
17978−// else if ( fileType == WVOUT_MAT )
17979−// closeMatFile();
17980−// fd = 0;
17981−//
17982−// // printf("%f Seconds Computed\n\n", getTime() );
17983−// totalCount = 0;
17984−// }
17985−//
17986−// str_filename.set( "" );
17987−// //m_filename[0] = '\0';
17988−//}
17989−//
17990−//void WvOut :: openFile( const char *fileName, unsigned int nChannels, WvOut::FILE_TYPE type, Stk::STK_FORMAT format )
17991−//{
17992−// closeFile();
17993−// str_filename.set( fileName );
17994−// //strncpy( m_filename, fileName, 255);
17995−// //if ( strlen( fileName ) > 255 )
17996−// // m_filename[255] = '\0';
17997−//
17998−// if ( nChannels < 1 ) {
17999−// sprintf(msg, "[chuck](via WvOut): the channels argument must be greater than zero!");
18000−// handleError( msg, StkError::FUNCTION_ARGUMENT );
18001−// }
18002−//
18003−// unsigned int lastChannels = channels;
18004−// channels = nChannels;
18005−// fileType = type;
18006−//
18007−// if ( format != STK_SINT8 && format != STK_SINT16 &&
18008−// format != STK_SINT32 && format != MY_FLOAT32 &&
18009−// format != MY_FLOAT64 ) {
18010−// sprintf( msg, "[chuck](via WvOut): Unknown data type specified (%ld).", format );
18011−// handleError(msg, StkError::FUNCTION_ARGUMENT);
18012−// }
18013−// dataType = format;
18014−//
18015−// bool result = false;
18016−// if ( fileType == WVOUT_RAW ) {
18017−// if ( channels != 1 ) {
18018−// sprintf(msg, "[chuck](via WvOut): STK RAW files are, by definition, always monaural (channels = %d not supported)!", nChannels);
18019−// handleError( msg, StkError::FUNCTION_ARGUMENT );
18020−// }
18021−// result = setRawFile( fileName );
18022−// }
18023−// else if ( fileType == WVOUT_WAV )
18024−// result = setWavFile( fileName );
18025−// else if ( fileType == WVOUT_SND )
18026−// result = setSndFile( fileName );
18027−// else if ( fileType == WVOUT_AIF )
18028−// result = setAifFile( fileName );
18029−// else if ( fileType == WVOUT_MAT )
18030−// result = setMatFile( fileName );
18031−// else {
18032−// sprintf(msg, "[chuck](via WvOut): Unknown file type specified (%ld).", fileType);
18033−// handleError(msg, StkError::FUNCTION_ARGUMENT);
18034−// }
18035−//
18036−// if ( result == false )
18037−// {
18038−// //closeFile();
18039−// handleError(msg, StkError::FILE_ERROR);
18040−// // handleError( msg, StkError::WARNING );
18041−// // return;
18042−// }
18043−//
18044−// // Allocate new memory if necessary.
18045−// if ( lastChannels < channels ) {
18046−// if ( data ) delete [] data;
18047−// data = (MY_FLOAT *) new MY_FLOAT[BUFFER_SIZE*channels];
18048−// }
18049−// counter = 0;
18050−//}
18051−//
18052−//bool WvOut :: setRawFile( const char *fileName )
18053−//{
18054−// char name[128];
18055−// strncpy(name, fileName, 128);
18056−// if ( strstr(name, ".raw") == NULL) strcat(name, ".raw");
18057−// fd = fopen(name, "wb");
18058−// if ( !fd ) {
18059−// sprintf(msg, "[chuck](via WvOut): Could not create RAW file: %s", name);
18060−// return false;
18061−// }
18062−//
18063−// if ( dataType != STK_SINT16 ) {
18064−// dataType = STK_SINT16;
18065−// sprintf(msg, "[chuck](via WvOut): Using 16-bit signed integer data format for file %s.", name);
18066−// handleError(msg, StkError::WARNING);
18067−// }
18068−//
18069−// byteswap = false;
18070−// if( little_endian )
18071−// byteswap = true;
18072−//
18073−// // printf("\nCreating RAW file: %s\n", name);
18074−// return true;
18075−//}
18076−//
18077−//bool WvOut :: setWavFile( const char *fileName )
18078−//{
18079−// char name[128];
18080−// strncpy(name, fileName, 128);
18081−// if( strstr(name, ".wav") == NULL ) strcat(name, ".wav");
18082−// fd = fopen( name, "wb" );
18083−// if( !fd ) {
18084−// sprintf(msg, "[chuck](via WvOut): Could not create WAV file: %s", name);
18085−// return false;
18086−// }
18087−//
18088−// struct wavhdr hdr = {"RIF", 44, "WAV", "fmt", 16, 1, 1,
18089−// (SINT32) Stk::sampleRate(), 0, 2, 16, "dat", 0};
18090−// hdr.riff[3] = 'F';
18091−// hdr.wave[3] = 'E';
18092−// hdr.fmt[3] = ' ';
18093−// hdr.data[3] = 'a';
18094−// hdr.num_chans = (SINT16) channels;
18095−// if ( dataType == STK_SINT8 )
18096−// hdr.bits_per_samp = 8;
18097−// else if ( dataType == STK_SINT16 )
18098−// hdr.bits_per_samp = 16;
18099−// else if ( dataType == STK_SINT32 )
18100−// hdr.bits_per_samp = 32;
18101−// else if ( dataType == MY_FLOAT32 ) {
18102−// hdr.format_tag = 3;
18103−// hdr.bits_per_samp = 32;
18104−// }
18105−// else if ( dataType == MY_FLOAT64 ) {
18106−// hdr.format_tag = 3;
18107−// hdr.bits_per_samp = 64;
18108−// }
18109−// hdr.bytes_per_samp = (SINT16) (channels * hdr.bits_per_samp / 8);
18110−// hdr.bytes_per_sec = (SINT32) (hdr.sample_rate * hdr.bytes_per_samp);
18111−//
18112−// byteswap = false;
18113−// if( !little_endian )
18114−// {
18115−// byteswap = true;
18116−// swap32((unsigned char *)&hdr.file_size);
18117−// swap32((unsigned char *)&hdr.chunk_size);
18118−// swap16((unsigned char *)&hdr.format_tag);
18119−// swap16((unsigned char *)&hdr.num_chans);
18120−// swap32((unsigned char *)&hdr.sample_rate);
18121−// swap32((unsigned char *)&hdr.bytes_per_sec);
18122−// swap16((unsigned char *)&hdr.bytes_per_samp);
18123−// swap16((unsigned char *)&hdr.bits_per_samp);
18124−// }
18125−//
18126−// if ( fwrite(&hdr, 4, 11, fd) != 11 ) {
18127−// sprintf(msg, "[chuck](via WvOut): Could not write WAV header for file %s", name);
18128−// return false;
18129−// }
18130−//
18131−// // printf("\nCreating WAV file: %s\n", name);
18132−// return true;
18133−//}
18134−//
18135−//void WvOut :: closeWavFile( void )
18136−//{
18137−// int bytes_per_sample = 1;
18138−// if ( dataType == STK_SINT16 )
18139−// bytes_per_sample = 2;
18140−// else if ( dataType == STK_SINT32 || dataType == MY_FLOAT32 )
18141−// bytes_per_sample = 4;
18142−// else if ( dataType == MY_FLOAT64 )
18143−// bytes_per_sample = 8;
18144−//
18145−// SINT32 bytes = totalCount * channels * bytes_per_sample;
18146−//if( !little_endian )
18147−// swap32((unsigned char *)&bytes);
18148−//
18149−// fseek(fd, 40, SEEK_SET); // jump to data length
18150−// fwrite(&bytes, 4, 1, fd);
18151−//
18152−// bytes = totalCount * channels * bytes_per_sample + 44;
18153−//if( !little_endian )
18154−// swap32((unsigned char *)&bytes);
18155−//
18156−// fseek(fd, 4, SEEK_SET); // jump to file size
18157−// fwrite(&bytes, 4, 1, fd);
18158−// fclose( fd );
18159−//}
18160−//
18161−//bool WvOut :: setSndFile( const char *fileName )
18162−//{
18163−// char name[128];
18164−// strncpy(name, fileName, 128);
18165−// if ( strstr(name, ".snd") == NULL) strcat(name, ".snd");
18166−// fd = fopen(name, "wb");
18167−// if ( !fd ) {
18168−// sprintf(msg, "[chuck](via WvOut): Could not create SND file: %s", name);
18169−// return false;
18170−// }
18171−//
18172−// struct sndhdr hdr = {".sn", 40, 0, 3, (SINT32) Stk::sampleRate(), 1, "Created by STK"};
18173−// hdr.pref[3] = 'd';
18174−// hdr.num_channels = channels;
18175−// if ( dataType == STK_SINT8 )
18176−// hdr.format = 2;
18177−// else if ( dataType == STK_SINT16 )
18178−// hdr.format = 3;
18179−// else if ( dataType == STK_SINT32 )
18180−// hdr.format = 5;
18181−// else if ( dataType == MY_FLOAT32 )
18182−// hdr.format = 6;
18183−// else if ( dataType == MY_FLOAT64 )
18184−// hdr.format = 7;
18185−//
18186−// byteswap = false;
18187−//if( little_endian )
18188−//{
18189−// byteswap = true;
18190−// swap32 ((unsigned char *)&hdr.hdr_length);
18191−// swap32 ((unsigned char *)&hdr.format);
18192−// swap32 ((unsigned char *)&hdr.sample_rate);
18193−// swap32 ((unsigned char *)&hdr.num_channels);
18194−//}
18195−//
18196−// if ( fwrite(&hdr, 4, 10, fd) != 10 ) {
18197−// sprintf(msg, "[chuck](via WvOut): Could not write SND header for file %s", name);
18198−// return false;
18199−// }
18200−//
18201−// // printf("\nCreating SND file: %s\n", name);
18202−// return true;
18203−//}
18204−//
18205−//void WvOut :: closeSndFile( void )
18206−//{
18207−// int bytes_per_sample = 1;
18208−// if ( dataType == STK_SINT16 )
18209−// bytes_per_sample = 2;
18210−// else if ( dataType == STK_SINT32 )
18211−// bytes_per_sample = 4;
18212−// else if ( dataType == MY_FLOAT32 )
18213−// bytes_per_sample = 4;
18214−// else if ( dataType == MY_FLOAT64 )
18215−// bytes_per_sample = 8;
18216−//
18217−// SINT32 bytes = totalCount * bytes_per_sample * channels;
18218−//if( little_endian )
18219−// swap32 ((unsigned char *)&bytes);
18220−//
18221−// fseek(fd, 8, SEEK_SET); // jump to data size
18222−// fwrite(&bytes, 4, 1, fd);
18223−// fclose(fd);
18224−//}
18225−//
18226−//bool WvOut :: setAifFile( const char *fileName )
18227−//{
18228−// char name[128];
18229−// strncpy(name, fileName, 128);
18230−// if ( strstr(name, ".aif") == NULL) strcat(name, ".aif");
18231−// fd = fopen(name, "wb");
18232−// if ( !fd ) {
18233−// sprintf(msg, "[chuck](via WvOut): Could not create AIF file: %s", name);
18234−// return false;
18235−// }
18236−//
18237−// // Common parts of AIFF/AIFC header.
18238−// struct aifhdr hdr = {"FOR", 46, "AIF", "COM", 18, 0, 0, 16, "0"};
18239−// struct aifssnd ssnd = {"SSN", 8, 0, 0};
18240−// hdr.form[3] = 'M';
18241−// hdr.aiff[3] = 'F';
18242−// hdr.comm[3] = 'M';
18243−// ssnd.ssnd[3] = 'D';
18244−// hdr.num_chans = channels;
18245−// if ( dataType == STK_SINT8 )
18246−// hdr.sample_size = 8;
18247−// else if ( dataType == STK_SINT16 )
18248−// hdr.sample_size = 16;
18249−// else if ( dataType == STK_SINT32 )
18250−// hdr.sample_size = 32;
18251−// else if ( dataType == MY_FLOAT32 ) {
18252−// hdr.aiff[3] = 'C';
18253−// hdr.sample_size = 32;
18254−// hdr.comm_size = 24;
18255−// }
18256−// else if ( dataType == MY_FLOAT64 ) {
18257−// hdr.aiff[3] = 'C';
18258−// hdr.sample_size = 64;
18259−// hdr.comm_size = 24;
18260−// }
18261−//
18262−// // For AIFF files, the sample rate is stored in a 10-byte,
18263−// // IEEE Standard 754 floating point number, so we need to
18264−// // convert to that.
18265−// SINT16 i;
18266−// unsigned long exp;
18267−// unsigned long rate = (unsigned long) Stk::sampleRate();
18268−// memset(hdr.srate, 0, 10);
18269−// exp = rate;
18270−// for (i=0; i<32; i++) {
18271−// exp >>= 1;
18272−// if (!exp) break;
18273−// }
18274−// i += 16383;
18275−//if( little_endian )
18276−// swap16((unsigned char *)&i);
18277−//
18278−// *(SINT16 *)(hdr.srate) = (SINT16) i;
18279−//
18280−// for (i=32; i; i--) {
18281−// if (rate & 0x80000000) break;
18282−// rate <<= 1;
18283−// }
18284−//
18285−//if( little_endian )
18286−// swap32((unsigned char *)&rate);
18287−//
18288−// *(unsigned long *)(hdr.srate+2) = (unsigned long) rate;
18289−//
18290−// byteswap = false;
18291−//if( little_endian )
18292−//{
18293−// byteswap = true;
18294−// swap32((unsigned char *)&hdr.form_size);
18295−// swap32((unsigned char *)&hdr.comm_size);
18296−// swap16((unsigned char *)&hdr.num_chans);
18297−// swap16((unsigned char *)&hdr.sample_size);
18298−// swap32((unsigned char *)&ssnd.ssnd_size);
18299−// swap32((unsigned char *)&ssnd.offset);
18300−// swap32((unsigned char *)&ssnd.block_size);
18301−//}
18302−//
18303−// // The structure boundaries don't allow a single write of 54 bytes.
18304−// if ( fwrite(&hdr, 4, 5, fd) != 5 ) goto error;
18305−// if ( fwrite(&hdr.num_chans, 2, 1, fd) != 1 ) goto error;
18306−// if ( fwrite(&hdr.sample_frames, 4, 1, fd) != 1 ) goto error;
18307−// if ( fwrite(&hdr.sample_size, 2, 1, fd) != 1 ) goto error;
18308−// if ( fwrite(&hdr.srate, 10, 1, fd) != 1 ) goto error;
18309−//
18310−// if ( dataType == MY_FLOAT32 ) {
18311−// char type[4] = {'f','l','3','2'};
18312−// char zeroes[2] = { 0, 0 };
18313−// if ( fwrite(&type, 4, 1, fd) != 1 ) goto error;
18314−// if ( fwrite(&zeroes, 2, 1, fd) != 1 ) goto error;
18315−// }
18316−// else if ( dataType == MY_FLOAT64 ) {
18317−// char type[4] = {'f','l','6','4'};
18318−// char zeroes[2] = { 0, 0 };
18319−// if ( fwrite(&type, 4, 1, fd) != 1 ) goto error;
18320−// if ( fwrite(&zeroes, 2, 1, fd) != 1 ) goto error;
18321−// }
18322−//
18323−// if ( fwrite(&ssnd, 4, 4, fd) != 4 ) goto error;
18324−//
18325−// // printf("\nCreating AIF file: %s\n", name);
18326−// return true;
18327−//
18328−// error:
18329−// sprintf(msg, "[chuck](via WvOut): Could not write AIF header for file %s", name);
18330−// return false;
18331−//}
18332−//
18333−//void WvOut :: closeAifFile( void )
18334−//{
18335−// unsigned long frames = (unsigned long) totalCount;
18336−//if( little_endian )
18337−// swap32((unsigned char *)&frames);
18338−//
18339−// fseek(fd, 22, SEEK_SET); // jump to "COMM" sample_frames
18340−// fwrite(&frames, 4, 1, fd);
18341−//
18342−// int bytes_per_sample = 1;
18343−// if ( dataType == STK_SINT16 )
18344−// bytes_per_sample = 2;
18345−// else if ( dataType == STK_SINT32 || dataType == MY_FLOAT32 )
18346−// bytes_per_sample = 4;
18347−// else if ( dataType == MY_FLOAT64 )
18348−// bytes_per_sample = 8;
18349−//
18350−// unsigned long bytes = totalCount * bytes_per_sample * channels + 46;
18351−// if ( dataType == MY_FLOAT32 || dataType == MY_FLOAT64 ) bytes += 6;
18352−//if( little_endian )
18353−// swap32((unsigned char *)&bytes);
18354−//
18355−// fseek(fd, 4, SEEK_SET); // jump to file size
18356−// fwrite(&bytes, 4, 1, fd);
18357−//
18358−// bytes = totalCount * bytes_per_sample * channels + 8;
18359−// if ( dataType == MY_FLOAT32 || dataType == MY_FLOAT64 ) bytes += 6;
18360−//if( little_endian )
18361−// swap32((unsigned char *)&bytes);
18362−//
18363−// if ( dataType == MY_FLOAT32 || dataType == MY_FLOAT64 )
18364−// fseek(fd, 48, SEEK_SET); // jump to "SSND" chunk size
18365−// else
18366−// fseek(fd, 42, SEEK_SET); // jump to "SSND" chunk size
18367−// fwrite(&bytes, 4, 1, fd);
18368−//
18369−// fclose( fd );
18370−//}
18371−//
18372−//bool WvOut :: setMatFile( const char *fileName )
18373−//{
18374−// char name[128];
18375−// strncpy(name, fileName, 128);
18376−// if ( strstr(name, ".mat") == NULL) strcat(name, ".mat");
18377−// fd = fopen(name, "w+b");
18378−// if ( !fd ) {
18379−// sprintf(msg, "[chuck](via WvOut): Could not create MAT file: %s", name);
18380−// return false;
18381−// }
18382−//
18383−// if ( dataType != MY_FLOAT64 ) {
18384−// dataType = MY_FLOAT64;
18385−// sprintf(msg, "[chuck](via WvOut): Using 64-bit floating-point data format for file %s", name);
18386−// handleError(msg, StkError::WARNING);
18387−// }
18388−//
18389−// struct mathdr hdr;
18390−// strcpy(hdr.heading,"MATLAB 5.0 MAT-file, Generated using the Synthesis ToolKit in C++ (STK). By Perry R. Cook and Gary P. Scavone, 1995-2002.");
18391−//
18392−// int i;
18393−// for (i=strlen(hdr.heading);i<124;i++) hdr.heading[i] = ' ';
18394−//
18395−// // Header Flag Fields
18396−// hdr.hff[0] = (SINT16) 0x0100; // Version field
18397−// hdr.hff[1] = (SINT16) 'M'; // Endian indicator field ("MI")
18398−// hdr.hff[1] <<= 8;
18399−// hdr.hff[1] += 'I';
18400−//
18401−// hdr.adf[0] = (SINT32) 14; // Matlab array data type value
18402−// hdr.adf[1] = (SINT32) 0; // Size of file after this point to end (in bytes)
18403−// // Don't know size yet.
18404−//
18405−// // Numeric Array Subelements (4):
18406−// // 1. Array Flags
18407−// hdr.adf[2] = (SINT32) 6; // Matlab 32-bit unsigned integer data type value
18408−// hdr.adf[3] = (SINT32) 8; // 8 bytes of data to follow
18409−// hdr.adf[4] = (SINT32) 6; // Double-precision array, no array flags set
18410−// hdr.adf[5] = (SINT32) 0; // 4 bytes undefined
18411−// // 2. Array Dimensions
18412−// hdr.adf[6] = (SINT32) 5; // Matlab 32-bit signed integer data type value
18413−// hdr.adf[7] = (SINT32) 8; // 8 bytes of data to follow (2D array)
18414−// hdr.adf[8] = (SINT32) channels; // This is the number of rows
18415−// hdr.adf[9] = (SINT32) 0; // This is the number of columns
18416−//
18417−// // 3. Array Name
18418−// // We'll use fileName for the matlab array name (as well as the file name).
18419−// // If fileName is 4 characters or less, we have to use a compressed data element
18420−// // format for the array name data element. Otherwise, the array name must
18421−// // be formatted in 8-byte increments (up to 31 characters + NULL).
18422−// SINT32 namelength = (SINT32) strlen(fileName);
18423−// if (strstr(fileName, ".mat")) namelength -= 4;
18424−// if (namelength > 31) namelength = 31; // Truncate name to 31 characters.
18425−// char arrayName[64];
18426−// strncpy(arrayName, fileName, namelength);
18427−// arrayName[namelength] = '\0';
18428−// if (namelength > 4) {
18429−// hdr.adf[10] = (SINT32) 1; // Matlab 8-bit signed integer data type value
18430−// }
18431−// else { // Compressed data element format
18432−// hdr.adf[10] = namelength;
18433−// hdr.adf[10] <<= 16;
18434−// hdr.adf[10] += 1;
18435−// }
18436−// SINT32 headsize = 40; // Number of bytes in data element so far.
18437−//
18438−// // Write the fixed portion of the header
18439−// if ( fwrite(&hdr, 172, 1, fd) != 1 ) goto error;
18440−//
18441−// // Write MATLAB array name
18442−// SINT32 tmp;
18443−// if (namelength > 4) {
18444−// if ( fwrite(&namelength, 4, 1, fd) != 1) goto error;
18445−// if ( fwrite(arrayName, namelength, 1, fd) != 1 ) goto error;
18446−// tmp = (SINT32) ceil((float)namelength / 8);
18447−// if ( fseek(fd, tmp*8-namelength, SEEK_CUR) == -1 ) goto error;
18448−// headsize += tmp * 8;
18449−// }
18450−// else { // Compressed data element format
18451−// if ( fwrite(arrayName, namelength, 1, fd) != 1 ) goto error;
18452−// tmp = 4 - namelength;
18453−// if ( fseek(fd, tmp, SEEK_CUR) == -1 ) goto error;
18454−// }
18455−//
18456−// // Finish writing known header information
18457−// tmp = 9; // Matlab IEEE 754 double data type
18458−// if ( fwrite(&tmp, 4, 1, fd) != 1 ) goto error;
18459−// tmp = 0; // Size of real part subelement in bytes (8 per sample)
18460−// if ( fwrite(&tmp, 4, 1, fd) != 1 ) goto error;
18461−// headsize += 8; // Total number of bytes in data element so far
18462−//
18463−// if ( fseek(fd, 132, SEEK_SET) == -1 ) goto error;
18464−// if ( fwrite(&headsize, 4, 1, fd) != 1 ) goto error; // Write header size ... will update at end
18465−// if ( fseek(fd, 0, SEEK_END) == -1 ) goto error;
18466−//
18467−// byteswap = false;
18468−// CK_FPRINTF_STDERR( "[chuck]:(via STK): creating MAT-file (%s) containing MATLAB array: %s\n", name, arrayName);
18469−// return true;
18470−//
18471−// error:
18472−// sprintf(msg, "[chuck](via WvOut): Could not write MAT-file header for file %s", name);
18473−// return false;
18474−//}
18475−//
18476−//void WvOut :: closeMatFile( void )
18477−//{
18478−// fseek(fd, 164, SEEK_SET); // jump to number of columns
18479−// fwrite(&totalCount, 4, 1, fd);
18480−//
18481−// SINT32 headsize, temp;
18482−// fseek(fd, 132, SEEK_SET); // jump to header size
18483−// fread(&headsize, 4, 1, fd);
18484−// temp = headsize;
18485−// headsize += (SINT32) (totalCount * 8 * channels);
18486−// fseek(fd, 132, SEEK_SET);
18487−// // Write file size (minus some header info)
18488−// fwrite(&headsize, 4, 1, fd);
18489−//
18490−// fseek(fd, temp+132, SEEK_SET); // jumpt to data size (in bytes)
18491−// temp = totalCount * 8 * channels;
18492−// fwrite(&temp, 4, 1, fd);
18493−//
18494−// fclose(fd);
18495−//}
18496−//
18497−//unsigned long WvOut :: getFrames( void ) const
18498−//{
18499−// return totalCount;
18500−//}
18501−//
18502−//MY_FLOAT WvOut :: getTime( void ) const
18503−//{
18504−// return (MY_FLOAT) totalCount / Stk::sampleRate();
18505−//}
18506−//
18507−//void WvOut :: writeData( unsigned long frames )
18508−//{
18509−// // make sure we have file descriptor
18510−// if( !fd ) return;
18511−//
18512−// if ( dataType == STK_SINT8 ) {
18513−// if ( fileType == WVOUT_WAV ) { // 8-bit WAV data is unsigned!
18514−// for ( unsigned long k=0; k<frames*channels; k++ ) {
18515−// float float_sample = data[k] * 127.0 + 128.0;
18516−// if(float_sample < 0) float_sample = 0;
18517−// if(float_sample > 255) float_sample = 255;
18518−// unsigned char sample = (unsigned char) float_sample;
18519−//
18520−// if ( fwrite(&sample, 1, 1, fd) != 1 ) goto error;
18521−// }
18522−// }
18523−// else {
18524−// for ( unsigned long k=0; k<frames*channels; k++ ) {
18525−// float float_sample = data[k] * 127.0;
18526−// if(float_sample < -128) float_sample = -128;
18527−// if(float_sample > 127) float_sample = 127;
18528−// signed char sample = (signed char) float_sample;
18529−//
18530−// if ( fwrite(&sample, 1, 1, fd) != 1 ) goto error;
18531−// }
18532−// }
18533−// }
18534−// else if ( dataType == STK_SINT16 ) {
18535−// for ( unsigned long k=0; k<frames*channels; k++ ) {
18536−// float float_sample = data[k] * 32767.0;
18537−// if(float_sample < -32767) float_sample = -32767;
18538−// if(float_sample > 32767) float_sample = 32767;
18539−// SINT16 sample = (SINT16) float_sample;
18540−//
18541−// if ( byteswap ) swap16( (unsigned char *)&sample );
18542−// if ( fwrite(&sample, 2, 1, fd) != 1 ) goto error;
18543−// }
18544−// }
18545−// else if ( dataType == STK_SINT32 ) {
18546−// for ( unsigned long k=0; k<frames*channels; k++ ) {
18547−// float float_sample = data[k] * 32767.0;
18548−// if(float_sample < -2147483647) float_sample = (float)-2147483647;
18549−// if(float_sample > 2147483647) float_sample = (float)2147483647;
18550−// SINT32 sample = (SINT32) float_sample;
18551−//
18552−// if ( byteswap ) swap32( (unsigned char *)&sample );
18553−// if ( fwrite(&sample, 4, 1, fd) != 1 ) goto error;
18554−// }
18555−// }
18556−// else if ( dataType == MY_FLOAT32 ) {
18557−// FLOAT32 sample;
18558−// for ( unsigned long k=0; k<frames*channels; k++ ) {
18559−// sample = (FLOAT32) (data[k]);
18560−//
18561−// if ( byteswap ) swap32( (unsigned char *)&sample );
18562−// if ( fwrite(&sample, 4, 1, fd) != 1 ) goto error;
18563−// }
18564−// }
18565−// else if ( dataType == MY_FLOAT64 ) {
18566−// FLOAT64 sample;
18567−// for ( unsigned long k=0; k<frames*channels; k++ ) {
18568−// sample = (FLOAT64) (data[k]);
18569−//
18570−// if ( byteswap ) swap64( (unsigned char *)&sample );
18571−// if ( fwrite(&sample, 8, 1, fd) != 1 ) goto error;
18572−// }
18573−// }
18574−//
18575−// flush += frames;
18576−// if( flush >= 8192 )
18577−// {
18578−// flush = 0;
18579−// fflush( fd );
18580−// }
18581−//
18582−// return;
18583−//
18584−// error:
18585−// sprintf(msg, "[chuck](via WvOut): Error writing data to file.");
18586−// handleError(msg, StkError::FILE_ERROR);
18587−//}
18588−//
18589−//void WvOut :: tick(const MY_FLOAT sample)
18590−//{
18591−// if ( !fd ) return;
18592−//
18593−// for ( unsigned int j=0; j<channels; j++ )
18594−// data[counter*channels+j] = sample;
18595−//
18596−// counter++;
18597−// totalCount++;
18598−//
18599−// if ( counter == BUFFER_SIZE ) {
18600−// writeData( BUFFER_SIZE );
18601−// counter = 0;
18602−// }
18603−//}
18604−//
18605−//void WvOut :: tick(const MY_FLOAT *vec, unsigned int vectorSize)
18606−//{
18607−// if ( !fd ) return;
18608−//
18609−// for (unsigned int i=0; i<vectorSize; i++)
18610−// tick( vec[i] );
18611−//}
18612−//
18613−//void WvOut :: tickFrame(const MY_FLOAT *frameVector, unsigned int frames)
18614−//{
18615−// if ( !fd ) return;
18616−//
18617−// unsigned int j;
18618−// for ( unsigned int i=0; i<frames; i++ ) {
18619−// for ( j=0; j<channels; j++ ) {
18620−// data[counter*channels+j] = frameVector[i*channels+j];
18621−// }
18622−// counter++;
18623−// totalCount++;
18624−//
18625−// if ( counter == BUFFER_SIZE ) {
18626−// writeData( BUFFER_SIZE );
18627−// counter = 0;
18628−// }
18629−// }
18630−//}
18631−//
1863217893
17894+#ifndef __DISABLE_WVOUT__
17895+size_t WvOut::fwrite(const void * ptr, size_t size, size_t nitems, FILE * stream)
17896+{
17897+ if(asyncIO)
17898+ return asyncWriteThread->fwrite(ptr, size, nitems, stream);
17899+ else
17900+ return ::fwrite(ptr, size, nitems, stream);
17901+}
1863317902
18634−/**********************************************************************/
18635−/*! \class MidiFileIn
18636− \brief A standard MIDI file reading/parsing class.
18637−
18638− This class can be used to read events from a standard MIDI file.
18639− Event bytes are copied to a C++ vector and must be subsequently
18640− interpreted by the user. The function getNextMidiEvent() skips
18641− meta and sysex events, returning only MIDI channel messages.
18642− Event delta-times are returned in the form of "ticks" and a
18643− function is provided to determine the current "seconds per tick".
18644− Tempo changes are internally tracked by the class and reflected in
18645− the values returned by the function getTickSeconds().
18646−
18647− by Gary P. Scavone, 2003 - 2010.
18648− */
18649−/**********************************************************************/
17903+int WvOut::fseek(FILE *stream, long offset, int whence)
17904+{
17905+ if(asyncIO)
17906+ return asyncWriteThread->fseek(stream, offset, whence);
17907+ else
17908+ return ::fseek(stream, offset, whence);
17909+}
1865017910
18651−#include <cstring>
18652−#include <iostream>
17911+int WvOut::fflush(FILE *stream)
17912+{
17913+ if(asyncIO)
17914+ return asyncWriteThread->fflush(stream);
17915+ else
17916+ return ::fflush(stream);
17917+}
1865317918
18654−#if !defined(__BIG_ENDIAN__) && !defined(__LITTLE_ENDIAN__)
18655−#define __LITTLE_ENDIAN__
18656−#endif // !defined(__BIG_ENDIAN__) && !defined(__LITTLE_ENDIAN__)
17919+int WvOut::fclose(FILE *stream)
17920+{
17921+ if(asyncIO)
17922+ return asyncWriteThread->fclose(stream);
17923+ else
17924+ return ::fclose(stream);
17925+}
1865717926
18658−namespace stk {
18659−
18660−MidiFileIn :: MidiFileIn( std::string fileName )
17927+size_t WvOut::fread(void *ptr, size_t size, size_t nitems, FILE *stream)
1866117928 {
18662− // Attempt to open the file.
18663− file_.open( fileName.c_str(), std::ios::in | std::ios::binary );
18664− if ( !file_ ) {
18665− CK_STDCOUT << "MidiFileIn: error opening or finding file (" << fileName << ").";
18666− handleError( "", StkError::FILE_NOT_FOUND );
18667− }
18668−
18669− // Parse header info.
18670− char chunkType[4];
18671− char buffer[4];
18672− SINT32 *length;
18673− if ( !file_.read( chunkType, 4 ) ) goto error;
18674− if ( !file_.read( buffer, 4 ) ) goto error;
18675−#ifdef __LITTLE_ENDIAN__
18676− swap32((unsigned char *)&buffer);
18677−#endif
18678− length = (SINT32 *) &buffer;
18679− if ( strncmp( chunkType, "MThd", 4 ) || ( *length != 6 ) ) {
18680− CK_STDCOUT << "MidiFileIn: file (" << fileName << ") does not appear to be a MIDI file!";
18681− handleError( "", StkError::FILE_UNKNOWN_FORMAT );
18682− }
18683−
18684− // Read the MIDI file format.
18685− SINT16 *data;
18686− if ( !file_.read( buffer, 2 ) ) goto error;
18687−#ifdef __LITTLE_ENDIAN__
18688− swap16((unsigned char *)&buffer);
18689−#endif
18690− data = (SINT16 *) &buffer;
18691− if ( *data < 0 || *data > 2 ) {
17929+ // can't read asynchronously (yet)
17930+ assert(0);
17931+ return 0;
17932+}
17933+
17934+WvOut :: WvOut()
17935+{
17936+ init();
17937+}
17938+
17939+WvOut::WvOut( const char *fileName, unsigned int nChannels, FILE_TYPE type, Stk::STK_FORMAT format )
17940+{
17941+ init();
17942+ openFile( fileName, nChannels, type, format );
17943+}
17944+
17945+WvOut :: ~WvOut()
17946+{
17947+ closeFile();
17948+
17949+ if (data)
17950+ delete [] data;
17951+}
17952+
17953+void WvOut :: init()
17954+{
17955+ fd = 0;
17956+ data = 0;
17957+ fileType = 0;
17958+ dataType = 0;
17959+ channels = 0;
17960+ counter = 0;
17961+ totalCount = 0;
17962+ //m_filename[0] = '\0';
17963+ start = TRUE;
17964+ flush = 0;
17965+ fileGain = 1;
17966+
17967+ // spencer: added as flag for off-thread write
17968+ asyncIO = FALSE;
17969+ asyncWriteThread = NULL;
17970+}
17971+
17972+void WvOut :: closeFile( void )
17973+{
17974+ if( fd ) {
17975+ // If there's an existing file, close it first.
17976+ writeData( counter );
17977+
17978+ if ( fileType == WVOUT_RAW )
17979+ fclose( fd );
17980+ else if ( fileType == WVOUT_WAV )
17981+ closeWavFile();
17982+ else if ( fileType == WVOUT_SND )
17983+ closeSndFile();
17984+ else if ( fileType == WVOUT_AIF )
17985+ closeAifFile();
17986+ else if ( fileType == WVOUT_MAT )
17987+ closeMatFile();
17988+ fd = 0;
17989+
17990+ // printf("%f Seconds Computed\n\n", getTime() );
17991+ totalCount = 0;
17992+ }
17993+
17994+ str_filename.set( "" );
17995+ //m_filename[0] = '\0';
17996+}
17997+
17998+void WvOut :: openFile( const char *fileName, unsigned int nChannels, WvOut::FILE_TYPE type, Stk::STK_FORMAT format )
17999+{
18000+ closeFile();
18001+ str_filename.set( fileName );
18002+ //strncpy( m_filename, fileName, 255);
18003+ //if ( strlen( fileName ) > 255 )
18004+ // m_filename[255] = '\0';
18005+
18006+ if ( nChannels < 1 ) {
18007+ sprintf(msg, "[chuck](via WvOut): the channels argument must be greater than zero!");
18008+ handleError( msg, StkError::FUNCTION_ARGUMENT );
18009+ }
18010+
18011+ unsigned int lastChannels = channels;
18012+ channels = nChannels;
18013+ fileType = type;
18014+
18015+ if ( format != STK_SINT8 && format != STK_SINT16 &&
18016+ format != STK_SINT32 && format != MY_FLOAT32 &&
18017+ format != MY_FLOAT64 ) {
18018+ sprintf( msg, "[chuck](via WvOut): Unknown data type specified (%ld).", format );
18019+ handleError(msg, StkError::FUNCTION_ARGUMENT);
18020+ }
18021+ dataType = format;
18022+
18023+ bool result = false;
18024+ if ( fileType == WVOUT_RAW ) {
18025+ if ( channels != 1 ) {
18026+ sprintf(msg, "[chuck](via WvOut): STK RAW files are, by definition, always monaural (channels = %d not supported)!", nChannels);
18027+ handleError( msg, StkError::FUNCTION_ARGUMENT );
18028+ }
18029+ result = setRawFile( fileName );
18030+ }
18031+ else if ( fileType == WVOUT_WAV )
18032+ result = setWavFile( fileName );
18033+ else if ( fileType == WVOUT_SND )
18034+ result = setSndFile( fileName );
18035+ else if ( fileType == WVOUT_AIF )
18036+ result = setAifFile( fileName );
18037+ else if ( fileType == WVOUT_MAT )
18038+ result = setMatFile( fileName );
18039+ else {
18040+ sprintf(msg, "[chuck](via WvOut): Unknown file type specified (%ld).", fileType);
18041+ handleError(msg, StkError::FUNCTION_ARGUMENT);
18042+ }
18043+
18044+ if ( result == false )
18045+ {
18046+ //closeFile();
18047+ handleError(msg, StkError::FILE_ERROR);
18048+ // handleError( msg, StkError::WARNING );
18049+ // return;
18050+ }
18051+
18052+ // Allocate new memory if necessary.
18053+ if ( lastChannels < channels ) {
18054+ if ( data ) delete [] data;
18055+ data = (MY_FLOAT *) new MY_FLOAT[BUFFER_SIZE*channels];
18056+ }
18057+ counter = 0;
18058+}
18059+
18060+bool WvOut :: setRawFile( const char *fileName )
18061+{
18062+ char name[128];
18063+ strncpy(name, fileName, 128);
18064+ if ( strstr(name, ".raw") == NULL) strcat(name, ".raw");
18065+ fd = fopen(name, "wb");
18066+ if ( !fd ) {
18067+ sprintf(msg, "[chuck](via WvOut): Could not create RAW file: %s", name);
18068+ return false;
18069+ }
18070+
18071+ if ( dataType != STK_SINT16 ) {
18072+ dataType = STK_SINT16;
18073+ sprintf(msg, "[chuck](via WvOut): Using 16-bit signed integer data format for file %s.", name);
18074+ handleError(msg, StkError::WARNING);
18075+ }
18076+
18077+ byteswap = false;
18078+ if( little_endian )
18079+ byteswap = true;
18080+
18081+ // printf("\nCreating RAW file: %s\n", name);
18082+ return true;
18083+}
18084+
18085+bool WvOut :: setWavFile( const char *fileName )
18086+{
18087+ char name[128];
18088+ strncpy(name, fileName, 128);
18089+ if( strstr(name, ".wav") == NULL ) strcat(name, ".wav");
18090+ fd = fopen( name, "wb" );
18091+ if( !fd ) {
18092+ sprintf(msg, "[chuck](via WvOut): Could not create WAV file: %s", name);
18093+ return false;
18094+ }
18095+
18096+ struct wavhdr hdr = {"RIF", 44, "WAV", "fmt", 16, 1, 1,
18097+ (SINT32) Stk::sampleRate(), 0, 2, 16, "dat", 0};
18098+ hdr.riff[3] = 'F';
18099+ hdr.wave[3] = 'E';
18100+ hdr.fmt[3] = ' ';
18101+ hdr.data[3] = 'a';
18102+ hdr.num_chans = (SINT16) channels;
18103+ if ( dataType == STK_SINT8 )
18104+ hdr.bits_per_samp = 8;
18105+ else if ( dataType == STK_SINT16 )
18106+ hdr.bits_per_samp = 16;
18107+ else if ( dataType == STK_SINT32 )
18108+ hdr.bits_per_samp = 32;
18109+ else if ( dataType == MY_FLOAT32 ) {
18110+ hdr.format_tag = 3;
18111+ hdr.bits_per_samp = 32;
18112+ }
18113+ else if ( dataType == MY_FLOAT64 ) {
18114+ hdr.format_tag = 3;
18115+ hdr.bits_per_samp = 64;
18116+ }
18117+ hdr.bytes_per_samp = (SINT16) (channels * hdr.bits_per_samp / 8);
18118+ hdr.bytes_per_sec = (SINT32) (hdr.sample_rate * hdr.bytes_per_samp);
18119+
18120+ byteswap = false;
18121+ if( !little_endian )
18122+ {
18123+ byteswap = true;
18124+ swap32((unsigned char *)&hdr.file_size);
18125+ swap32((unsigned char *)&hdr.chunk_size);
18126+ swap16((unsigned char *)&hdr.format_tag);
18127+ swap16((unsigned char *)&hdr.num_chans);
18128+ swap32((unsigned char *)&hdr.sample_rate);
18129+ swap32((unsigned char *)&hdr.bytes_per_sec);
18130+ swap16((unsigned char *)&hdr.bytes_per_samp);
18131+ swap16((unsigned char *)&hdr.bits_per_samp);
18132+ }
18133+
18134+ if ( fwrite(&hdr, 4, 11, fd) != 11 ) {
18135+ sprintf(msg, "[chuck](via WvOut): Could not write WAV header for file %s", name);
18136+ return false;
18137+ }
18138+
18139+ // printf("\nCreating WAV file: %s\n", name);
18140+ return true;
18141+}
18142+
18143+void WvOut :: closeWavFile( void )
18144+{
18145+ int bytes_per_sample = 1;
18146+ if ( dataType == STK_SINT16 )
18147+ bytes_per_sample = 2;
18148+ else if ( dataType == STK_SINT32 || dataType == MY_FLOAT32 )
18149+ bytes_per_sample = 4;
18150+ else if ( dataType == MY_FLOAT64 )
18151+ bytes_per_sample = 8;
18152+
18153+ SINT32 bytes = totalCount * channels * bytes_per_sample;
18154+if( !little_endian )
18155+ swap32((unsigned char *)&bytes);
18156+
18157+ fseek(fd, 40, SEEK_SET); // jump to data length
18158+ fwrite(&bytes, 4, 1, fd);
18159+
18160+ bytes = totalCount * channels * bytes_per_sample + 44;
18161+if( !little_endian )
18162+ swap32((unsigned char *)&bytes);
18163+
18164+ fseek(fd, 4, SEEK_SET); // jump to file size
18165+ fwrite(&bytes, 4, 1, fd);
18166+ fclose( fd );
18167+}
18168+
18169+bool WvOut :: setSndFile( const char *fileName )
18170+{
18171+ char name[128];
18172+ strncpy(name, fileName, 128);
18173+ if ( strstr(name, ".snd") == NULL) strcat(name, ".snd");
18174+ fd = fopen(name, "wb");
18175+ if ( !fd ) {
18176+ sprintf(msg, "[chuck](via WvOut): Could not create SND file: %s", name);
18177+ return false;
18178+ }
18179+
18180+ struct sndhdr hdr = {".sn", 40, 0, 3, (SINT32) Stk::sampleRate(), 1, "Created by STK"};
18181+ hdr.pref[3] = 'd';
18182+ hdr.num_channels = channels;
18183+ if ( dataType == STK_SINT8 )
18184+ hdr.format = 2;
18185+ else if ( dataType == STK_SINT16 )
18186+ hdr.format = 3;
18187+ else if ( dataType == STK_SINT32 )
18188+ hdr.format = 5;
18189+ else if ( dataType == MY_FLOAT32 )
18190+ hdr.format = 6;
18191+ else if ( dataType == MY_FLOAT64 )
18192+ hdr.format = 7;
18193+
18194+ byteswap = false;
18195+if( little_endian )
18196+{
18197+ byteswap = true;
18198+ swap32 ((unsigned char *)&hdr.hdr_length);
18199+ swap32 ((unsigned char *)&hdr.format);
18200+ swap32 ((unsigned char *)&hdr.sample_rate);
18201+ swap32 ((unsigned char *)&hdr.num_channels);
18202+}
18203+
18204+ if ( fwrite(&hdr, 4, 10, fd) != 10 ) {
18205+ sprintf(msg, "[chuck](via WvOut): Could not write SND header for file %s", name);
18206+ return false;
18207+ }
18208+
18209+ // printf("\nCreating SND file: %s\n", name);
18210+ return true;
18211+}
18212+
18213+void WvOut :: closeSndFile( void )
18214+{
18215+ int bytes_per_sample = 1;
18216+ if ( dataType == STK_SINT16 )
18217+ bytes_per_sample = 2;
18218+ else if ( dataType == STK_SINT32 )
18219+ bytes_per_sample = 4;
18220+ else if ( dataType == MY_FLOAT32 )
18221+ bytes_per_sample = 4;
18222+ else if ( dataType == MY_FLOAT64 )
18223+ bytes_per_sample = 8;
18224+
18225+ SINT32 bytes = totalCount * bytes_per_sample * channels;
18226+if( little_endian )
18227+ swap32 ((unsigned char *)&bytes);
18228+
18229+ fseek(fd, 8, SEEK_SET); // jump to data size
18230+ fwrite(&bytes, 4, 1, fd);
18231+ fclose(fd);
18232+}
18233+
18234+bool WvOut :: setAifFile( const char *fileName )
18235+{
18236+ char name[128];
18237+ strncpy(name, fileName, 128);
18238+ if ( strstr(name, ".aif") == NULL) strcat(name, ".aif");
18239+ fd = fopen(name, "wb");
18240+ if ( !fd ) {
18241+ sprintf(msg, "[chuck](via WvOut): Could not create AIF file: %s", name);
18242+ return false;
18243+ }
18244+
18245+ // Common parts of AIFF/AIFC header.
18246+ struct aifhdr hdr = {"FOR", 46, "AIF", "COM", 18, 0, 0, 16, "0"};
18247+ struct aifssnd ssnd = {"SSN", 8, 0, 0};
18248+ hdr.form[3] = 'M';
18249+ hdr.aiff[3] = 'F';
18250+ hdr.comm[3] = 'M';
18251+ ssnd.ssnd[3] = 'D';
18252+ hdr.num_chans = channels;
18253+ if ( dataType == STK_SINT8 )
18254+ hdr.sample_size = 8;
18255+ else if ( dataType == STK_SINT16 )
18256+ hdr.sample_size = 16;
18257+ else if ( dataType == STK_SINT32 )
18258+ hdr.sample_size = 32;
18259+ else if ( dataType == MY_FLOAT32 ) {
18260+ hdr.aiff[3] = 'C';
18261+ hdr.sample_size = 32;
18262+ hdr.comm_size = 24;
18263+ }
18264+ else if ( dataType == MY_FLOAT64 ) {
18265+ hdr.aiff[3] = 'C';
18266+ hdr.sample_size = 64;
18267+ hdr.comm_size = 24;
18268+ }
18269+
18270+ // For AIFF files, the sample rate is stored in a 10-byte,
18271+ // IEEE Standard 754 floating point number, so we need to
18272+ // convert to that.
18273+ SINT16 i;
18274+ unsigned long exp;
18275+ unsigned long rate = (unsigned long) Stk::sampleRate();
18276+ memset(hdr.srate, 0, 10);
18277+ exp = rate;
18278+ for (i=0; i<32; i++) {
18279+ exp >>= 1;
18280+ if (!exp) break;
18281+ }
18282+ i += 16383;
18283+if( little_endian )
18284+ swap16((unsigned char *)&i);
18285+
18286+ *(SINT16 *)(hdr.srate) = (SINT16) i;
18287+
18288+ for (i=32; i; i--) {
18289+ if (rate & 0x80000000) break;
18290+ rate <<= 1;
18291+ }
18292+
18293+if( little_endian )
18294+ swap32((unsigned char *)&rate);
18295+
18296+ *(unsigned long *)(hdr.srate+2) = (unsigned long) rate;
18297+
18298+ byteswap = false;
18299+if( little_endian )
18300+{
18301+ byteswap = true;
18302+ swap32((unsigned char *)&hdr.form_size);
18303+ swap32((unsigned char *)&hdr.comm_size);
18304+ swap16((unsigned char *)&hdr.num_chans);
18305+ swap16((unsigned char *)&hdr.sample_size);
18306+ swap32((unsigned char *)&ssnd.ssnd_size);
18307+ swap32((unsigned char *)&ssnd.offset);
18308+ swap32((unsigned char *)&ssnd.block_size);
18309+}
18310+
18311+ // The structure boundaries don't allow a single write of 54 bytes.
18312+ if ( fwrite(&hdr, 4, 5, fd) != 5 ) goto error;
18313+ if ( fwrite(&hdr.num_chans, 2, 1, fd) != 1 ) goto error;
18314+ if ( fwrite(&hdr.sample_frames, 4, 1, fd) != 1 ) goto error;
18315+ if ( fwrite(&hdr.sample_size, 2, 1, fd) != 1 ) goto error;
18316+ if ( fwrite(&hdr.srate, 10, 1, fd) != 1 ) goto error;
18317+
18318+ if ( dataType == MY_FLOAT32 ) {
18319+ char type[4] = {'f','l','3','2'};
18320+ char zeroes[2] = { 0, 0 };
18321+ if ( fwrite(&type, 4, 1, fd) != 1 ) goto error;
18322+ if ( fwrite(&zeroes, 2, 1, fd) != 1 ) goto error;
18323+ }
18324+ else if ( dataType == MY_FLOAT64 ) {
18325+ char type[4] = {'f','l','6','4'};
18326+ char zeroes[2] = { 0, 0 };
18327+ if ( fwrite(&type, 4, 1, fd) != 1 ) goto error;
18328+ if ( fwrite(&zeroes, 2, 1, fd) != 1 ) goto error;
18329+ }
18330+
18331+ if ( fwrite(&ssnd, 4, 4, fd) != 4 ) goto error;
18332+
18333+ // printf("\nCreating AIF file: %s\n", name);
18334+ return true;
18335+
18336+ error:
18337+ sprintf(msg, "[chuck](via WvOut): Could not write AIF header for file %s", name);
18338+ return false;
18339+}
18340+
18341+void WvOut :: closeAifFile( void )
18342+{
18343+ unsigned long frames = (unsigned long) totalCount;
18344+if( little_endian )
18345+ swap32((unsigned char *)&frames);
18346+
18347+ fseek(fd, 22, SEEK_SET); // jump to "COMM" sample_frames
18348+ fwrite(&frames, 4, 1, fd);
18349+
18350+ int bytes_per_sample = 1;
18351+ if ( dataType == STK_SINT16 )
18352+ bytes_per_sample = 2;
18353+ else if ( dataType == STK_SINT32 || dataType == MY_FLOAT32 )
18354+ bytes_per_sample = 4;
18355+ else if ( dataType == MY_FLOAT64 )
18356+ bytes_per_sample = 8;
18357+
18358+ unsigned long bytes = totalCount * bytes_per_sample * channels + 46;
18359+ if ( dataType == MY_FLOAT32 || dataType == MY_FLOAT64 ) bytes += 6;
18360+if( little_endian )
18361+ swap32((unsigned char *)&bytes);
18362+
18363+ fseek(fd, 4, SEEK_SET); // jump to file size
18364+ fwrite(&bytes, 4, 1, fd);
18365+
18366+ bytes = totalCount * bytes_per_sample * channels + 8;
18367+ if ( dataType == MY_FLOAT32 || dataType == MY_FLOAT64 ) bytes += 6;
18368+if( little_endian )
18369+ swap32((unsigned char *)&bytes);
18370+
18371+ if ( dataType == MY_FLOAT32 || dataType == MY_FLOAT64 )
18372+ fseek(fd, 48, SEEK_SET); // jump to "SSND" chunk size
18373+ else
18374+ fseek(fd, 42, SEEK_SET); // jump to "SSND" chunk size
18375+ fwrite(&bytes, 4, 1, fd);
18376+
18377+ fclose( fd );
18378+}
18379+
18380+bool WvOut :: setMatFile( const char *fileName )
18381+{
18382+ char name[128];
18383+ strncpy(name, fileName, 128);
18384+ if ( strstr(name, ".mat") == NULL) strcat(name, ".mat");
18385+ fd = fopen(name, "w+b");
18386+ if ( !fd ) {
18387+ sprintf(msg, "[chuck](via WvOut): Could not create MAT file: %s", name);
18388+ return false;
18389+ }
18390+
18391+ if ( dataType != MY_FLOAT64 ) {
18392+ dataType = MY_FLOAT64;
18393+ sprintf(msg, "[chuck](via WvOut): Using 64-bit floating-point data format for file %s", name);
18394+ handleError(msg, StkError::WARNING);
18395+ }
18396+
18397+ struct mathdr hdr;
18398+ strcpy(hdr.heading,"MATLAB 5.0 MAT-file, Generated using the Synthesis ToolKit in C++ (STK). By Perry R. Cook and Gary P. Scavone, 1995-2002.");
18399+
18400+ int i;
18401+ for (i=strlen(hdr.heading);i<124;i++) hdr.heading[i] = ' ';
18402+
18403+ // Header Flag Fields
18404+ hdr.hff[0] = (SINT16) 0x0100; // Version field
18405+ hdr.hff[1] = (SINT16) 'M'; // Endian indicator field ("MI")
18406+ hdr.hff[1] <<= 8;
18407+ hdr.hff[1] += 'I';
18408+
18409+ hdr.adf[0] = (SINT32) 14; // Matlab array data type value
18410+ hdr.adf[1] = (SINT32) 0; // Size of file after this point to end (in bytes)
18411+ // Don't know size yet.
18412+
18413+ // Numeric Array Subelements (4):
18414+ // 1. Array Flags
18415+ hdr.adf[2] = (SINT32) 6; // Matlab 32-bit unsigned integer data type value
18416+ hdr.adf[3] = (SINT32) 8; // 8 bytes of data to follow
18417+ hdr.adf[4] = (SINT32) 6; // Double-precision array, no array flags set
18418+ hdr.adf[5] = (SINT32) 0; // 4 bytes undefined
18419+ // 2. Array Dimensions
18420+ hdr.adf[6] = (SINT32) 5; // Matlab 32-bit signed integer data type value
18421+ hdr.adf[7] = (SINT32) 8; // 8 bytes of data to follow (2D array)
18422+ hdr.adf[8] = (SINT32) channels; // This is the number of rows
18423+ hdr.adf[9] = (SINT32) 0; // This is the number of columns
18424+
18425+ // 3. Array Name
18426+ // We'll use fileName for the matlab array name (as well as the file name).
18427+ // If fileName is 4 characters or less, we have to use a compressed data element
18428+ // format for the array name data element. Otherwise, the array name must
18429+ // be formatted in 8-byte increments (up to 31 characters + NULL).
18430+ SINT32 namelength = (SINT32) strlen(fileName);
18431+ if (strstr(fileName, ".mat")) namelength -= 4;
18432+ if (namelength > 31) namelength = 31; // Truncate name to 31 characters.
18433+ char arrayName[64];
18434+ strncpy(arrayName, fileName, namelength);
18435+ arrayName[namelength] = '\0';
18436+ if (namelength > 4) {
18437+ hdr.adf[10] = (SINT32) 1; // Matlab 8-bit signed integer data type value
18438+ }
18439+ else { // Compressed data element format
18440+ hdr.adf[10] = namelength;
18441+ hdr.adf[10] <<= 16;
18442+ hdr.adf[10] += 1;
18443+ }
18444+ SINT32 headsize = 40; // Number of bytes in data element so far.
18445+
18446+ // Write the fixed portion of the header
18447+ if ( fwrite(&hdr, 172, 1, fd) != 1 ) goto error;
18448+
18449+ // Write MATLAB array name
18450+ SINT32 tmp;
18451+ if (namelength > 4) {
18452+ if ( fwrite(&namelength, 4, 1, fd) != 1) goto error;
18453+ if ( fwrite(arrayName, namelength, 1, fd) != 1 ) goto error;
18454+ tmp = (SINT32) ceil((float)namelength / 8);
18455+ if ( fseek(fd, tmp*8-namelength, SEEK_CUR) == -1 ) goto error;
18456+ headsize += tmp * 8;
18457+ }
18458+ else { // Compressed data element format
18459+ if ( fwrite(arrayName, namelength, 1, fd) != 1 ) goto error;
18460+ tmp = 4 - namelength;
18461+ if ( fseek(fd, tmp, SEEK_CUR) == -1 ) goto error;
18462+ }
18463+
18464+ // Finish writing known header information
18465+ tmp = 9; // Matlab IEEE 754 double data type
18466+ if ( fwrite(&tmp, 4, 1, fd) != 1 ) goto error;
18467+ tmp = 0; // Size of real part subelement in bytes (8 per sample)
18468+ if ( fwrite(&tmp, 4, 1, fd) != 1 ) goto error;
18469+ headsize += 8; // Total number of bytes in data element so far
18470+
18471+ if ( fseek(fd, 132, SEEK_SET) == -1 ) goto error;
18472+ if ( fwrite(&headsize, 4, 1, fd) != 1 ) goto error; // Write header size ... will update at end
18473+ if ( fseek(fd, 0, SEEK_END) == -1 ) goto error;
18474+
18475+ byteswap = false;
18476+ CK_FPRINTF_STDERR( "[chuck]:(via STK): creating MAT-file (%s) containing MATLAB array: %s\n", name, arrayName);
18477+ return true;
18478+
18479+ error:
18480+ sprintf(msg, "[chuck](via WvOut): Could not write MAT-file header for file %s", name);
18481+ return false;
18482+}
18483+
18484+void WvOut :: closeMatFile( void )
18485+{
18486+ fseek(fd, 164, SEEK_SET); // jump to number of columns
18487+ fwrite(&totalCount, 4, 1, fd);
18488+
18489+ SINT32 headsize, temp;
18490+ fseek(fd, 132, SEEK_SET); // jump to header size
18491+ fread(&headsize, 4, 1, fd);
18492+ temp = headsize;
18493+ headsize += (SINT32) (totalCount * 8 * channels);
18494+ fseek(fd, 132, SEEK_SET);
18495+ // Write file size (minus some header info)
18496+ fwrite(&headsize, 4, 1, fd);
18497+
18498+ fseek(fd, temp+132, SEEK_SET); // jumpt to data size (in bytes)
18499+ temp = totalCount * 8 * channels;
18500+ fwrite(&temp, 4, 1, fd);
18501+
18502+ fclose(fd);
18503+}
18504+
18505+unsigned long WvOut :: getFrames( void ) const
18506+{
18507+ return totalCount;
18508+}
18509+
18510+MY_FLOAT WvOut :: getTime( void ) const
18511+{
18512+ return (MY_FLOAT) totalCount / Stk::sampleRate();
18513+}
18514+
18515+void WvOut :: writeData( unsigned long frames )
18516+{
18517+ // make sure we have file descriptor
18518+ if( !fd ) return;
18519+
18520+ if ( dataType == STK_SINT8 ) {
18521+ if ( fileType == WVOUT_WAV ) { // 8-bit WAV data is unsigned!
18522+ for ( unsigned long k=0; k<frames*channels; k++ ) {
18523+ float float_sample = data[k] * 127.0 + 128.0;
18524+ if(float_sample < 0) float_sample = 0;
18525+ if(float_sample > 255) float_sample = 255;
18526+ unsigned char sample = (unsigned char) float_sample;
18527+
18528+ if ( fwrite(&sample, 1, 1, fd) != 1 ) goto error;
18529+ }
18530+ }
18531+ else {
18532+ for ( unsigned long k=0; k<frames*channels; k++ ) {
18533+ float float_sample = data[k] * 127.0;
18534+ if(float_sample < -128) float_sample = -128;
18535+ if(float_sample > 127) float_sample = 127;
18536+ signed char sample = (signed char) float_sample;
18537+
18538+ if ( fwrite(&sample, 1, 1, fd) != 1 ) goto error;
18539+ }
18540+ }
18541+ }
18542+ else if ( dataType == STK_SINT16 ) {
18543+ for ( unsigned long k=0; k<frames*channels; k++ ) {
18544+ float float_sample = data[k] * 32767.0;
18545+ if(float_sample < -32767) float_sample = -32767;
18546+ if(float_sample > 32767) float_sample = 32767;
18547+ SINT16 sample = (SINT16) float_sample;
18548+
18549+ if ( byteswap ) swap16( (unsigned char *)&sample );
18550+ if ( fwrite(&sample, 2, 1, fd) != 1 ) goto error;
18551+ }
18552+ }
18553+ else if ( dataType == STK_SINT32 ) {
18554+ for ( unsigned long k=0; k<frames*channels; k++ ) {
18555+ float float_sample = data[k] * 32767.0;
18556+ if(float_sample < -2147483647) float_sample = (float)-2147483647;
18557+ if(float_sample > 2147483647) float_sample = (float)2147483647;
18558+ SINT32 sample = (SINT32) float_sample;
18559+
18560+ if ( byteswap ) swap32( (unsigned char *)&sample );
18561+ if ( fwrite(&sample, 4, 1, fd) != 1 ) goto error;
18562+ }
18563+ }
18564+ else if ( dataType == MY_FLOAT32 ) {
18565+ FLOAT32 sample;
18566+ for ( unsigned long k=0; k<frames*channels; k++ ) {
18567+ sample = (FLOAT32) (data[k]);
18568+
18569+ if ( byteswap ) swap32( (unsigned char *)&sample );
18570+ if ( fwrite(&sample, 4, 1, fd) != 1 ) goto error;
18571+ }
18572+ }
18573+ else if ( dataType == MY_FLOAT64 ) {
18574+ FLOAT64 sample;
18575+ for ( unsigned long k=0; k<frames*channels; k++ ) {
18576+ sample = (FLOAT64) (data[k]);
18577+
18578+ if ( byteswap ) swap64( (unsigned char *)&sample );
18579+ if ( fwrite(&sample, 8, 1, fd) != 1 ) goto error;
18580+ }
18581+ }
18582+
18583+ flush += frames;
18584+ if( flush >= 8192 )
18585+ {
18586+ flush = 0;
18587+ fflush( fd );
18588+ }
18589+
18590+ return;
18591+
18592+ error:
18593+ sprintf(msg, "[chuck](via WvOut): Error writing data to file.");
18594+ handleError(msg, StkError::FILE_ERROR);
18595+}
18596+
18597+void WvOut :: tick(const MY_FLOAT sample)
18598+{
18599+ if ( !fd ) return;
18600+
18601+ for ( unsigned int j=0; j<channels; j++ )
18602+ data[counter*channels+j] = sample;
18603+
18604+ counter++;
18605+ totalCount++;
18606+
18607+ if ( counter == BUFFER_SIZE ) {
18608+ writeData( BUFFER_SIZE );
18609+ counter = 0;
18610+ }
18611+}
18612+
18613+void WvOut :: tick(const MY_FLOAT *vec, unsigned int vectorSize)
18614+{
18615+ if ( !fd ) return;
18616+
18617+ for (unsigned int i=0; i<vectorSize; i++)
18618+ tick( vec[i] );
18619+}
18620+
18621+void WvOut :: tickFrame(const MY_FLOAT *frameVector, unsigned int frames)
18622+{
18623+ if ( !fd ) return;
18624+
18625+ unsigned int j;
18626+ for ( unsigned int i=0; i<frames; i++ ) {
18627+ for ( j=0; j<channels; j++ ) {
18628+ data[counter*channels+j] = frameVector[i*channels+j];
18629+ }
18630+ counter++;
18631+ totalCount++;
18632+
18633+ if ( counter == BUFFER_SIZE ) {
18634+ writeData( BUFFER_SIZE );
18635+ counter = 0;
18636+ }
18637+ }
18638+}
18639+#endif //__DISABLE_WVOUT__
18640+
18641+
18642+
18643+
18644+/**********************************************************************/
18645+/*! \class MidiFileIn
18646+ \brief A standard MIDI file reading/parsing class.
18647+
18648+ This class can be used to read events from a standard MIDI file.
18649+ Event bytes are copied to a C++ vector and must be subsequently
18650+ interpreted by the user. The function getNextMidiEvent() skips
18651+ meta and sysex events, returning only MIDI channel messages.
18652+ Event delta-times are returned in the form of "ticks" and a
18653+ function is provided to determine the current "seconds per tick".
18654+ Tempo changes are internally tracked by the class and reflected in
18655+ the values returned by the function getTickSeconds().
18656+
18657+ by Gary P. Scavone, 2003 - 2010.
18658+ */
18659+/**********************************************************************/
18660+
18661+#include <cstring>
18662+#include <iostream>
18663+
18664+#if !defined(__BIG_ENDIAN__) && !defined(__LITTLE_ENDIAN__)
18665+#define __LITTLE_ENDIAN__
18666+#endif // !defined(__BIG_ENDIAN__) && !defined(__LITTLE_ENDIAN__)
18667+
18668+namespace stk {
18669+
18670+MidiFileIn :: MidiFileIn( std::string fileName )
18671+{
18672+ // Attempt to open the file.
18673+ file_.open( fileName.c_str(), std::ios::in | std::ios::binary );
18674+ if ( !file_ ) {
18675+ CK_STDCOUT << "MidiFileIn: error opening or finding file (" << fileName << ").";
18676+ handleError( "", StkError::FILE_NOT_FOUND );
18677+ }
18678+
18679+ // Parse header info.
18680+ char chunkType[4];
18681+ char buffer[4];
18682+ SINT32 *length;
18683+ if ( !file_.read( chunkType, 4 ) ) goto error;
18684+ if ( !file_.read( buffer, 4 ) ) goto error;
18685+#ifdef __LITTLE_ENDIAN__
18686+ swap32((unsigned char *)&buffer);
18687+#endif
18688+ length = (SINT32 *) &buffer;
18689+ if ( strncmp( chunkType, "MThd", 4 ) || ( *length != 6 ) ) {
18690+ CK_STDCOUT << "MidiFileIn: file (" << fileName << ") does not appear to be a MIDI file!";
18691+ handleError( "", StkError::FILE_UNKNOWN_FORMAT );
18692+ }
18693+
18694+ // Read the MIDI file format.
18695+ SINT16 *data;
18696+ if ( !file_.read( buffer, 2 ) ) goto error;
18697+#ifdef __LITTLE_ENDIAN__
18698+ swap16((unsigned char *)&buffer);
18699+#endif
18700+ data = (SINT16 *) &buffer;
18701+ if ( *data < 0 || *data > 2 ) {
1869218702 CK_STDCOUT << "MidiFileIn: the file (" << fileName << ") format is invalid!";
1869318703 handleError( "", StkError::FILE_ERROR );
1869418704 }
@@ -20472,173 +20482,412 @@ struct Brass_ · 1777 unmodified lines
2047220482 imp = new Brass(d);
2047320483 m_frequency = 100.0;
2047420484 m_rate = 0.5;
20475− m_lip = 0.1;
20476− }
20477−
20478− ~Brass_()
20479− {
20480− SAFE_DELETE( imp );
20485+ m_lip = 0.1;
20486+ }
20487+
20488+ ~Brass_()
20489+ {
20490+ SAFE_DELETE( imp );
20491+ }
20492+}; */
20493+
20494+
20495+//-----------------------------------------------------------------------------
20496+// name: Brass_ctor()
20497+// desc: CTOR function ...
20498+//-----------------------------------------------------------------------------
20499+CK_DLL_CTOR( Brass_ctor )
20500+{
20501+ OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data) = (t_CKUINT)new Brass( 20.0 );
20502+}
20503+
20504+
20505+//-----------------------------------------------------------------------------
20506+// name: Brass_dtor()
20507+// desc: DTOR function ...
20508+//-----------------------------------------------------------------------------
20509+CK_DLL_DTOR( Brass_dtor )
20510+{
20511+ delete (Brass *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data);
20512+ OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data) = 0;
20513+}
20514+
20515+
20516+//-----------------------------------------------------------------------------
20517+// name: Brass_tick()
20518+// desc: TICK function ...
20519+//-----------------------------------------------------------------------------
20520+CK_DLL_TICK( Brass_tick )
20521+{
20522+ Brass * b = (Brass *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data);
20523+ *out = b->tick();
20524+ return TRUE;
20525+}
20526+
20527+
20528+//-----------------------------------------------------------------------------
20529+// name: Brass_pmsg()
20530+// desc: PMSG function ...
20531+//-----------------------------------------------------------------------------
20532+CK_DLL_PMSG( Brass_pmsg )
20533+{
20534+ return TRUE;
20535+}
20536+
20537+
20538+//-----------------------------------------------------------------------------
20539+// name: Brass_ctrl_startBlowing()
20540+// desc: CTRL function ...
20541+//-----------------------------------------------------------------------------
20542+CK_DLL_CTRL( Brass_ctrl_startBlowing )
20543+{
20544+ Brass * b = (Brass *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data);
20545+ t_CKFLOAT f = GET_NEXT_FLOAT(ARGS);
20546+ b->startBlowing( f, b->m_rate );
20547+}
20548+
20549+
20550+//-----------------------------------------------------------------------------
20551+// name: Brass_ctrl_stopBlowing()
20552+// desc: CTRL function ...
20553+//-----------------------------------------------------------------------------
20554+CK_DLL_CTRL( Brass_ctrl_stopBlowing )
20555+{
20556+ Brass * b = (Brass *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data);
20557+ t_CKFLOAT f = GET_NEXT_FLOAT(ARGS);
20558+ b->stopBlowing( f );
20559+}
20560+
20561+
20562+//-----------------------------------------------------------------------------
20563+// name: Brass_ctrl_clear()
20564+// desc: CTRL function ...
20565+//-----------------------------------------------------------------------------
20566+CK_DLL_CTRL( Brass_ctrl_clear )
20567+{
20568+ Brass * b = (Brass *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data);
20569+ b->clear();
20570+}
20571+
20572+
20573+//-----------------------------------------------------------------------------
20574+// name: Brass_ctrl_rate()
20575+// desc: CTRL function ...
20576+//-----------------------------------------------------------------------------
20577+CK_DLL_CTRL( Brass_ctrl_rate )
20578+{
20579+ Brass * b = (Brass *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data);
20580+ t_CKFLOAT f = GET_NEXT_FLOAT(ARGS);
20581+ b->m_rate = f;
20582+ RETURN->v_float = (t_CKFLOAT)b->m_rate;
20583+}
20584+
20585+
20586+//-----------------------------------------------------------------------------
20587+// name: Brass_cget_rate()
20588+// desc: CGET function ...
20589+//-----------------------------------------------------------------------------
20590+CK_DLL_CGET( Brass_cget_rate )
20591+{
20592+ Brass * b = (Brass *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data);
20593+ RETURN->v_float = (t_CKFLOAT)b->m_rate;
20594+}
20595+
20596+
20597+//-----------------------------------------------------------------------------
20598+// name: Brass_ctrl_lip()
20599+// desc: CTRL function ...
20600+//-----------------------------------------------------------------------------
20601+CK_DLL_CTRL( Brass_ctrl_lip )
20602+{
20603+ Brass * b = (Brass *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data);
20604+ t_CKFLOAT f = GET_NEXT_FLOAT(ARGS);
20605+ b->controlChange( 2, f * 128.0 );
20606+ RETURN->v_float = (t_CKFLOAT)b->m_lip;
20607+}
20608+
20609+
20610+//-----------------------------------------------------------------------------
20611+// name: Brass_cget_lip()
20612+// desc: CGET function ...
20613+//-----------------------------------------------------------------------------
20614+CK_DLL_CGET( Brass_cget_lip )
20615+{
20616+ Brass * b = (Brass *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data);
20617+ RETURN->v_float = (t_CKFLOAT)b->m_lip;
20618+}
20619+
20620+
20621+//-----------------------------------------------------------------------------
20622+// name: Brass_ctrl_slide()
20623+// desc: CTRL function ...
20624+//-----------------------------------------------------------------------------
20625+CK_DLL_CTRL( Brass_ctrl_slide )
20626+{
20627+ Brass * b = (Brass *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data);
20628+ t_CKFLOAT f = GET_NEXT_FLOAT(ARGS);
20629+ b->controlChange( 4, f * 128.0 );
20630+ RETURN->v_float = (t_CKFLOAT)b->m_slide;
20631+}
20632+
20633+
20634+//-----------------------------------------------------------------------------
20635+// name: Brass_cget_slide()
20636+// desc: CGET function ...
20637+//-----------------------------------------------------------------------------
20638+CK_DLL_CGET( Brass_cget_slide )
20639+{
20640+ Brass * b = (Brass *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data);
20641+ RETURN->v_float = (t_CKFLOAT)b->m_slide;
20642+}
20643+
20644+
20645+//-----------------------------------------------------------------------------
20646+// name: Brass_ctrl_vibratoFreq()
20647+// desc: CTRL function ...
20648+//-----------------------------------------------------------------------------
20649+CK_DLL_CTRL( Brass_ctrl_vibratoFreq )
20650+{
20651+ Brass * b = (Brass *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data);
20652+ t_CKFLOAT f = GET_NEXT_FLOAT(ARGS);
20653+ b->setVibratoFreq( f );
20654+ RETURN->v_float = (t_CKFLOAT)b->m_vibratoFreq;
20655+}
20656+
20657+
20658+//-----------------------------------------------------------------------------
20659+// name: Brass_cget_vibratoFreq()
20660+// desc: CGET function ...
20661+//-----------------------------------------------------------------------------
20662+CK_DLL_CGET( Brass_cget_vibratoFreq )
20663+{
20664+ Brass * b = (Brass *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data);
20665+ RETURN->v_float = (t_CKFLOAT)b->m_vibratoFreq;
20666+}
20667+
20668+
20669+//-----------------------------------------------------------------------------
20670+// name: Brass_ctrl_vibratoGain()
20671+// desc: CTRL function ...
20672+//-----------------------------------------------------------------------------
20673+CK_DLL_CTRL( Brass_ctrl_vibratoGain )
20674+{
20675+ Brass * b = (Brass *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data);
20676+ t_CKFLOAT f = GET_NEXT_FLOAT(ARGS);
20677+ b->controlChange( 1, f * 128.0 );
20678+ RETURN->v_float = (t_CKFLOAT)b->m_vibratoGain;
20679+}
20680+
20681+
20682+//-----------------------------------------------------------------------------
20683+// name: Brass_cget_vibratoGain()
20684+// desc: CGET function ...
20685+//-----------------------------------------------------------------------------
20686+CK_DLL_CGET( Brass_cget_vibratoGain)
20687+{
20688+ Brass * b = (Brass *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data);
20689+ RETURN->v_float = (t_CKFLOAT)b->m_vibratoGain;
20690+}
20691+
20692+
20693+//-----------------------------------------------------------------------------
20694+// name: Brass_ctrl_volume()
20695+// desc: CTRL function ...
20696+//-----------------------------------------------------------------------------
20697+CK_DLL_CTRL( Brass_ctrl_volume )
20698+{
20699+ Brass * b = (Brass *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data);
20700+ t_CKFLOAT f = GET_NEXT_FLOAT(ARGS);
20701+ b->controlChange( 128, f * 128.0 );
20702+ RETURN->v_float = (t_CKFLOAT)b->m_volume;
20703+}
20704+
20705+
20706+//-----------------------------------------------------------------------------
20707+// name: Brass_cget_volume()
20708+// desc: CGET function ...
20709+//-----------------------------------------------------------------------------
20710+CK_DLL_CGET( Brass_cget_volume )
20711+{
20712+ Brass * b = (Brass *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data);
20713+ RETURN->v_float = (t_CKFLOAT)b->m_volume;
20714+}
20715+
20716+
20717+
20718+
20719+/*
20720+struct Clarinet_ {
20721+ Clarinet * imp;
20722+ double m_frequency;
20723+ double m_rate;
20724+ double m_reed;
20725+ Clarinet_ ( double d ) {
20726+ imp = new Clarinet(d);
20727+ m_frequency = 100.0;
20728+ m_rate = 0.5;
20729+ m_reed = 0.5;
2048120730 }
2048220731 }; */
2048320732
2048420733
20734+// Clarinet
2048520735 //-----------------------------------------------------------------------------
20486−// name: Brass_ctor()
20736+// name: Clarinet_ctor()
2048720737 // desc: CTOR function ...
2048820738 //-----------------------------------------------------------------------------
20489−CK_DLL_CTOR( Brass_ctor )
20739+CK_DLL_CTOR( Clarinet_ctor )
2049020740 {
20491− OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data) = (t_CKUINT)new Brass( 20.0 );
20741+ OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data) = (t_CKUINT)new Clarinet( 30.0 );
2049220742 }
2049320743
2049420744
2049520745 //-----------------------------------------------------------------------------
20496−// name: Brass_dtor()
20746+// name: Clarinet_dtor()
2049720747 // desc: DTOR function ...
2049820748 //-----------------------------------------------------------------------------
20499−CK_DLL_DTOR( Brass_dtor )
20749+CK_DLL_DTOR( Clarinet_dtor )
2050020750 {
20501− delete (Brass *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data);
20751+ delete (Clarinet *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data);
2050220752 OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data) = 0;
2050320753 }
2050420754
20505−
2050620755 //-----------------------------------------------------------------------------
20507−// name: Brass_tick()
20756+// name: Clarinet_tick()
2050820757 // desc: TICK function ...
2050920758 //-----------------------------------------------------------------------------
20510−CK_DLL_TICK( Brass_tick )
20759+CK_DLL_TICK( Clarinet_tick )
2051120760 {
20512− Brass * b = (Brass *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data);
20761+ Clarinet * b = (Clarinet *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data);
2051320762 *out = b->tick();
2051420763 return TRUE;
2051520764 }
2051620765
2051720766
2051820767 //-----------------------------------------------------------------------------
20519−// name: Brass_pmsg()
20768+// name: Clarinet_pmsg()
2052020769 // desc: PMSG function ...
2052120770 //-----------------------------------------------------------------------------
20522−CK_DLL_PMSG( Brass_pmsg )
20771+CK_DLL_PMSG( Clarinet_pmsg )
2052320772 {
2052420773 return TRUE;
2052520774 }
2052620775
2052720776
2052820777 //-----------------------------------------------------------------------------
20529−// name: Brass_ctrl_startBlowing()
20778+// name: Clarinet_ctrl_startBlowing()
2053020779 // desc: CTRL function ...
2053120780 //-----------------------------------------------------------------------------
20532−CK_DLL_CTRL( Brass_ctrl_startBlowing )
20781+CK_DLL_CTRL( Clarinet_ctrl_startBlowing )
2053320782 {
20534− Brass * b = (Brass *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data);
20783+ Clarinet * b = (Clarinet *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data);
2053520784 t_CKFLOAT f = GET_NEXT_FLOAT(ARGS);
2053620785 b->startBlowing( f, b->m_rate );
2053720786 }
2053820787
2053920788
2054020789 //-----------------------------------------------------------------------------
20541−// name: Brass_ctrl_stopBlowing()
20790+// name: Clarinet_ctrl_stopBlowing()
2054220791 // desc: CTRL function ...
2054320792 //-----------------------------------------------------------------------------
20544−CK_DLL_CTRL( Brass_ctrl_stopBlowing )
20793+CK_DLL_CTRL( Clarinet_ctrl_stopBlowing )
2054520794 {
20546− Brass * b = (Brass *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data);
20795+ Clarinet * b = (Clarinet *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data);
2054720796 t_CKFLOAT f = GET_NEXT_FLOAT(ARGS);
2054820797 b->stopBlowing( f );
2054920798 }
2055020799
2055120800
2055220801 //-----------------------------------------------------------------------------
20553−// name: Brass_ctrl_clear()
20802+// name: Clarinet_ctrl_clear()
2055420803 // desc: CTRL function ...
2055520804 //-----------------------------------------------------------------------------
20556−CK_DLL_CTRL( Brass_ctrl_clear )
20805+CK_DLL_CTRL( Clarinet_ctrl_clear )
2055720806 {
20558− Brass * b = (Brass *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data);
20807+ Clarinet * b = (Clarinet *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data);
2055920808 b->clear();
2056020809 }
2056120810
2056220811
2056320812 //-----------------------------------------------------------------------------
20564−// name: Brass_ctrl_rate()
20813+// name: Clarinet_ctrl_reed()
2056520814 // desc: CTRL function ...
2056620815 //-----------------------------------------------------------------------------
20567−CK_DLL_CTRL( Brass_ctrl_rate )
20816+CK_DLL_CTRL( Clarinet_ctrl_reed )
2056820817 {
20569− Brass * b = (Brass *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data);
20818+ Clarinet * b = (Clarinet *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data);
2057020819 t_CKFLOAT f = GET_NEXT_FLOAT(ARGS);
20571− b->m_rate = f;
20572− RETURN->v_float = (t_CKFLOAT)b->m_rate;
20820+ b->controlChange( 2, f * 128.0 );
20821+ RETURN->v_float = (t_CKFLOAT)b->m_reed;
2057320822 }
2057420823
2057520824
2057620825 //-----------------------------------------------------------------------------
20577−// name: Brass_cget_rate()
20826+// name: Clarinet_cget_reed()
2057820827 // desc: CGET function ...
2057920828 //-----------------------------------------------------------------------------
20580−CK_DLL_CGET( Brass_cget_rate )
20829+CK_DLL_CGET( Clarinet_cget_reed )
2058120830 {
20582− Brass * b = (Brass *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data);
20583− RETURN->v_float = (t_CKFLOAT)b->m_rate;
20831+ Clarinet * b = (Clarinet *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data);
20832+ RETURN->v_float = (t_CKFLOAT)b->m_reed;
2058420833 }
2058520834
2058620835
2058720836 //-----------------------------------------------------------------------------
20588−// name: Brass_ctrl_lip()
20837+// name: Clarinet_ctrl_rate()
2058920838 // desc: CTRL function ...
2059020839 //-----------------------------------------------------------------------------
20591−CK_DLL_CTRL( Brass_ctrl_lip )
20840+CK_DLL_CTRL( Clarinet_ctrl_rate )
2059220841 {
20593− Brass * b = (Brass *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data);
20842+ Clarinet * b = (Clarinet *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data);
2059420843 t_CKFLOAT f = GET_NEXT_FLOAT(ARGS);
20595− b->controlChange( 2, f * 128.0 );
20596− RETURN->v_float = (t_CKFLOAT)b->m_lip;
20844+ b->m_rate = f;
20845+ RETURN->v_float = (t_CKFLOAT)b->m_rate;
2059720846 }
2059820847
2059920848
2060020849 //-----------------------------------------------------------------------------
20601−// name: Brass_cget_lip()
20850+// name: Clarinet_cget_rate()
2060220851 // desc: CGET function ...
2060320852 //-----------------------------------------------------------------------------
20604−CK_DLL_CGET( Brass_cget_lip )
20853+CK_DLL_CGET( Clarinet_cget_rate )
2060520854 {
20606− Brass * b = (Brass *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data);
20607− RETURN->v_float = (t_CKFLOAT)b->m_lip;
20855+ Clarinet * b = (Clarinet *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data);
20856+ RETURN->v_float = (t_CKFLOAT) b->m_rate;
2060820857 }
2060920858
2061020859
2061120860 //-----------------------------------------------------------------------------
20612−// name: Brass_ctrl_slide()
20861+// name: Clarinet_ctrl_noiseGain()
2061320862 // desc: CTRL function ...
2061420863 //-----------------------------------------------------------------------------
20615−CK_DLL_CTRL( Brass_ctrl_slide )
20864+CK_DLL_CTRL( Clarinet_ctrl_noiseGain )
2061620865 {
20617− Brass * b = (Brass *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data);
20866+ Clarinet * b = (Clarinet *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data);
2061820867 t_CKFLOAT f = GET_NEXT_FLOAT(ARGS);
2061920868 b->controlChange( 4, f * 128.0 );
20620− RETURN->v_float = (t_CKFLOAT)b->m_slide;
20869+ RETURN->v_float = (t_CKFLOAT)b->m_noiseGain;
2062120870 }
2062220871
2062320872
2062420873 //-----------------------------------------------------------------------------
20625−// name: Brass_cget_slide()
20874+// name: Clarinet_cget_noiseGain()
2062620875 // desc: CGET function ...
2062720876 //-----------------------------------------------------------------------------
20628−CK_DLL_CGET( Brass_cget_slide )
20877+CK_DLL_CGET( Clarinet_cget_noiseGain )
2062920878 {
20630− Brass * b = (Brass *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data);
20631− RETURN->v_float = (t_CKFLOAT)b->m_slide;
20879+ Clarinet * b = (Clarinet *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data);
20880+ RETURN->v_float = (t_CKFLOAT)b->m_noiseGain;
2063220881 }
2063320882
2063420883
2063520884 //-----------------------------------------------------------------------------
20636−// name: Brass_ctrl_vibratoFreq()
20885+// name: Clarinet_ctrl_vibratoFreq()
2063720886 // desc: CTRL function ...
2063820887 //-----------------------------------------------------------------------------
20639−CK_DLL_CTRL( Brass_ctrl_vibratoFreq )
20888+CK_DLL_CTRL( Clarinet_ctrl_vibratoFreq )
2064020889 {
20641− Brass * b = (Brass *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data);
20890+ Clarinet * b = (Clarinet *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data);
2064220891 t_CKFLOAT f = GET_NEXT_FLOAT(ARGS);
2064320892 b->setVibratoFreq( f );
2064420893 RETURN->v_float = (t_CKFLOAT)b->m_vibratoFreq;
@@ -20646,23 +20895,23 @@ CK_DLL_CTRL( Brass_ctrl_vibratoFreq ) · 1 unmodified line
2064620895
2064720896
2064820897 //-----------------------------------------------------------------------------
20649−// name: Brass_cget_vibratoFreq()
20898+// name: Clarinet_cget_vibratoFreq()
2065020899 // desc: CGET function ...
2065120900 //-----------------------------------------------------------------------------
20652−CK_DLL_CGET( Brass_cget_vibratoFreq )
20901+CK_DLL_CGET( Clarinet_cget_vibratoFreq )
2065320902 {
20654− Brass * b = (Brass *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data);
20903+ Clarinet * b = (Clarinet *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data);
2065520904 RETURN->v_float = (t_CKFLOAT)b->m_vibratoFreq;
2065620905 }
2065720906
2065820907
2065920908 //-----------------------------------------------------------------------------
20660−// name: Brass_ctrl_vibratoGain()
20909+// name: Clarinet_ctrl_vibratoGain()
2066120910 // desc: CTRL function ...
2066220911 //-----------------------------------------------------------------------------
20663−CK_DLL_CTRL( Brass_ctrl_vibratoGain )
20912+CK_DLL_CTRL( Clarinet_ctrl_vibratoGain )
2066420913 {
20665− Brass * b = (Brass *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data);
20914+ Clarinet * b = (Clarinet *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data);
2066620915 t_CKFLOAT f = GET_NEXT_FLOAT(ARGS);
2066720916 b->controlChange( 1, f * 128.0 );
2066820917 RETURN->v_float = (t_CKFLOAT)b->m_vibratoGain;
@@ -20670,23 +20919,23 @@ CK_DLL_CTRL( Brass_ctrl_vibratoGain ) · 1 unmodified line
2067020919
2067120920
2067220921 //-----------------------------------------------------------------------------
20673−// name: Brass_cget_vibratoGain()
20922+// name: Clarinet_cget_vibratoGain()
2067420923 // desc: CGET function ...
2067520924 //-----------------------------------------------------------------------------
20676−CK_DLL_CGET( Brass_cget_vibratoGain)
20925+CK_DLL_CGET( Clarinet_cget_vibratoGain )
2067720926 {
20678− Brass * b = (Brass *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data);
20927+ Clarinet * b = (Clarinet *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data);
2067920928 RETURN->v_float = (t_CKFLOAT)b->m_vibratoGain;
2068020929 }
2068120930
2068220931
2068320932 //-----------------------------------------------------------------------------
20684−// name: Brass_ctrl_volume()
20933+// name: Clarinet_ctrl_pressure()
2068520934 // desc: CTRL function ...
2068620935 //-----------------------------------------------------------------------------
20687−CK_DLL_CTRL( Brass_ctrl_volume )
20936+CK_DLL_CTRL( Clarinet_ctrl_pressure )
2068820937 {
20689− Brass * b = (Brass *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data);
20938+ Clarinet * b = (Clarinet *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data);
2069020939 t_CKFLOAT f = GET_NEXT_FLOAT(ARGS);
2069120940 b->controlChange( 128, f * 128.0 );
2069220941 RETURN->v_float = (t_CKFLOAT)b->m_volume;
@@ -20694,166 +20943,217 @@ CK_DLL_CTRL( Brass_ctrl_volume ) · 1 unmodified line
2069420943
2069520944
2069620945 //-----------------------------------------------------------------------------
20697−// name: Brass_cget_volume()
20946+// name: Clarinet_cget_pressure()
2069820947 // desc: CGET function ...
2069920948 //-----------------------------------------------------------------------------
20700−CK_DLL_CGET( Brass_cget_volume )
20949+CK_DLL_CGET( Clarinet_cget_pressure )
2070120950 {
20702− Brass * b = (Brass *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data);
20951+ Clarinet * b = (Clarinet *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data);
2070320952 RETURN->v_float = (t_CKFLOAT)b->m_volume;
2070420953 }
2070520954
2070620955
20956+// Flute
20957+struct Flute_ {
20958+ Flute * imp;
2070720959
20708−
20709−/*
20710−struct Clarinet_ {
20711− Clarinet * imp;
2071220960 double m_frequency;
2071320961 double m_rate;
20714− double m_reed;
20715− Clarinet_ ( double d ) {
20716− imp = new Clarinet(d);
20962+ double m_jetDelay;
20963+ double m_jetReflection;
20964+ double m_endReflection;
20965+
20966+ Flute_ ( double d ) {
20967+ imp = new Flute(d);
2071720968 m_frequency = 100.0;
2071820969 m_rate = 0.5;
20719− m_reed = 0.5;
20970+ m_jetDelay = 0.0;
20971+ m_jetReflection = 0.0;
20972+ m_endReflection = 0.0;
2072020973 }
20721−}; */
20974+};
2072220975
2072320976
20724−// Clarinet
2072520977 //-----------------------------------------------------------------------------
20726−// name: Clarinet_ctor()
20978+// name: Flute_ctor()
2072720979 // desc: CTOR function ...
2072820980 //-----------------------------------------------------------------------------
20729−CK_DLL_CTOR( Clarinet_ctor )
20981+CK_DLL_CTOR( Flute_ctor )
2073020982 {
20731− OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data) = (t_CKUINT)new Clarinet( 30.0 );
20983+ OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data) = (t_CKUINT) new Flute( 40.0 );
2073220984 }
2073320985
2073420986
2073520987 //-----------------------------------------------------------------------------
20736−// name: Clarinet_dtor()
20988+// name: Flute_dtor()
2073720989 // desc: DTOR function ...
2073820990 //-----------------------------------------------------------------------------
20739−CK_DLL_DTOR( Clarinet_dtor )
20991+CK_DLL_DTOR( Flute_dtor )
2074020992 {
20741− delete (Clarinet *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data);
20993+ Flute * f = (Flute *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data);
20994+ SAFE_DELETE(f);
2074220995 OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data) = 0;
2074320996 }
2074420997
20998+
2074520999 //-----------------------------------------------------------------------------
20746−// name: Clarinet_tick()
21000+// name: Flute_tick()
2074721001 // desc: TICK function ...
2074821002 //-----------------------------------------------------------------------------
20749−CK_DLL_TICK( Clarinet_tick )
21003+CK_DLL_TICK( Flute_tick )
2075021004 {
20751− Clarinet * b = (Clarinet *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data);
21005+ Flute * b = (Flute *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data);
2075221006 *out = b->tick();
2075321007 return TRUE;
2075421008 }
2075521009
20756−
2075721010 //-----------------------------------------------------------------------------
20758−// name: Clarinet_pmsg()
21011+// name: Flute_pmsg()
2075921012 // desc: PMSG function ...
2076021013 //-----------------------------------------------------------------------------
20761−CK_DLL_PMSG( Clarinet_pmsg )
21014+CK_DLL_PMSG( Flute_pmsg )
2076221015 {
2076321016 return TRUE;
2076421017 }
2076521018
2076621019
2076721020 //-----------------------------------------------------------------------------
20768−// name: Clarinet_ctrl_startBlowing()
21021+// name: Flute_ctrl_startBlowing()
2076921022 // desc: CTRL function ...
2077021023 //-----------------------------------------------------------------------------
20771−CK_DLL_CTRL( Clarinet_ctrl_startBlowing )
21024+CK_DLL_CTRL( Flute_ctrl_startBlowing )
2077221025 {
20773− Clarinet * b = (Clarinet *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data);
21026+ Flute * b = (Flute *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data);
2077421027 t_CKFLOAT f = GET_NEXT_FLOAT(ARGS);
2077521028 b->startBlowing( f, b->m_rate );
2077621029 }
2077721030
20778−
2077921031 //-----------------------------------------------------------------------------
20780−// name: Clarinet_ctrl_stopBlowing()
21032+// name: Flute_ctrl_stopBlowing()
2078121033 // desc: CTRL function ...
2078221034 //-----------------------------------------------------------------------------
20783−CK_DLL_CTRL( Clarinet_ctrl_stopBlowing )
21035+CK_DLL_CTRL( Flute_ctrl_stopBlowing )
2078421036 {
20785− Clarinet * b = (Clarinet *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data);
21037+ Flute * b = (Flute *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data);
2078621038 t_CKFLOAT f = GET_NEXT_FLOAT(ARGS);
2078721039 b->stopBlowing( f );
2078821040 }
2078921041
2079021042
2079121043 //-----------------------------------------------------------------------------
20792−// name: Clarinet_ctrl_clear()
21044+// name: Flute_ctrl_clear()
2079321045 // desc: CTRL function ...
2079421046 //-----------------------------------------------------------------------------
20795−CK_DLL_CTRL( Clarinet_ctrl_clear )
21047+CK_DLL_CTRL( Flute_ctrl_clear )
2079621048 {
20797− Clarinet * b = (Clarinet *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data);
21049+ Flute * b = (Flute *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data);
2079821050 b->clear();
2079921051 }
2080021052
2080121053
2080221054 //-----------------------------------------------------------------------------
20803−// name: Clarinet_ctrl_reed()
21055+// name: Flute_ctrl_rate()
2080421056 // desc: CTRL function ...
2080521057 //-----------------------------------------------------------------------------
20806−CK_DLL_CTRL( Clarinet_ctrl_reed )
21058+CK_DLL_CTRL( Flute_ctrl_rate )
21059+{
21060+ Flute * b = (Flute *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data);
21061+ t_CKFLOAT f = GET_NEXT_FLOAT(ARGS);
21062+ b->m_rate = f;
21063+ RETURN->v_float = (t_CKFLOAT)b->m_rate;
21064+}
21065+
21066+
21067+//-----------------------------------------------------------------------------
21068+// name: Flute_cget_rate()
21069+// desc: CGET function ...
21070+//-----------------------------------------------------------------------------
21071+CK_DLL_CGET( Flute_cget_rate )
21072+{
21073+ Flute * b = (Flute *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data);
21074+ RETURN->v_float = (t_CKFLOAT)b->m_rate;
21075+}
21076+
21077+
21078+//-----------------------------------------------------------------------------
21079+// name: Flute_ctrl_jetDelay()
21080+// desc: CTRL function ...
21081+//-----------------------------------------------------------------------------
21082+CK_DLL_CTRL( Flute_ctrl_jetDelay )
21083+{
21084+ Flute * b = (Flute *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data);
21085+ t_CKFLOAT f = GET_NEXT_FLOAT(ARGS);
21086+ b->setJetDelay( f);
21087+ RETURN->v_float = (t_CKFLOAT)b->m_jetDelay;
21088+}
21089+
21090+
21091+//-----------------------------------------------------------------------------
21092+// name: Flute_cget_jetDelay()
21093+// desc: CGET function ...
21094+//-----------------------------------------------------------------------------
21095+CK_DLL_CGET( Flute_cget_jetDelay )
21096+{
21097+ Flute * b = (Flute *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data);
21098+ RETURN->v_float = (t_CKFLOAT)b->m_jetDelay;
21099+}
21100+
21101+
21102+//-----------------------------------------------------------------------------
21103+// name: Flute_ctrl_jetReflection()
21104+// desc: CTRL function ...
21105+//-----------------------------------------------------------------------------
21106+CK_DLL_CTRL( Flute_ctrl_jetReflection )
2080721107 {
20808− Clarinet * b = (Clarinet *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data);
21108+ Flute * b = (Flute *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data);
2080921109 t_CKFLOAT f = GET_NEXT_FLOAT(ARGS);
20810− b->controlChange( 2, f * 128.0 );
20811− RETURN->v_float = (t_CKFLOAT)b->m_reed;
21110+ b->setJetReflection( f);
21111+ RETURN->v_float = (t_CKFLOAT)b->m_jetReflection;
2081221112 }
2081321113
2081421114
2081521115 //-----------------------------------------------------------------------------
20816−// name: Clarinet_cget_reed()
21116+// name: Flute_cget_jetReflection()
2081721117 // desc: CGET function ...
2081821118 //-----------------------------------------------------------------------------
20819−CK_DLL_CGET( Clarinet_cget_reed )
21119+CK_DLL_CGET( Flute_cget_jetReflection )
2082021120 {
20821− Clarinet * b = (Clarinet *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data);
20822− RETURN->v_float = (t_CKFLOAT)b->m_reed;
21121+ Flute * b = (Flute *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data);
21122+ RETURN->v_float = (t_CKFLOAT)b->m_jetReflection;
2082321123 }
2082421124
2082521125
2082621126 //-----------------------------------------------------------------------------
20827−// name: Clarinet_ctrl_rate()
21127+// name: Flute_ctrl_endReflection()
2082821128 // desc: CTRL function ...
2082921129 //-----------------------------------------------------------------------------
20830−CK_DLL_CTRL( Clarinet_ctrl_rate )
21130+CK_DLL_CTRL( Flute_ctrl_endReflection )
2083121131 {
20832− Clarinet * b = (Clarinet *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data);
21132+ Flute * b = (Flute *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data);
2083321133 t_CKFLOAT f = GET_NEXT_FLOAT(ARGS);
20834− b->m_rate = f;
20835− RETURN->v_float = (t_CKFLOAT)b->m_rate;
21134+ b->setEndReflection(f);
21135+ RETURN->v_float = (t_CKFLOAT)b->m_endReflection;
2083621136 }
2083721137
2083821138
2083921139 //-----------------------------------------------------------------------------
20840−// name: Clarinet_cget_rate()
21140+// name: Flute_cget_endReflection()
2084121141 // desc: CGET function ...
2084221142 //-----------------------------------------------------------------------------
20843−CK_DLL_CGET( Clarinet_cget_rate )
21143+CK_DLL_CGET( Flute_cget_endReflection )
2084421144 {
20845− Clarinet * b = (Clarinet *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data);
20846− RETURN->v_float = (t_CKFLOAT) b->m_rate;
21145+ Flute * b = (Flute *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data);
21146+ RETURN->v_float = (t_CKFLOAT)b->m_endReflection;
2084721147 }
2084821148
2084921149
2085021150 //-----------------------------------------------------------------------------
20851−// name: Clarinet_ctrl_noiseGain()
21151+// name: Flute_ctrl_noiseGain()
2085221152 // desc: CTRL function ...
2085321153 //-----------------------------------------------------------------------------
20854−CK_DLL_CTRL( Clarinet_ctrl_noiseGain )
21154+CK_DLL_CTRL( Flute_ctrl_noiseGain )
2085521155 {
20856− Clarinet * b = (Clarinet *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data);
21156+ Flute * b = (Flute *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data);
2085721157 t_CKFLOAT f = GET_NEXT_FLOAT(ARGS);
2085821158 b->controlChange( 4, f * 128.0 );
2085921159 RETURN->v_float = (t_CKFLOAT)b->m_noiseGain;
@@ -20861,23 +21161,23 @@ CK_DLL_CTRL( Clarinet_ctrl_noiseGain ) · 1 unmodified line
2086121161
2086221162
2086321163 //-----------------------------------------------------------------------------
20864−// name: Clarinet_cget_noiseGain()
21164+// name: Flute_cget_noiseGain()
2086521165 // desc: CGET function ...
2086621166 //-----------------------------------------------------------------------------
20867−CK_DLL_CGET( Clarinet_cget_noiseGain )
21167+CK_DLL_CGET( Flute_cget_noiseGain )
2086821168 {
20869− Clarinet * b = (Clarinet *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data);
21169+ Flute * b = (Flute *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data);
2087021170 RETURN->v_float = (t_CKFLOAT)b->m_noiseGain;
2087121171 }
2087221172
2087321173
2087421174 //-----------------------------------------------------------------------------
20875−// name: Clarinet_ctrl_vibratoFreq()
21175+// name: Flute_ctrl_vibratoFreq()
2087621176 // desc: CTRL function ...
2087721177 //-----------------------------------------------------------------------------
20878−CK_DLL_CTRL( Clarinet_ctrl_vibratoFreq )
21178+CK_DLL_CTRL( Flute_ctrl_vibratoFreq )
2087921179 {
20880− Clarinet * b = (Clarinet *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data);
21180+ Flute * b = (Flute *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data);
2088121181 t_CKFLOAT f = GET_NEXT_FLOAT(ARGS);
2088221182 b->setVibratoFreq( f );
2088321183 RETURN->v_float = (t_CKFLOAT)b->m_vibratoFreq;
@@ -20885,23 +21185,23 @@ CK_DLL_CTRL( Clarinet_ctrl_vibratoFreq ) · 1 unmodified line
2088521185
2088621186
2088721187 //-----------------------------------------------------------------------------
20888−// name: Clarinet_cget_vibratoFreq()
21188+// name: Flute_cget_vibratoFreq()
2088921189 // desc: CGET function ...
2089021190 //-----------------------------------------------------------------------------
20891−CK_DLL_CGET( Clarinet_cget_vibratoFreq )
21191+CK_DLL_CGET( Flute_cget_vibratoFreq )
2089221192 {
20893− Clarinet * b = (Clarinet *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data);
21193+ Flute * b = (Flute *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data);
2089421194 RETURN->v_float = (t_CKFLOAT)b->m_vibratoFreq;
2089521195 }
2089621196
2089721197
2089821198 //-----------------------------------------------------------------------------
20899−// name: Clarinet_ctrl_vibratoGain()
21199+// name: Flute_ctrl_vibratoGain()
2090021200 // desc: CTRL function ...
2090121201 //-----------------------------------------------------------------------------
20902−CK_DLL_CTRL( Clarinet_ctrl_vibratoGain )
21202+CK_DLL_CTRL( Flute_ctrl_vibratoGain )
2090321203 {
20904− Clarinet * b = (Clarinet *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data);
21204+ Flute * b = (Flute *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data);
2090521205 t_CKFLOAT f = GET_NEXT_FLOAT(ARGS);
2090621206 b->controlChange( 1, f * 128.0 );
2090721207 RETURN->v_float = (t_CKFLOAT)b->m_vibratoGain;
@@ -20909,2290 +21209,2313 @@ CK_DLL_CTRL( Clarinet_ctrl_vibratoGain ) · 1 unmodified line
2090921209
2091021210
2091121211 //-----------------------------------------------------------------------------
20912−// name: Clarinet_cget_vibratoGain()
21212+// name: Flute_cget_vibratoGain()
2091321213 // desc: CGET function ...
2091421214 //-----------------------------------------------------------------------------
20915−CK_DLL_CGET( Clarinet_cget_vibratoGain )
21215+CK_DLL_CGET( Flute_cget_vibratoGain )
2091621216 {
20917− Clarinet * b = (Clarinet *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data);
21217+ Flute * b = (Flute *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data);
2091821218 RETURN->v_float = (t_CKFLOAT)b->m_vibratoGain;
2091921219 }
2092021220
2092121221
2092221222 //-----------------------------------------------------------------------------
20923−// name: Clarinet_ctrl_pressure()
21223+// name: Flute_ctrl_pressure()
2092421224 // desc: CTRL function ...
2092521225 //-----------------------------------------------------------------------------
20926−CK_DLL_CTRL( Clarinet_ctrl_pressure )
21226+CK_DLL_CTRL( Flute_ctrl_pressure )
2092721227 {
20928− Clarinet * b = (Clarinet *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data);
21228+ Flute * b = (Flute *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data);
2092921229 t_CKFLOAT f = GET_NEXT_FLOAT(ARGS);
2093021230 b->controlChange( 128, f * 128.0 );
20931− RETURN->v_float = (t_CKFLOAT)b->m_volume;
21231+ RETURN->v_float = (t_CKFLOAT)b->m_pressure;
2093221232 }
2093321233
2093421234
2093521235 //-----------------------------------------------------------------------------
20936−// name: Clarinet_cget_pressure()
21236+// name: Flute_cget_pressure()
2093721237 // desc: CGET function ...
2093821238 //-----------------------------------------------------------------------------
20939−CK_DLL_CGET( Clarinet_cget_pressure )
21239+CK_DLL_CGET( Flute_cget_pressure )
2094021240 {
20941− Clarinet * b = (Clarinet *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data);
20942− RETURN->v_float = (t_CKFLOAT)b->m_volume;
21241+ Flute * b = (Flute *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data);
21242+ RETURN->v_float = (t_CKFLOAT)b->m_pressure;
2094321243 }
2094421244
2094521245
20946−// Flute
20947−struct Flute_ {
20948− Flute * imp;
20949−
20950− double m_frequency;
20951− double m_rate;
20952− double m_jetDelay;
20953− double m_jetReflection;
20954− double m_endReflection;
21246+// ModalBar
21247+struct ModalBar_ {
21248+ ModalBar modalbar;
2095521249
20956− Flute_ ( double d ) {
20957− imp = new Flute(d);
20958− m_frequency = 100.0;
20959− m_rate = 0.5;
20960− m_jetDelay = 0.0;
20961− m_jetReflection = 0.0;
20962− m_endReflection = 0.0;
21250+ int m_preset;
21251+ int m_modeIndex;
21252+ double m_modeRatio;
21253+ double m_modeRadius;
21254+
21255+ ModalBar_ ( ) {
21256+ m_preset = 0;
21257+ m_modeIndex = 0;
2096321258 }
2096421259 };
2096521260
2096621261
2096721262 //-----------------------------------------------------------------------------
20968−// name: Flute_ctor()
21263+// name: ModalBar_ctor()
2096921264 // desc: CTOR function ...
2097021265 //-----------------------------------------------------------------------------
20971−CK_DLL_CTOR( Flute_ctor )
21266+CK_DLL_CTOR( ModalBar_ctor )
2097221267 {
20973− OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data) = (t_CKUINT) new Flute( 40.0 );
21268+ OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data) = (t_CKUINT)new ModalBar_();
2097421269 }
2097521270
2097621271
2097721272 //-----------------------------------------------------------------------------
20978−// name: Flute_dtor()
21273+// name: ModalBar_dtor()
2097921274 // desc: DTOR function ...
2098021275 //-----------------------------------------------------------------------------
20981−CK_DLL_DTOR( Flute_dtor )
21276+CK_DLL_DTOR( ModalBar_dtor )
2098221277 {
20983− Flute * f = (Flute *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data);
20984− SAFE_DELETE(f);
21278+ delete (ModalBar_ *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data);
2098521279 OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data) = 0;
2098621280 }
2098721281
2098821282
2098921283 //-----------------------------------------------------------------------------
20990−// name: Flute_tick()
21284+// name: ModalBar_tick()
2099121285 // desc: TICK function ...
2099221286 //-----------------------------------------------------------------------------
20993−CK_DLL_TICK( Flute_tick )
21287+CK_DLL_TICK( ModalBar_tick )
2099421288 {
20995− Flute * b = (Flute *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data);
20996− *out = b->tick();
21289+ ModalBar_ * b = (ModalBar_ *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data);
21290+ *out = b->modalbar.tick();
2099721291 return TRUE;
2099821292 }
2099921293
21294+
2100021295 //-----------------------------------------------------------------------------
21001−// name: Flute_pmsg()
21296+// name: ModalBar_pmsg()
2100221297 // desc: PMSG function ...
2100321298 //-----------------------------------------------------------------------------
21004−CK_DLL_PMSG( Flute_pmsg )
21299+CK_DLL_PMSG( ModalBar_pmsg )
2100521300 {
2100621301 return TRUE;
2100721302 }
2100821303
2100921304
2101021305 //-----------------------------------------------------------------------------
21011−// name: Flute_ctrl_startBlowing()
21306+// name: ModalBar_ctrl_strike()
2101221307 // desc: CTRL function ...
2101321308 //-----------------------------------------------------------------------------
21014−CK_DLL_CTRL( Flute_ctrl_startBlowing )
21309+CK_DLL_CTRL( ModalBar_ctrl_strike )
2101521310 {
21016− Flute * b = (Flute *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data);
21311+ ModalBar_ * b = (ModalBar_ *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data);
2101721312 t_CKFLOAT f = GET_NEXT_FLOAT(ARGS);
21018− b->startBlowing( f, b->m_rate );
21313+ b->modalbar.strike( f );
2101921314 }
2102021315
21316+
2102121317 //-----------------------------------------------------------------------------
21022−// name: Flute_ctrl_stopBlowing()
21318+// name: ModalBar_ctrl_damp()
2102321319 // desc: CTRL function ...
2102421320 //-----------------------------------------------------------------------------
21025−CK_DLL_CTRL( Flute_ctrl_stopBlowing )
21321+CK_DLL_CTRL( ModalBar_ctrl_damp )
2102621322 {
21027− Flute * b = (Flute *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data);
21323+ ModalBar_ * b = (ModalBar_ *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data);
2102821324 t_CKFLOAT f = GET_NEXT_FLOAT(ARGS);
21029− b->stopBlowing( f );
21325+ b->modalbar.damp( f );
2103021326 }
2103121327
2103221328
2103321329 //-----------------------------------------------------------------------------
21034−// name: Flute_ctrl_clear()
21330+// name: ModalBar_ctrl_clear()
2103521331 // desc: CTRL function ...
2103621332 //-----------------------------------------------------------------------------
21037−CK_DLL_CTRL( Flute_ctrl_clear )
21333+CK_DLL_CTRL( ModalBar_ctrl_clear )
21334+{
21335+ ModalBar_ * b = (ModalBar_ *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data);
21336+ b->modalbar.clear();
21337+}
21338+
21339+
21340+//-----------------------------------------------------------------------------
21341+// name: ModalBar_ctrl_preset()
21342+// desc: CTRL function ...
21343+//-----------------------------------------------------------------------------
21344+CK_DLL_CTRL( ModalBar_ctrl_preset )
21345+{
21346+ ModalBar_ * b = (ModalBar_ *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data);
21347+ int f = GET_CK_INT(ARGS);
21348+ b->m_preset = f;
21349+ b->modalbar.setPreset ( f );
21350+ RETURN->v_int = (t_CKINT)b->m_preset;
21351+}
21352+
21353+
21354+//-----------------------------------------------------------------------------
21355+// name: ModalBar_cget_preset()
21356+// desc: CGET function ...
21357+//-----------------------------------------------------------------------------
21358+CK_DLL_CGET( ModalBar_cget_preset )
21359+{
21360+ ModalBar_ * b = (ModalBar_ *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data);
21361+ RETURN->v_int = (t_CKINT)b->m_preset;
21362+}
21363+
21364+
21365+//-----------------------------------------------------------------------------
21366+// name: ModalBar_ctrl_strikePosition()
21367+// desc: CTRL function ...
21368+//-----------------------------------------------------------------------------
21369+CK_DLL_CTRL( ModalBar_ctrl_strikePosition )
21370+{
21371+ ModalBar_ * b = (ModalBar_ *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data);
21372+ t_CKFLOAT f = GET_NEXT_FLOAT(ARGS);
21373+ b->modalbar.setStrikePosition( f );
21374+ RETURN->v_float = (t_CKFLOAT)b->modalbar.strikePosition;
21375+}
21376+
21377+
21378+//-----------------------------------------------------------------------------
21379+// name: ModalBar_cget_strikePosition()
21380+// desc: CGET function ...
21381+//-----------------------------------------------------------------------------
21382+CK_DLL_CGET( ModalBar_cget_strikePosition )
21383+{
21384+ ModalBar_ * b = (ModalBar_ *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data);
21385+ RETURN->v_float = (t_CKFLOAT)b->modalbar.strikePosition;
21386+}
21387+
21388+
21389+//-----------------------------------------------------------------------------
21390+// name: ModalBar_ctrl_vibratoGain()
21391+// desc: CTRL function ...
21392+//-----------------------------------------------------------------------------
21393+CK_DLL_CTRL( ModalBar_ctrl_vibratoGain )
21394+{
21395+ ModalBar_ * b = (ModalBar_ *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data);
21396+ t_CKFLOAT f = GET_NEXT_FLOAT(ARGS);
21397+ b->modalbar.controlChange( 11, f*128 );
21398+ RETURN->v_float = (t_CKFLOAT)b->modalbar.m_vibratoGain;
21399+}
21400+
21401+
21402+//-----------------------------------------------------------------------------
21403+// name: ModalBar_cget_vibratoGain()
21404+// desc: CGET function ...
21405+//-----------------------------------------------------------------------------
21406+CK_DLL_CGET( ModalBar_cget_vibratoGain )
21407+{
21408+ ModalBar_ * b = (ModalBar_ *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data);
21409+ RETURN->v_float = (t_CKFLOAT)b->modalbar.m_vibratoGain;
21410+}
21411+
21412+
21413+//-----------------------------------------------------------------------------
21414+// name: ModalBar_ctrl_vibratoFreq()
21415+// desc: CTRL function ...
21416+//-----------------------------------------------------------------------------
21417+CK_DLL_CTRL( ModalBar_ctrl_vibratoFreq )
21418+{
21419+ ModalBar_ * b = (ModalBar_ *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data);
21420+ t_CKFLOAT f = GET_NEXT_FLOAT(ARGS);
21421+ b->modalbar.vibrato->setFrequency( f );
21422+ b->modalbar.m_vibratoFreq = b->modalbar.vibrato->m_freq;
21423+ RETURN->v_float = (t_CKFLOAT)b->modalbar.m_vibratoFreq;
21424+}
21425+
21426+
21427+//-----------------------------------------------------------------------------
21428+// name: ModalBar_cget_vibratoFreq()
21429+// desc: CGET function ...
21430+//-----------------------------------------------------------------------------
21431+CK_DLL_CGET( ModalBar_cget_vibratoFreq )
2103821432 {
21039− Flute * b = (Flute *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data);
21040− b->clear();
21433+ ModalBar_ * b = (ModalBar_ *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data);
21434+ RETURN->v_float = (t_CKFLOAT)b->modalbar.m_vibratoFreq;
2104121435 }
2104221436
2104321437
2104421438 //-----------------------------------------------------------------------------
21045−// name: Flute_ctrl_rate()
21439+// name: ModalBar_ctrl_stickHardness()
2104621440 // desc: CTRL function ...
2104721441 //-----------------------------------------------------------------------------
21048−CK_DLL_CTRL( Flute_ctrl_rate )
21442+CK_DLL_CTRL( ModalBar_ctrl_stickHardness )
2104921443 {
21050− Flute * b = (Flute *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data);
21444+ ModalBar_ * b = (ModalBar_ *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data);
2105121445 t_CKFLOAT f = GET_NEXT_FLOAT(ARGS);
21052− b->m_rate = f;
21053− RETURN->v_float = (t_CKFLOAT)b->m_rate;
21446+ b->modalbar.setStickHardness ( f );
21447+ RETURN->v_float = (t_CKFLOAT)b->modalbar.stickHardness;
2105421448 }
2105521449
2105621450
21451+
2105721452 //-----------------------------------------------------------------------------
21058−// name: Flute_cget_rate()
21453+// name: ModalBar_cget_stickHardness()
2105921454 // desc: CGET function ...
2106021455 //-----------------------------------------------------------------------------
21061−CK_DLL_CGET( Flute_cget_rate )
21456+CK_DLL_CGET( ModalBar_cget_stickHardness )
2106221457 {
21063− Flute * b = (Flute *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data);
21064− RETURN->v_float = (t_CKFLOAT)b->m_rate;
21458+ ModalBar_ * b = (ModalBar_ *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data);
21459+ RETURN->v_float = (t_CKFLOAT)b->modalbar.stickHardness;
2106521460 }
2106621461
2106721462
2106821463 //-----------------------------------------------------------------------------
21069−// name: Flute_ctrl_jetDelay()
21464+// name: ModalBar_ctrl_masterGain()
2107021465 // desc: CTRL function ...
2107121466 //-----------------------------------------------------------------------------
21072−CK_DLL_CTRL( Flute_ctrl_jetDelay )
21467+CK_DLL_CTRL( ModalBar_ctrl_masterGain )
2107321468 {
21074− Flute * b = (Flute *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data);
21469+ ModalBar_ * b = (ModalBar_ *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data);
2107521470 t_CKFLOAT f = GET_NEXT_FLOAT(ARGS);
21076− b->setJetDelay( f);
21077− RETURN->v_float = (t_CKFLOAT)b->m_jetDelay;
21471+ b->modalbar.setMasterGain( f );
21472+ RETURN->v_float = (t_CKFLOAT)b->modalbar.masterGain;
2107821473 }
2107921474
2108021475
2108121476 //-----------------------------------------------------------------------------
21082−// name: Flute_cget_jetDelay()
21477+// name: ModalBar_cget_masterGain()
2108321478 // desc: CGET function ...
2108421479 //-----------------------------------------------------------------------------
21085−CK_DLL_CGET( Flute_cget_jetDelay )
21480+CK_DLL_CGET( ModalBar_cget_masterGain )
2108621481 {
21087− Flute * b = (Flute *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data);
21088− RETURN->v_float = (t_CKFLOAT)b->m_jetDelay;
21482+ ModalBar_ * b = (ModalBar_ *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data);
21483+ RETURN->v_float = (t_CKFLOAT)b->modalbar.masterGain;
2108921484 }
2109021485
2109121486
2109221487 //-----------------------------------------------------------------------------
21093−// name: Flute_ctrl_jetReflection()
21488+// name: ModalBar_ctrl_directGain()
2109421489 // desc: CTRL function ...
2109521490 //-----------------------------------------------------------------------------
21096−CK_DLL_CTRL( Flute_ctrl_jetReflection )
21491+CK_DLL_CTRL( ModalBar_ctrl_directGain )
2109721492 {
21098− Flute * b = (Flute *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data);
21493+ ModalBar_ * b = (ModalBar_ *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data);
2109921494 t_CKFLOAT f = GET_NEXT_FLOAT(ARGS);
21100− b->setJetReflection( f);
21101− RETURN->v_float = (t_CKFLOAT)b->m_jetReflection;
21495+ b->modalbar.setDirectGain( f );
21496+ RETURN->v_float = (t_CKFLOAT) b->modalbar.directGain;
2110221497 }
2110321498
2110421499
2110521500 //-----------------------------------------------------------------------------
21106−// name: Flute_cget_jetReflection()
21501+// name: ModalBar_cget_directGain()
2110721502 // desc: CGET function ...
2110821503 //-----------------------------------------------------------------------------
21109−CK_DLL_CGET( Flute_cget_jetReflection )
21504+CK_DLL_CGET( ModalBar_cget_directGain )
2111021505 {
21111− Flute * b = (Flute *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data);
21112− RETURN->v_float = (t_CKFLOAT)b->m_jetReflection;
21506+ ModalBar_ * b = (ModalBar_ *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data);
21507+ RETURN->v_float = (t_CKFLOAT)b->modalbar.directGain;
2111321508 }
2111421509
2111521510
2111621511 //-----------------------------------------------------------------------------
21117−// name: Flute_ctrl_endReflection()
21512+// name: ModalBar_ctrl_mode()
2111821513 // desc: CTRL function ...
2111921514 //-----------------------------------------------------------------------------
21120−CK_DLL_CTRL( Flute_ctrl_endReflection )
21515+CK_DLL_CTRL( ModalBar_ctrl_mode )
2112121516 {
21122− Flute * b = (Flute *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data);
21123− t_CKFLOAT f = GET_NEXT_FLOAT(ARGS);
21124− b->setEndReflection(f);
21125− RETURN->v_float = (t_CKFLOAT)b->m_endReflection;
21517+ ModalBar_ * b = (ModalBar_ *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data);
21518+ int i = GET_CK_INT(ARGS);
21519+ if ( i >= 0 && i < b->modalbar.nModes )
21520+ {
21521+ b->m_modeIndex = i;
21522+ b->m_modeRatio = b->modalbar.ratios[i];
21523+ b->m_modeRadius = b->modalbar.radii[i];
21524+ RETURN->v_float = (t_CKFLOAT)b->m_modeIndex;
21525+ }
2112621526 }
2112721527
2112821528
2112921529 //-----------------------------------------------------------------------------
21130−// name: Flute_cget_endReflection()
21530+// name: ModalBar_cget_mode()
2113121531 // desc: CGET function ...
2113221532 //-----------------------------------------------------------------------------
21133−CK_DLL_CGET( Flute_cget_endReflection )
21533+CK_DLL_CGET( ModalBar_cget_mode )
2113421534 {
21135− Flute * b = (Flute *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data);
21136− RETURN->v_float = (t_CKFLOAT)b->m_endReflection;
21535+ ModalBar_ * b = (ModalBar_ *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data);
21536+ RETURN->v_float = (t_CKFLOAT)b->m_modeIndex;
2113721537 }
2113821538
2113921539
2114021540 //-----------------------------------------------------------------------------
21141−// name: Flute_ctrl_noiseGain()
21541+// name: ModalBar_ctrl_modeGain()
2114221542 // desc: CTRL function ...
2114321543 //-----------------------------------------------------------------------------
21144−CK_DLL_CTRL( Flute_ctrl_noiseGain )
21544+CK_DLL_CTRL( ModalBar_ctrl_modeGain )
2114521545 {
21146− Flute * b = (Flute *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data);
21546+ ModalBar_ * b = (ModalBar_ *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data);
2114721547 t_CKFLOAT f = GET_NEXT_FLOAT(ARGS);
21148− b->controlChange( 4, f * 128.0 );
21149− RETURN->v_float = (t_CKFLOAT)b->m_noiseGain;
21548+ b->modalbar.setModeGain( b->m_modeIndex, f );
21549+ RETURN->v_float = (t_CKFLOAT)b->modalbar.filters[b->m_modeIndex]->getGain();
2115021550 }
2115121551
2115221552
2115321553 //-----------------------------------------------------------------------------
21154−// name: Flute_cget_noiseGain()
21554+// name: ModalBar_cget_modeGain()
2115521555 // desc: CGET function ...
2115621556 //-----------------------------------------------------------------------------
21157−CK_DLL_CGET( Flute_cget_noiseGain )
21557+CK_DLL_CGET( ModalBar_cget_modeGain )
2115821558 {
21159− Flute * b = (Flute *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data);
21160− RETURN->v_float = (t_CKFLOAT)b->m_noiseGain;
21559+ ModalBar_ * b = (ModalBar_ *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data);
21560+ RETURN->v_float = (t_CKFLOAT)b->modalbar.filters[b->m_modeIndex]->getGain();
2116121561 }
2116221562
2116321563
2116421564 //-----------------------------------------------------------------------------
21165−// name: Flute_ctrl_vibratoFreq()
21565+// name: ModalBar_ctrl_modeRatio()
2116621566 // desc: CTRL function ...
2116721567 //-----------------------------------------------------------------------------
21168−CK_DLL_CTRL( Flute_ctrl_vibratoFreq )
21568+CK_DLL_CTRL( ModalBar_ctrl_modeRatio )
2116921569 {
21170− Flute * b = (Flute *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data);
21570+ ModalBar_ * b = (ModalBar_ *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data);
2117121571 t_CKFLOAT f = GET_NEXT_FLOAT(ARGS);
21172− b->setVibratoFreq( f );
21173− RETURN->v_float = (t_CKFLOAT)b->m_vibratoFreq;
21572+ if ( b->m_modeIndex >= 0 && b->m_modeIndex < b->modalbar.nModes )
21573+ {
21574+ b->modalbar.setRatioAndRadius( b->m_modeIndex, f , b->m_modeRadius );
21575+ b->m_modeRatio = b->modalbar.ratios[b->m_modeIndex];
21576+ RETURN->v_float = (t_CKFLOAT) b->m_modeRatio;
21577+ }
2117421578 }
2117521579
2117621580
2117721581 //-----------------------------------------------------------------------------
21178−// name: Flute_cget_vibratoFreq()
21582+// name: ModalBar_cget_modeRatio()
2117921583 // desc: CGET function ...
2118021584 //-----------------------------------------------------------------------------
21181−CK_DLL_CGET( Flute_cget_vibratoFreq )
21585+CK_DLL_CGET( ModalBar_cget_modeRatio )
2118221586 {
21183− Flute * b = (Flute *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data);
21184− RETURN->v_float = (t_CKFLOAT)b->m_vibratoFreq;
21587+ ModalBar_ * b = (ModalBar_ *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data);
21588+ RETURN->v_float = (t_CKFLOAT)b->m_modeRatio;
2118521589 }
2118621590
2118721591
2118821592 //-----------------------------------------------------------------------------
21189−// name: Flute_ctrl_vibratoGain()
21593+// name: ModalBar_ctrl_modeRadius()
2119021594 // desc: CTRL function ...
2119121595 //-----------------------------------------------------------------------------
21192−CK_DLL_CTRL( Flute_ctrl_vibratoGain )
21596+CK_DLL_CTRL( ModalBar_ctrl_modeRadius )
2119321597 {
21194− Flute * b = (Flute *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data);
21598+ ModalBar_ * b = (ModalBar_ *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data);
2119521599 t_CKFLOAT f = GET_NEXT_FLOAT(ARGS);
21196− b->controlChange( 1, f * 128.0 );
21197− RETURN->v_float = (t_CKFLOAT)b->m_vibratoGain;
21600+ if( b->m_modeIndex >= 0 && b->m_modeIndex < b->modalbar.nModes )
21601+ {
21602+ b->modalbar.setRatioAndRadius ( b->m_modeIndex, b->m_modeRatio, f );
21603+ b->m_modeRadius = b->modalbar.radii[b->m_modeIndex];
21604+ RETURN->v_float = (t_CKFLOAT) b->m_modeRadius;
21605+ }
2119821606 }
2119921607
2120021608
2120121609 //-----------------------------------------------------------------------------
21202−// name: Flute_cget_vibratoGain()
21610+// name: ModalBar_cget_modeRadius()
2120321611 // desc: CGET function ...
2120421612 //-----------------------------------------------------------------------------
21205−CK_DLL_CGET( Flute_cget_vibratoGain )
21613+CK_DLL_CGET( ModalBar_cget_modeRadius )
2120621614 {
21207− Flute * b = (Flute *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data);
21208− RETURN->v_float = (t_CKFLOAT)b->m_vibratoGain;
21615+ ModalBar_ * b = (ModalBar_ *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data);
21616+ RETURN->v_float = (t_CKFLOAT)b->m_modeRadius;
2120921617 }
2121021618
2121121619
2121221620 //-----------------------------------------------------------------------------
21213−// name: Flute_ctrl_pressure()
21621+// name: ModalBar_ctrl_volume()
2121421622 // desc: CTRL function ...
2121521623 //-----------------------------------------------------------------------------
21216−CK_DLL_CTRL( Flute_ctrl_pressure )
21624+CK_DLL_CTRL( ModalBar_ctrl_volume )
2121721625 {
21218− Flute * b = (Flute *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data);
21626+ ModalBar_ * b = (ModalBar_ *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data);
2121921627 t_CKFLOAT f = GET_NEXT_FLOAT(ARGS);
21220− b->controlChange( 128, f * 128.0 );
21221− RETURN->v_float = (t_CKFLOAT)b->m_pressure;
21628+ b->modalbar.controlChange( 128, f*128 );
21629+ RETURN->v_float = (t_CKFLOAT)b->modalbar.m_volume;
2122221630 }
2122321631
2122421632
2122521633 //-----------------------------------------------------------------------------
21226−// name: Flute_cget_pressure()
21634+// name: ModalBar_cget_volume()
2122721635 // desc: CGET function ...
2122821636 //-----------------------------------------------------------------------------
21229−CK_DLL_CGET( Flute_cget_pressure )
21637+CK_DLL_CGET( ModalBar_cget_volume )
2123021638 {
21231− Flute * b = (Flute *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data);
21232− RETURN->v_float = (t_CKFLOAT)b->m_pressure;
21639+ ModalBar_ * b = (ModalBar_ *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data);
21640+ RETURN->v_float = (t_CKFLOAT)b->modalbar.m_volume;
2123321641 }
2123421642
2123521643
21236−// ModalBar
21237−struct ModalBar_ {
21238− ModalBar modalbar;
2123921644
21240− int m_preset;
21241− int m_modeIndex;
21242− double m_modeRatio;
21243− double m_modeRadius;
21244−
21245− ModalBar_ ( ) {
21246− m_preset = 0;
21247− m_modeIndex = 0;
21645+
21646+// Sitar
21647+/*
21648+struct Sitar_ {
21649+ Sitar * imp;
21650+ double m_frequency;
21651+
21652+ Sitar_ ( double d ) {
21653+ imp = new Sitar(d);
21654+ m_frequency = 100.0;
2124821655 }
21249−};
21656+};*/
2125021657
2125121658
2125221659 //-----------------------------------------------------------------------------
21253−// name: ModalBar_ctor()
21660+// name: Sitar_ctor()
2125421661 // desc: CTOR function ...
2125521662 //-----------------------------------------------------------------------------
21256−CK_DLL_CTOR( ModalBar_ctor )
21663+CK_DLL_CTOR( Sitar_ctor )
2125721664 {
21258− OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data) = (t_CKUINT)new ModalBar_();
21665+ Sitar * sitar = new Sitar( 20 );
21666+ OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data) = (t_CKUINT)sitar;
21667+ // default
21668+ sitar->setFrequency( 220 );
2125921669 }
2126021670
2126121671
2126221672 //-----------------------------------------------------------------------------
21263−// name: ModalBar_dtor()
21673+// name: Sitar_dtor()
2126421674 // desc: DTOR function ...
2126521675 //-----------------------------------------------------------------------------
21266−CK_DLL_DTOR( ModalBar_dtor )
21676+CK_DLL_DTOR( Sitar_dtor )
2126721677 {
21268− delete (ModalBar_ *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data);
21678+ Sitar * s = (Sitar *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data);
21679+ SAFE_DELETE(s);
2126921680 OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data) = 0;
2127021681 }
2127121682
2127221683
2127321684 //-----------------------------------------------------------------------------
21274−// name: ModalBar_tick()
21685+// name: Sitar_tick()
2127521686 // desc: TICK function ...
2127621687 //-----------------------------------------------------------------------------
21277−CK_DLL_TICK( ModalBar_tick )
21688+CK_DLL_TICK( Sitar_tick )
2127821689 {
21279− ModalBar_ * b = (ModalBar_ *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data);
21280− *out = b->modalbar.tick();
21690+ Sitar * b = (Sitar *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data);
21691+ *out = b->tick();
2128121692 return TRUE;
2128221693 }
2128321694
2128421695
2128521696 //-----------------------------------------------------------------------------
21286−// name: ModalBar_pmsg()
21697+// name: Sitar_pmsg()
2128721698 // desc: PMSG function ...
2128821699 //-----------------------------------------------------------------------------
21289−CK_DLL_PMSG( ModalBar_pmsg )
21700+CK_DLL_PMSG( Sitar_pmsg )
2129021701 {
2129121702 return TRUE;
2129221703 }
2129321704
2129421705
2129521706 //-----------------------------------------------------------------------------
21296−// name: ModalBar_ctrl_strike()
21297−// desc: CTRL function ...
21298−//-----------------------------------------------------------------------------
21299−CK_DLL_CTRL( ModalBar_ctrl_strike )
21300−{
21301− ModalBar_ * b = (ModalBar_ *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data);
21302− t_CKFLOAT f = GET_NEXT_FLOAT(ARGS);
21303− b->modalbar.strike( f );
21304−}
21305−
21306−
21307−//-----------------------------------------------------------------------------
21308−// name: ModalBar_ctrl_damp()
21707+// name: Sitar_ctrl_pluck()
2130921708 // desc: CTRL function ...
2131021709 //-----------------------------------------------------------------------------
21311−CK_DLL_CTRL( ModalBar_ctrl_damp )
21710+CK_DLL_CTRL( Sitar_ctrl_pluck )
2131221711 {
21313− ModalBar_ * b = (ModalBar_ *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data);
21712+ Sitar * b = (Sitar *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data);
2131421713 t_CKFLOAT f = GET_NEXT_FLOAT(ARGS);
21315− b->modalbar.damp( f );
21316−}
21317−
21318−
21319−//-----------------------------------------------------------------------------
21320−// name: ModalBar_ctrl_clear()
21321−// desc: CTRL function ...
21322−//-----------------------------------------------------------------------------
21323−CK_DLL_CTRL( ModalBar_ctrl_clear )
21324−{
21325− ModalBar_ * b = (ModalBar_ *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data);
21326− b->modalbar.clear();
21714+ b->pluck( f );
2132721715 }
2132821716
2132921717
2133021718 //-----------------------------------------------------------------------------
21331−// name: ModalBar_ctrl_preset()
21719+// name: Sitar_ctrl_clear()
2133221720 // desc: CTRL function ...
2133321721 //-----------------------------------------------------------------------------
21334−CK_DLL_CTRL( ModalBar_ctrl_preset )
21722+CK_DLL_CTRL( Sitar_ctrl_clear )
2133521723 {
21336− ModalBar_ * b = (ModalBar_ *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data);
21337− int f = GET_CK_INT(ARGS);
21338− b->m_preset = f;
21339− b->modalbar.setPreset ( f );
21340− RETURN->v_int = (t_CKINT)b->m_preset;
21724+ Sitar * b = (Sitar *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data);
21725+ b->clear();
2134121726 }
2134221727
2134321728
21729+
21730+
2134421731 //-----------------------------------------------------------------------------
21345−// name: ModalBar_cget_preset()
21346−// desc: CGET function ...
21732+// name: Saxofony_ctor()
21733+// desc: CTOR function ...
2134721734 //-----------------------------------------------------------------------------
21348−CK_DLL_CGET( ModalBar_cget_preset )
21735+CK_DLL_CTOR( Saxofony_ctor )
2134921736 {
21350− ModalBar_ * b = (ModalBar_ *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data);
21351− RETURN->v_int = (t_CKINT)b->m_preset;
21737+ Saxofony * fony = new Saxofony( 20 );
21738+ OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data) = (t_CKUINT)fony;
21739+ // default
21740+ fony->setFrequency( 220 );
2135221741 }
2135321742
2135421743
2135521744 //-----------------------------------------------------------------------------
21356−// name: ModalBar_ctrl_strikePosition()
21357−// desc: CTRL function ...
21745+// name: Saxofony_dtor()
21746+// desc: DTOR function ...
2135821747 //-----------------------------------------------------------------------------
21359−CK_DLL_CTRL( ModalBar_ctrl_strikePosition )
21748+CK_DLL_DTOR( Saxofony_dtor )
2136021749 {
21361− ModalBar_ * b = (ModalBar_ *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data);
21362− t_CKFLOAT f = GET_NEXT_FLOAT(ARGS);
21363− b->modalbar.setStrikePosition( f );
21364− RETURN->v_float = (t_CKFLOAT)b->modalbar.strikePosition;
21750+ Saxofony * d = (Saxofony *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data);
21751+ SAFE_DELETE(d);
21752+ OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data) = 0;
2136521753 }
2136621754
2136721755
2136821756 //-----------------------------------------------------------------------------
21369−// name: ModalBar_cget_strikePosition()
21370−// desc: CGET function ...
21757+// name: Saxofony_tick()
21758+// desc: TICK function ...
2137121759 //-----------------------------------------------------------------------------
21372−CK_DLL_CGET( ModalBar_cget_strikePosition )
21760+CK_DLL_TICK( Saxofony_tick )
2137321761 {
21374− ModalBar_ * b = (ModalBar_ *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data);
21375− RETURN->v_float = (t_CKFLOAT)b->modalbar.strikePosition;
21762+ Saxofony * b = (Saxofony *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data);
21763+ *out = b->tick();
21764+ return TRUE;
2137621765 }
2137721766
2137821767
2137921768 //-----------------------------------------------------------------------------
21380−// name: ModalBar_ctrl_vibratoGain()
21381−// desc: CTRL function ...
21769+// name: Saxofony_pmsg()
21770+// desc: PMSG function ...
2138221771 //-----------------------------------------------------------------------------
21383−CK_DLL_CTRL( ModalBar_ctrl_vibratoGain )
21772+CK_DLL_PMSG( Saxofony_pmsg )
2138421773 {
21385− ModalBar_ * b = (ModalBar_ *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data);
21386− t_CKFLOAT f = GET_NEXT_FLOAT(ARGS);
21387− b->modalbar.controlChange( 11, f*128 );
21388− RETURN->v_float = (t_CKFLOAT)b->modalbar.m_vibratoGain;
21774+ return TRUE;
2138921775 }
2139021776
2139121777
2139221778 //-----------------------------------------------------------------------------
21393−// name: ModalBar_cget_vibratoGain()
21394−// desc: CGET function ...
21779+// name: Saxofony_ctrl_startBlowing()
21780+// desc: CTRL function ...
2139521781 //-----------------------------------------------------------------------------
21396−CK_DLL_CGET( ModalBar_cget_vibratoGain )
21782+CK_DLL_CTRL( Saxofony_ctrl_startBlowing )
2139721783 {
21398− ModalBar_ * b = (ModalBar_ *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data);
21399− RETURN->v_float = (t_CKFLOAT)b->modalbar.m_vibratoGain;
21784+ Saxofony * b = (Saxofony *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data);
21785+ t_CKFLOAT f = GET_NEXT_FLOAT(ARGS);
21786+ b->startBlowing( f, b->m_rate );
2140021787 }
2140121788
2140221789
2140321790 //-----------------------------------------------------------------------------
21404−// name: ModalBar_ctrl_vibratoFreq()
21791+// name: Saxofony_ctrl_stopBlowing()
2140521792 // desc: CTRL function ...
2140621793 //-----------------------------------------------------------------------------
21407−CK_DLL_CTRL( ModalBar_ctrl_vibratoFreq )
21794+CK_DLL_CTRL( Saxofony_ctrl_stopBlowing )
2140821795 {
21409− ModalBar_ * b = (ModalBar_ *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data);
21796+ Saxofony * b = (Saxofony *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data);
2141021797 t_CKFLOAT f = GET_NEXT_FLOAT(ARGS);
21411− b->modalbar.vibrato->setFrequency( f );
21412− b->modalbar.m_vibratoFreq = b->modalbar.vibrato->m_freq;
21413− RETURN->v_float = (t_CKFLOAT)b->modalbar.m_vibratoFreq;
21798+ b->stopBlowing( f );
2141421799 }
2141521800
2141621801
2141721802 //-----------------------------------------------------------------------------
21418−// name: ModalBar_cget_vibratoFreq()
21419−// desc: CGET function ...
21803+// name: Saxofony_ctrl_clear()
21804+// desc: CTRL function ...
2142021805 //-----------------------------------------------------------------------------
21421−CK_DLL_CGET( ModalBar_cget_vibratoFreq )
21806+CK_DLL_CTRL( Saxofony_ctrl_clear )
2142221807 {
21423− ModalBar_ * b = (ModalBar_ *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data);
21424− RETURN->v_float = (t_CKFLOAT)b->modalbar.m_vibratoFreq;
21808+ Saxofony * b = (Saxofony *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data);
21809+ b->clear();
2142521810 }
2142621811
2142721812
2142821813 //-----------------------------------------------------------------------------
21429−// name: ModalBar_ctrl_stickHardness()
21814+// name: Saxofony_ctrl_rate()
2143021815 // desc: CTRL function ...
2143121816 //-----------------------------------------------------------------------------
21432−CK_DLL_CTRL( ModalBar_ctrl_stickHardness )
21817+CK_DLL_CTRL( Saxofony_ctrl_rate )
2143321818 {
21434− ModalBar_ * b = (ModalBar_ *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data);
21819+ Saxofony * b = (Saxofony *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data);
2143521820 t_CKFLOAT f = GET_NEXT_FLOAT(ARGS);
21436− b->modalbar.setStickHardness ( f );
21437− RETURN->v_float = (t_CKFLOAT)b->modalbar.stickHardness;
21821+ b->m_rate = f;
21822+ RETURN->v_float = (t_CKFLOAT)b->m_rate;
2143821823 }
2143921824
2144021825
21441−
2144221826 //-----------------------------------------------------------------------------
21443−// name: ModalBar_cget_stickHardness()
21827+// name: Saxofony_cget_rate()
2144421828 // desc: CGET function ...
2144521829 //-----------------------------------------------------------------------------
21446−CK_DLL_CGET( ModalBar_cget_stickHardness )
21830+CK_DLL_CGET( Saxofony_cget_rate )
2144721831 {
21448− ModalBar_ * b = (ModalBar_ *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data);
21449− RETURN->v_float = (t_CKFLOAT)b->modalbar.stickHardness;
21832+ Saxofony * b = (Saxofony *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data);
21833+ RETURN->v_float = (t_CKFLOAT)b->m_rate;
2145021834 }
2145121835
2145221836
2145321837 //-----------------------------------------------------------------------------
21454−// name: ModalBar_ctrl_masterGain()
21838+// name: Saxofony_ctrl_blowPosition()
2145521839 // desc: CTRL function ...
2145621840 //-----------------------------------------------------------------------------
21457−CK_DLL_CTRL( ModalBar_ctrl_masterGain )
21841+CK_DLL_CTRL( Saxofony_ctrl_blowPosition )
2145821842 {
21459− ModalBar_ * b = (ModalBar_ *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data);
21843+ Saxofony * b = (Saxofony *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data);
2146021844 t_CKFLOAT f = GET_NEXT_FLOAT(ARGS);
21461− b->modalbar.setMasterGain( f );
21462− RETURN->v_float = (t_CKFLOAT)b->modalbar.masterGain;
21845+ b->setBlowPosition(f);
21846+ RETURN->v_float = (t_CKFLOAT)b->position;
2146321847 }
2146421848
2146521849
2146621850 //-----------------------------------------------------------------------------
21467−// name: ModalBar_cget_masterGain()
21851+// name: Saxofony_cget_blowPosition()
2146821852 // desc: CGET function ...
2146921853 //-----------------------------------------------------------------------------
21470−CK_DLL_CGET( ModalBar_cget_masterGain )
21854+CK_DLL_CGET( Saxofony_cget_blowPosition )
2147121855 {
21472− ModalBar_ * b = (ModalBar_ *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data);
21473− RETURN->v_float = (t_CKFLOAT)b->modalbar.masterGain;
21856+ Saxofony * b = (Saxofony *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data);
21857+ RETURN->v_float = (t_CKFLOAT)b->position;
2147421858 }
2147521859
2147621860
2147721861 //-----------------------------------------------------------------------------
21478−// name: ModalBar_ctrl_directGain()
21862+// name: Saxofony_ctrl_reed()
2147921863 // desc: CTRL function ...
2148021864 //-----------------------------------------------------------------------------
21481−CK_DLL_CTRL( ModalBar_ctrl_directGain )
21865+CK_DLL_CTRL( Saxofony_ctrl_reed )
2148221866 {
21483− ModalBar_ * b = (ModalBar_ *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data);
21867+ Saxofony * b = (Saxofony *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data);
2148421868 t_CKFLOAT f = GET_NEXT_FLOAT(ARGS);
21485− b->modalbar.setDirectGain( f );
21486− RETURN->v_float = (t_CKFLOAT) b->modalbar.directGain;
21869+ b->controlChange( 2, f * 128 );
21870+ RETURN->v_float = (t_CKFLOAT)b->m_stiffness;
2148721871 }
2148821872
2148921873
2149021874 //-----------------------------------------------------------------------------
21491−// name: ModalBar_cget_directGain()
21875+// name: Saxofony_cget_reed()
2149221876 // desc: CGET function ...
2149321877 //-----------------------------------------------------------------------------
21494−CK_DLL_CGET( ModalBar_cget_directGain )
21878+CK_DLL_CGET( Saxofony_cget_reed )
2149521879 {
21496− ModalBar_ * b = (ModalBar_ *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data);
21497− RETURN->v_float = (t_CKFLOAT)b->modalbar.directGain;
21880+ Saxofony * b = (Saxofony *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data);
21881+ RETURN->v_float = (t_CKFLOAT)b->m_stiffness;
2149821882 }
2149921883
2150021884
2150121885 //-----------------------------------------------------------------------------
21502−// name: ModalBar_ctrl_mode()
21886+// name: Saxofony_ctrl_aperture()
2150321887 // desc: CTRL function ...
2150421888 //-----------------------------------------------------------------------------
21505−CK_DLL_CTRL( ModalBar_ctrl_mode )
21889+CK_DLL_CTRL( Saxofony_ctrl_aperture )
2150621890 {
21507− ModalBar_ * b = (ModalBar_ *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data);
21508− int i = GET_CK_INT(ARGS);
21509− if ( i >= 0 && i < b->modalbar.nModes )
21510− {
21511− b->m_modeIndex = i;
21512− b->m_modeRatio = b->modalbar.ratios[i];
21513− b->m_modeRadius = b->modalbar.radii[i];
21514− RETURN->v_float = (t_CKFLOAT)b->m_modeIndex;
21515− }
21891+ Saxofony * b = (Saxofony *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data);
21892+ t_CKFLOAT f = GET_NEXT_FLOAT(ARGS);
21893+ b->controlChange( 26, f * 128 );
21894+ RETURN->v_float = (t_CKFLOAT)b->m_aperture;
2151621895 }
2151721896
2151821897
2151921898 //-----------------------------------------------------------------------------
21520−// name: ModalBar_cget_mode()
21899+// name: Saxofony_cget_aperture()
2152121900 // desc: CGET function ...
2152221901 //-----------------------------------------------------------------------------
21523−CK_DLL_CGET( ModalBar_cget_mode )
21902+CK_DLL_CGET( Saxofony_cget_aperture )
2152421903 {
21525− ModalBar_ * b = (ModalBar_ *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data);
21526− RETURN->v_float = (t_CKFLOAT)b->m_modeIndex;
21904+ Saxofony * b = (Saxofony *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data);
21905+ RETURN->v_float = (t_CKFLOAT)b->m_aperture;
2152721906 }
2152821907
2152921908
2153021909 //-----------------------------------------------------------------------------
21531−// name: ModalBar_ctrl_modeGain()
21910+// name: Saxofony_ctrl_noiseGain()
2153221911 // desc: CTRL function ...
2153321912 //-----------------------------------------------------------------------------
21534−CK_DLL_CTRL( ModalBar_ctrl_modeGain )
21913+CK_DLL_CTRL( Saxofony_ctrl_noiseGain )
2153521914 {
21536− ModalBar_ * b = (ModalBar_ *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data);
21915+ Saxofony * b = (Saxofony *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data);
2153721916 t_CKFLOAT f = GET_NEXT_FLOAT(ARGS);
21538− b->modalbar.setModeGain( b->m_modeIndex, f );
21539− RETURN->v_float = (t_CKFLOAT)b->modalbar.filters[b->m_modeIndex]->getGain();
21917+ b->controlChange( 4, f * 128 );
21918+ RETURN->v_float = (t_CKFLOAT)b->m_noiseGain;
2154021919 }
2154121920
2154221921
2154321922 //-----------------------------------------------------------------------------
21544−// name: ModalBar_cget_modeGain()
21923+// name: Saxofony_cget_noiseGain()
2154521924 // desc: CGET function ...
2154621925 //-----------------------------------------------------------------------------
21547−CK_DLL_CGET( ModalBar_cget_modeGain )
21926+CK_DLL_CGET( Saxofony_cget_noiseGain )
2154821927 {
21549− ModalBar_ * b = (ModalBar_ *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data);
21550− RETURN->v_float = (t_CKFLOAT)b->modalbar.filters[b->m_modeIndex]->getGain();
21928+ Saxofony * b = (Saxofony *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data);
21929+ RETURN->v_float = (t_CKFLOAT)b->m_noiseGain;
2155121930 }
2155221931
2155321932
2155421933 //-----------------------------------------------------------------------------
21555−// name: ModalBar_ctrl_modeRatio()
21934+// name: Saxofony_ctrl_vibratoFreq()
2155621935 // desc: CTRL function ...
2155721936 //-----------------------------------------------------------------------------
21558−CK_DLL_CTRL( ModalBar_ctrl_modeRatio )
21937+CK_DLL_CTRL( Saxofony_ctrl_vibratoFreq )
2155921938 {
21560− ModalBar_ * b = (ModalBar_ *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data);
21939+ Saxofony * b = (Saxofony *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data);
2156121940 t_CKFLOAT f = GET_NEXT_FLOAT(ARGS);
21562− if ( b->m_modeIndex >= 0 && b->m_modeIndex < b->modalbar.nModes )
21563− {
21564− b->modalbar.setRatioAndRadius( b->m_modeIndex, f , b->m_modeRadius );
21565− b->m_modeRatio = b->modalbar.ratios[b->m_modeIndex];
21566− RETURN->v_float = (t_CKFLOAT) b->m_modeRatio;
21567− }
21941+ b->vibrato->setFrequency( f );
21942+ RETURN->v_float = (t_CKFLOAT)b->vibrato->m_freq;
2156821943 }
2156921944
2157021945
2157121946 //-----------------------------------------------------------------------------
21572−// name: ModalBar_cget_modeRatio()
21947+// name: Saxofony_cget_vibratoFreq()
2157321948 // desc: CGET function ...
2157421949 //-----------------------------------------------------------------------------
21575−CK_DLL_CGET( ModalBar_cget_modeRatio )
21950+CK_DLL_CGET( Saxofony_cget_vibratoFreq )
2157621951 {
21577− ModalBar_ * b = (ModalBar_ *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data);
21578− RETURN->v_float = (t_CKFLOAT)b->m_modeRatio;
21952+ Saxofony * b = (Saxofony *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data);
21953+ RETURN->v_float = (t_CKFLOAT)b->vibrato->m_freq;
2157921954 }
2158021955
2158121956
2158221957 //-----------------------------------------------------------------------------
21583−// name: ModalBar_ctrl_modeRadius()
21958+// name: Saxofony_ctrl_vibratoGain()
2158421959 // desc: CTRL function ...
2158521960 //-----------------------------------------------------------------------------
21586−CK_DLL_CTRL( ModalBar_ctrl_modeRadius )
21961+CK_DLL_CTRL( Saxofony_ctrl_vibratoGain )
2158721962 {
21588− ModalBar_ * b = (ModalBar_ *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data);
21963+ Saxofony * b = (Saxofony *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data);
2158921964 t_CKFLOAT f = GET_NEXT_FLOAT(ARGS);
21590− if( b->m_modeIndex >= 0 && b->m_modeIndex < b->modalbar.nModes )
21591− {
21592− b->modalbar.setRatioAndRadius ( b->m_modeIndex, b->m_modeRatio, f );
21593− b->m_modeRadius = b->modalbar.radii[b->m_modeIndex];
21594− RETURN->v_float = (t_CKFLOAT) b->m_modeRadius;
21595− }
21965+ b->controlChange( 1, f * 128 );
21966+ RETURN->v_float = (t_CKFLOAT)b->m_vibratoGain;
2159621967 }
2159721968
2159821969
2159921970 //-----------------------------------------------------------------------------
21600−// name: ModalBar_cget_modeRadius()
21971+// name: Saxofony_cget_vibratoGain()
2160121972 // desc: CGET function ...
2160221973 //-----------------------------------------------------------------------------
21603−CK_DLL_CGET( ModalBar_cget_modeRadius )
21974+CK_DLL_CGET( Saxofony_cget_vibratoGain )
2160421975 {
21605− ModalBar_ * b = (ModalBar_ *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data);
21606− RETURN->v_float = (t_CKFLOAT)b->m_modeRadius;
21976+ Saxofony * b = (Saxofony *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data);
21977+ RETURN->v_float = (t_CKFLOAT)b->m_vibratoGain;
2160721978 }
2160821979
2160921980
2161021981 //-----------------------------------------------------------------------------
21611−// name: ModalBar_ctrl_volume()
21982+// name: Saxofony_ctrl_pressure()
2161221983 // desc: CTRL function ...
2161321984 //-----------------------------------------------------------------------------
21614−CK_DLL_CTRL( ModalBar_ctrl_volume )
21985+CK_DLL_CTRL( Saxofony_ctrl_pressure )
2161521986 {
21616− ModalBar_ * b = (ModalBar_ *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data);
21987+ Saxofony * b = (Saxofony *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data);
2161721988 t_CKFLOAT f = GET_NEXT_FLOAT(ARGS);
21618− b->modalbar.controlChange( 128, f*128 );
21619− RETURN->v_float = (t_CKFLOAT)b->modalbar.m_volume;
21989+ b->controlChange( 128, f * 128 );
21990+ RETURN->v_float = (t_CKFLOAT)b->m_pressure;
2162021991 }
2162121992
2162221993
2162321994 //-----------------------------------------------------------------------------
21624−// name: ModalBar_cget_volume()
21995+// name: Saxofony_cget_pressure()
2162521996 // desc: CGET function ...
2162621997 //-----------------------------------------------------------------------------
21627−CK_DLL_CGET( ModalBar_cget_volume )
21998+CK_DLL_CGET( Saxofony_cget_pressure )
2162821999 {
21629− ModalBar_ * b = (ModalBar_ *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data);
21630− RETURN->v_float = (t_CKFLOAT)b->modalbar.m_volume;
22000+ Saxofony * b = (Saxofony *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data);
22001+ RETURN->v_float = (t_CKFLOAT)b->m_pressure;
2163122002 }
2163222003
2163322004
2163422005
2163522006
21636−// Sitar
21637−/*
21638−struct Sitar_ {
21639− Sitar * imp;
21640− double m_frequency;
21641−
21642− Sitar_ ( double d ) {
21643− imp = new Sitar(d);
21644− m_frequency = 100.0;
21645− }
21646−};*/
21647−
22007+// StifKarp
2164822008
2164922009 //-----------------------------------------------------------------------------
21650−// name: Sitar_ctor()
22010+// name: StifKarp_ctor()
2165122011 // desc: CTOR function ...
2165222012 //-----------------------------------------------------------------------------
21653−CK_DLL_CTOR( Sitar_ctor )
22013+CK_DLL_CTOR( StifKarp_ctor )
2165422014 {
21655− Sitar * sitar = new Sitar( 20 );
21656− OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data) = (t_CKUINT)sitar;
22015+ // initialize member object
22016+ StifKarp * karp = new StifKarp( 20.0 );
22017+ OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data) = (t_CKUINT)karp;
2165722018 // default
21658− sitar->setFrequency( 220 );
22019+ karp->setFrequency( 220.0 );
2165922020 }
2166022021
2166122022
2166222023 //-----------------------------------------------------------------------------
21663−// name: Sitar_dtor()
22024+// name: StifKarp_dtor()
2166422025 // desc: DTOR function ...
2166522026 //-----------------------------------------------------------------------------
21666−CK_DLL_DTOR( Sitar_dtor )
22027+CK_DLL_DTOR( StifKarp_dtor )
2166722028 {
21668− Sitar * s = (Sitar *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data);
21669− SAFE_DELETE(s);
22029+ delete (StifKarp *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data);
2167022030 OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data) = 0;
2167122031 }
2167222032
2167322033
2167422034 //-----------------------------------------------------------------------------
21675−// name: Sitar_tick()
22035+// name: StifKarp_tick()
2167622036 // desc: TICK function ...
2167722037 //-----------------------------------------------------------------------------
21678−CK_DLL_TICK( Sitar_tick )
22038+CK_DLL_TICK( StifKarp_tick )
2167922039 {
21680− Sitar * b = (Sitar *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data);
22040+ StifKarp * b = (StifKarp *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data);
2168122041 *out = b->tick();
2168222042 return TRUE;
2168322043 }
2168422044
2168522045
2168622046 //-----------------------------------------------------------------------------
21687−// name: Sitar_pmsg()
22047+// name: StifKarp_pmsg()
2168822048 // desc: PMSG function ...
2168922049 //-----------------------------------------------------------------------------
21690−CK_DLL_PMSG( Sitar_pmsg )
22050+CK_DLL_PMSG( StifKarp_pmsg )
2169122051 {
2169222052 return TRUE;
2169322053 }
2169422054
2169522055
2169622056 //-----------------------------------------------------------------------------
21697−// name: Sitar_ctrl_pluck()
22057+// name: StifKarp_ctrl_pluck()
2169822058 // desc: CTRL function ...
2169922059 //-----------------------------------------------------------------------------
21700−CK_DLL_CTRL( Sitar_ctrl_pluck )
22060+CK_DLL_CTRL( StifKarp_ctrl_pluck )
2170122061 {
21702− Sitar * b = (Sitar *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data);
22062+ StifKarp * b = (StifKarp *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data);
2170322063 t_CKFLOAT f = GET_NEXT_FLOAT(ARGS);
2170422064 b->pluck( f );
2170522065 }
2170622066
2170722067
2170822068 //-----------------------------------------------------------------------------
21709−// name: Sitar_ctrl_clear()
22069+// name: StifKarp_ctrl_clear()
2171022070 // desc: CTRL function ...
2171122071 //-----------------------------------------------------------------------------
21712−CK_DLL_CTRL( Sitar_ctrl_clear )
22072+CK_DLL_CTRL( StifKarp_ctrl_clear )
2171322073 {
21714− Sitar * b = (Sitar *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data);
22074+ StifKarp * b = (StifKarp *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data);
2171522075 b->clear();
2171622076 }
2171722077
2171822078
21719−
21720−
2172122079 //-----------------------------------------------------------------------------
21722−// name: Saxofony_ctor()
21723−// desc: CTOR function ...
22080+// name: StifKarp_ctrl_pickupPosition()
22081+// desc: CTRL function ...
2172422082 //-----------------------------------------------------------------------------
21725−CK_DLL_CTOR( Saxofony_ctor )
22083+CK_DLL_CTRL( StifKarp_ctrl_pickupPosition )
2172622084 {
21727− Saxofony * fony = new Saxofony( 20 );
21728− OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data) = (t_CKUINT)fony;
21729− // default
21730− fony->setFrequency( 220 );
22085+ StifKarp * b = (StifKarp *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data);
22086+ t_CKFLOAT f = GET_NEXT_FLOAT(ARGS);
22087+ b->setPickupPosition( f );
22088+ RETURN->v_float = (t_CKFLOAT)b->pickupPosition;
2173122089 }
2173222090
2173322091
2173422092 //-----------------------------------------------------------------------------
21735−// name: Saxofony_dtor()
21736−// desc: DTOR function ...
22093+// name: StifKarp_cget_pickupPosition()
22094+// desc: CGET function ...
2173722095 //-----------------------------------------------------------------------------
21738−CK_DLL_DTOR( Saxofony_dtor )
22096+CK_DLL_CGET( StifKarp_cget_pickupPosition )
2173922097 {
21740− Saxofony * d = (Saxofony *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data);
21741− SAFE_DELETE(d);
21742− OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data) = 0;
22098+ StifKarp * b = (StifKarp *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data);
22099+ RETURN->v_float = (t_CKFLOAT)b->pickupPosition;
2174322100 }
2174422101
2174522102
2174622103 //-----------------------------------------------------------------------------
21747−// name: Saxofony_tick()
21748−// desc: TICK function ...
22104+// name: StifKarp_ctrl_stretch()
22105+// desc: CTRL function ...
2174922106 //-----------------------------------------------------------------------------
21750−CK_DLL_TICK( Saxofony_tick )
22107+CK_DLL_CTRL( StifKarp_ctrl_stretch )
2175122108 {
21752− Saxofony * b = (Saxofony *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data);
21753− *out = b->tick();
21754− return TRUE;
22109+ StifKarp * b = (StifKarp *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data);
22110+ t_CKFLOAT f = GET_NEXT_FLOAT(ARGS);
22111+ b->setStretch( f );
22112+ RETURN->v_float = (t_CKFLOAT)b->stretching;
2175522113 }
2175622114
2175722115
2175822116 //-----------------------------------------------------------------------------
21759−// name: Saxofony_pmsg()
21760−// desc: PMSG function ...
22117+// name: StifKarp_cget_stretch()
22118+// desc: CGET function ...
2176122119 //-----------------------------------------------------------------------------
21762−CK_DLL_PMSG( Saxofony_pmsg )
22120+CK_DLL_CGET( StifKarp_cget_stretch )
2176322121 {
21764− return TRUE;
22122+ StifKarp * b = (StifKarp *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data);
22123+ RETURN->v_float = (t_CKFLOAT)b->stretching;
2176522124 }
2176622125
2176722126
2176822127 //-----------------------------------------------------------------------------
21769−// name: Saxofony_ctrl_startBlowing()
22128+// name: StifKarp_ctrl_sustain()
2177022129 // desc: CTRL function ...
2177122130 //-----------------------------------------------------------------------------
21772−CK_DLL_CTRL( Saxofony_ctrl_startBlowing )
22131+CK_DLL_CTRL( StifKarp_ctrl_sustain )
2177322132 {
21774− Saxofony * b = (Saxofony *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data);
22133+ StifKarp * b = (StifKarp *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data);
2177522134 t_CKFLOAT f = GET_NEXT_FLOAT(ARGS);
21776− b->startBlowing( f, b->m_rate );
22135+ b->controlChange( __SK_StringDamping_, f * 128 );
22136+ RETURN->v_float = (t_CKFLOAT)b->m_sustain;
2177722137 }
2177822138
2177922139
2178022140 //-----------------------------------------------------------------------------
21781−// name: Saxofony_ctrl_stopBlowing()
21782−// desc: CTRL function ...
22141+// name: StifKarp_cget_sustain()
22142+// desc: CGET function ...
2178322143 //-----------------------------------------------------------------------------
21784−CK_DLL_CTRL( Saxofony_ctrl_stopBlowing )
22144+CK_DLL_CGET( StifKarp_cget_sustain )
2178522145 {
21786− Saxofony * b = (Saxofony *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data);
21787− t_CKFLOAT f = GET_NEXT_FLOAT(ARGS);
21788− b->stopBlowing( f );
22146+ StifKarp * b = (StifKarp *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data);
22147+ RETURN->v_float = (t_CKFLOAT)b->m_sustain;
2178922148 }
2179022149
2179122150
2179222151 //-----------------------------------------------------------------------------
21793−// name: Saxofony_ctrl_clear()
22152+// name: StifKarp_ctrl_baseLoopGain()
2179422153 // desc: CTRL function ...
2179522154 //-----------------------------------------------------------------------------
21796−CK_DLL_CTRL( Saxofony_ctrl_clear )
22155+CK_DLL_CTRL( StifKarp_ctrl_baseLoopGain )
2179722156 {
21798− Saxofony * b = (Saxofony *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data);
21799− b->clear();
22157+ StifKarp * b = (StifKarp *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data);
22158+ t_CKFLOAT f = GET_NEXT_FLOAT(ARGS);
22159+ b->setBaseLoopGain( f );
22160+ RETURN->v_float = (t_CKFLOAT)b->baseLoopGain;
2180022161 }
2180122162
2180222163
2180322164 //-----------------------------------------------------------------------------
21804−// name: Saxofony_ctrl_rate()
21805−// desc: CTRL function ...
22165+// name: StifKarp_cget_baseLoopGain()
22166+// desc: CGET function ...
2180622167 //-----------------------------------------------------------------------------
21807−CK_DLL_CTRL( Saxofony_ctrl_rate )
22168+CK_DLL_CGET( StifKarp_cget_baseLoopGain )
2180822169 {
21809− Saxofony * b = (Saxofony *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data);
21810− t_CKFLOAT f = GET_NEXT_FLOAT(ARGS);
21811− b->m_rate = f;
21812− RETURN->v_float = (t_CKFLOAT)b->m_rate;
22170+ StifKarp * b = (StifKarp *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data);
22171+ RETURN->v_float = (t_CKFLOAT)b->baseLoopGain;
2181322172 }
2181422173
2181522174
22175+
22176+// Delay
2181622177 //-----------------------------------------------------------------------------
21817−// name: Saxofony_cget_rate()
21818−// desc: CGET function ...
22178+// name: Delay_ctor()
22179+// desc: CTOR function ...
2181922180 //-----------------------------------------------------------------------------
21820−CK_DLL_CGET( Saxofony_cget_rate )
22181+CK_DLL_CTOR( Delay_ctor )
2182122182 {
21822− Saxofony * b = (Saxofony *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data);
21823− RETURN->v_float = (t_CKFLOAT)b->m_rate;
22183+ OBJ_MEMBER_UINT(SELF, Delay_offset_data) = (t_CKUINT)new Delay;
2182422184 }
2182522185
2182622186
2182722187 //-----------------------------------------------------------------------------
21828−// name: Saxofony_ctrl_blowPosition()
21829−// desc: CTRL function ...
22188+// name: Delay_dtor()
22189+// desc: DTOR function ...
2183022190 //-----------------------------------------------------------------------------
21831−CK_DLL_CTRL( Saxofony_ctrl_blowPosition )
22191+CK_DLL_DTOR( Delay_dtor )
2183222192 {
21833− Saxofony * b = (Saxofony *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data);
21834− t_CKFLOAT f = GET_NEXT_FLOAT(ARGS);
21835− b->setBlowPosition(f);
21836− RETURN->v_float = (t_CKFLOAT)b->position;
22193+ delete (Delay *)OBJ_MEMBER_UINT(SELF, Delay_offset_data);
22194+ OBJ_MEMBER_UINT(SELF, Delay_offset_data) = 0;
2183722195 }
2183822196
2183922197
2184022198 //-----------------------------------------------------------------------------
21841−// name: Saxofony_cget_blowPosition()
21842−// desc: CGET function ...
22199+// name: Delay_tick()
22200+// desc: TICK function ...
2184322201 //-----------------------------------------------------------------------------
21844−CK_DLL_CGET( Saxofony_cget_blowPosition )
22202+CK_DLL_TICK( Delay_tick )
2184522203 {
21846− Saxofony * b = (Saxofony *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data);
21847− RETURN->v_float = (t_CKFLOAT)b->position;
22204+ *out = (SAMPLE)((Delay *)OBJ_MEMBER_UINT(SELF, Delay_offset_data))->tick( in );
22205+ return TRUE;
2184822206 }
2184922207
2185022208
2185122209 //-----------------------------------------------------------------------------
21852−// name: Saxofony_ctrl_reed()
21853−// desc: CTRL function ...
22210+// name: Delay_pmsg()
22211+// desc: PMSG function ...
2185422212 //-----------------------------------------------------------------------------
21855−CK_DLL_CTRL( Saxofony_ctrl_reed )
22213+CK_DLL_PMSG( Delay_pmsg )
2185622214 {
21857− Saxofony * b = (Saxofony *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data);
21858− t_CKFLOAT f = GET_NEXT_FLOAT(ARGS);
21859− b->controlChange( 2, f * 128 );
21860− RETURN->v_float = (t_CKFLOAT)b->m_stiffness;
22215+ return FALSE;
2186122216 }
2186222217
2186322218
2186422219 //-----------------------------------------------------------------------------
21865−// name: Saxofony_cget_reed()
21866−// desc: CGET function ...
22220+// name: Delay_ctrl_delay()
22221+// desc: CTRL function ...
2186722222 //-----------------------------------------------------------------------------
21868−CK_DLL_CGET( Saxofony_cget_reed )
22223+CK_DLL_CTRL( Delay_ctrl_delay )
2186922224 {
21870− Saxofony * b = (Saxofony *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data);
21871− RETURN->v_float = (t_CKFLOAT)b->m_stiffness;
22225+ ((Delay *)OBJ_MEMBER_UINT(SELF, Delay_offset_data))->setDelay( (long)(GET_NEXT_DUR(ARGS)+.5) );
22226+ RETURN->v_dur = (t_CKDUR)((Delay *)OBJ_MEMBER_UINT(SELF, Delay_offset_data))->getDelay();
2187222227 }
2187322228
2187422229
2187522230 //-----------------------------------------------------------------------------
21876−// name: Saxofony_ctrl_aperture()
21877−// desc: CTRL function ...
22231+// name: Delay_cget_delay()
22232+// desc: CGET function ...
2187822233 //-----------------------------------------------------------------------------
21879−CK_DLL_CTRL( Saxofony_ctrl_aperture )
22234+CK_DLL_CGET( Delay_cget_delay )
2188022235 {
21881− Saxofony * b = (Saxofony *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data);
21882− t_CKFLOAT f = GET_NEXT_FLOAT(ARGS);
21883− b->controlChange( 26, f * 128 );
21884− RETURN->v_float = (t_CKFLOAT)b->m_aperture;
22236+ RETURN->v_dur = (t_CKDUR)((Delay *)OBJ_MEMBER_UINT(SELF, Delay_offset_data))->getDelay();
2188522237 }
2188622238
2188722239
2188822240 //-----------------------------------------------------------------------------
21889−// name: Saxofony_cget_aperture()
21890−// desc: CGET function ...
22241+// name: Delay_ctrl_max()
22242+// desc: CTRL function ...
2189122243 //-----------------------------------------------------------------------------
21892−CK_DLL_CGET( Saxofony_cget_aperture )
22244+CK_DLL_CTRL( Delay_ctrl_max )
2189322245 {
21894− Saxofony * b = (Saxofony *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data);
21895− RETURN->v_float = (t_CKFLOAT)b->m_aperture;
22246+ Delay * delay = (Delay *)OBJ_MEMBER_UINT(SELF, Delay_offset_data);
22247+ t_CKFLOAT val = (t_CKFLOAT)delay->getDelay();
22248+ t_CKDUR max = GET_NEXT_DUR(ARGS);
22249+ delay->set( (long)(val+.5), (long)(max+1.5) );
22250+ RETURN->v_dur = (t_CKDUR)((Delay *)OBJ_MEMBER_UINT(SELF, Delay_offset_data))->length-1.0;
2189622251 }
2189722252
2189822253
2189922254 //-----------------------------------------------------------------------------
21900−// name: Saxofony_ctrl_noiseGain()
21901−// desc: CTRL function ...
22255+// name: Delay_cget_max()
22256+// desc: CGET function ...
2190222257 //-----------------------------------------------------------------------------
21903−CK_DLL_CTRL( Saxofony_ctrl_noiseGain )
22258+CK_DLL_CGET( Delay_cget_max )
2190422259 {
21905− Saxofony * b = (Saxofony *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data);
21906− t_CKFLOAT f = GET_NEXT_FLOAT(ARGS);
21907− b->controlChange( 4, f * 128 );
21908− RETURN->v_float = (t_CKFLOAT)b->m_noiseGain;
22260+ RETURN->v_dur = (t_CKDUR)((Delay *)OBJ_MEMBER_UINT(SELF, Delay_offset_data))->length-1.0;
2190922261 }
2191022262
2191122263
2191222264 //-----------------------------------------------------------------------------
21913−// name: Saxofony_cget_noiseGain()
22265+// name: Delay_clear()
2191422266 // desc: CGET function ...
2191522267 //-----------------------------------------------------------------------------
21916−CK_DLL_CGET( Saxofony_cget_noiseGain )
22268+CK_DLL_CGET( Delay_clear )
2191722269 {
21918− Saxofony * b = (Saxofony *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data);
21919− RETURN->v_float = (t_CKFLOAT)b->m_noiseGain;
22270+ Delay * delay = (Delay *)OBJ_MEMBER_UINT(SELF, Delay_offset_data);
22271+ delay->clear();
2192022272 }
2192122273
2192222274
22275+
22276+
22277+// DelayA
2192322278 //-----------------------------------------------------------------------------
21924−// name: Saxofony_ctrl_vibratoFreq()
21925−// desc: CTRL function ...
22279+// name: DelayA_ctor()
22280+// desc: CTOR function ...
2192622281 //-----------------------------------------------------------------------------
21927−CK_DLL_CTRL( Saxofony_ctrl_vibratoFreq )
22282+CK_DLL_CTOR( DelayA_ctor )
2192822283 {
21929− Saxofony * b = (Saxofony *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data);
21930− t_CKFLOAT f = GET_NEXT_FLOAT(ARGS);
21931− b->vibrato->setFrequency( f );
21932− RETURN->v_float = (t_CKFLOAT)b->vibrato->m_freq;
22284+ OBJ_MEMBER_UINT(SELF, DelayA_offset_data) = (t_CKUINT)new DelayA;
2193322285 }
2193422286
2193522287
2193622288 //-----------------------------------------------------------------------------
21937−// name: Saxofony_cget_vibratoFreq()
21938−// desc: CGET function ...
22289+// name: DelayA_dtor()
22290+// desc: DTOR function ...
2193922291 //-----------------------------------------------------------------------------
21940−CK_DLL_CGET( Saxofony_cget_vibratoFreq )
22292+CK_DLL_DTOR( DelayA_dtor )
2194122293 {
21942− Saxofony * b = (Saxofony *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data);
21943− RETURN->v_float = (t_CKFLOAT)b->vibrato->m_freq;
22294+ delete (DelayA *)OBJ_MEMBER_UINT(SELF, DelayA_offset_data);
22295+ OBJ_MEMBER_UINT(SELF, DelayA_offset_data) = 0;
2194422296 }
2194522297
2194622298
2194722299 //-----------------------------------------------------------------------------
21948−// name: Saxofony_ctrl_vibratoGain()
21949−// desc: CTRL function ...
22300+// name: DelayA_tick()
22301+// desc: TICK function ...
2195022302 //-----------------------------------------------------------------------------
21951−CK_DLL_CTRL( Saxofony_ctrl_vibratoGain )
22303+CK_DLL_TICK( DelayA_tick )
2195222304 {
21953− Saxofony * b = (Saxofony *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data);
21954− t_CKFLOAT f = GET_NEXT_FLOAT(ARGS);
21955− b->controlChange( 1, f * 128 );
21956− RETURN->v_float = (t_CKFLOAT)b->m_vibratoGain;
22305+ *out = (SAMPLE)((DelayA *)OBJ_MEMBER_UINT(SELF, DelayA_offset_data))->tick( in );
22306+ return TRUE;
2195722307 }
2195822308
2195922309
2196022310 //-----------------------------------------------------------------------------
21961−// name: Saxofony_cget_vibratoGain()
21962−// desc: CGET function ...
22311+// name: DelayA_pmsg()
22312+// desc: PMSG function ...
2196322313 //-----------------------------------------------------------------------------
21964−CK_DLL_CGET( Saxofony_cget_vibratoGain )
22314+CK_DLL_PMSG( DelayA_pmsg )
2196522315 {
21966− Saxofony * b = (Saxofony *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data);
21967− RETURN->v_float = (t_CKFLOAT)b->m_vibratoGain;
22316+ return FALSE;
2196822317 }
2196922318
2197022319
2197122320 //-----------------------------------------------------------------------------
21972−// name: Saxofony_ctrl_pressure()
22321+// name: DelayA_ctrl_delay()
2197322322 // desc: CTRL function ...
2197422323 //-----------------------------------------------------------------------------
21975−CK_DLL_CTRL( Saxofony_ctrl_pressure )
22324+CK_DLL_CTRL( DelayA_ctrl_delay )
2197622325 {
21977− Saxofony * b = (Saxofony *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data);
21978− t_CKFLOAT f = GET_NEXT_FLOAT(ARGS);
21979− b->controlChange( 128, f * 128 );
21980− RETURN->v_float = (t_CKFLOAT)b->m_pressure;
22326+ ((DelayA *)OBJ_MEMBER_UINT(SELF, DelayA_offset_data))->setDelay( GET_NEXT_DUR(ARGS) );
22327+ RETURN->v_dur = (t_CKDUR)((DelayA *)OBJ_MEMBER_UINT(SELF, DelayA_offset_data))->getDelay();
2198122328 }
2198222329
2198322330
2198422331 //-----------------------------------------------------------------------------
21985−// name: Saxofony_cget_pressure()
22332+// name: DelayA_cget_delay()
2198622333 // desc: CGET function ...
2198722334 //-----------------------------------------------------------------------------
21988−CK_DLL_CGET( Saxofony_cget_pressure )
22335+CK_DLL_CGET( DelayA_cget_delay )
2198922336 {
21990− Saxofony * b = (Saxofony *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data);
21991− RETURN->v_float = (t_CKFLOAT)b->m_pressure;
22337+ RETURN->v_dur = (t_CKDUR)((DelayA *)OBJ_MEMBER_UINT(SELF, DelayA_offset_data))->getDelay();
2199222338 }
2199322339
2199422340
21995−
21996−
21997−// StifKarp
21998−
2199922341 //-----------------------------------------------------------------------------
22000−// name: StifKarp_ctor()
22001−// desc: CTOR function ...
22342+// name: DelayA_ctrl_max()
22343+// desc: CTRL function ...
2200222344 //-----------------------------------------------------------------------------
22003−CK_DLL_CTOR( StifKarp_ctor )
22345+CK_DLL_CTRL( DelayA_ctrl_max )
2200422346 {
22005− // initialize member object
22006− StifKarp * karp = new StifKarp( 20.0 );
22007− OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data) = (t_CKUINT)karp;
22008− // default
22009− karp->setFrequency( 220.0 );
22347+ DelayA * delay = (DelayA *)OBJ_MEMBER_UINT(SELF, DelayA_offset_data);
22348+ t_CKDUR val = (t_CKDUR)delay->getDelay();
22349+ t_CKDUR max = GET_NEXT_DUR(ARGS);
22350+ delay->set( val, (long)(max+1.5) );
22351+ RETURN->v_dur = (t_CKDUR)((DelayA *)OBJ_MEMBER_UINT(SELF, DelayA_offset_data))->length-1.0;
2201022352 }
2201122353
2201222354
2201322355 //-----------------------------------------------------------------------------
22014−// name: StifKarp_dtor()
22015−// desc: DTOR function ...
22356+// name: DelayA_cget_max()
22357+// desc: CGET function ...
2201622358 //-----------------------------------------------------------------------------
22017−CK_DLL_DTOR( StifKarp_dtor )
22359+CK_DLL_CGET( DelayA_cget_max )
2201822360 {
22019− delete (StifKarp *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data);
22020− OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data) = 0;
22361+ RETURN->v_dur = (t_CKDUR)((DelayA *)OBJ_MEMBER_UINT(SELF, DelayA_offset_data))->length-1.0;
2202122362 }
2202222363
2202322364
2202422365 //-----------------------------------------------------------------------------
22025−// name: StifKarp_tick()
22026−// desc: TICK function ...
22366+// name: DelayA_clear()
22367+// desc: CGET function ...
2202722368 //-----------------------------------------------------------------------------
22028−CK_DLL_TICK( StifKarp_tick )
22369+CK_DLL_CGET( DelayA_clear )
2202922370 {
22030− StifKarp * b = (StifKarp *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data);
22031− *out = b->tick();
22032− return TRUE;
22371+ DelayA * delay = (DelayA *)OBJ_MEMBER_UINT(SELF, DelayA_offset_data);
22372+ delay->clear();
2203322373 }
2203422374
2203522375
22036−//-----------------------------------------------------------------------------
22037−// name: StifKarp_pmsg()
22038−// desc: PMSG function ...
22039−//-----------------------------------------------------------------------------
22040−CK_DLL_PMSG( StifKarp_pmsg )
22041−{
22042− return TRUE;
22043−}
2204422376
2204522377
22378+// DelayL
2204622379 //-----------------------------------------------------------------------------
22047−// name: StifKarp_ctrl_pluck()
22048−// desc: CTRL function ...
22380+// name: DelayL_ctor()
22381+// desc: CTOR function ...
2204922382 //-----------------------------------------------------------------------------
22050−CK_DLL_CTRL( StifKarp_ctrl_pluck )
22383+CK_DLL_CTOR( DelayL_ctor )
2205122384 {
22052− StifKarp * b = (StifKarp *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data);
22053− t_CKFLOAT f = GET_NEXT_FLOAT(ARGS);
22054− b->pluck( f );
22385+ OBJ_MEMBER_UINT(SELF, DelayL_offset_data) = (t_CKUINT)new DelayL;
2205522386 }
2205622387
2205722388
2205822389 //-----------------------------------------------------------------------------
22059−// name: StifKarp_ctrl_clear()
22060−// desc: CTRL function ...
22390+// name: DelayL_dtor()
22391+// desc: DTOR function ...
2206122392 //-----------------------------------------------------------------------------
22062−CK_DLL_CTRL( StifKarp_ctrl_clear )
22393+CK_DLL_DTOR( DelayL_dtor )
2206322394 {
22064− StifKarp * b = (StifKarp *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data);
22065− b->clear();
22395+ delete (DelayL *)OBJ_MEMBER_UINT(SELF, DelayL_offset_data);
22396+ OBJ_MEMBER_UINT(SELF, DelayL_offset_data) = 0;
2206622397 }
2206722398
2206822399
2206922400 //-----------------------------------------------------------------------------
22070−// name: StifKarp_ctrl_pickupPosition()
22071−// desc: CTRL function ...
22401+// name: DelayL_tick()
22402+// desc: TICK function ...
2207222403 //-----------------------------------------------------------------------------
22073−CK_DLL_CTRL( StifKarp_ctrl_pickupPosition )
22404+CK_DLL_TICK( DelayL_tick )
2207422405 {
22075− StifKarp * b = (StifKarp *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data);
22076− t_CKFLOAT f = GET_NEXT_FLOAT(ARGS);
22077− b->setPickupPosition( f );
22078− RETURN->v_float = (t_CKFLOAT)b->pickupPosition;
22406+ *out = (SAMPLE)((DelayL *)OBJ_MEMBER_UINT(SELF, DelayL_offset_data))->tick( in );
22407+ return TRUE;
2207922408 }
2208022409
2208122410
2208222411 //-----------------------------------------------------------------------------
22083−// name: StifKarp_cget_pickupPosition()
22084−// desc: CGET function ...
22412+// name: DelayL_pmsg()
22413+// desc: PMSG function ...
2208522414 //-----------------------------------------------------------------------------
22086−CK_DLL_CGET( StifKarp_cget_pickupPosition )
22415+CK_DLL_PMSG( DelayL_pmsg )
2208722416 {
22088− StifKarp * b = (StifKarp *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data);
22089− RETURN->v_float = (t_CKFLOAT)b->pickupPosition;
22417+ return FALSE;
2209022418 }
2209122419
2209222420
2209322421 //-----------------------------------------------------------------------------
22094−// name: StifKarp_ctrl_stretch()
22422+// name: DelayL_ctrl_delay()
2209522423 // desc: CTRL function ...
2209622424 //-----------------------------------------------------------------------------
22097−CK_DLL_CTRL( StifKarp_ctrl_stretch )
22425+CK_DLL_CTRL( DelayL_ctrl_delay )
2209822426 {
22099− StifKarp * b = (StifKarp *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data);
22100− t_CKFLOAT f = GET_NEXT_FLOAT(ARGS);
22101− b->setStretch( f );
22102− RETURN->v_float = (t_CKFLOAT)b->stretching;
22427+ ((DelayL *)OBJ_MEMBER_UINT(SELF, DelayL_offset_data))->setDelay( GET_NEXT_DUR(ARGS) );
22428+ RETURN->v_dur = (t_CKDUR)((DelayL *)OBJ_MEMBER_UINT(SELF, DelayL_offset_data))->getDelay();
2210322429 }
2210422430
2210522431
2210622432 //-----------------------------------------------------------------------------
22107−// name: StifKarp_cget_stretch()
22433+// name: DelayL_cget_delay()
2210822434 // desc: CGET function ...
2210922435 //-----------------------------------------------------------------------------
22110−CK_DLL_CGET( StifKarp_cget_stretch )
22436+CK_DLL_CGET( DelayL_cget_delay )
2211122437 {
22112− StifKarp * b = (StifKarp *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data);
22113− RETURN->v_float = (t_CKFLOAT)b->stretching;
22438+ RETURN->v_dur = (t_CKDUR)((DelayL *)OBJ_MEMBER_UINT(SELF, DelayL_offset_data))->getDelay();
2211422439 }
2211522440
2211622441
2211722442 //-----------------------------------------------------------------------------
22118−// name: StifKarp_ctrl_sustain()
22443+// name: DelayL_ctrl_max()
2211922444 // desc: CTRL function ...
2212022445 //-----------------------------------------------------------------------------
22121−CK_DLL_CTRL( StifKarp_ctrl_sustain )
22446+CK_DLL_CTRL( DelayL_ctrl_max )
2212222447 {
22123− StifKarp * b = (StifKarp *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data);
22124− t_CKFLOAT f = GET_NEXT_FLOAT(ARGS);
22125− b->controlChange( __SK_StringDamping_, f * 128 );
22126− RETURN->v_float = (t_CKFLOAT)b->m_sustain;
22448+ DelayL * delay = (DelayL *)OBJ_MEMBER_UINT(SELF, DelayL_offset_data);
22449+ t_CKDUR val = (t_CKDUR)delay->getDelay();
22450+ t_CKDUR max = GET_NEXT_DUR(ARGS);
22451+ delay->set( val, (long)(max+1.5) );
22452+ RETURN->v_dur = (t_CKDUR)delay->length-1.0;
2212722453 }
2212822454
2212922455
2213022456 //-----------------------------------------------------------------------------
22131−// name: StifKarp_cget_sustain()
22457+// name: DelayL_cget_max()
2213222458 // desc: CGET function ...
2213322459 //-----------------------------------------------------------------------------
22134−CK_DLL_CGET( StifKarp_cget_sustain )
22135−{
22136− StifKarp * b = (StifKarp *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data);
22137− RETURN->v_float = (t_CKFLOAT)b->m_sustain;
22138−}
22139−
22140−
22141−//-----------------------------------------------------------------------------
22142−// name: StifKarp_ctrl_baseLoopGain()
22143−// desc: CTRL function ...
22144−//-----------------------------------------------------------------------------
22145−CK_DLL_CTRL( StifKarp_ctrl_baseLoopGain )
22460+CK_DLL_CGET( DelayL_cget_max )
2214622461 {
22147− StifKarp * b = (StifKarp *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data);
22148− t_CKFLOAT f = GET_NEXT_FLOAT(ARGS);
22149− b->setBaseLoopGain( f );
22150− RETURN->v_float = (t_CKFLOAT)b->baseLoopGain;
22462+ RETURN->v_dur = (t_CKDUR)((DelayL *)OBJ_MEMBER_UINT(SELF, DelayL_offset_data))->length-1.0;
2215122463 }
2215222464
2215322465
2215422466 //-----------------------------------------------------------------------------
22155−// name: StifKarp_cget_baseLoopGain()
22467+// name: DelayL_clear()
2215622468 // desc: CGET function ...
2215722469 //-----------------------------------------------------------------------------
22158−CK_DLL_CGET( StifKarp_cget_baseLoopGain )
22470+CK_DLL_CGET( DelayL_clear )
2215922471 {
22160− StifKarp * b = (StifKarp *)OBJ_MEMBER_UINT(SELF, Instrmnt_offset_data);
22161− RETURN->v_float = (t_CKFLOAT)b->baseLoopGain;
22472+ DelayL * delay = (DelayL *)OBJ_MEMBER_UINT(SELF, DelayL_offset_data);
22473+ delay->clear();
2216222474 }
2216322475
2216422476
2216522477
22166−// Delay
22478+
22479+// Echo
2216722480 //-----------------------------------------------------------------------------
22168−// name: Delay_ctor()
22481+// name: Echo_ctor()
2216922482 // desc: CTOR function ...
2217022483 //-----------------------------------------------------------------------------
22171−CK_DLL_CTOR( Delay_ctor )
22484+CK_DLL_CTOR( Echo_ctor )
2217222485 {
22173− OBJ_MEMBER_UINT(SELF, Delay_offset_data) = (t_CKUINT)new Delay;
22486+ // initialize member object
22487+ OBJ_MEMBER_UINT(SELF, Echo_offset_data) = (t_CKUINT)new Echo( Stk::sampleRate() / 2.0 );
2217422488 }
2217522489
2217622490
2217722491 //-----------------------------------------------------------------------------
22178−// name: Delay_dtor()
22492+// name: Echo_dtor()
2217922493 // desc: DTOR function ...
2218022494 //-----------------------------------------------------------------------------
22181−CK_DLL_DTOR( Delay_dtor )
22495+CK_DLL_DTOR( Echo_dtor )
2218222496 {
22183− delete (Delay *)OBJ_MEMBER_UINT(SELF, Delay_offset_data);
22184− OBJ_MEMBER_UINT(SELF, Delay_offset_data) = 0;
22497+ delete (Echo *)OBJ_MEMBER_UINT(SELF, Echo_offset_data);
22498+ OBJ_MEMBER_UINT(SELF, Echo_offset_data) = 0;
2218522499 }
2218622500
2218722501
2218822502 //-----------------------------------------------------------------------------
22189−// name: Delay_tick()
22503+// name: Echo_tick()
2219022504 // desc: TICK function ...
2219122505 //-----------------------------------------------------------------------------
22192−CK_DLL_TICK( Delay_tick )
22506+CK_DLL_TICK( Echo_tick )
2219322507 {
22194− *out = (SAMPLE)((Delay *)OBJ_MEMBER_UINT(SELF, Delay_offset_data))->tick( in );
22508+ *out = (SAMPLE)((Echo *)OBJ_MEMBER_UINT(SELF, Echo_offset_data))->tick( in );
2219522509 return TRUE;
2219622510 }
2219722511
2219822512
2219922513 //-----------------------------------------------------------------------------
22200−// name: Delay_pmsg()
22514+// name: Echo_pmsg()
2220122515 // desc: PMSG function ...
2220222516 //-----------------------------------------------------------------------------
22203−CK_DLL_PMSG( Delay_pmsg )
22517+CK_DLL_PMSG( Echo_pmsg )
2220422518 {
2220522519 return FALSE;
2220622520 }
2220722521
2220822522
2220922523 //-----------------------------------------------------------------------------
22210−// name: Delay_ctrl_delay()
22524+// name: Echo_ctrl_delay()
2221122525 // desc: CTRL function ...
2221222526 //-----------------------------------------------------------------------------
22213−CK_DLL_CTRL( Delay_ctrl_delay )
22527+CK_DLL_CTRL( Echo_ctrl_delay )
2221422528 {
22215− ((Delay *)OBJ_MEMBER_UINT(SELF, Delay_offset_data))->setDelay( (long)(GET_NEXT_DUR(ARGS)+.5) );
22216− RETURN->v_dur = (t_CKDUR)((Delay *)OBJ_MEMBER_UINT(SELF, Delay_offset_data))->getDelay();
22529+ ((Echo *)OBJ_MEMBER_UINT(SELF, Echo_offset_data))->setDelay( GET_NEXT_DUR(ARGS) );
22530+ RETURN->v_dur = (t_CKDUR)((Echo *)OBJ_MEMBER_UINT(SELF, Echo_offset_data))->getDelay();
2221722531 }
2221822532
2221922533
2222022534 //-----------------------------------------------------------------------------
22221−// name: Delay_cget_delay()
22535+// name: Echo_cget_delay()
2222222536 // desc: CGET function ...
2222322537 //-----------------------------------------------------------------------------
22224−CK_DLL_CGET( Delay_cget_delay )
22538+CK_DLL_CGET( Echo_cget_delay )
2222522539 {
22226− RETURN->v_dur = (t_CKDUR)((Delay *)OBJ_MEMBER_UINT(SELF, Delay_offset_data))->getDelay();
22540+ RETURN->v_dur = (t_CKDUR)((Echo *)OBJ_MEMBER_UINT(SELF, Echo_offset_data))->getDelay();
2222722541 }
2222822542
2222922543
2223022544 //-----------------------------------------------------------------------------
22231−// name: Delay_ctrl_max()
22545+// name: Echo_ctrl_max()
2223222546 // desc: CTRL function ...
2223322547 //-----------------------------------------------------------------------------
22234−CK_DLL_CTRL( Delay_ctrl_max )
22548+CK_DLL_CTRL( Echo_ctrl_max )
2223522549 {
22236− Delay * delay = (Delay *)OBJ_MEMBER_UINT(SELF, Delay_offset_data);
22237− t_CKFLOAT val = (t_CKFLOAT)delay->getDelay();
22238− t_CKDUR max = GET_NEXT_DUR(ARGS);
22239− delay->set( (long)(val+.5), (long)(max+1.5) );
22240− RETURN->v_dur = (t_CKDUR)((Delay *)OBJ_MEMBER_UINT(SELF, Delay_offset_data))->length-1.0;
22550+ ((Echo *)OBJ_MEMBER_UINT(SELF, Echo_offset_data))->set( GET_NEXT_DUR(ARGS) );
22551+ RETURN->v_dur = (t_CKDUR)((Echo *)OBJ_MEMBER_UINT(SELF, Echo_offset_data))->length;
2224122552 }
2224222553
2224322554
2224422555 //-----------------------------------------------------------------------------
22245−// name: Delay_cget_max()
22556+// name: Echo_cget_max()
2224622557 // desc: CGET function ...
2224722558 //-----------------------------------------------------------------------------
22248−CK_DLL_CGET( Delay_cget_max )
22559+CK_DLL_CGET( Echo_cget_max )
2224922560 {
22250− RETURN->v_dur = (t_CKDUR)((Delay *)OBJ_MEMBER_UINT(SELF, Delay_offset_data))->length-1.0;
22561+ RETURN->v_dur = (t_CKDUR)((Echo *)OBJ_MEMBER_UINT(SELF, Echo_offset_data))->length;
2225122562 }
2225222563
2225322564
2225422565 //-----------------------------------------------------------------------------
22255−// name: Delay_clear()
22256−// desc: CGET function ...
22566+// name: Echo_ctrl_mix()
22567+// desc: CTRL function ...
2225722568 //-----------------------------------------------------------------------------
22258−CK_DLL_CGET( Delay_clear )
22569+CK_DLL_CTRL( Echo_ctrl_mix )
2225922570 {
22260− Delay * delay = (Delay *)OBJ_MEMBER_UINT(SELF, Delay_offset_data);
22261− delay->clear();
22571+ ((Echo *)OBJ_MEMBER_UINT(SELF, Echo_offset_data))->setEffectMix( GET_NEXT_FLOAT(ARGS) );
22572+ RETURN->v_float = (t_CKFLOAT)((Echo *)OBJ_MEMBER_UINT(SELF, Echo_offset_data))->effectMix;
2226222573 }
2226322574
2226422575
22576+//-----------------------------------------------------------------------------
22577+// name: Echo_cget_mix()
22578+// desc: CGET function ...
22579+//-----------------------------------------------------------------------------
22580+CK_DLL_CGET( Echo_cget_mix )
22581+{
22582+ RETURN->v_float = (t_CKFLOAT)((Echo *)OBJ_MEMBER_UINT(SELF, Echo_offset_data))->effectMix;
22583+}
2226522584
2226622585
22267−// DelayA
2226822586 //-----------------------------------------------------------------------------
22269−// name: DelayA_ctor()
22587+// name: Envelope - import
22588+// desc: ..
22589+//-----------------------------------------------------------------------------
22590+//-----------------------------------------------------------------------------
22591+// name: Envelope_ctor()
2227022592 // desc: CTOR function ...
2227122593 //-----------------------------------------------------------------------------
22272−CK_DLL_CTOR( DelayA_ctor )
22594+CK_DLL_CTOR( Envelope_ctor )
2227322595 {
22274− OBJ_MEMBER_UINT(SELF, DelayA_offset_data) = (t_CKUINT)new DelayA;
22596+ OBJ_MEMBER_UINT(SELF, Envelope_offset_data) = (t_CKUINT)new Envelope;
2227522597 }
2227622598
2227722599
2227822600 //-----------------------------------------------------------------------------
22279−// name: DelayA_dtor()
22601+// name: Envelope_dtor()
2228022602 // desc: DTOR function ...
2228122603 //-----------------------------------------------------------------------------
22282−CK_DLL_DTOR( DelayA_dtor )
22604+CK_DLL_DTOR( Envelope_dtor )
2228322605 {
22284− delete (DelayA *)OBJ_MEMBER_UINT(SELF, DelayA_offset_data);
22285− OBJ_MEMBER_UINT(SELF, DelayA_offset_data) = 0;
22606+ delete (Envelope *)OBJ_MEMBER_UINT(SELF, Envelope_offset_data);
22607+ OBJ_MEMBER_UINT(SELF, Envelope_offset_data) = 0;
2228622608 }
2228722609
2228822610
2228922611 //-----------------------------------------------------------------------------
22290−// name: DelayA_tick()
22612+// name: Envelope_tick()
2229122613 // desc: TICK function ...
2229222614 //-----------------------------------------------------------------------------
22293−CK_DLL_TICK( DelayA_tick )
22615+CK_DLL_TICK( Envelope_tick )
2229422616 {
22295− *out = (SAMPLE)((DelayA *)OBJ_MEMBER_UINT(SELF, DelayA_offset_data))->tick( in );
22617+ Envelope * d = (Envelope *)OBJ_MEMBER_UINT(SELF, Envelope_offset_data);
22618+ *out = in * d->tick();
2229622619 return TRUE;
2229722620 }
2229822621
2229922622
2230022623 //-----------------------------------------------------------------------------
22301−// name: DelayA_pmsg()
22624+// name: Envelope_pmsg()
2230222625 // desc: PMSG function ...
2230322626 //-----------------------------------------------------------------------------
22304−CK_DLL_PMSG( DelayA_pmsg )
22627+CK_DLL_PMSG( Envelope_pmsg )
2230522628 {
2230622629 return FALSE;
2230722630 }
2230822631
2230922632
2231022633 //-----------------------------------------------------------------------------
22311−// name: DelayA_ctrl_delay()
22634+// name: Envelope_ctrl_time()
2231222635 // desc: CTRL function ...
2231322636 //-----------------------------------------------------------------------------
22314−CK_DLL_CTRL( DelayA_ctrl_delay )
22637+CK_DLL_CTRL( Envelope_ctrl_time )
2231522638 {
22316− ((DelayA *)OBJ_MEMBER_UINT(SELF, DelayA_offset_data))->setDelay( GET_NEXT_DUR(ARGS) );
22317− RETURN->v_dur = (t_CKDUR)((DelayA *)OBJ_MEMBER_UINT(SELF, DelayA_offset_data))->getDelay();
22639+ Envelope * d = (Envelope *)OBJ_MEMBER_UINT(SELF, Envelope_offset_data);
22640+ d->setTime( GET_NEXT_FLOAT(ARGS) );
22641+ RETURN->v_float = d->m_time;
2231822642 }
2231922643
2232022644
2232122645 //-----------------------------------------------------------------------------
22322−// name: DelayA_cget_delay()
22646+// name: Envelope_cget_time()
2232322647 // desc: CGET function ...
2232422648 //-----------------------------------------------------------------------------
22325−CK_DLL_CGET( DelayA_cget_delay )
22649+CK_DLL_CGET( Envelope_cget_time )
2232622650 {
22327− RETURN->v_dur = (t_CKDUR)((DelayA *)OBJ_MEMBER_UINT(SELF, DelayA_offset_data))->getDelay();
22651+ Envelope * d = (Envelope *)OBJ_MEMBER_UINT(SELF, Envelope_offset_data);
22652+ RETURN->v_float = d->m_time;
2232822653 }
2232922654
2233022655
2233122656 //-----------------------------------------------------------------------------
22332−// name: DelayA_ctrl_max()
22657+// name: Envelope_ctrl_duration()
2233322658 // desc: CTRL function ...
2233422659 //-----------------------------------------------------------------------------
22335−CK_DLL_CTRL( DelayA_ctrl_max )
22660+CK_DLL_CTRL( Envelope_ctrl_duration )
2233622661 {
22337− DelayA * delay = (DelayA *)OBJ_MEMBER_UINT(SELF, DelayA_offset_data);
22338− t_CKDUR val = (t_CKDUR)delay->getDelay();
22339− t_CKDUR max = GET_NEXT_DUR(ARGS);
22340− delay->set( val, (long)(max+1.5) );
22341− RETURN->v_dur = (t_CKDUR)((DelayA *)OBJ_MEMBER_UINT(SELF, DelayA_offset_data))->length-1.0;
22662+ Envelope * d = (Envelope *)OBJ_MEMBER_UINT(SELF, Envelope_offset_data);
22663+ d->setTime( GET_NEXT_FLOAT(ARGS) / Stk::sampleRate() );
22664+ RETURN->v_float = d->m_time * Stk::sampleRate();
2234222665 }
2234322666
2234422667
2234522668 //-----------------------------------------------------------------------------
22346−// name: DelayA_cget_max()
22669+// name: Envelope_cget_duration()
2234722670 // desc: CGET function ...
2234822671 //-----------------------------------------------------------------------------
22349−CK_DLL_CGET( DelayA_cget_max )
22672+CK_DLL_CGET( Envelope_cget_duration )
2235022673 {
22351− RETURN->v_dur = (t_CKDUR)((DelayA *)OBJ_MEMBER_UINT(SELF, DelayA_offset_data))->length-1.0;
22674+ Envelope * d = (Envelope *)OBJ_MEMBER_UINT(SELF, Envelope_offset_data);
22675+ RETURN->v_float = d->m_time * Stk::sampleRate();
2235222676 }
2235322677
2235422678
2235522679 //-----------------------------------------------------------------------------
22356−// name: DelayA_clear()
22357−// desc: CGET function ...
22680+// name: Envelope_ctrl_rate()
22681+// desc: CTRL function ...
2235822682 //-----------------------------------------------------------------------------
22359−CK_DLL_CGET( DelayA_clear )
22683+CK_DLL_CTRL( Envelope_ctrl_rate )
2236022684 {
22361− DelayA * delay = (DelayA *)OBJ_MEMBER_UINT(SELF, DelayA_offset_data);
22362− delay->clear();
22685+ Envelope * d = (Envelope *)OBJ_MEMBER_UINT(SELF, Envelope_offset_data);
22686+ d->setRate( GET_NEXT_FLOAT(ARGS) );
22687+ RETURN->v_float = (t_CKFLOAT)d->rate;
2236322688 }
2236422689
2236522690
22366−
22367−
22368−// DelayL
2236922691 //-----------------------------------------------------------------------------
22370−// name: DelayL_ctor()
22371−// desc: CTOR function ...
22692+// name: Envelope_cget_rate()
22693+// desc: CGET function ...
2237222694 //-----------------------------------------------------------------------------
22373−CK_DLL_CTOR( DelayL_ctor )
22695+CK_DLL_CGET( Envelope_cget_rate )
2237422696 {
22375− OBJ_MEMBER_UINT(SELF, DelayL_offset_data) = (t_CKUINT)new DelayL;
22697+ Envelope * d = (Envelope *)OBJ_MEMBER_UINT(SELF, Envelope_offset_data);
22698+ RETURN->v_float = (t_CKFLOAT)d->rate;
2237622699 }
2237722700
2237822701
2237922702 //-----------------------------------------------------------------------------
22380−// name: DelayL_dtor()
22381−// desc: DTOR function ...
22703+// name: Envelope_ctrl_target()
22704+// desc: CTRL function ...
2238222705 //-----------------------------------------------------------------------------
22383−CK_DLL_DTOR( DelayL_dtor )
22706+CK_DLL_CTRL( Envelope_ctrl_target )
2238422707 {
22385− delete (DelayL *)OBJ_MEMBER_UINT(SELF, DelayL_offset_data);
22386− OBJ_MEMBER_UINT(SELF, DelayL_offset_data) = 0;
22708+ Envelope * d = (Envelope *)OBJ_MEMBER_UINT(SELF, Envelope_offset_data);
22709+ d->setTarget( GET_NEXT_FLOAT(ARGS) );
22710+ RETURN->v_float = (t_CKFLOAT)d->target;
2238722711 }
2238822712
2238922713
2239022714 //-----------------------------------------------------------------------------
22391−// name: DelayL_tick()
22392−// desc: TICK function ...
22715+// name: Envelope_cget_target()
22716+// desc: CGET function ...
2239322717 //-----------------------------------------------------------------------------
22394−CK_DLL_TICK( DelayL_tick )
22718+CK_DLL_CGET( Envelope_cget_target )
2239522719 {
22396− *out = (SAMPLE)((DelayL *)OBJ_MEMBER_UINT(SELF, DelayL_offset_data))->tick( in );
22397− return TRUE;
22720+ Envelope * d = (Envelope *)OBJ_MEMBER_UINT(SELF, Envelope_offset_data);
22721+ RETURN->v_float = (t_CKFLOAT)d->target;
2239822722 }
2239922723
2240022724
2240122725 //-----------------------------------------------------------------------------
22402−// name: DelayL_pmsg()
22403−// desc: PMSG function ...
22726+// name: Envelope_ctrl_value()
22727+// desc: CTRL function ...
2240422728 //-----------------------------------------------------------------------------
22405−CK_DLL_PMSG( DelayL_pmsg )
22729+CK_DLL_CTRL( Envelope_ctrl_value )
2240622730 {
22407− return FALSE;
22731+ Envelope * d = (Envelope *)OBJ_MEMBER_UINT(SELF, Envelope_offset_data);
22732+ d->setValue( GET_NEXT_FLOAT(ARGS) );
22733+ RETURN->v_float = (t_CKFLOAT)d->value;
2240822734 }
2240922735
2241022736
2241122737 //-----------------------------------------------------------------------------
22412−// name: DelayL_ctrl_delay()
22413−// desc: CTRL function ...
22738+// name: Envelope_cget_value()
22739+// desc: CGET function ...
2241422740 //-----------------------------------------------------------------------------
22415−CK_DLL_CTRL( DelayL_ctrl_delay )
22741+CK_DLL_CGET( Envelope_cget_value )
2241622742 {
22417− ((DelayL *)OBJ_MEMBER_UINT(SELF, DelayL_offset_data))->setDelay( GET_NEXT_DUR(ARGS) );
22418− RETURN->v_dur = (t_CKDUR)((DelayL *)OBJ_MEMBER_UINT(SELF, DelayL_offset_data))->getDelay();
22743+ Envelope * d = (Envelope *)OBJ_MEMBER_UINT(SELF, Envelope_offset_data);
22744+ RETURN->v_float = (t_CKFLOAT)d->value;
2241922745 }
2242022746
2242122747
2242222748 //-----------------------------------------------------------------------------

6396 more lines aren’t shown here.

src/core/ugen_stk.h+128−125
@@ -5398,131 +5398,134 @@ public: // SWAP formerly protected · 5397 unmodified lines
53985398 #if !defined(__WVOUT_H)
53995399 #define __WVOUT_H
54005400
5401−//#include <stdio.h>
5402−////#include "util_thread.h"
5403−//
5404−//#define BUFFER_SIZE 1024 // sample frames
5405−//
5406−//class WvOut : public Stk
5407−//{
5408−// public:
5409−//
5410−// typedef unsigned long FILE_TYPE;
5411−//
5412−// static const FILE_TYPE WVOUT_RAW; /*!< STK RAW file type. */
5413−// static const FILE_TYPE WVOUT_WAV; /*!< WAV file type. */
5414−// static const FILE_TYPE WVOUT_SND; /*!< SND (AU) file type. */
5415−// static const FILE_TYPE WVOUT_AIF; /*!< AIFF file type. */
5416−// static const FILE_TYPE WVOUT_MAT; /*!< Matlab MAT-file type. */
5417−//
5418−// // chuck: override stdio fwrite/etc. functions
5419−// size_t fwrite(const void * ptr, size_t size, size_t nitems, FILE * stream);
5420−// int fseek(FILE *stream, long offset, int whence);
5421−// int fflush(FILE *stream);
5422−// int fclose(FILE *stream);
5423−// size_t fread(void *ptr, size_t size, size_t nitems, FILE *stream);
5424−//
5425−// //! Default constructor.
5426−// WvOut();
5427−//
5428−// //! Overloaded constructor used to specify a file name, type, and data format with this object.
5429−// /*!
5430−// An StkError is thrown for invalid argument values or if an error occurs when initializing the output file.
5431−// */
5432−// WvOut( const char *fileName, unsigned int nChannels = 1, FILE_TYPE type = WVOUT_WAV, Stk::STK_FORMAT format = STK_SINT16 );
5433−//
5434−// //! Class destructor.
5435−// virtual ~WvOut();
5436−//
5437−// //! Create a file of the specified type and name and output samples to it in the given data format.
5438−// /*!
5439−// An StkError is thrown for invalid argument values or if an error occurs when initializing the output file.
5440−// */
5441−// void openFile( const char *fileName, unsigned int nChannels = 1, \
5442−// WvOut::FILE_TYPE type = WVOUT_WAV, Stk::STK_FORMAT = STK_SINT16 );
5443−// //! If a file is open, write out samples in the queue and then close it.
5444−// void closeFile( void );
5445−//
5446−// //! Return the number of sample frames output.
5447−// unsigned long getFrames( void ) const;
5448−//
5449−// //! Return the number of seconds of data output.
5450−// MY_FLOAT getTime( void ) const;
5451−//
5452−// //! Output a single sample to all channels in a sample frame.
5453−// /*!
5454−// An StkError is thrown if a file write error occurs.
5455−// */
5456−// virtual void tick(const MY_FLOAT sample);
5457−//
5458−// //! Output each sample in \e vector to all channels in \e vectorSize sample frames.
5459−// /*!
5460−// An StkError is thrown if a file write error occurs.
5461−// */
5462−// virtual void tick(const MY_FLOAT *vector, unsigned int vectorSize);
5463−//
5464−// //! Output the \e frameVector of sample frames of the given length.
5465−// /*!
5466−// An StkError is thrown if a file write error occurs.
5467−// */
5468−// virtual void tickFrame(const MY_FLOAT *frameVector, unsigned int frames = 1);
5469−//
5470−// public: // SWAP formerly protected
5471−//
5472−// // Initialize class variables.
5473−// void init( void );
5474−//
5475−// // Write data to output file;
5476−// virtual void writeData( unsigned long frames );
5477−//
5478−// // Write STK RAW file header.
5479−// bool setRawFile( const char *fileName );
5480−//
5481−// // Write WAV file header.
5482−// bool setWavFile( const char *fileName );
5483−//
5484−// // Close WAV file, updating the header.
5485−// void closeWavFile( void );
5486−//
5487−// // Write SND (AU) file header.
5488−// bool setSndFile( const char *fileName );
5489−//
5490−// // Close SND file, updating the header.
5491−// void closeSndFile( void );
5492−//
5493−// // Write AIFF file header.
5494−// bool setAifFile( const char *fileName );
5495−//
5496−// // Close AIFF file, updating the header.
5497−// void closeAifFile( void );
5498−//
5499−// // Write MAT-file header.
5500−// bool setMatFile( const char *fileName );
5501−//
5502−// // Close MAT-file, updating the header.
5503−// void closeMatFile( void );
5504−//
5505−// char msg[256];
5506−// FILE *fd;
5507−// MY_FLOAT *data;
5508−// FILE_TYPE fileType;
5509−// STK_FORMAT dataType;
5510−// bool byteswap;
5511−// unsigned int channels;
5512−// unsigned long counter;
5513−// unsigned long totalCount;
5514−// // char m_filename[1024];
5515−// Chuck_String str_filename;
5516−// t_CKUINT start;
5517−// // char autoPrefix[1024];
5518−// Chuck_String autoPrefix;
5519−// t_CKUINT flush;
5520−// t_CKFLOAT fileGain;
5521−//
5522−// // spencer: for data asynch write
5523−// t_CKBOOL asyncIO;
5524−// XWriteThread * asyncWriteThread;
5525−//};
5401+
5402+#ifndef __DISABLE_WVOUT__
5403+#include <stdio.h>
5404+//#include "util_thread.h"
5405+
5406+#define BUFFER_SIZE 1024 // sample frames
5407+
5408+class WvOut : public Stk
5409+{
5410+ public:
5411+
5412+ typedef unsigned long FILE_TYPE;
5413+
5414+ static const FILE_TYPE WVOUT_RAW; /*!< STK RAW file type. */
5415+ static const FILE_TYPE WVOUT_WAV; /*!< WAV file type. */
5416+ static const FILE_TYPE WVOUT_SND; /*!< SND (AU) file type. */
5417+ static const FILE_TYPE WVOUT_AIF; /*!< AIFF file type. */
5418+ static const FILE_TYPE WVOUT_MAT; /*!< Matlab MAT-file type. */
5419+
5420+ // chuck: override stdio fwrite/etc. functions
5421+ size_t fwrite(const void * ptr, size_t size, size_t nitems, FILE * stream);
5422+ int fseek(FILE *stream, long offset, int whence);
5423+ int fflush(FILE *stream);
5424+ int fclose(FILE *stream);
5425+ size_t fread(void *ptr, size_t size, size_t nitems, FILE *stream);
5426+
5427+ //! Default constructor.
5428+ WvOut();
5429+
5430+ //! Overloaded constructor used to specify a file name, type, and data format with this object.
5431+ /*!
5432+ An StkError is thrown for invalid argument values or if an error occurs when initializing the output file.
5433+ */
5434+ WvOut( const char *fileName, unsigned int nChannels = 1, FILE_TYPE type = WVOUT_WAV, Stk::STK_FORMAT format = STK_SINT16 );
5435+
5436+ //! Class destructor.
5437+ virtual ~WvOut();
5438+
5439+ //! Create a file of the specified type and name and output samples to it in the given data format.
5440+ /*!
5441+ An StkError is thrown for invalid argument values or if an error occurs when initializing the output file.
5442+ */
5443+ void openFile( const char *fileName, unsigned int nChannels = 1, \
5444+ WvOut::FILE_TYPE type = WVOUT_WAV, Stk::STK_FORMAT = STK_SINT16 );
5445+ //! If a file is open, write out samples in the queue and then close it.
5446+ void closeFile( void );
5447+
5448+ //! Return the number of sample frames output.
5449+ unsigned long getFrames( void ) const;
5450+
5451+ //! Return the number of seconds of data output.
5452+ MY_FLOAT getTime( void ) const;
5453+
5454+ //! Output a single sample to all channels in a sample frame.
5455+ /*!
5456+ An StkError is thrown if a file write error occurs.
5457+ */
5458+ virtual void tick(const MY_FLOAT sample);
5459+
5460+ //! Output each sample in \e vector to all channels in \e vectorSize sample frames.
5461+ /*!
5462+ An StkError is thrown if a file write error occurs.
5463+ */
5464+ virtual void tick(const MY_FLOAT *vector, unsigned int vectorSize);
5465+
5466+ //! Output the \e frameVector of sample frames of the given length.
5467+ /*!
5468+ An StkError is thrown if a file write error occurs.
5469+ */
5470+ virtual void tickFrame(const MY_FLOAT *frameVector, unsigned int frames = 1);
5471+
5472+ public: // SWAP formerly protected
5473+
5474+ // Initialize class variables.
5475+ void init( void );
5476+
5477+ // Write data to output file;
5478+ virtual void writeData( unsigned long frames );
5479+
5480+ // Write STK RAW file header.
5481+ bool setRawFile( const char *fileName );
5482+
5483+ // Write WAV file header.
5484+ bool setWavFile( const char *fileName );
5485+
5486+ // Close WAV file, updating the header.
5487+ void closeWavFile( void );
5488+
5489+ // Write SND (AU) file header.
5490+ bool setSndFile( const char *fileName );
5491+
5492+ // Close SND file, updating the header.
5493+ void closeSndFile( void );
5494+
5495+ // Write AIFF file header.
5496+ bool setAifFile( const char *fileName );
5497+
5498+ // Close AIFF file, updating the header.
5499+ void closeAifFile( void );
5500+
5501+ // Write MAT-file header.
5502+ bool setMatFile( const char *fileName );
5503+
5504+ // Close MAT-file, updating the header.
5505+ void closeMatFile( void );
5506+
5507+ char msg[256];
5508+ FILE *fd;
5509+ MY_FLOAT *data;
5510+ FILE_TYPE fileType;
5511+ STK_FORMAT dataType;
5512+ bool byteswap;
5513+ unsigned int channels;
5514+ unsigned long counter;
5515+ unsigned long totalCount;
5516+ // char m_filename[1024];
5517+ Chuck_String str_filename;
5518+ t_CKUINT start;
5519+ // char autoPrefix[1024];
5520+ Chuck_String autoPrefix;
5521+ t_CKUINT flush;
5522+ t_CKFLOAT fileGain;
5523+
5524+ // spencer: for data asynch write
5525+ t_CKBOOL asyncIO;
5526+ XWriteThread * asyncWriteThread;
5527+};
5528+#endif // __DISABLED_WVOUT__
55265529
55275530 #endif // defined(__WVOUT_H)
55285531
src/core/ugen_xxx.cpp+7−5
@@ -41,11 +41,13 @@ · 40 unmodified lines
4141 #include <sys/stat.h>
4242 #include <limits.h>
4343
44−//#if defined(__CK_SNDFILE_NATIVE__)
45−//#include <sndfile.h>
46−//#else
47−//#include "util_sndfile.h"
48−//#endif
44+#ifndef __DISABLE_SNDBUF__
45+#if defined(__CK_SNDFILE_NATIVE__)
46+#include <sndfile.h>
47+#else
48+#include "util_sndfile.h"
49+#endif
50+#endif
4951
5052 #include "ugen_xxx.h"
5153 #include "chuck_type.h"
src/core/ulib_machine.h+1−1
@@ -33,7 +33,7 @@ · 32 unmodified lines
3333 #define __ULIB_MACHINE_H__
3434
3535 #include "chuck_dl.h"
36−//#include "chuck_otf.h"
36+#include "chuck_otf.h"
3737
3838 // forward reference
3939 struct Chuck_VM;
src/core/ulib_std.cpp+9−3
@@ -34,10 +34,14 @@ · 33 unmodified lines
3434 #include <time.h>
3535 #include <math.h>
3636 #include "util_buffers.h"
37−//#include "util_console.h"
37+#ifndef __DISABLE_PROMPTER__
38+#include "util_console.h"
39+#endif
3840 #include "util_math.h"
3941 #include "util_string.h"
40−//#include "util_thread.h"
42+#ifndef __DISABLE_THREADS__
43+#include "util_thread.h"
44+#endif
4145 #include "chuck.h"
4246 #include "chuck_type.h"
4347 #include "chuck_compile.h"
@@ -61,7 +65,9 @@ int setenv( const char *n, const char *v, int i ) · 17 unmodified lines
6165 // for ConsoleInput and StringTokenizer
6266 #include <sstream>
6367 #include <iostream>
64−//#include "util_thread.h"
68+#ifndef __DISABLE_THREADS__
69+#include "util_thread.h"
70+#endif
6571 using namespace std;
6672
6773
src/core/util_buffers.cpp+33−11
@@ -121,7 +121,9 @@ void CBufferAdvance::cleanup() · 120 unmodified lines
121121 UINT__ CBufferAdvance::join( Chuck_Event * event )
122122 {
123123 // TODO: necessary?
124−// m_mutex.acquire();
124+ #ifndef __DISABLE_THREADS__
125+ m_mutex.acquire();
126+ #endif
125127
126128 // index of new pointer that will be pushed back
127129 UINT__ read_offset_index;
@@ -143,7 +145,9 @@ UINT__ CBufferAdvance::join( Chuck_Event * event ) · 15 unmodified lines
143145 }
144146
145147 // TODO: necessary?
146−// m_mutex.release();
148+ #ifndef __DISABLE_THREADS__
149+ m_mutex.release();
150+ #endif
147151
148152 // return index
149153 return read_offset_index;
@@ -161,7 +165,9 @@ void CBufferAdvance::resign( UINT__ read_offset_index ) · 11 unmodified lines
161165 return;
162166
163167 // TODO: necessary?
164−// m_mutex.acquire();
168+ #ifndef __DISABLE_THREADS__
169+ m_mutex.acquire();
170+ #endif
165171
166172 // add this index to free queue
167173 m_free.push( read_offset_index );
@@ -171,7 +177,9 @@ void CBufferAdvance::resign( UINT__ read_offset_index ) · 3 unmodified lines
171177 m_read_offsets[read_offset_index].event = NULL;
172178
173179 // TODO: necessary?
174−// m_mutex.release();
180+ #ifndef __DISABLE_THREADS__
181+ m_mutex.release();
182+ #endif
175183 }
176184
177185
@@ -208,7 +216,9 @@ void CBufferAdvance::put( void * data, UINT__ num_elem ) · 30 unmodified lines
208216 BYTE__ * d = (BYTE__ *)data;
209217
210218 // TODO: necessary?
211−// m_mutex.acquire();
219+ #ifndef __DISABLE_THREADS__
220+ m_mutex.acquire();
221+ #endif
212222
213223 // copy
214224 for( i = 0; i < num_elem; i++ )
@@ -240,7 +250,9 @@ void CBufferAdvance::put( void * data, UINT__ num_elem ) · 25 unmodified lines
240250 }
241251
242252 // TODO: necessary?
243−// m_mutex.release();
253+ #ifndef __DISABLE_THREADS__
254+ m_mutex.release();
255+ #endif
244256 }
245257
246258
@@ -308,17 +320,23 @@ UINT__ CBufferAdvance::get( void * data, UINT__ num_elem, UINT__ read_offset_ind · 61 unmodified lines
308320 BYTE__ * d = (BYTE__ *)data;
309321
310322 // TODO: necessary?
311−// m_mutex.acquire();
323+ #ifndef __DISABLE_THREADS__
324+ m_mutex.acquire();
325+ #endif
312326
313327 // make sure index is valid
314328 if( read_offset_index >= m_read_offsets.size() )
315329 {
316−// m_mutex.release();
330+ #ifndef __DISABLE_THREADS__
331+ m_mutex.release();
332+ #endif
317333 return 0;
318334 }
319335 if( m_read_offsets[read_offset_index].read_offset < 0 )
320336 {
321−// m_mutex.release();
337+ #ifndef __DISABLE_THREADS__
338+ m_mutex.release();
339+ #endif
322340 return 0;
323341 }
324342
@@ -327,7 +345,9 @@ UINT__ CBufferAdvance::get( void * data, UINT__ num_elem, UINT__ read_offset_ind · 2 unmodified lines
327345 // read catch up with write
328346 if( m_read_offset == m_write_offset )
329347 {
330−// m_mutex.release();
348+ #ifndef __DISABLE_THREADS__
349+ m_mutex.release();
350+ #endif
331351 return 0;
332352 }
333353
@@ -357,7 +377,9 @@ UINT__ CBufferAdvance::get( void * data, UINT__ num_elem, UINT__ read_offset_ind · 23 unmodified lines
357377 m_read_offsets[read_offset_index].read_offset = m_read_offset;
358378
359379 // TODO: necessary?
360−// m_mutex.release();
380+ #ifndef __DISABLE_THREADS__
381+ m_mutex.release();
382+ #endif
361383
362384 // return number of elems
363385 return i;
src/core/util_buffers.h+6−2
@@ -36,7 +36,9 @@ · 35 unmodified lines
3636 #define __UTIL_BUFFERS_H__
3737
3838 #include "chuck_oo.h"
39−//#include "util_thread.h"
39+#ifndef __DISABLE_THREADS__
40+#include "util_thread.h"
41+#endif
4042 #include <vector>
4143 #include <queue>
4244 #include <iostream>
@@ -98,7 +100,9 @@ protected: · 55 unmodified lines
98100 SINT__ m_max_elem;
99101
100102 // TODO: necessary?
101−// XMutex m_mutex;
103+ #ifndef __DISABLE_THREADS__
104+ XMutex m_mutex;
105+ #endif
102106
103107 CBufferSimple * m_event_buffer;
104108 };
src/core/util_string.cpp+25−24
@@ -361,34 +361,35 @@ done: · 360 unmodified lines
361361
362362 /* from http://developer.apple.com/library/mac/#qa/qa1549/_index.html */
363363
364−#ifndef __PLATFORM_WIN32__
364+#if !defined(__PLATFORM_WIN32__) && !defined(__EMSCRIPTEN__)
365365
366366 #include <glob.h>
367367
368−//char* CreatePathByExpandingTildePath(const char* path)
369−//{
370−// glob_t globbuf;
371−// char **v;
372−// char *expandedPath = NULL, *result = NULL;
373−//
374−// assert(path != NULL);
375−//
376−// if (glob(path, GLOB_TILDE, NULL, &globbuf) == 0) //success
377−// {
378−// v = globbuf.gl_pathv; //list of matched pathnames
379−// expandedPath = v[0]; //number of matched pathnames, gl_pathc == 1
380−//
381−// result = (char*)calloc(1, strlen(expandedPath) + 1); //the extra char is for the null-termination
382−// if(result)
383−// strncpy(result, expandedPath, strlen(expandedPath) + 1); //copy the null-termination as well
384−//
385−// globfree(&globbuf);
386−// }
387−//
388−// return result;
389−//}
390368
391−#endif // __PLATFORM_WIN32__
369+char* CreatePathByExpandingTildePath(const char* path)
370+{
371+ glob_t globbuf;
372+ char **v;
373+ char *expandedPath = NULL, *result = NULL;
374+
375+ assert(path != NULL);
376+
377+ if (glob(path, GLOB_TILDE, NULL, &globbuf) == 0) //success
378+ {
379+ v = globbuf.gl_pathv; //list of matched pathnames
380+ expandedPath = v[0]; //number of matched pathnames, gl_pathc == 1
381+
382+ result = (char*)calloc(1, strlen(expandedPath) + 1); //the extra char is for the null-termination
383+ if(result)
384+ strncpy(result, expandedPath, strlen(expandedPath) + 1); //copy the null-termination as well
385+
386+ globfree(&globbuf);
387+ }
388+
389+ return result;
390+}
391+
392+#endif // __PLATFORM_WIN32__ && __EMSCRIPTEN__
392393
393394
394395 // get full path to file
src/makefile+5−2
@@ -26,7 +26,7 @@ endif · 25 unmodified lines
2626 endif
2727
2828
29−############################## MAKE EMSCRIPTEN##################################
29+############################## MAKE EMSCRIPTEN #################################
3030 EMSCRIPTENSRCS=host_web/chuck_emscripten.cpp \
3131 host_web/chuck_emscripten_main.cpp core/chuck.cpp core/chuck_absyn.cpp \
3232 core/chuck_carrier.cpp core/chuck_compile.cpp core/chuck_dl.cpp \
@@ -48,7 +48,10 @@ emscripten: host_web/chuckscript.js · 15 unmodified lines
4848 host_web/chuckscript.js: $(EMSCRIPTENSRCS)
4949 emcc -Icore -D__DISABLE_MIDI__ -D__DISABLE_WATCHDOG__ -D__DISABLE_RAW__ \
5050 -D__DISABLE_KBHIT__ -D__DISABLE_PROMPTER__ -D__DISABLE_RTAUDIO__ \
51− -D__DISABLE_OTF_SERVER__ -D__ALTER_HID__ -D__DISABLE_SNDBUF__ \
51+ -D__DISABLE_OTF_SERVER__ -D__ALTER_HID__ -D__DISABLE_HID__ \
52+ -D__DISABLE_SNDBUF__ -D__DISABLE_SERIAL__ -D__DISABLE_THREADS__ \
53+ -D__DISABLE_NETWORK__ -D__DISABLE_SHELL__ -D__DISABLE_WVOUT__ \
54+ -D__DISABLE_FILEIO__ \
5255 $(EMSCRIPTENSRCS) -o host_web/chuckscript.js \
5356 -s EXTRA_EXPORTED_RUNTIME_METHODS='["ccall", "cwrap", "getValue", "setValue"]' \
5457 -s LINKABLE=1 -s MODULARIZE=1 -s 'EXPORT_NAME="ChucK"'

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t