Skip to content

Commit

Permalink
Various cleanups to avoid compile errors and warnings building Chunre…
Browse files Browse the repository at this point in the history
…al for macOS
  • Loading branch information
max-jardetzky committed Oct 22, 2023
1 parent e5d1d2c commit e6402a1
Show file tree
Hide file tree
Showing 10 changed files with 107 additions and 59 deletions.
4 changes: 2 additions & 2 deletions src/core/chuck_dl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1949,11 +1949,11 @@ remove_all_shreds(ck_remove_all_shreds)
//-----------------------------------------------------------------------------
Chuck_DL_Api::ObjectApi::ObjectApi() :
get_type(ck_get_type),
create(ck_create_with_shred),
create_without_shred(ck_create_without_shred),
add_ref(ck_add_ref),
release(ck_release),
refcount(ck_refcount),
create(ck_create_with_shred),
create_without_shred(ck_create_without_shred),
create_string(ck_create_string),
get_origin_shred(ck_get_origin_shred),
set_origin_shred(ck_set_origin_shred),
Expand Down
4 changes: 2 additions & 2 deletions src/core/chuck_emit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3636,8 +3636,8 @@ t_CKBOOL emit_engine_emit_exp_primary( Chuck_Emitter * emit, a_Exp_Primary exp )
}
else if( exp->var == insert_symbol( "pi" ) )
{
double pi = 3.14159265358979323846;
emit->append( new Chuck_Instr_Reg_Push_Imm2( pi ) );
double ckPi = 3.14159265358979323846;
emit->append( new Chuck_Instr_Reg_Push_Imm2( ckPi ) );
}
else if( exp->var == insert_symbol( "dac" ) )
{
Expand Down
20 changes: 10 additions & 10 deletions src/core/chuck_type.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8205,16 +8205,16 @@ static t_CKBOOL g_escape_ready = FALSE;
void escape_table( )
{
// escape
g_escape['\''] = '\'';
g_escape['"'] = '"';
g_escape['\\'] = '\\';
g_escape['a'] = (char)7; // audible bell
g_escape['b'] = (char)8; // back space
g_escape['f'] = (char)12; // form feed
g_escape['n'] = (char)10; // new line
g_escape['r'] = (char)13; // carriage return
g_escape['t'] = (char)9; // horizontal tab
g_escape['v'] = (char)11; // vertical tab
g_escape[(t_CKUINT)'\''] = '\'';
g_escape[(t_CKUINT)'"'] = '"';
g_escape[(t_CKUINT)'\\'] = '\\';
g_escape[(t_CKUINT)'a'] = (char)7; // audible bell
g_escape[(t_CKUINT)'b'] = (char)8; // back space
g_escape[(t_CKUINT)'f'] = (char)12; // form feed
g_escape[(t_CKUINT)'n'] = (char)10; // new line
g_escape[(t_CKUINT)'r'] = (char)13; // carriage return
g_escape[(t_CKUINT)'t'] = (char)9; // horizontal tab
g_escape[(t_CKUINT)'v'] = (char)11; // vertical tab

// done
g_escape_ready = TRUE;
Expand Down
4 changes: 2 additions & 2 deletions src/core/chuck_type.h
Original file line number Diff line number Diff line change
Expand Up @@ -1018,11 +1018,11 @@ struct Chuck_Type : public Chuck_Object
// struct to hold callback on instantiate
struct CallbackOnInstantiate
{
// the callback
f_callback_on_instantiate callback;
// whether to auto-set shred origin at instantiation;
// see t_CKBOOL initialize_object( ... )
t_CKBOOL shouldSetShredOrigin;
// the callback
f_callback_on_instantiate callback;
// constructor
CallbackOnInstantiate( f_callback_on_instantiate cb = NULL, t_CKBOOL setShredOrigin = FALSE )
: callback(cb), shouldSetShredOrigin(setShredOrigin) { }
Expand Down
40 changes: 20 additions & 20 deletions src/core/ugen_stk.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7963,7 +7963,7 @@ MY_FLOAT Delay :: lastOut(void) const
return FilterStk::lastOut();
}

MY_FLOAT Delay :: nextOut(void) const
MY_FLOAT Delay :: nextOut(void)
{
return inputs[outPoint];
}
Expand Down Expand Up @@ -8486,7 +8486,7 @@ void Echo :: set( MY_FLOAT max )
MY_FLOAT delay = delayLine ? delayLine->getDelay() : length>>1;
if( delayLine ) delete delayLine;
if( delay >= max ) delay = max;
delayLine = new Delay(length>>1, length);
delayLine = new class Delay(length>>1, length);
this->clear();
this->setDelay(delay+.5);
}
Expand Down Expand Up @@ -10428,15 +10428,15 @@ JCRev :: JCRev(MY_FLOAT T60)
}

for (i=0; i<3; i++)
allpassDelays[i] = new Delay(lengths[i+4], lengths[i+4]);
allpassDelays[i] = new class Delay(lengths[i+4], lengths[i+4]);

for (i=0; i<4; i++) {
combDelays[i] = new Delay(lengths[i], lengths[i]);
combDelays[i] = new class Delay(lengths[i], lengths[i]);
combCoefficient[i] = pow(10.0,(-3 * lengths[i] / (T60 * Stk::sampleRate())));
}

outLeftDelay = new Delay(lengths[7], lengths[7]);
outRightDelay = new Delay(lengths[8], lengths[8]);
outLeftDelay = new class Delay(lengths[7], lengths[7]);
outRightDelay = new class Delay(lengths[8], lengths[8]);
allpassCoefficient = 0.7;
effectMix = 0.3;
this->clear();
Expand Down Expand Up @@ -11888,12 +11888,12 @@ NRev :: NRev(MY_FLOAT T60)
}

for (i=0; i<6; i++) {
combDelays[i] = new Delay( lengths[i], lengths[i]);
combDelays[i] = new class Delay( lengths[i], lengths[i]);
combCoefficient[i] = pow(10.0, (-3 * lengths[i] / (T60 * Stk::sampleRate())));
}

for (i=0; i<8; i++)
allpassDelays[i] = new Delay(lengths[i+6], lengths[i+6]);
allpassDelays[i] = new class Delay(lengths[i+6], lengths[i+6]);

allpassCoefficient = 0.7;
effectMix = 0.3;
Expand Down Expand Up @@ -12275,8 +12275,8 @@ PRCRev :: PRCRev(MY_FLOAT T60)
}

for (i=0; i<2; i++) {
allpassDelays[i] = new Delay( lengths[i], lengths[i] );
combDelays[i] = new Delay( lengths[i+2], lengths[i+2] );
allpassDelays[i] = new class Delay( lengths[i], lengths[i] );
combDelays[i] = new class Delay( lengths[i+2], lengths[i+2] );
combCoefficient[i] = pow(10.0,(-3 * lengths[i+2] / (T60 * Stk::sampleRate())));
}

Expand Down Expand Up @@ -23549,7 +23549,7 @@ CK_DLL_CGET( StifKarp_cget_baseLoopGain )
//-----------------------------------------------------------------------------
CK_DLL_CTOR( Delay_ctor )
{
OBJ_MEMBER_UINT(SELF, Delay_offset_data) = (t_CKUINT)new Delay;
OBJ_MEMBER_UINT(SELF, Delay_offset_data) = (t_CKUINT)new class Delay;
}


Expand All @@ -23559,7 +23559,7 @@ CK_DLL_CTOR( Delay_ctor )
//-----------------------------------------------------------------------------
CK_DLL_DTOR( Delay_dtor )
{
delete (Delay *)OBJ_MEMBER_UINT(SELF, Delay_offset_data);
delete (class Delay *)OBJ_MEMBER_UINT(SELF, Delay_offset_data);
OBJ_MEMBER_UINT(SELF, Delay_offset_data) = 0;
}

Expand All @@ -23570,7 +23570,7 @@ CK_DLL_DTOR( Delay_dtor )
//-----------------------------------------------------------------------------
CK_DLL_TICK( Delay_tick )
{
*out = (SAMPLE)((Delay *)OBJ_MEMBER_UINT(SELF, Delay_offset_data))->tick( in );
*out = (SAMPLE)((class Delay *)OBJ_MEMBER_UINT(SELF, Delay_offset_data))->tick( in );
return TRUE;
}

Expand All @@ -23591,8 +23591,8 @@ CK_DLL_PMSG( Delay_pmsg )
//-----------------------------------------------------------------------------
CK_DLL_CTRL( Delay_ctrl_delay )
{
((Delay *)OBJ_MEMBER_UINT(SELF, Delay_offset_data))->setDelay( (long)(GET_NEXT_DUR(ARGS)+.5) );
RETURN->v_dur = (t_CKDUR)((Delay *)OBJ_MEMBER_UINT(SELF, Delay_offset_data))->getDelay();
((class Delay *)OBJ_MEMBER_UINT(SELF, Delay_offset_data))->setDelay( (long)(GET_NEXT_DUR(ARGS)+.5) );
RETURN->v_dur = (t_CKDUR)((class Delay *)OBJ_MEMBER_UINT(SELF, Delay_offset_data))->getDelay();
}


Expand All @@ -23602,7 +23602,7 @@ CK_DLL_CTRL( Delay_ctrl_delay )
//-----------------------------------------------------------------------------
CK_DLL_CGET( Delay_cget_delay )
{
RETURN->v_dur = (t_CKDUR)((Delay *)OBJ_MEMBER_UINT(SELF, Delay_offset_data))->getDelay();
RETURN->v_dur = (t_CKDUR)((class Delay *)OBJ_MEMBER_UINT(SELF, Delay_offset_data))->getDelay();
}


Expand All @@ -23612,11 +23612,11 @@ CK_DLL_CGET( Delay_cget_delay )
//-----------------------------------------------------------------------------
CK_DLL_CTRL( Delay_ctrl_max )
{
Delay * delay = (Delay *)OBJ_MEMBER_UINT(SELF, Delay_offset_data);
class Delay * delay = (class Delay *)OBJ_MEMBER_UINT(SELF, Delay_offset_data);
t_CKFLOAT val = (t_CKFLOAT)delay->getDelay();
t_CKDUR max = GET_NEXT_DUR(ARGS);
delay->set( (long)(val+.5), (long)(max+1.5) );
RETURN->v_dur = (t_CKDUR)((Delay *)OBJ_MEMBER_UINT(SELF, Delay_offset_data))->length-1.0;
RETURN->v_dur = (t_CKDUR)((class Delay *)OBJ_MEMBER_UINT(SELF, Delay_offset_data))->length-1.0;
}


Expand All @@ -23626,7 +23626,7 @@ CK_DLL_CTRL( Delay_ctrl_max )
//-----------------------------------------------------------------------------
CK_DLL_CGET( Delay_cget_max )
{
RETURN->v_dur = (t_CKDUR)((Delay *)OBJ_MEMBER_UINT(SELF, Delay_offset_data))->length-1.0;
RETURN->v_dur = (t_CKDUR)((class Delay *)OBJ_MEMBER_UINT(SELF, Delay_offset_data))->length-1.0;
}


Expand All @@ -23636,7 +23636,7 @@ CK_DLL_CGET( Delay_cget_max )
//-----------------------------------------------------------------------------
CK_DLL_CGET( Delay_clear )
{
Delay * delay = (Delay *)OBJ_MEMBER_UINT(SELF, Delay_offset_data);
class Delay * delay = (class Delay *)OBJ_MEMBER_UINT(SELF, Delay_offset_data);
delay->clear();
}

Expand Down
31 changes: 17 additions & 14 deletions src/core/ugen_stk.h
Original file line number Diff line number Diff line change
Expand Up @@ -747,8 +747,9 @@ class Delay : public FilterStk
//! Return the value which will be output by the next call to tick().
/*!
This method is valid only for delay settings greater than zero!
[VERSION #] Removed const qualification because derived class signatures are non-const: avoid virtual function shadowing warnings by agreeing signatures
*/
virtual MY_FLOAT nextOut(void) const;
virtual MY_FLOAT nextOut(void);

//! Input one sample to the delay-line and return one output.
virtual MY_FLOAT tick(MY_FLOAT sample);
Expand Down Expand Up @@ -821,10 +822,10 @@ class DelayL : public Delay
/*!
This method is valid only for delay settings greater than zero!
*/
MY_FLOAT nextOut(void);
virtual MY_FLOAT nextOut(void);

//! Input one sample to the delay-line and return one output.
MY_FLOAT tick(MY_FLOAT sample);
virtual MY_FLOAT tick(MY_FLOAT sample);

public: // SWAP formerly protected
MY_FLOAT alpha;
Expand Down Expand Up @@ -1376,6 +1377,7 @@ class WaveLoop : public WvIn
//! Class constructor.
WaveLoop( const char *fileName, bool raw = FALSE, bool generate = true );

using WvIn::openFile; // tell the compiler we're OK overloading/shadowing a virtual function
virtual void openFile( const char * fileName, bool raw = FALSE, bool n = TRUE );

//! Class destructor.
Expand Down Expand Up @@ -2485,10 +2487,10 @@ class DelayA : public Delay
/*!
This method is valid only for delay settings greater than zero!
*/
MY_FLOAT nextOut(void);
virtual MY_FLOAT nextOut(void);

//! Input one sample to the delay-line and return one output.
MY_FLOAT tick(MY_FLOAT sample);
virtual MY_FLOAT tick(MY_FLOAT sample);

public: // SWAP formerly protected
MY_FLOAT alpha;
Expand Down Expand Up @@ -2869,7 +2871,7 @@ class Echo : public Stk
MY_FLOAT *tick(MY_FLOAT *vector, unsigned int vectorSize);

public:
Delay *delayLine;
class Delay *delayLine;
long length;
MY_FLOAT lastOutput;
MY_FLOAT effectMix;
Expand Down Expand Up @@ -3476,10 +3478,10 @@ class JCRev : public Reverb
MY_FLOAT tick(MY_FLOAT input);

public: // SWAP formerly protected
Delay *allpassDelays[3];
Delay *combDelays[4];
Delay *outLeftDelay;
Delay *outRightDelay;
class Delay *allpassDelays[3];
class Delay *combDelays[4];
class Delay *outLeftDelay;
class Delay *outRightDelay;
MY_FLOAT allpassCoefficient;
MY_FLOAT combCoefficient[4];

Expand Down Expand Up @@ -3725,6 +3727,7 @@ class Mesh2D : public Instrmnt
MY_FLOAT tick();

//! Input a sample to the mesh and compute one output sample.
using Instrmnt::tick; // tell the compiler we're OK overloading/shadowing a virtual function
MY_FLOAT tick(MY_FLOAT input);

//! Perform the control change specified by \e number and \e value (0.0 - 128.0).
Expand Down Expand Up @@ -4192,8 +4195,8 @@ class NRev : public Reverb
MY_FLOAT tick(MY_FLOAT input);

public: // SWAP formerly protected
Delay *allpassDelays[8];
Delay *combDelays[6];
class Delay *allpassDelays[8];
class Delay *combDelays[6];
MY_FLOAT allpassCoefficient;
MY_FLOAT combCoefficient[6];
MY_FLOAT lowpassState;
Expand Down Expand Up @@ -4242,8 +4245,8 @@ class PRCRev : public Reverb
MY_FLOAT tick(MY_FLOAT input);

public: // SWAP formerly protected
Delay *allpassDelays[2];
Delay *combDelays[2];
class Delay *allpassDelays[2];
class Delay *combDelays[2];
MY_FLOAT allpassCoefficient;
MY_FLOAT combCoefficient[2];

Expand Down
2 changes: 1 addition & 1 deletion src/core/ulib_ai.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3437,7 +3437,7 @@ struct MLP_Object
else if( activation_per_layer[i] == g_at_softmax )
v = exp( v );
else if( activation_per_layer[i] == g_at_linear )
v = v;
{ /* v = v; */ }
activations[i + 1]->v( j ) = v;
}
if( activation_per_layer[i] == g_at_softmax )
Expand Down
14 changes: 9 additions & 5 deletions src/core/ulib_ai.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,11 @@
#include "chuck_errmsg.h"
#include "util_math.h"


#ifndef __CHUNREAL_ENGINE__
#define CK_TYPEID_CSTR(t) ( typeid( t ).name() )
#else
#define CK_TYPEID_CSTR(t) ( "[chunreal type info disabled]" )
#endif


// query
Expand Down Expand Up @@ -136,7 +140,7 @@ class ChaiMatrixFast
{
// error
CK_FPRINTF_STDERR( "[chuck]: ChaiMatrixFast allocation failure: %s, %d x %d...\n",
typeid( T ).name(), xDim, yDim );
CK_TYPEID_CSTR( T ), xDim, yDim );
// bail
return FALSE;
}
Expand All @@ -156,7 +160,7 @@ class ChaiMatrixFast
{
// error
CK_FPRINTF_STDERR( "[chuck]: ChaiMatrixFast out of bound: %s[%d][%d]...\n",
typeid( T ).name(), x, y );
CK_TYPEID_CSTR( T ), x, y );
// halt
// TODO: this should throw (a shred-level, probably) exception
assert( FALSE );
Expand Down Expand Up @@ -236,7 +240,7 @@ class ChaiVectorFast
{
// error
CK_FPRINTF_STDERR( "[chuck]: ChaiVectorFast allocation failure: %s[%d]...\n",
typeid( T ).name(), length );
CK_TYPEID_CSTR( T ), length );
// bail
return FALSE;
}
Expand Down Expand Up @@ -296,7 +300,7 @@ class ChaiVectorFast
{
// error
CK_FPRINTF_STDERR( "[chuck]: ChaiVectorFast out of bound: %s[%d] (capacity=%d)...\n",
typeid( T ).name(), i, m_length );
CK_TYPEID_CSTR( T ), i, m_length );
// TODO: this should throw (a shred-level, probably) exception
assert( FALSE );
}
Expand Down
Loading

0 comments on commit e6402a1

Please sign in to comment.