cwFlowTypes.h : Changes to account for changed dsp::types.
Added is_connected_to_source_proc(), var_is_source() and is_source_var().
This commit is contained in:
parent
a0b4e9c120
commit
bdcb26ac72
@ -24,7 +24,6 @@ namespace cw
|
||||
{ kUIntTFl, "uint" },
|
||||
{ kIntTFl, "int", },
|
||||
{ kFloatTFl, "float"},
|
||||
{ kRealTFl, "real"},
|
||||
{ kDoubleTFl,"double"},
|
||||
|
||||
{ kBoolMtxTFl, "bool_mtx" },
|
||||
@ -38,6 +37,14 @@ namespace cw
|
||||
{ kMBufTFl, "midi" },
|
||||
{ kStringTFl, "string" },
|
||||
{ kTimeTFl, "time" },
|
||||
{ kCfgTFl, "cfg" },
|
||||
|
||||
// alias types to map to cwDspTypes.h
|
||||
{ kFloatTFl, "srate"},
|
||||
{ kFloatTFl, "sample"},
|
||||
{ kFloatTFl, "coeff"},
|
||||
{ kDoubleTFl, "ftime" },
|
||||
|
||||
{ kInvalidTFl, nullptr }
|
||||
};
|
||||
|
||||
@ -461,12 +468,18 @@ namespace cw
|
||||
rc_t _var_broadcast_new_value( variable_t* var )
|
||||
{
|
||||
rc_t rc = kOkRC;
|
||||
/*
|
||||
|
||||
// notify each connected var that the value has changed
|
||||
for(variable_t* con_var = var->connect_link; con_var!=nullptr; con_var=con_var->connect_link)
|
||||
if((rc = con_var->inst->class_desc->members->value( con_var->inst, con_var )) != kOkRC )
|
||||
break;
|
||||
*/
|
||||
{
|
||||
// the var->local_value[] slot used by the source variable may have changed - update the destination variable
|
||||
// so that it points to the correct value.
|
||||
con_var->value = var->value;
|
||||
|
||||
//if((rc = con_var->inst->class_desc->members->value( con_var->inst, con_var )) != kOkRC )
|
||||
// break;
|
||||
|
||||
}
|
||||
return rc;
|
||||
}
|
||||
|
||||
@ -604,7 +617,7 @@ namespace cw
|
||||
}
|
||||
|
||||
|
||||
bool is_connected_to_external_proc( const variable_t* var )
|
||||
bool is_connected_to_source_proc( const variable_t* var )
|
||||
{
|
||||
// if this var does not have a 'src_ptr' then it can't be connected to an external proc
|
||||
if( var->src_var == nullptr || var->value == nullptr )
|
||||
@ -618,13 +631,16 @@ namespace cw
|
||||
return true;
|
||||
}
|
||||
|
||||
bool is_a_source_var( const variable_t* var )
|
||||
{ return var->connect_link != nullptr; }
|
||||
|
||||
template< typename T >
|
||||
rc_t _var_set_driver( variable_t* var, unsigned typeFlag, T value )
|
||||
{
|
||||
rc_t rc;
|
||||
|
||||
// if this variable is fed from the output of an external proc - then it's local value cannot be set
|
||||
if(is_connected_to_external_proc(var) )
|
||||
if(is_connected_to_source_proc(var) )
|
||||
return kOkRC;
|
||||
|
||||
|
||||
@ -687,6 +703,7 @@ namespace cw
|
||||
{
|
||||
rc_t rc = kOkRC;
|
||||
|
||||
// get the variable type - note that the value type (value->flags) may be differnt
|
||||
unsigned typeFlag = var->varDesc->type & kTypeMask;
|
||||
|
||||
switch( typeFlag )
|
||||
@ -882,7 +899,7 @@ namespace cw
|
||||
|
||||
void _var_print( const variable_t* var )
|
||||
{
|
||||
const char* conn_label = is_connected_to_external_proc(var) ? "extern" : " ";
|
||||
const char* conn_label = is_connected_to_source_proc(var) ? "extern" : " ";
|
||||
|
||||
printf(" %20s:%5i id:%4i ch:%3i : %s : ", var->label, var->label_sfx_id, var->vid, var->chIdx, conn_label );
|
||||
|
||||
@ -969,7 +986,7 @@ const cw::flow::sample_t* cw::flow::abuf_get_channel( abuf_t* abuf, unsigned c
|
||||
return abuf->buf + (chIdx*abuf->frameN);
|
||||
}
|
||||
|
||||
cw::flow::fbuf_t* cw::flow::fbuf_create( srate_t srate, unsigned chN, const unsigned* maxBinN_V, const unsigned* binN_V, const unsigned* hopSmpN_V, const fd_real_t** magV, const fd_real_t** phsV, const fd_real_t** hzV )
|
||||
cw::flow::fbuf_t* cw::flow::fbuf_create( srate_t srate, unsigned chN, const unsigned* maxBinN_V, const unsigned* binN_V, const unsigned* hopSmpN_V, const fd_sample_t** magV, const fd_sample_t** phsV, const fd_sample_t** hzV )
|
||||
{
|
||||
for(unsigned i=0; i<chN; ++i)
|
||||
if( binN_V[i] > maxBinN_V[i] )
|
||||
@ -985,9 +1002,9 @@ cw::flow::fbuf_t* cw::flow::fbuf_create( srate_t srate, unsigned chN, const unsi
|
||||
f->maxBinN_V = mem::allocZ<unsigned>(chN);
|
||||
f->binN_V = mem::allocZ<unsigned>(chN);
|
||||
f->hopSmpN_V = mem::allocZ<unsigned>(chN);
|
||||
f->magV = mem::allocZ<fd_real_t*>(chN);
|
||||
f->phsV = mem::allocZ<fd_real_t*>(chN);
|
||||
f->hzV = mem::allocZ<fd_real_t*>(chN);
|
||||
f->magV = mem::allocZ<fd_sample_t*>(chN);
|
||||
f->phsV = mem::allocZ<fd_sample_t*>(chN);
|
||||
f->hzV = mem::allocZ<fd_sample_t*>(chN);
|
||||
f->readyFlV = mem::allocZ<bool>(chN);
|
||||
|
||||
vop::copy( f->binN_V, binN_V, chN );
|
||||
@ -998,17 +1015,17 @@ cw::flow::fbuf_t* cw::flow::fbuf_create( srate_t srate, unsigned chN, const unsi
|
||||
{
|
||||
for(unsigned chIdx=0; chIdx<chN; ++chIdx)
|
||||
{
|
||||
f->magV[ chIdx ] = (fd_real_t*)magV[chIdx];
|
||||
f->phsV[ chIdx ] = (fd_real_t*)phsV[chIdx];
|
||||
f->hzV[ chIdx ] = (fd_real_t*)hzV[chIdx];
|
||||
f->magV[ chIdx ] = (fd_sample_t*)magV[chIdx];
|
||||
f->phsV[ chIdx ] = (fd_sample_t*)phsV[chIdx];
|
||||
f->hzV[ chIdx ] = (fd_sample_t*)hzV[chIdx];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
unsigned maxTotalBinsN = vop::sum( maxBinN_V, chN );
|
||||
|
||||
fd_real_t* buf = mem::allocZ<fd_real_t>( kFbufVectN * maxTotalBinsN );
|
||||
fd_real_t* m = buf;
|
||||
fd_sample_t* buf = mem::allocZ<fd_sample_t>( kFbufVectN * maxTotalBinsN );
|
||||
fd_sample_t* m = buf;
|
||||
for(unsigned chIdx=0; chIdx<chN; ++chIdx)
|
||||
{
|
||||
f->magV[chIdx] = m + 0 * f->binN_V[chIdx];
|
||||
@ -1026,7 +1043,7 @@ cw::flow::fbuf_t* cw::flow::fbuf_create( srate_t srate, unsigned chN, const unsi
|
||||
}
|
||||
|
||||
|
||||
cw::flow::fbuf_t* cw::flow::fbuf_create( srate_t srate, unsigned chN, unsigned maxBinN, unsigned binN, unsigned hopSmpN, const fd_real_t** magV, const fd_real_t** phsV, const fd_real_t** hzV )
|
||||
cw::flow::fbuf_t* cw::flow::fbuf_create( srate_t srate, unsigned chN, unsigned maxBinN, unsigned binN, unsigned hopSmpN, const fd_sample_t** magV, const fd_sample_t** phsV, const fd_sample_t** hzV )
|
||||
{
|
||||
unsigned maxBinN_V[ chN ];
|
||||
unsigned binN_V[ chN ];
|
||||
@ -1250,11 +1267,9 @@ cw::rc_t cw::flow::var_channelize( instance_t* inst, const char* var_label, uns
|
||||
goto errLabel;
|
||||
}
|
||||
|
||||
|
||||
// locate the variable with the stated chIdx
|
||||
var = _var_find_on_label_and_ch( inst, var_label, sfx_id, chIdx );
|
||||
|
||||
|
||||
// 'src' variables cannot be channelized
|
||||
if( cwIsFlag(base_var->varDesc->flags,kSrcVarFl) )
|
||||
{
|
||||
@ -1287,6 +1302,7 @@ cw::rc_t cw::flow::var_channelize( instance_t* inst, const char* var_label, uns
|
||||
// a correctly channelized var was found - but we still may need to set the value
|
||||
if( value_cfg != nullptr )
|
||||
{
|
||||
//cwLogInfo("%s ch:%i",var_label,chIdx);
|
||||
rc = _set_var_value_from_cfg( var, value_cfg );
|
||||
}
|
||||
else
|
||||
@ -1300,7 +1316,7 @@ cw::rc_t cw::flow::var_channelize( instance_t* inst, const char* var_label, uns
|
||||
|
||||
errLabel:
|
||||
if( rc != kOkRC )
|
||||
rc = cwLogError(rc,"Channelize failed for variable '%s:%i' on instance '%s:i' ch:%i.", var_label, sfx_id, inst->label, inst->label_sfx_id, chIdx );
|
||||
rc = cwLogError(rc,"Channelize failed for variable '%s:%i' on instance '%s:%i' ch:%i.", var_label, sfx_id, inst->label, inst->label_sfx_id, chIdx );
|
||||
|
||||
return rc;
|
||||
}
|
||||
@ -1319,6 +1335,31 @@ bool cw::flow::var_has_value( instance_t* inst, const char* label, unsigned sfx_
|
||||
return varPtr->value != nullptr;
|
||||
}
|
||||
|
||||
bool cw::flow::var_is_a_source( instance_t* inst, const char* label, unsigned sfx_id, unsigned chIdx )
|
||||
{
|
||||
rc_t rc;
|
||||
variable_t* varPtr = nullptr;
|
||||
if((rc = var_find( inst, label, sfx_id, chIdx, varPtr)) != kOkRC )
|
||||
{
|
||||
cwLogError(kEleNotFoundRC,"The variable '%s:%i' was not found on proc:'%s:%i'. 'source' state query is invalid.",cwStringNullGuard(label),sfx_id,cwStringNullGuard(inst->label),inst->label_sfx_id);
|
||||
return false;
|
||||
}
|
||||
|
||||
return is_a_source_var(varPtr);
|
||||
}
|
||||
|
||||
bool cw::flow::var_is_a_source( instance_t* inst, unsigned vid, unsigned chIdx )
|
||||
{
|
||||
rc_t rc;
|
||||
variable_t* varPtr = nullptr;
|
||||
if((rc = var_find( inst, vid, chIdx, varPtr)) != kOkRC )
|
||||
{
|
||||
cwLogError(kEleNotFoundRC,"The variable with vid '%i' was not found on proc:'%s:%i'. 'source' state query is invalid.",vid,cwStringNullGuard(inst->label),inst->label_sfx_id);
|
||||
return false;
|
||||
}
|
||||
|
||||
return is_a_source_var(varPtr);
|
||||
}
|
||||
|
||||
cw::rc_t cw::flow::var_find( instance_t* inst, unsigned vid, unsigned chIdx, variable_t*& varRef )
|
||||
{
|
||||
@ -1471,7 +1512,7 @@ cw::rc_t cw::flow::var_register_and_set( instance_t* inst, const char* va
|
||||
return rc;
|
||||
}
|
||||
|
||||
cw::rc_t cw::flow::var_register_and_set( instance_t* inst, const char* var_label, unsigned sfx_id, unsigned vid, unsigned chIdx, srate_t srate, unsigned chN, const unsigned* maxBinN_V, const unsigned* binN_V, const unsigned* hopSmpN_V, const fd_real_t** magV, const fd_real_t** phsV, const fd_real_t** hzV )
|
||||
cw::rc_t cw::flow::var_register_and_set( instance_t* inst, const char* var_label, unsigned sfx_id, unsigned vid, unsigned chIdx, srate_t srate, unsigned chN, const unsigned* maxBinN_V, const unsigned* binN_V, const unsigned* hopSmpN_V, const fd_sample_t** magV, const fd_sample_t** phsV, const fd_sample_t** hzV )
|
||||
{
|
||||
rc_t rc = kOkRC;
|
||||
fbuf_t* fbuf;
|
||||
@ -1499,7 +1540,7 @@ cw::rc_t cw::flow::var_register_and_set( instance_t* inst, const char* va
|
||||
}
|
||||
|
||||
|
||||
cw::rc_t cw::flow::var_register_and_set( instance_t* inst, const char* var_label, unsigned sfx_id, unsigned vid, unsigned chIdx, srate_t srate, unsigned chN, unsigned maxBinN, unsigned binN, unsigned hopSmpN, const fd_real_t** magV, const fd_real_t** phsV, const fd_real_t** hzV )
|
||||
cw::rc_t cw::flow::var_register_and_set( instance_t* inst, const char* var_label, unsigned sfx_id, unsigned vid, unsigned chIdx, srate_t srate, unsigned chN, unsigned maxBinN, unsigned binN, unsigned hopSmpN, const fd_sample_t** magV, const fd_sample_t** phsV, const fd_sample_t** hzV )
|
||||
{
|
||||
unsigned maxBinN_V[ chN ];
|
||||
unsigned binN_V[ chN ];
|
||||
|
@ -3,11 +3,11 @@ namespace cw
|
||||
namespace flow
|
||||
{
|
||||
|
||||
#define kRealTFl kFloatTFl
|
||||
typedef dsp::real_t real_t;
|
||||
typedef dsp::coeff_t coeff_t;
|
||||
typedef dsp::sample_t sample_t;
|
||||
typedef dsp::fd_real_t fd_real_t;
|
||||
typedef dsp::fd_sample_t fd_sample_t;
|
||||
typedef dsp::srate_t srate_t;
|
||||
typedef dsp::ftime_t ftime_t;
|
||||
typedef unsigned uint_t;
|
||||
typedef int int_t;
|
||||
|
||||
@ -40,11 +40,11 @@ namespace cw
|
||||
unsigned* maxBinN_V; // max value that binN_V[i] is allowed to take
|
||||
unsigned* binN_V; // binN_V[ chN ] count of sample frames per channel
|
||||
unsigned* hopSmpN_V; // hopSmpN_V[ chN ] hop sample count
|
||||
fd_real_t** magV; // magV[ chN ][ binN ]
|
||||
fd_real_t** phsV; // phsV[ chN ][ binN ]
|
||||
fd_real_t** hzV; // hzV[ chN ][ binN ]
|
||||
fd_sample_t** magV; // magV[ chN ][ binN ]
|
||||
fd_sample_t** phsV; // phsV[ chN ][ binN ]
|
||||
fd_sample_t** hzV; // hzV[ chN ][ binN ]
|
||||
bool* readyFlV; // readyFlV[chN] true if this channel is ready to be processed (used to sync. fbuf rate to abuf rate)
|
||||
fd_real_t* buf; // memory used by this buffer (or NULL if magV,phsV,hzV point are proxied to another buffer)
|
||||
fd_sample_t* buf; // memory used by this buffer (or NULL if magV,phsV,hzV point are proxied to another buffer)
|
||||
} fbuf_t;
|
||||
|
||||
typedef struct mbuf_str
|
||||
@ -66,15 +66,15 @@ namespace cw
|
||||
kBoolMtxTFl = 0x00000020,
|
||||
kUIntMtxTFl = 0x00000040,
|
||||
kIntMtxTFl = 0x00000080,
|
||||
kRealMtxTFl = 0x00000100,
|
||||
kFloatMtxTFl = 0x00000200,
|
||||
kDoubleMtxTFl= 0x00000400,
|
||||
kFloatMtxTFl = 0x00000100,
|
||||
kDoubleMtxTFl= 0x00000200,
|
||||
|
||||
kABufTFl = 0x00000800,
|
||||
kFBufTFl = 0x00001000,
|
||||
kMBufTFl = 0x00002000,
|
||||
kStringTFl = 0x00004000,
|
||||
kTimeTFl = 0x00008000,
|
||||
kABufTFl = 0x00000400,
|
||||
kFBufTFl = 0x00000800,
|
||||
kMBufTFl = 0x00001000,
|
||||
kStringTFl = 0x00002000,
|
||||
kTimeTFl = 0x00004000,
|
||||
kCfgTFl = 0x00008000,
|
||||
|
||||
kTypeMask = 0x0000ffff,
|
||||
|
||||
@ -85,7 +85,6 @@ namespace cw
|
||||
union {
|
||||
struct mtx::mtx_str< unsigned >* u;
|
||||
struct mtx::mtx_str< int >* i;
|
||||
struct mtx::mtx_str< real_t >* r;
|
||||
struct mtx::mtx_str< float >* f;
|
||||
struct mtx::mtx_str< double >* d;
|
||||
} u;
|
||||
@ -102,13 +101,13 @@ namespace cw
|
||||
double d;
|
||||
|
||||
mtx_t* mtx;
|
||||
|
||||
abuf_t* abuf;
|
||||
fbuf_t* fbuf;
|
||||
mbuf_t* mbuf;
|
||||
|
||||
char* s;
|
||||
char* fname;
|
||||
|
||||
const object_t* cfg;
|
||||
|
||||
} u;
|
||||
|
||||
@ -269,8 +268,8 @@ namespace cw
|
||||
rc_t abuf_set_channel( abuf_t* buf, unsigned chIdx, const sample_t* v, unsigned vN );
|
||||
const sample_t* abuf_get_channel( abuf_t* buf, unsigned chIdx );
|
||||
|
||||
fbuf_t* fbuf_create( srate_t srate, unsigned chN, const unsigned* maxBinN_V, const unsigned* binN_V, const unsigned* hopSmpN_V, const fd_real_t** magV=nullptr, const fd_real_t** phsV=nullptr, const fd_real_t** hzV=nullptr );
|
||||
fbuf_t* fbuf_create( srate_t srate, unsigned chN, unsigned maxBinN, unsigned binN, unsigned hopSmpN, const fd_real_t** magV=nullptr, const fd_real_t** phsV=nullptr, const fd_real_t** hzV=nullptr );
|
||||
fbuf_t* fbuf_create( srate_t srate, unsigned chN, const unsigned* maxBinN_V, const unsigned* binN_V, const unsigned* hopSmpN_V, const fd_sample_t** magV=nullptr, const fd_sample_t** phsV=nullptr, const fd_sample_t** hzV=nullptr );
|
||||
fbuf_t* fbuf_create( srate_t srate, unsigned chN, unsigned maxBinN, unsigned binN, unsigned hopSmpN, const fd_sample_t** magV=nullptr, const fd_sample_t** phsV=nullptr, const fd_sample_t** hzV=nullptr );
|
||||
void fbuf_destroy( fbuf_t*& buf );
|
||||
fbuf_t* fbuf_duplicate( const fbuf_t* src );
|
||||
|
||||
@ -332,8 +331,12 @@ namespace cw
|
||||
// `value_cfg` is optional. Set it to NULL to ignore
|
||||
rc_t var_register( instance_t* inst, const char* var_label, unsigned sfx_id, unsigned vid, unsigned chIdx, const object_t* value_cfg, variable_t*& varRef );
|
||||
|
||||
// Returns true if this var is connected to an external proc variable
|
||||
bool is_connected_to_external_proc( const variable_t* var );
|
||||
// Returns true if this var is connected to an source proc variable
|
||||
bool is_connected_to_source_proc( const variable_t* var );
|
||||
|
||||
// Return true if this var is acting as a source for another var.
|
||||
bool is_a_source_var( const variable_t* var );
|
||||
|
||||
|
||||
//-----------------
|
||||
//
|
||||
@ -411,8 +414,8 @@ namespace cw
|
||||
|
||||
rc_t var_register_and_set( instance_t* inst, const char* var_label, unsigned sfx_id, unsigned vid, unsigned chIdx, srate_t srate, unsigned chN, unsigned frameN );
|
||||
rc_t var_register_and_set( instance_t* inst, const char* var_label, unsigned sfx_id, unsigned vid, unsigned chIdx, midi::ch_msg_t* midiA, unsigned midiN );
|
||||
rc_t var_register_and_set( instance_t* inst, const char* var_label, unsigned sfx_id, unsigned vid, unsigned chIdx, srate_t srate, unsigned chN, const unsigned* maxBinN_V, const unsigned* binN_V, const unsigned* hopSmpN_V, const fd_real_t** magV=nullptr, const fd_real_t** phsV=nullptr, const fd_real_t** hzV=nullptr );
|
||||
rc_t var_register_and_set( instance_t* inst, const char* var_label, unsigned sfx_id, unsigned vid, unsigned chIdx, srate_t srate, unsigned chN, unsigned maxBinN, unsigned binN, unsigned hopSmpN, const fd_real_t** magV=nullptr, const fd_real_t** phsV=nullptr, const fd_real_t** hzV=nullptr );
|
||||
rc_t var_register_and_set( instance_t* inst, const char* var_label, unsigned sfx_id, unsigned vid, unsigned chIdx, srate_t srate, unsigned chN, const unsigned* maxBinN_V, const unsigned* binN_V, const unsigned* hopSmpN_V, const fd_sample_t** magV=nullptr, const fd_sample_t** phsV=nullptr, const fd_sample_t** hzV=nullptr );
|
||||
rc_t var_register_and_set( instance_t* inst, const char* var_label, unsigned sfx_id, unsigned vid, unsigned chIdx, srate_t srate, unsigned chN, unsigned maxBinN, unsigned binN, unsigned hopSmpN, const fd_sample_t** magV=nullptr, const fd_sample_t** phsV=nullptr, const fd_sample_t** hzV=nullptr );
|
||||
|
||||
inline rc_t _var_register_and_set(cw::flow::instance_t*, unsigned int ) { return kOkRC; }
|
||||
|
||||
@ -424,7 +427,8 @@ namespace cw
|
||||
variable_t* var = nullptr;
|
||||
if((rc = var_register_and_set( inst, var_label, sfx_id, vid, chIdx, var)) == kOkRC )
|
||||
{
|
||||
var_set( inst, vid, chIdx, val );
|
||||
if((rc = var_set( inst, vid, chIdx, val )) != kOkRC )
|
||||
return rc;
|
||||
|
||||
if((rc = _var_register_and_set( inst, chIdx, std::forward<ARGS>(args)...)) != kOkRC )
|
||||
return rc;
|
||||
@ -444,6 +448,8 @@ namespace cw
|
||||
|
||||
bool var_exists( instance_t* inst, const char* label, unsigned sfx_id, unsigned chIdx );
|
||||
bool var_has_value( instance_t* inst, const char* label, unsigned sfx_id, unsigned chIdx );
|
||||
bool var_is_a_source( instance_t* inst, const char* label, unsigned sfx_id, unsigned chIdx );
|
||||
bool var_is_a_source( instance_t* inst, unsigned vid, unsigned chIdx );
|
||||
|
||||
rc_t var_find( instance_t* inst, const char* var_label, unsigned sfx_id, unsigned chIdx, const variable_t*& varRef );
|
||||
rc_t var_find( instance_t* inst, const char* var_label, unsigned sfx_id, unsigned chIdx, variable_t*& varRef );
|
||||
|
Loading…
Reference in New Issue
Block a user