From 53c337aedb6c3940c4f94c0e166053134d92c7a7 Mon Sep 17 00:00:00 2001 From: gw-chuck Date: Wed, 13 Aug 2008 17:42:50 +0000 Subject: [PATCH] *** empty log message *** --- v2/chuck_compile.cpp | 2 + v2/chuck_def.h | 9 + v2/chuck_emit.cpp | 2 +- v2/chuck_globals.cpp | 4 + v2/chuck_globals.h | 4 +- v2/chuck_lang.cpp | 75 ++++--- v2/chuck_lang.h | 2 +- v2/chuck_main.cpp | 18 +- v2/chuck_oo.cpp | 58 ++--- v2/chuck_shell.cpp | 44 ++-- v2/chuck_symbol.cpp | 2 +- v2/chuck_type.h | 2 +- v2/chuck_ugen.cpp | 42 ++-- v2/chuck_ugen.h | 2 +- v2/chuck_vm.cpp | 2 +- v2/midiio_rtmidi.cpp | 36 +++ v2/rtaudio.cpp | 2 +- v2/uana_extract.cpp | 624 +++++++++++++++++++++++++-------------------------- v2/ugen_osc.cpp | 32 +-- v2/ugen_stk.cpp | 2 +- v2/ugen_xxx.cpp | 16 +- v2/ulib_math.cpp | 4 +- v2/ulib_math.h | 4 +- v2/ulib_std.cpp | 36 +-- v2/util_hid.cpp | 428 +++++++++++++++++++++++++++++------ v2/util_opsc.cpp | 2 +- 26 files changed, 914 insertions(+), 540 deletions(-) diff --git a/v2/chuck_compile.cpp b/v2/chuck_compile.cpp index d4074663..228f2fb1 100755 --- a/v2/chuck_compile.cpp +++ b/v2/chuck_compile.cpp @@ -552,8 +552,10 @@ t_CKBOOL load_internal_modules( Chuck_Compiler * compiler ) if( !load_module( env, opensoundcontrol_query, "opsc", "global" ) ) goto error; // if( !load_module( env, net_query, "net", "global" ) ) goto error; +#ifndef __DISABLE_MIDI__ if( !init_class_Midi( env ) ) goto error; if( !init_class_MidiRW( env ) ) goto error; +#endif // __DISABLE_MIDI__ if( !init_class_HID( env ) ) goto error; // clear context diff --git a/v2/chuck_def.h b/v2/chuck_def.h index 71c89eed..cc83e621 100755 --- a/v2/chuck_def.h +++ b/v2/chuck_def.h @@ -152,5 +152,14 @@ typedef struct { SAMPLE re ; SAMPLE im ; } t_CKCOMPLEX_SAMPLE; #pragma warning (disable : 4068) // unknown pragma #endif +#ifdef __CHIP_MODE__ +#define __DISABLE_MIDI__ +#define __DISABLE_SNDBUF__ +#define __ALTER_HID__ +#define __ALTER_ENTRY_POINT__ +#endif + + + #endif diff --git a/v2/chuck_emit.cpp b/v2/chuck_emit.cpp index 8a69017d..2d3fd189 100755 --- a/v2/chuck_emit.cpp +++ b/v2/chuck_emit.cpp @@ -4032,7 +4032,7 @@ t_CKBOOL emit_engine_emit_symbol( Chuck_Emitter * emit, S_Symbol symbol, // try this (thanks Robin Davies) assert( isa( emit->env->class_def, v->owner_class ) /* || is_global( v->owner_class ) */ ); - // emit as this.v + // emit as this.v // BUG: passing "this" below might be bad if the exp is freed and string with it a_Exp base = new_exp_from_id( (char *)"this", linepos ); a_Exp dot = new_exp_from_member_dot( base, (char *)v->name.c_str(), linepos ); diff --git a/v2/chuck_globals.cpp b/v2/chuck_globals.cpp index 6e6f48e8..7020ff0f 100755 --- a/v2/chuck_globals.cpp +++ b/v2/chuck_globals.cpp @@ -87,12 +87,16 @@ extern "C" void all_detach() EM_pushlog(); // close stk file handles stk_detach( 0, NULL ); +#ifndef __DISABLE_MIDI__ // close midi file handles midirw_detach(); +#endif // __DISABLE_MIDI__ // shutdown kb loop KBHitManager::shutdown(); +#ifndef __ALTER_HID__ // shutdown HID HidInManager::cleanup(); +#endif // __ALTER_HID__ // pop EM_poplog(); } diff --git a/v2/chuck_globals.h b/v2/chuck_globals.h index 7ee22cb1..cb1f5560 100755 --- a/v2/chuck_globals.h +++ b/v2/chuck_globals.h @@ -68,8 +68,8 @@ extern t_CKUINT g_watchdog_countermeasure_priority; // watchdog timeout extern t_CKFLOAT g_watchdog_timeout; // thread id for whatever -extern CHUCK_THREAD g_tid_whatever; -// flag for providing Std.system( string ) +extern CHUCK_THREAD g_tid_whatever; +// flag for providing Std.system( string ) extern t_CKBOOL g_enable_system_cmd; diff --git a/v2/chuck_lang.cpp b/v2/chuck_lang.cpp index 17f6ab84..a323e645 100755 --- a/v2/chuck_lang.cpp +++ b/v2/chuck_lang.cpp @@ -36,10 +36,13 @@ #include "chuck_vm.h" #include "chuck_errmsg.h" #include "chuck_ugen.h" -#include "midiio_rtmidi.h" #include "hidio_sdl.h" #include "util_string.h" +#ifndef __DISABLE_MIDI__ +#include "midiio_rtmidi.h" +#endif + #include #include #include @@ -153,7 +156,7 @@ t_CKBOOL init_class_ugen( Chuck_Env * env, Chuck_Type * type ) func = make_new_mfun( "int", "isConnectedTo", ugen_connected ); func->add_arg( "UGen", "right" ); if( !type_engine_import_mfun( env, func ) ) goto error; - + // end type_engine_import_class_end( env ); @@ -219,11 +222,11 @@ t_CKBOOL init_class_uana( Chuck_Env * env, Chuck_Type * type ) func = make_new_mfun( "complex", "cval", uana_cval ); func->add_arg( "int", "index" ); if( !type_engine_import_mfun( env, func ) ) goto error; - - // add isUpConnectedTo - func = make_new_mfun( "int", "isUpConnectedTo", uana_connected ); - func->add_arg( "UAna", "right" ); - if( !type_engine_import_mfun( env, func ) ) goto error; + + // add isUpConnectedTo + func = make_new_mfun( "int", "isUpConnectedTo", uana_connected ); + func->add_arg( "UAna", "right" ); + if( !type_engine_import_mfun( env, func ) ) goto error; // TODO: add nonchuck // func = make_new_mfun( "void", "nonchuck", uana_nonchuck ); @@ -801,6 +804,7 @@ error: +#ifndef __DISABLE_MIDI__ // static static t_CKUINT MidiIn_offset_data = 0; @@ -936,6 +940,8 @@ error: return FALSE; } +#endif // __DISABLE_MIDI__ + @@ -1358,6 +1364,8 @@ error: +#ifndef __DISABLE_MIDI__ + // static static t_CKUINT MidiRW_offset_data = 0; static t_CKUINT MidiMsgOut_offset_data = 0; @@ -1471,6 +1479,12 @@ error: } + +#endif // __DISABLE_MIDI__ + + + + // Object ctor CK_DLL_CTOR( object_ctor ) { @@ -1792,27 +1806,27 @@ CK_DLL_MFUN( uana_cval ) cvals.get( i, &val ); RETURN->v_complex = val; } -} - -CK_DLL_MFUN( uana_connected ) -{ - // get ugen - Chuck_UAna * uana = (Chuck_UAna *)SELF; - Chuck_UAna * right = (Chuck_UAna *)GET_NEXT_OBJECT(ARGS); - - // sanity - t_CKINT ret = FALSE; - if( !right ) - { - ret = FALSE; - } - else - { - ret = right->is_up_connected_from( uana ); - } - - RETURN->v_int = ret; -} +} + +CK_DLL_MFUN( uana_connected ) +{ + // get ugen + Chuck_UAna * uana = (Chuck_UAna *)SELF; + Chuck_UAna * right = (Chuck_UAna *)GET_NEXT_OBJECT(ARGS); + + // sanity + t_CKINT ret = FALSE; + if( !right ) + { + ret = FALSE; + } + else + { + ret = right->is_up_connected_from( uana ); + } + + RETURN->v_int = ret; +} // blob proxy implementation @@ -2311,6 +2325,8 @@ CK_DLL_MFUN( array_pop_back ) } +#ifndef __DISABLE_MIDI__ + //----------------------------------------------------------------------------- // MidiIn API //----------------------------------------------------------------------------- @@ -2448,6 +2464,7 @@ CK_DLL_MFUN( MidiOut_send ) RETURN->v_int = mout->send( &the_msg ); } +#endif // __DISABLE_MIDI__ //----------------------------------------------------------------------------- @@ -2835,6 +2852,7 @@ CK_DLL_MFUN( HidOut_send ) } +#ifndef __DISABLE_MIDI__ //----------------------------------------------------------------------------- // MidiRW API @@ -2969,3 +2987,4 @@ CK_DLL_MFUN( MidiMsgIn_read ) OBJ_MEMBER_TIME(fake_msg, MidiMsg_offset_when) = time; } +#endif // __DISABLE_MIDI__ \ No newline at end of file diff --git a/v2/chuck_lang.h b/v2/chuck_lang.h index 0066e418..85d61ed1 100755 --- a/v2/chuck_lang.h +++ b/v2/chuck_lang.h @@ -104,7 +104,7 @@ CK_DLL_MFUN( uana_blob ); CK_DLL_MFUN( uana_fvals ); CK_DLL_MFUN( uana_cvals ); CK_DLL_MFUN( uana_fval ); -CK_DLL_MFUN( uana_cval ); +CK_DLL_MFUN( uana_cval ); CK_DLL_MFUN( uana_connected ); diff --git a/v2/chuck_main.cpp b/v2/chuck_main.cpp index 2123a0a8..eab09fee 100755 --- a/v2/chuck_main.cpp +++ b/v2/chuck_main.cpp @@ -264,7 +264,11 @@ static void usage() // name: main() // desc: entry point //----------------------------------------------------------------------------- -int main( int argc, const char ** argv ) +#ifndef __ALTER_ENTRY_POINT__ + int main( int argc, const char ** argv ) +#else + extern "C" int chuck_main( int argc, const char ** argv ) +#endif { Chuck_Compiler * compiler = NULL; Chuck_VM * vm = NULL; @@ -416,8 +420,8 @@ int main( int argc, const char ** argv ) else if( !strcmp( argv[i], "--probe" ) ) probe = TRUE; else if( !strcmp( argv[i], "--poop" ) ) - uh(); - else if( !strcmp( argv[i], "--caution-to-the-wind" ) ) + uh(); + else if( !strcmp( argv[i], "--caution-to-the-wind" ) ) g_enable_system_cmd = TRUE; else if( !strcmp(argv[i], "--help") || !strcmp(argv[i], "-h") || !strcmp(argv[i], "--about") ) @@ -463,13 +467,15 @@ int main( int argc, const char ** argv ) { Digitalio::probe(); +#ifndef __DISABLE_MIDI__ EM_error2b( 0, "" ); probeMidiIn(); EM_error2b( 0, "" ); probeMidiOut(); EM_error2b( 0, "" ); - - //HidInManager::probeHidIn(); +#endif // __DISABLE_MIDI__ + + // HidInManager::probeHidIn(); // exit exit( 0 ); @@ -545,8 +551,10 @@ int main( int argc, const char ** argv ) exit( 1 ); } +#ifndef __ALTER_HID__ // pre-load hid if( load_hid ) HidInManager::init(); +#endif // __ALTER_HID__ // catch SIGINT signal( SIGINT, signal_int ); diff --git a/v2/chuck_oo.cpp b/v2/chuck_oo.cpp index 77e4de41..f5a67bc7 100755 --- a/v2/chuck_oo.cpp +++ b/v2/chuck_oo.cpp @@ -598,19 +598,19 @@ t_CKINT Chuck_Array4::set_size( t_CKINT size ) // zero out section zero( size, m_vector.size() ); } - - // what the size was + + // what the size was t_CKINT size2 = m_vector.size(); // resize vector m_vector.resize( size ); - // if clearing size - if( m_vector.size() > size2 ) - { - // zero out section - zero( size2, m_vector.size() ); - } - + // if clearing size + if( m_vector.size() > size2 ) + { + // zero out section + zero( size2, m_vector.size() ); + } + return m_vector.size(); } @@ -900,7 +900,7 @@ t_CKINT Chuck_Array8::set_capacity( t_CKINT capacity ) { // sanity check assert( capacity >= 0 ); - + // ensure size set_size( capacity ); @@ -925,19 +925,19 @@ t_CKINT Chuck_Array8::set_size( t_CKINT size ) // zero out section zero( size, m_vector.size() ); } - - // what the size was + + // what the size was t_CKINT size2 = m_vector.size(); // resize vector m_vector.resize( size ); - // if clearing size - if( m_vector.size() > size2 ) - { - // zero out section - zero( size2, m_vector.size() ); - } - + // if clearing size + if( m_vector.size() > size2 ) + { + // zero out section + zero( size2, m_vector.size() ); + } + return m_vector.size(); } @@ -1210,7 +1210,7 @@ t_CKINT Chuck_Array16::set_capacity( t_CKINT capacity ) { // sanity check assert( capacity >= 0 ); - + // ensure size set_size( capacity ); @@ -1235,18 +1235,18 @@ t_CKINT Chuck_Array16::set_size( t_CKINT size ) // zero out section zero( size, m_vector.size() ); } - - // remember + + // remember t_CKINT size2 = m_vector.size(); // resize vector m_vector.resize( size ); - - // if clearing size - if( m_vector.size() > size2 ) - { - // zero out section - zero( size2, m_vector.size() ); - } + + // if clearing size + if( m_vector.size() > size2 ) + { + // zero out section + zero( size2, m_vector.size() ); + } return m_vector.size(); } diff --git a/v2/chuck_shell.cpp b/v2/chuck_shell.cpp index 46ef1c03..e409a4a8 100755 --- a/v2/chuck_shell.cpp +++ b/v2/chuck_shell.cpp @@ -714,7 +714,7 @@ t_CKBOOL Chuck_Shell_Network_VM::add_shred( const vector< string > & files, /* prepare an argument vector to submit to otf_send_cmd */ /* first, specify an add command */ char * argv0 = new char [2]; - strncpy( argv0, "+", 2 ); + strncpy( argv0, "+", 2 ); argv[0] = argv0; /* copy file paths into argv */ @@ -722,7 +722,7 @@ t_CKBOOL Chuck_Shell_Network_VM::add_shred( const vector< string > & files, { str_len = files[j - 1].size() + 1; char * argvj = new char [str_len]; - strncpy( argvj, files[j - 1].c_str(), str_len ); + strncpy( argvj, files[j - 1].c_str(), str_len ); argv[j] = argvj; } @@ -736,11 +736,11 @@ t_CKBOOL Chuck_Shell_Network_VM::add_shred( const vector< string > & files, } /* clean up heap data */ - for( j = 0; j < vec_len; j++ ) - { - // TODO: verify this is alright + for( j = 0; j < vec_len; j++ ) + { + // TODO: verify this is alright char * arg = (char *)argv[j]; - delete[] arg; + delete[] arg; } delete[] argv; @@ -762,7 +762,7 @@ t_CKBOOL Chuck_Shell_Network_VM::remove_shred( const vector< string > & ids, /* prepare an argument vector to submit to otf_send_cmd */ /* first, specify an add command */ char * argv0 = new char [2]; - strncpy( argv0, "-", 2 ); + strncpy( argv0, "-", 2 ); argv[0] = argv0; /* copy ids into argv */ @@ -770,7 +770,7 @@ t_CKBOOL Chuck_Shell_Network_VM::remove_shred( const vector< string > & ids, { str_len = ids[j - 1].size() + 1; char * argvj = new char [str_len]; - strncpy( argvj, ids[j - 1].c_str(), str_len ); + strncpy( argvj, ids[j - 1].c_str(), str_len ); argv[j] = argvj; } @@ -784,11 +784,11 @@ t_CKBOOL Chuck_Shell_Network_VM::remove_shred( const vector< string > & ids, } /* clean up heap data */ - for( j = 0; j < vec_len; j++ ) - { - // TODO: verify this is ok + for( j = 0; j < vec_len; j++ ) + { + // TODO: verify this is ok char * arg = (char *)argv[j]; - delete[] arg; + delete[] arg; } delete[] argv; @@ -803,7 +803,7 @@ t_CKBOOL Chuck_Shell_Network_VM::remove_all( string & out ) { t_CKBOOL return_val = TRUE; t_CKINT j = 0; - const char * argv = "--removeall"; + const char * argv = "--removeall"; if( !otf_send_cmd( 1, &argv, j, hostname.c_str(), port ) ) { out += "removeall: error: command failed\n"; @@ -820,13 +820,13 @@ t_CKBOOL Chuck_Shell_Network_VM::remove_all( string & out ) t_CKBOOL Chuck_Shell_Network_VM::remove_last( string & out ) { t_CKBOOL return_val = TRUE; - t_CKINT j = 0; + t_CKINT j = 0; const char * argv = "--"; if( !otf_send_cmd( 1, &argv, j, hostname.c_str(), port ) ) { out += "removelast: error: command failed\n"; return_val = FALSE; - } + } return return_val; } @@ -850,7 +850,7 @@ t_CKBOOL Chuck_Shell_Network_VM::replace_shred( const vector< string > &vec, const char ** argv = new const char * [ vec_len ]; /* prepare an argument vector to submit to otf_send_cmd */ - /* first, specify an add command */ + /* first, specify an add command */ argv[0] = "--replace"; /* copy ids/files into argv */ @@ -858,7 +858,7 @@ t_CKBOOL Chuck_Shell_Network_VM::replace_shred( const vector< string > &vec, { str_len = vec[j - 1].size() + 1; char * argvj = new char [str_len]; - strncpy( argvj, vec[j - 1].c_str(), str_len ); + strncpy( argvj, vec[j - 1].c_str(), str_len ); argv[j] = argvj; } @@ -879,11 +879,11 @@ t_CKBOOL Chuck_Shell_Network_VM::replace_shred( const vector< string > &vec, } /* clean up heap data */ - for( j = 1; j < vec_len; j++ ) - { - // TODO: verify this is ok - char * arg = (char *)argv[j]; - delete[] arg; + for( j = 1; j < vec_len; j++ ) + { + // TODO: verify this is ok + char * arg = (char *)argv[j]; + delete[] arg; } delete[] argv; diff --git a/v2/chuck_symbol.cpp b/v2/chuck_symbol.cpp index 20e25808..110beccc 100755 --- a/v2/chuck_symbol.cpp +++ b/v2/chuck_symbol.cpp @@ -115,7 +115,7 @@ void * S_look2( S_table t, c_constr str ) { return TAB_look(t,insert_symbol(str)); } - + // BUG: this could result in a bad free if the S_Symbol ever gets cleaned up static struct S_Symbol_ marksym = { (char *)"", 0 }; diff --git a/v2/chuck_type.h b/v2/chuck_type.h index dadce0f8..bfc249f8 100755 --- a/v2/chuck_type.h +++ b/v2/chuck_type.h @@ -542,7 +542,7 @@ public: // free only if not locked: to prevent garbage collection after exit if( !this->m_locked ) - { + { // TODO: uncomment this, fix it to behave correctly // release references // SAFE_RELEASE(parent); diff --git a/v2/chuck_ugen.cpp b/v2/chuck_ugen.cpp index 0463d29d..34de11f7 100755 --- a/v2/chuck_ugen.cpp +++ b/v2/chuck_ugen.cpp @@ -768,27 +768,27 @@ Chuck_UAna * Chuck_UAna::getIncomingUAna( t_CKUINT index ) const // TODO: DANGER: this cast is very dangerous! return ((Chuck_UAna *)m_src_uana_list[index]); } - - - - -//----------------------------------------------------------------------------- -// name: is_up_connected_from() -// desc: ... -//----------------------------------------------------------------------------- -t_CKBOOL Chuck_UAna::is_up_connected_from( Chuck_UAna * src ) -{ - if( m_src_uana_list != NULL && fa_lookup( m_src_uana_list, m_num_uana_src, src ) ) - return TRUE; - - // TODO: multichannel? - - return FALSE; -} - - - - + + + + +//----------------------------------------------------------------------------- +// name: is_up_connected_from() +// desc: ... +//----------------------------------------------------------------------------- +t_CKBOOL Chuck_UAna::is_up_connected_from( Chuck_UAna * src ) +{ + if( m_src_uana_list != NULL && fa_lookup( m_src_uana_list, m_num_uana_src, src ) ) + return TRUE; + + // TODO: multichannel? + + return FALSE; +} + + + + //----------------------------------------------------------------------------- // name: tock() // dsec: ... diff --git a/v2/chuck_ugen.h b/v2/chuck_ugen.h index fc91c5a7..16d72e8f 100755 --- a/v2/chuck_ugen.h +++ b/v2/chuck_ugen.h @@ -141,7 +141,7 @@ public: virtual ~Chuck_UAna( ); public: - t_CKBOOL system_tock( t_CKTIME now ); + t_CKBOOL system_tock( t_CKTIME now ); t_CKBOOL is_up_connected_from( Chuck_UAna * src ); public: // blob retrieval diff --git a/v2/chuck_vm.cpp b/v2/chuck_vm.cpp index 93116c01..0b02f0c3 100755 --- a/v2/chuck_vm.cpp +++ b/v2/chuck_vm.cpp @@ -39,7 +39,7 @@ #include "chuck_globals.h" #include "chuck_lang.h" #include "ugen_xxx.h" - + #include using namespace std; diff --git a/v2/midiio_rtmidi.cpp b/v2/midiio_rtmidi.cpp index b5409362..ae5ffaa4 100755 --- a/v2/midiio_rtmidi.cpp +++ b/v2/midiio_rtmidi.cpp @@ -32,6 +32,9 @@ // date: summer 2005 //----------------------------------------------------------------------------- #include "midiio_rtmidi.h" + +#ifndef __DISABLE_MIDI__ + #include "chuck_errmsg.h" #include #include @@ -792,3 +795,36 @@ t_CKBOOL MidiMsgIn::read( MidiMsg * msg, t_CKTIME * time ) return m && t; } + +#else // __DISABLE_MIDI__ + +MidiOut::MidiOut() +{ + +} + +MidiOut::~MidiOut() +{ +} + +t_CKBOOL MidiOut::open( t_CKUINT device_num ) +{ + return TRUE; +} + +MidiIn::MidiIn() +{ + +} + +MidiIn::~MidiIn() +{ + +} + +t_CKBOOL MidiIn::open( t_CKUINT device_num ) +{ + return FALSE; +} + +#endif // __DISABLE_MIDI__ diff --git a/v2/rtaudio.cpp b/v2/rtaudio.cpp index fab6fad3..592b4c13 100755 --- a/v2/rtaudio.cpp +++ b/v2/rtaudio.cpp @@ -49,7 +49,7 @@ #include "rtaudio.h" #include "chuck_errmsg.h" #include "digiio_rtaudio.h" -#include +#include #include // old // #include "RtAudio.h" diff --git a/v2/uana_extract.cpp b/v2/uana_extract.cpp index 2acf4f4a..9df643cd 100755 --- a/v2/uana_extract.cpp +++ b/v2/uana_extract.cpp @@ -103,18 +103,18 @@ CK_DLL_TOCK( XCorr_tock ); CK_DLL_PMSG( XCorr_pmsg ); CK_DLL_SFUN( XCorr_compute ); CK_DLL_MFUN( XCorr_ctrl_normalize ); -CK_DLL_MFUN( XCorr_cget_normalize ); -// offset -static t_CKUINT XCorr_offset_data = 0; - -// ZeroX -CK_DLL_CTOR( ZeroX_ctor ); -CK_DLL_DTOR( ZeroX_dtor ); -CK_DLL_TICK( ZeroX_tick ); -CK_DLL_TOCK( ZeroX_tock ); -CK_DLL_PMSG( ZeroX_pmsg ); -CK_DLL_SFUN( ZeroX_compute ); -// offset +CK_DLL_MFUN( XCorr_cget_normalize ); +// offset +static t_CKUINT XCorr_offset_data = 0; + +// ZeroX +CK_DLL_CTOR( ZeroX_ctor ); +CK_DLL_DTOR( ZeroX_dtor ); +CK_DLL_TICK( ZeroX_tick ); +CK_DLL_TOCK( ZeroX_tock ); +CK_DLL_PMSG( ZeroX_pmsg ); +CK_DLL_SFUN( ZeroX_compute ); +// offset static t_CKUINT ZeroX_offset_data = 0; // LPC @@ -129,8 +129,8 @@ CK_DLL_MFUN( LPC_cget_pitch ); CK_DLL_MFUN( LPC_ctrl_power ); CK_DLL_MFUN( LPC_cget_power ); CK_DLL_MFUN( LPC_ctrl_coefs ); -CK_DLL_MFUN( LPC_cget_coefs ); -// offset +CK_DLL_MFUN( LPC_cget_coefs ); +// offset static t_CKUINT LPC_offset_data = 0; @@ -279,7 +279,7 @@ DLL_QUERY extract_query( Chuck_DL_Query * QUERY ) // compute func = make_new_sfun( "float[]", "compute", AutoCorr_compute ); - func->add_arg( "float[]", "input" ); + func->add_arg( "float[]", "input" ); func->add_arg( "int", "normalize" ); func->add_arg( "float[]", "output" ); if( !type_engine_import_sfun( env, func ) ) goto error; @@ -287,60 +287,60 @@ DLL_QUERY extract_query( Chuck_DL_Query * QUERY ) // end the class import type_engine_import_class_end( env ); - //--------------------------------------------------------------------- - // init as base class: XCorr - //--------------------------------------------------------------------- - if( !type_engine_import_uana_begin( env, "XCorr", "UAna", env->global(), - XCorr_ctor, XCorr_dtor, - XCorr_tick, XCorr_tock, XCorr_pmsg ) ) - return FALSE; - - // data offset - XCorr_offset_data = type_engine_import_mvar( env, "float", "@XCorr_data", FALSE ); - if( XCorr_offset_data == CK_INVALID_OFFSET ) goto error; - - // normalize - func = make_new_mfun( "int", "normalize", XCorr_ctrl_normalize ); - func->add_arg( "int", "flag" ); - if( !type_engine_import_mfun( env, func ) ) goto error; - - // normalize - func = make_new_mfun( "int", "normalize", XCorr_cget_normalize ); - if( !type_engine_import_mfun( env, func ) ) goto error; - - // compute - func = make_new_sfun( "float[]", "compute", XCorr_compute ); - func->add_arg( "float[]", "f" ); - func->add_arg( "float[]", "g" ); - func->add_arg( "int", "normalize" ); - func->add_arg( "float[]", "y" ); - if( !type_engine_import_sfun( env, func ) ) goto error; - - // end the class import - type_engine_import_class_end( env ); - - //--------------------------------------------------------------------- - // init as base class: zerox - //--------------------------------------------------------------------- - if( !type_engine_import_uana_begin( env, "ZeroX", "UAna", env->global(), - ZeroX_ctor, ZeroX_dtor, - ZeroX_tick, ZeroX_tock, NULL ) ) - return FALSE; - - // data offset - ZeroX_offset_data = type_engine_import_mvar( env, "int", "@ZeroX_data", FALSE ); - if( ZeroX_offset_data == CK_INVALID_OFFSET ) goto error; - - // compute - func = make_new_sfun( "float", "compute", ZeroX_compute ); - func->add_arg( "float[]", "input" ); - if( !type_engine_import_sfun( env, func ) ) goto error; - - // end import - if( !type_engine_import_class_end( env ) ) - return FALSE; - - + //--------------------------------------------------------------------- + // init as base class: XCorr + //--------------------------------------------------------------------- + if( !type_engine_import_uana_begin( env, "XCorr", "UAna", env->global(), + XCorr_ctor, XCorr_dtor, + XCorr_tick, XCorr_tock, XCorr_pmsg ) ) + return FALSE; + + // data offset + XCorr_offset_data = type_engine_import_mvar( env, "float", "@XCorr_data", FALSE ); + if( XCorr_offset_data == CK_INVALID_OFFSET ) goto error; + + // normalize + func = make_new_mfun( "int", "normalize", XCorr_ctrl_normalize ); + func->add_arg( "int", "flag" ); + if( !type_engine_import_mfun( env, func ) ) goto error; + + // normalize + func = make_new_mfun( "int", "normalize", XCorr_cget_normalize ); + if( !type_engine_import_mfun( env, func ) ) goto error; + + // compute + func = make_new_sfun( "float[]", "compute", XCorr_compute ); + func->add_arg( "float[]", "f" ); + func->add_arg( "float[]", "g" ); + func->add_arg( "int", "normalize" ); + func->add_arg( "float[]", "y" ); + if( !type_engine_import_sfun( env, func ) ) goto error; + + // end the class import + type_engine_import_class_end( env ); + + //--------------------------------------------------------------------- + // init as base class: zerox + //--------------------------------------------------------------------- + if( !type_engine_import_uana_begin( env, "ZeroX", "UAna", env->global(), + ZeroX_ctor, ZeroX_dtor, + ZeroX_tick, ZeroX_tock, NULL ) ) + return FALSE; + + // data offset + ZeroX_offset_data = type_engine_import_mvar( env, "int", "@ZeroX_data", FALSE ); + if( ZeroX_offset_data == CK_INVALID_OFFSET ) goto error; + + // compute + func = make_new_sfun( "float", "compute", ZeroX_compute ); + func->add_arg( "float[]", "input" ); + if( !type_engine_import_sfun( env, func ) ) goto error; + + // end import + if( !type_engine_import_class_end( env ) ) + return FALSE; + + return TRUE; error: @@ -371,7 +371,7 @@ CK_DLL_TOCK( FeatureCollector_tock ) if( num_incoming > 0 ) { //count the number of features in the array we're making - for( i = 0; i < num_incoming; i++ ) + for( i = 0; i < num_incoming; i++ ) { // get next blob Chuck_UAnaBlobProxy * BLOB_IN = UANA->getIncomingBlob( i ); @@ -388,13 +388,13 @@ CK_DLL_TOCK( FeatureCollector_tock ) fvals.set_size( num_feats ); t_CKINT next_index = 0; - for( i = 0; i < num_incoming; i++ ) + for( i = 0; i < num_incoming; i++ ) { // get next blob Chuck_UAnaBlobProxy * BLOB_IN = UANA->getIncomingBlob( i ); Chuck_Array8 & these_fvals = BLOB_IN->fvals(); t_CKINT num_these = these_fvals.size(); - for( j = 0; j < num_these; j++ ) + for( j = 0; j < num_these; j++ ) { t_CKFLOAT v; these_fvals.get( j, &v ); @@ -989,9 +989,9 @@ struct Corr_Object t_CKINT gcap; // result SAMPLE * buffy; - t_CKINT bufcap; - - // static corr instance + t_CKINT bufcap; + + // static corr instance static Corr_Object * ourCorr; // constructor @@ -1076,24 +1076,24 @@ struct Corr_Object this->clear(); return TRUE; - } - - // get our singleton - static Corr_Object * getOurObject() - { - // instantiate, if needed - if( ourCorr == NULL ) - { - ourCorr = new Corr_Object(); - assert( ourCorr != NULL ); - } - - // return new instance - return ourCorr; } -}; - -// static initialization + + // get our singleton + static Corr_Object * getOurObject() + { + // instantiate, if needed + if( ourCorr == NULL ) + { + ourCorr = new Corr_Object(); + assert( ourCorr != NULL ); + } + + // return new instance + return ourCorr; + } +}; + +// static initialization Corr_Object * Corr_Object::ourCorr = NULL; // compute correlation @@ -1121,20 +1121,20 @@ static void compute_corr( Corr_Object * corr, Chuck_Array8 & f, t_CKINT fs, // compute xcorr_fft( corr->fbuf, corr->fcap, corr->gbuf, corr->gcap, - corr->buffy, corr->bufcap ); - - // check flags - if( corr->normalize ) - { - // normalize - xcorr_normalize( corr->buffy, corr->bufcap, - corr->fbuf, corr->fcap, corr->gbuf, corr->gcap ); - } + corr->buffy, corr->bufcap ); + + // check flags + if( corr->normalize ) + { + // normalize + xcorr_normalize( corr->buffy, corr->bufcap, + corr->fbuf, corr->fcap, corr->gbuf, corr->gcap ); + } // copy into result size = fs + gs - 1; buffy.set_size( size ); - for( i = 0; i < size; i++ ) + for( i = 0; i < size; i++ ) { buffy.set( i, corr->buffy[i] ); } @@ -1217,119 +1217,119 @@ CK_DLL_CGET( AutoCorr_cget_normalize ) CK_DLL_SFUN( AutoCorr_compute ) { - // get input - Chuck_Array8 * input = (Chuck_Array8 *)GET_NEXT_OBJECT(ARGS); - // get normalize flag - t_CKINT normalize = GET_NEXT_INT(ARGS) != 0; - // get input - Chuck_Array8 * output = (Chuck_Array8 *)GET_NEXT_OBJECT(ARGS); - - // set normalize - Corr_Object::getOurObject()->normalize = normalize; - // compute autocrr - compute_corr( Corr_Object::getOurObject(), *input, input->size(), - *input, input->size(), *output ); + // get input + Chuck_Array8 * input = (Chuck_Array8 *)GET_NEXT_OBJECT(ARGS); + // get normalize flag + t_CKINT normalize = GET_NEXT_INT(ARGS) != 0; + // get input + Chuck_Array8 * output = (Chuck_Array8 *)GET_NEXT_OBJECT(ARGS); + + // set normalize + Corr_Object::getOurObject()->normalize = normalize; + // compute autocrr + compute_corr( Corr_Object::getOurObject(), *input, input->size(), + *input, input->size(), *output ); +} + + +// XCorr +CK_DLL_CTOR( XCorr_ctor ) +{ + Corr_Object * xc = new Corr_Object(); + OBJ_MEMBER_UINT( SELF, XCorr_offset_data ) = (t_CKUINT)xc; +} + +CK_DLL_DTOR( XCorr_dtor ) +{ + Corr_Object * xc = (Corr_Object *)OBJ_MEMBER_UINT( SELF, XCorr_offset_data ); + SAFE_DELETE(xc); + OBJ_MEMBER_UINT( SELF, XCorr_offset_data ) = 0; +} + +CK_DLL_TICK( XCorr_tick ) +{ + // do nothing + return TRUE; +} + +CK_DLL_TOCK( XCorr_tock ) +{ + // get object + Corr_Object * xc = (Corr_Object *)OBJ_MEMBER_UINT( SELF, XCorr_offset_data ); + + // TODO: get buffer from stream, and set + if( UANA->numIncomingUAnae() > 1 ) + { + // get first + Chuck_UAnaBlobProxy * BLOB_F = UANA->getIncomingBlob( 0 ); + // get second + Chuck_UAnaBlobProxy * BLOB_G = UANA->getIncomingBlob( 1 ); + // sanity check + assert( BLOB_F != NULL && BLOB_G != NULL ); + // get the array + Chuck_Array8 & mag_f = BLOB_F->fvals(); + Chuck_Array8 & mag_g = BLOB_G->fvals(); + // get fvals of output BLOB + Chuck_Array8 & fvals = BLOB->fvals(); + // compute xcorr + compute_corr( xc, mag_f, mag_f.size(), mag_g, mag_g.size(), fvals ); + } + // otherwise zero out + else + { + // get fvals of output BLOB + Chuck_Array8 & fvals = BLOB->fvals(); + // resize + fvals.set_size( 0 ); + } + + return TRUE; } +CK_DLL_PMSG( XCorr_pmsg ) +{ + // do nothing + return TRUE; +} + +CK_DLL_CTRL( XCorr_ctrl_normalize ) +{ + // get object + Corr_Object * ac = (Corr_Object *)OBJ_MEMBER_UINT( SELF, XCorr_offset_data ); + // get percent + ac->normalize = GET_NEXT_INT(ARGS) != 0; + // return it + RETURN->v_int = ac->normalize; +} + +CK_DLL_CGET( XCorr_cget_normalize ) +{ + // get object + Corr_Object * ac = (Corr_Object *)OBJ_MEMBER_UINT( SELF, XCorr_offset_data ); + // return it + RETURN->v_int = ac->normalize; +} + +CK_DLL_SFUN( XCorr_compute ) +{ + // get input + Chuck_Array8 * f = (Chuck_Array8 *)GET_NEXT_OBJECT(ARGS); + Chuck_Array8 * g = (Chuck_Array8 *)GET_NEXT_OBJECT(ARGS); + // get normalize flag + t_CKINT normalize = GET_NEXT_INT(ARGS) != 0; + // get output + Chuck_Array8 * output = (Chuck_Array8 *)GET_NEXT_OBJECT(ARGS); + + // set normalize + Corr_Object::getOurObject()->normalize = normalize; + // compute autocrr + compute_corr( Corr_Object::getOurObject(), *f, f->size(), + *g, g->size(), *output ); +} + + + -// XCorr -CK_DLL_CTOR( XCorr_ctor ) -{ - Corr_Object * xc = new Corr_Object(); - OBJ_MEMBER_UINT( SELF, XCorr_offset_data ) = (t_CKUINT)xc; -} - -CK_DLL_DTOR( XCorr_dtor ) -{ - Corr_Object * xc = (Corr_Object *)OBJ_MEMBER_UINT( SELF, XCorr_offset_data ); - SAFE_DELETE(xc); - OBJ_MEMBER_UINT( SELF, XCorr_offset_data ) = 0; -} - -CK_DLL_TICK( XCorr_tick ) -{ - // do nothing - return TRUE; -} - -CK_DLL_TOCK( XCorr_tock ) -{ - // get object - Corr_Object * xc = (Corr_Object *)OBJ_MEMBER_UINT( SELF, XCorr_offset_data ); - - // TODO: get buffer from stream, and set - if( UANA->numIncomingUAnae() > 1 ) - { - // get first - Chuck_UAnaBlobProxy * BLOB_F = UANA->getIncomingBlob( 0 ); - // get second - Chuck_UAnaBlobProxy * BLOB_G = UANA->getIncomingBlob( 1 ); - // sanity check - assert( BLOB_F != NULL && BLOB_G != NULL ); - // get the array - Chuck_Array8 & mag_f = BLOB_F->fvals(); - Chuck_Array8 & mag_g = BLOB_G->fvals(); - // get fvals of output BLOB - Chuck_Array8 & fvals = BLOB->fvals(); - // compute xcorr - compute_corr( xc, mag_f, mag_f.size(), mag_g, mag_g.size(), fvals ); - } - // otherwise zero out - else - { - // get fvals of output BLOB - Chuck_Array8 & fvals = BLOB->fvals(); - // resize - fvals.set_size( 0 ); - } - - return TRUE; -} - -CK_DLL_PMSG( XCorr_pmsg ) -{ - // do nothing - return TRUE; -} - -CK_DLL_CTRL( XCorr_ctrl_normalize ) -{ - // get object - Corr_Object * ac = (Corr_Object *)OBJ_MEMBER_UINT( SELF, XCorr_offset_data ); - // get percent - ac->normalize = GET_NEXT_INT(ARGS) != 0; - // return it - RETURN->v_int = ac->normalize; -} - -CK_DLL_CGET( XCorr_cget_normalize ) -{ - // get object - Corr_Object * ac = (Corr_Object *)OBJ_MEMBER_UINT( SELF, XCorr_offset_data ); - // return it - RETURN->v_int = ac->normalize; -} - -CK_DLL_SFUN( XCorr_compute ) -{ - // get input - Chuck_Array8 * f = (Chuck_Array8 *)GET_NEXT_OBJECT(ARGS); - Chuck_Array8 * g = (Chuck_Array8 *)GET_NEXT_OBJECT(ARGS); - // get normalize flag - t_CKINT normalize = GET_NEXT_INT(ARGS) != 0; - // get output - Chuck_Array8 * output = (Chuck_Array8 *)GET_NEXT_OBJECT(ARGS); - - // set normalize - Corr_Object::getOurObject()->normalize = normalize; - // compute autocrr - compute_corr( Corr_Object::getOurObject(), *f, f->size(), - *g, g->size(), *output ); -} - - - - //----------------------------------------------------------------------------- // name: xcorr_fft() // desc: FFT-based cross correlation @@ -1383,103 +1383,103 @@ void xcorr_normalize( SAMPLE * buffy, t_CKINT size, SAMPLE * f, t_CKINT fs, SAMP for( long k = 0; k < size; k++ ) buffy[k] /= sum; } - - - - -// ZeroX -#define __SGN(x) (x >= 0.0f ? 1.0f : -1.0f ) -static t_CKINT compute_zerox( Chuck_Array8 & buffer, t_CKUINT size ) -{ - t_CKUINT i, xings = 0; - t_CKFLOAT v = 0, p = 0; - buffer.get( 0, &p ); - - // Compute centroid using moments - for( i = 0; i < size; i++ ) - { - buffer.get( i, &v ); - xings += __SGN(v) != __SGN(p); - p = v; - } - - return xings; -} - -CK_DLL_CTOR( ZeroX_ctor ) -{ - OBJ_MEMBER_UINT(SELF, ZeroX_offset_data) = (t_CKUINT)new SAMPLE( 0.0f ); -} - -CK_DLL_DTOR( ZeroX_dtor ) -{ - delete (SAMPLE *)OBJ_MEMBER_UINT(SELF, ZeroX_offset_data); - OBJ_MEMBER_UINT(SELF, ZeroX_offset_data) = 0; -} - -CK_DLL_TICK( ZeroX_tick ) -{ - SAMPLE * d = (SAMPLE *)OBJ_MEMBER_UINT(SELF, ZeroX_offset_data); - *out = __SGN(in) != __SGN(*d); - *out *= __SGN(in); - *d = in; - - return TRUE; -} - -CK_DLL_TOCK( ZeroX_tock ) -{ - t_CKFLOAT result = 0.0; - - // TODO: get buffer from stream, and set in ifft - if( UANA->numIncomingUAnae() > 0 ) - { - // get first - Chuck_UAnaBlobProxy * BLOB_IN = UANA->getIncomingBlob( 0 ); - // sanity check - assert( BLOB_IN != NULL ); - // get the array - Chuck_Array8 & mag = BLOB_IN->fvals(); - // compute ZeroX - result = (t_CKFLOAT)( compute_zerox( mag, mag.size() ) + .5 ); - } - // otherwise zero out - else - { - // no input! - result = 0.0; - } - - // get fvals of output BLOB - Chuck_Array8 & fvals = BLOB->fvals(); - // ensure size == resulting size - if( fvals.size() != 1 ) - fvals.set_size( 1 ); - // copy the result in - fvals.set( 0, result ); - - return TRUE; -} - -CK_DLL_PMSG( ZeroX_pmsg ) -{ - // do nothing - return TRUE; -} - -CK_DLL_SFUN( ZeroX_compute ) -{ - // get array - Chuck_Array8 * array = (Chuck_Array8 *)GET_NEXT_OBJECT(ARGS); - // sanity check - if( !array ) - { - // no centroid - RETURN->v_float = 0.0; - } - else - { - // do it - RETURN->v_float = (t_CKFLOAT)( compute_centroid( *array, array->size() ) + .5 ); - } -} + + + + +// ZeroX +#define __SGN(x) (x >= 0.0f ? 1.0f : -1.0f ) +static t_CKINT compute_zerox( Chuck_Array8 & buffer, t_CKUINT size ) +{ + t_CKUINT i, xings = 0; + t_CKFLOAT v = 0, p = 0; + buffer.get( 0, &p ); + + // Compute centroid using moments + for( i = 0; i < size; i++ ) + { + buffer.get( i, &v ); + xings += __SGN(v) != __SGN(p); + p = v; + } + + return xings; +} + +CK_DLL_CTOR( ZeroX_ctor ) +{ + OBJ_MEMBER_UINT(SELF, ZeroX_offset_data) = (t_CKUINT)new SAMPLE( 0.0f ); +} + +CK_DLL_DTOR( ZeroX_dtor ) +{ + delete (SAMPLE *)OBJ_MEMBER_UINT(SELF, ZeroX_offset_data); + OBJ_MEMBER_UINT(SELF, ZeroX_offset_data) = 0; +} + +CK_DLL_TICK( ZeroX_tick ) +{ + SAMPLE * d = (SAMPLE *)OBJ_MEMBER_UINT(SELF, ZeroX_offset_data); + *out = __SGN(in) != __SGN(*d); + *out *= __SGN(in); + *d = in; + + return TRUE; +} + +CK_DLL_TOCK( ZeroX_tock ) +{ + t_CKFLOAT result = 0.0; + + // TODO: get buffer from stream, and set in ifft + if( UANA->numIncomingUAnae() > 0 ) + { + // get first + Chuck_UAnaBlobProxy * BLOB_IN = UANA->getIncomingBlob( 0 ); + // sanity check + assert( BLOB_IN != NULL ); + // get the array + Chuck_Array8 & mag = BLOB_IN->fvals(); + // compute ZeroX + result = (t_CKFLOAT)( compute_zerox( mag, mag.size() ) + .5 ); + } + // otherwise zero out + else + { + // no input! + result = 0.0; + } + + // get fvals of output BLOB + Chuck_Array8 & fvals = BLOB->fvals(); + // ensure size == resulting size + if( fvals.size() != 1 ) + fvals.set_size( 1 ); + // copy the result in + fvals.set( 0, result ); + + return TRUE; +} + +CK_DLL_PMSG( ZeroX_pmsg ) +{ + // do nothing + return TRUE; +} + +CK_DLL_SFUN( ZeroX_compute ) +{ + // get array + Chuck_Array8 * array = (Chuck_Array8 *)GET_NEXT_OBJECT(ARGS); + // sanity check + if( !array ) + { + // no centroid + RETURN->v_float = 0.0; + } + else + { + // do it + RETURN->v_float = (t_CKFLOAT)( compute_centroid( *array, array->size() ) + .5 ); + } +} diff --git a/v2/ugen_osc.cpp b/v2/ugen_osc.cpp index 13ad3063..4f864dff 100755 --- a/v2/ugen_osc.cpp +++ b/v2/ugen_osc.cpp @@ -143,10 +143,10 @@ DLL_QUERY osc_query( Chuck_DL_Query * QUERY ) func = make_new_mfun( "float", "width", osc_ctrl_width ); func->add_arg( "float", "width" ); if( !type_engine_import_mfun( env, func ) ) goto error; - - func = make_new_mfun( "float", "width", osc_cget_width ); - if( !type_engine_import_mfun( env, func ) ) goto error; - + + func = make_new_mfun( "float", "width", osc_cget_width ); + if( !type_engine_import_mfun( env, func ) ) goto error; + // end the class import type_engine_import_class_end( env ); @@ -162,9 +162,9 @@ DLL_QUERY osc_query( Chuck_DL_Query * QUERY ) func->add_arg( "float", "width" ); if( !type_engine_import_mfun( env, func ) ) goto error; - func = make_new_mfun( "float", "width", osc_cget_width ); - if( !type_engine_import_mfun( env, func ) ) goto error; - + func = make_new_mfun( "float", "width", osc_cget_width ); + if( !type_engine_import_mfun( env, func ) ) goto error; + // end the class import type_engine_import_class_end( env ); @@ -180,9 +180,9 @@ DLL_QUERY osc_query( Chuck_DL_Query * QUERY ) func->add_arg( "float", "width" ); if( !type_engine_import_mfun( env, func ) ) goto error; - func = make_new_mfun( "float", "width", osc_cget_width ); - if( !type_engine_import_mfun( env, func ) ) goto error; - + func = make_new_mfun( "float", "width", osc_cget_width ); + if( !type_engine_import_mfun( env, func ) ) goto error; + // end the class import type_engine_import_class_end( env ); @@ -194,9 +194,9 @@ DLL_QUERY osc_query( Chuck_DL_Query * QUERY ) sqrosc_ctor, NULL, NULL, NULL ) ) return FALSE; - func = make_new_mfun( "float", "width", sqrosc_ctrl_width ); - if( !type_engine_import_mfun( env, func ) ) goto error; - + func = make_new_mfun( "float", "width", sqrosc_ctrl_width ); + if( !type_engine_import_mfun( env, func ) ) goto error; + // end the class import type_engine_import_class_end( env ); @@ -321,8 +321,8 @@ CK_DLL_TICK( osc_tick ) d->phase = in; // no update inc_phase = FALSE; - // bound it (thanks Pyry) - if( d->phase > 1.0 || d->phase < 0.0 ) d->phase -= floor( d->phase ); + // bound it (thanks Pyry) + if( d->phase > 1.0 || d->phase < 0.0 ) d->phase -= floor( d->phase ); } // fm synthesis else if( d->sync == 2 ) @@ -351,7 +351,7 @@ CK_DLL_TICK( osc_tick ) // step the phase. d->phase += d->num; // keep the phase between 0 and 1 - if( d->phase > 1.0 ) d->phase -= 1.0; + if( d->phase > 1.0 ) d->phase -= 1.0; else if( d->phase < 0.0 ) d->phase += 1.0; } diff --git a/v2/ugen_stk.cpp b/v2/ugen_stk.cpp index d1e259ff..d51e86ae 100755 --- a/v2/ugen_stk.cpp +++ b/v2/ugen_stk.cpp @@ -40,7 +40,7 @@ #include #include #include -#include +#include #include diff --git a/v2/ugen_xxx.cpp b/v2/ugen_xxx.cpp index 7a8c292b..7ddedaec 100755 --- a/v2/ugen_xxx.cpp +++ b/v2/ugen_xxx.cpp @@ -71,7 +71,7 @@ static t_CKUINT step_offset_data = 0; static t_CKUINT delayp_offset_data = 0; static t_CKUINT sndbuf_offset_data = 0; static t_CKUINT dyno_offset_data = 0; -// static t_CKUINT zerox_offset_data = 0; +// static t_CKUINT zerox_offset_data = 0; Chuck_Type * g_t_dac = NULL; Chuck_Type * g_t_adc = NULL; @@ -510,6 +510,8 @@ DLL_QUERY xxx_query( Chuck_DL_Query * QUERY ) //! \section sound files +#ifndef __DISABLE_SNDBUF__ + // add sndbuf //! sound buffer ( now interpolating ) //! reads from a variety of file formats @@ -661,6 +663,9 @@ DLL_QUERY xxx_query( Chuck_DL_Query * QUERY ) // end import if( !type_engine_import_class_end( env ) ) return FALSE; + +#endif // __DISABLE_SNDBUF__ + //--------------------------------------------------------------------- // init as base class: Dyno @@ -1568,7 +1573,7 @@ CK_DLL_TICK( fullrect_tick ) - + /* //----------------------------------------------------------------------------- // name: zerox_ctor() @@ -1605,7 +1610,7 @@ CK_DLL_TICK( zerox_tick ) return TRUE; } -*/ +*/ @@ -1865,6 +1870,9 @@ CK_DLL_CGET( delayp_cget_max ) RETURN->v_dur = d->bufsize; } + +#ifndef __DISABLE_SNDBUF__ + //----------------------------------------------------------------------------- // name: sndbuf // desc: ... @@ -2878,6 +2886,8 @@ CK_DLL_CGET( sndbuf_cget_valueAt ) RETURN->v_float = ( i > d->num_frames || i < 0 ) ? 0 : d->buffer[i]; } +#endif // __DISABLE_SNDBUF__ + class Dyno_Data { diff --git a/v2/ulib_math.cpp b/v2/ulib_math.cpp index 429a8634..4dea9d6e 100755 --- a/v2/ulib_math.cpp +++ b/v2/ulib_math.cpp @@ -46,8 +46,8 @@ static t_CKFLOAT g_floatMax = DBL_MAX; static t_CKFLOAT g_floatMin = DBL_MIN; static t_CKFLOAT g_inf = 0.0; static t_CKINT g_intMax = LONG_MAX; -static t_CKCOMPLEX g_i = { 0.0, 1.0 }; -static t_CKFLOAT fzero() { return 0.0; } +static t_CKCOMPLEX g_i = { 0.0, 1.0 }; +static t_CKFLOAT fzero() { return 0.0; } // query diff --git a/v2/ulib_math.h b/v2/ulib_math.h index bab55c24..a917d70d 100755 --- a/v2/ulib_math.h +++ b/v2/ulib_math.h @@ -68,8 +68,8 @@ CK_DLL_SFUN( min_impl ); CK_DLL_SFUN( max_impl ); CK_DLL_SFUN( isinf_impl ); CK_DLL_SFUN( isnan_impl ); -CK_DLL_SFUN( floatMax_impl ); -CK_DLL_SFUN( intMax_impl ); +CK_DLL_SFUN( floatMax_impl ); +CK_DLL_SFUN( intMax_impl ); CK_DLL_SFUN( nextpow2_impl ); CK_DLL_SFUN( ensurepow2_impl ); diff --git a/v2/ulib_std.cpp b/v2/ulib_std.cpp index e6e8cc90..2794c6a2 100755 --- a/v2/ulib_std.cpp +++ b/v2/ulib_std.cpp @@ -40,7 +40,7 @@ #include "util_string.h" #include "util_thread.h" #include "chuck_type.h" -#include "chuck_instr.h" +#include "chuck_instr.h" #include "chuck_globals.h" #if defined(__PLATFORM_WIN32__) @@ -589,24 +589,24 @@ CK_DLL_SFUN( sgn_impl ) // system CK_DLL_SFUN( system_impl ) { - const char * cmd = GET_CK_STRING(ARGS)->str.c_str(); - - // check globals for permission - if( !g_enable_system_cmd ) - { - fprintf( stderr, "[chuck]:error: VM not authorized to call Std.system( string )...\n" ); - fprintf( stderr, "[chuck]: (command string was: \"%s\")\n", cmd ); - fprintf( stderr, "[chuck]: (note: enable via --caution-to-the-wind flag or other means)\n" ); - RETURN->v_int = 0; - } - else - { - // log - EM_log( CK_LOG_SEVERE, "invoking system( CMD )..." ); - EM_pushlog(); - EM_log( CK_LOG_SEVERE, "CMD: \"%s\"", cmd ); + const char * cmd = GET_CK_STRING(ARGS)->str.c_str(); + + // check globals for permission + if( !g_enable_system_cmd ) + { + fprintf( stderr, "[chuck]:error: VM not authorized to call Std.system( string )...\n" ); + fprintf( stderr, "[chuck]: (command string was: \"%s\")\n", cmd ); + fprintf( stderr, "[chuck]: (note: enable via --caution-to-the-wind flag or other means)\n" ); + RETURN->v_int = 0; + } + else + { + // log + EM_log( CK_LOG_SEVERE, "invoking system( CMD )..." ); + EM_pushlog(); + EM_log( CK_LOG_SEVERE, "CMD: \"%s\"", cmd ); EM_poplog(); - RETURN->v_int = system( cmd ); + RETURN->v_int = system( cmd ); } } diff --git a/v2/util_hid.cpp b/v2/util_hid.cpp index ecde84ef..87b29823 100644 --- a/v2/util_hid.cpp +++ b/v2/util_hid.cpp @@ -1,25 +1,25 @@ /*---------------------------------------------------------------------------- -ChucK Concurrent, On-the-fly Audio Programming Language -Compiler and Virtual Machine - -Copyright (c) 2004 Ge Wang and Perry R. Cook. All rights reserved. -http://chuck.cs.princeton.edu/ -http://soundlab.cs.princeton.edu/ - -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -U.S.A. + ChucK Concurrent, On-the-fly Audio Programming Language + Compiler and Virtual Machine + + Copyright (c) 2004 Ge Wang and Perry R. Cook. All rights reserved. + http://chuck.cs.princeton.edu/ + http://soundlab.cs.princeton.edu/ + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 + U.S.A. -----------------------------------------------------------------------------*/ //----------------------------------------------------------------------------- @@ -34,7 +34,7 @@ U.S.A. #include "chuck_errmsg.h" #include "util_hid.h" #include "hidio_sdl.h" - + #include #include #include @@ -71,7 +71,7 @@ const t_CKUINT CK_HID_TABLET_MOTION = 15; const t_CKUINT CK_HID_TABLET_ROTATION = 16; const t_CKUINT CK_HID_MSG_COUNT = 17; -#ifdef __PLATFORM_MACOSX__ +#if defined(__PLATFORM_MACOSX__) && !defined(__CHIP_MODE__) #pragma mark OS X General HID support /* TODO: *********************************************************************** @@ -4572,33 +4572,33 @@ void Hid_quit() g_device_event = NULL; }*/ } - - - - -/***************************************************************************** -ge: Windows tiltsensor non-support -*****************************************************************************/ -// designate new poll rate -t_CKINT TiltSensor_setPollRate( t_CKINT usec ) -{ - // sanity - assert( usec >= 0 ); - // not supported - fprintf( stderr, "TiltSensor - setPollRate is not (yet) supported on this platform...\n" ); - return -1; -} - -// query current poll rate -t_CKINT TiltSensor_getPollRate( ) -{ - // not supported - fprintf( stderr, "TiltSensor - getPollRate is not (yet) supported on this platform...\n" ); - return -1; -} - - - + + + + +/***************************************************************************** +ge: Windows tiltsensor non-support +*****************************************************************************/ +// designate new poll rate +t_CKINT TiltSensor_setPollRate( t_CKINT usec ) +{ + // sanity + assert( usec >= 0 ); + // not supported + fprintf( stderr, "TiltSensor - setPollRate is not (yet) supported on this platform...\n" ); + return -1; +} + +// query current poll rate +t_CKINT TiltSensor_getPollRate( ) +{ + // not supported + fprintf( stderr, "TiltSensor - getPollRate is not (yet) supported on this platform...\n" ); + return -1; +} + + + /***************************************************************************** Windows joystick support @@ -5971,8 +5971,8 @@ int Keyboard_close( int js ) { return -1; } - - + + #elif defined( __LINUX_ALSA__ ) || defined( __LINUX_OSS__ ) || defined( __LINUX_JACK__ ) /***************************************************************************** @@ -6833,25 +6833,25 @@ void Hid_quit() int TiltSensor_read( t_CKINT * x, t_CKINT * y, t_CKINT * z ) { return 0; -} - -// designate new poll rate -t_CKINT TiltSensor_setPollRate( t_CKINT usec ) -{ - // sanity - assert( usec >= 0 ); - // not supported - fprintf( stderr, "TiltSensor - setPollRate is not (yet) supported on this platform...\n" ); - return -1; -} - -// query current poll rate -t_CKINT TiltSensor_getPollRate( ) -{ - // not supported - fprintf( stderr, "TiltSensor - getPollRate is not (yet) supported on this platform...\n" ); - return -1; -} +} + +// designate new poll rate +t_CKINT TiltSensor_setPollRate( t_CKINT usec ) +{ + // sanity + assert( usec >= 0 ); + // not supported + fprintf( stderr, "TiltSensor - setPollRate is not (yet) supported on this platform...\n" ); + return -1; +} + +// query current poll rate +t_CKINT TiltSensor_getPollRate( ) +{ + // not supported + fprintf( stderr, "TiltSensor - getPollRate is not (yet) supported on this platform...\n" ); + return -1; +} /***************************************************************************** @@ -7403,3 +7403,289 @@ const char * TiltSensor_name( int ts ){ return NULL; } #endif + + +#ifdef __CHIP_MODE__ + +// #include "util_iphone.h" + +extern int get_tilt_sensor_x(); +extern int get_tilt_sensor_y(); +extern int get_tilt_sensor_z(); + +extern void start_hid_multi_touch(); +extern void stop_hid_multi_touch(); + +void Hid_init(){} +void Hid_poll(){} +void Hid_quit(){} + +void Mouse_init(){} +void Mouse_poll(){} +void Mouse_quit(){} +void Mouse_probe(){} + +int Mouse_count() +{ + return 1; +} + +int Mouse_count_elements( int js, int type ) +{ + return -1; +} + +int Mouse_open( int m ) +{ + if(m >= 0 && m < 1) + { + start_hid_multi_touch(); + return 0; + } + else + return -1; +} + +int Mouse_open( const char * name ) +{ + return -1; +} + +int Mouse_close( int m ) +{ + if(m >= 0 && m < 1) + { + stop_hid_multi_touch(); + return 0; + } + else + return -1; +} + +int Mouse_send( int m, const HidMsg * msg ) +{ + return -1; +} + +const char * Mouse_name( int m ) +{ + if(m == 0) + return "iPhone Multitouch"; + else + return NULL; +} + +int Mouse_buttons( int m ) +{ + if(m == 0) + return 2; + else + return -1; +} + +int Mouse_start_cursor_track() +{ + return -1; +} + +int Mouse_stop_cursor_track() +{ + return -1; +} + +void TiltSensor_init(){} +void TiltSensor_quit(){} +void TiltSensor_probe(){} + +int TiltSensor_count() +{ + return 1; +} + +int TiltSensor_open( int ts ) +{ + if(ts == 0) + return 0; + return -1; +} + +int TiltSensor_close( int ts ) +{ + if(ts == 0) + return 0; + return -1; +} + +int TiltSensor_read( int ts, int type, int num, HidMsg * msg ) +{ + if( type != CK_HID_ACCELEROMETER ) + return -1; + + msg->idata[0] = get_tilt_sensor_x(); + msg->idata[1] = get_tilt_sensor_y(); + msg->idata[2] = get_tilt_sensor_z(); + + return 0; +} + +const char * TiltSensor_name( int ts ) +{ + if(ts == 0) + return "iPhone Accelerometer"; + else + return NULL; +} + +// ge: SMS multi-thread poll rate +t_CKINT TiltSensor_setPollRate( t_CKINT usec ) +{ + return -1; +} + +t_CKINT TiltSensor_getPollRate( ) +{ + return -1; +} + +void Joystick_init(){} + +void Joystick_poll(){} + +void Joystick_quit(){} + +void Joystick_probe(){} + +int Joystick_count() +{ + return 0; +} + +int Joystick_count_elements( int js, int type ) +{ + return -1; +} + +int Joystick_open( int js ) +{ + return -1; +} + +int Joystick_open_async( int js ) +{ + return -1; +} + +int Joystick_open( const char * name ) +{ + return -1; +} + +int Joystick_close( int js ) +{ + return -1; +} + +int Joystick_send( int js, const HidMsg * msg ) +{ + return -1; +} + + +const char * Joystick_name( int js ) +{ + return NULL; +} + +int Joystick_axes( int js ) +{ + return -1; +} + +int Joystick_buttons( int js ) +{ + return -1; +} + +int Joystick_hats( int js ) +{ + return -1; +} + +void Keyboard_init(){} +void Keyboard_poll(){} +void Keyboard_quit(){} +void Keyboard_probe(){} + +int Keyboard_count() +{ + return 0; +} + +int Keyboard_count_elements( int js, int type ) +{ + return -1; +} + +int Keyboard_open( int kb ) +{ + return -1; +} + +int Keyboard_open( const char * name ) +{ + return -1; +} + +int Keyboard_close( int kb ) +{ + return -1; +} + +int Keyboard_send( int kb, const HidMsg * msg ) +{ + return -1; +} + +const char * Keyboard_name( int kb ) +{ + return NULL; +} + +void WiiRemote_init(){} +void WiiRemote_poll(){} +void WiiRemote_quit(){} +void WiiRemote_probe(){} + +int WiiRemote_count() +{ + return 0; +} + +int WiiRemote_open( int wr ) +{ + return -1; +} + +int WiiRemote_open( const char * name ) +{ + return -1; +} + +int WiiRemote_close( int wr ) +{ + return -1; +} + +int WiiRemote_send( int wr, const HidMsg * msg ) +{ + return -1; +} + +const char * WiiRemote_name( int wr ) +{ + return NULL; +} + + +#endif // __CHIP_MODE__ + diff --git a/v2/util_opsc.cpp b/v2/util_opsc.cpp index 13099d25..bf78a4b0 100644 --- a/v2/util_opsc.cpp +++ b/v2/util_opsc.cpp @@ -39,7 +39,7 @@ #include "chuck_errmsg.h" #include "chuck_vm.h" - + #include using namespace std; -- 2.11.4.GIT