cwFlow,cwFlowNet,cwFlowTypes,cwFlowProc : Many changes.

Added ability to set types at proc instantiation time.
Added ability to have multi-type variables which get resolved at proc. instantiation time.
Added ability to proc 'log' attribute to print selected variables as they change.
Values are now coerced to the variable type in var_set().
Added new proc's : list,add,preset.
This commit is contained in:
kevin 2024-04-30 19:58:10 -04:00
parent 4619fc43a1
commit b57693f4e4
7 changed files with 1745 additions and 414 deletions

View File

@ -34,8 +34,8 @@ namespace cw
{ "midi_out", &midi_out::members },
{ "audio_in", &audio_in::members },
{ "audio_out", &audio_out::members },
{ "audioFileIn", &audioFileIn::members },
{ "audioFileOut", &audioFileOut::members },
{ "audio_file_in", &audio_file_in::members },
{ "audio_file_out", &audio_file_out::members },
{ "audio_gain", &audio_gain::members },
{ "audio_split", &audio_split::members },
{ "audio_duplicate", &audio_duplicate::members },
@ -58,6 +58,9 @@ namespace cw
{ "number", &number::members },
{ "timer", &timer::members },
{ "counter", &counter::members },
{ "list", &list::members },
{ "add", &add::members },
{ "preset", &preset::members },
{ nullptr, nullptr }
};
@ -621,7 +624,7 @@ cw::rc_t cw::flow::test( const object_t* cfg, int argc, const char* argv[] )
// find the user requested test case
if((test_cfg = test_cases_cfg->find_child(argv[1])) == nullptr )
{
rc = cwLogError(kInvalidArgRC,"The test case named '%s' was not found.",argv[0]);
rc = cwLogError(kInvalidArgRC,"The test case named '%s' was not found.",argv[1]);
goto errLabel;
}

View File

@ -66,8 +66,10 @@ namespace cw
void _connect_vars( variable_t* src_var, variable_t* in_var )
{
// connect in_var into src_var's outgoing var chain
in_var->connect_link = src_var->connect_link;
src_var->connect_link = in_var;
in_var->dst_link = src_var->dst_tail;
src_var->dst_tail = in_var;
if( src_var->dst_head == nullptr )
src_var->dst_head = in_var;
assert( src_var->value != nullptr );
@ -171,7 +173,42 @@ namespace cw
}
}
}
rc_t _set_log_flags(instance_t* proc, const object_t* log_labels)
{
rc_t rc = kOkRC;
if( log_labels == nullptr )
return rc;
if( !log_labels->is_dict() )
{
rc = cwLogError(kSyntaxErrorRC,"The log spec on '%s:%i' is not a dictionary.",cwStringNullGuard(proc->label),proc->label_sfx_id);
goto errLabel;
}
for(unsigned i=0; i<log_labels->child_count(); ++i)
{
const object_t* pair;
unsigned sfx_id;
if((pair = log_labels->child_ele(i)) == nullptr || pair->pair_label()==nullptr || pair->pair_value()==nullptr || (rc=pair->pair_value()->value(sfx_id))!=kOkRC )
{
rc = cwLogError(kSyntaxErrorRC,"Syntax error on log var identifier.");
goto errLabel;
}
if((rc = var_set_flags( proc, kAnyChIdx, pair->pair_label(), sfx_id, kLogVarFl )) != kOkRC )
{
rc = cwLogError(rc,"Unable to set var flags on '%s:%i' var:'%s:%i'.",cwStringNullGuard(proc->label),proc->label_sfx_id,pair->pair_label(),sfx_id);
goto errLabel;
}
}
errLabel:
return rc;
}
rc_t _call_value_func_on_all_variables( instance_t* inst )
{
rc_t rc = kOkRC;
@ -181,40 +218,49 @@ namespace cw
if( inst->varMapA[i] != nullptr && inst->varMapA[i]->vid != kInvalidId )
{
variable_t* var = inst->varMapA[i];
if((rc = var->inst->class_desc->members->value( var->inst, var )) != kOkRC )
if((rc = var_call_custom_value_func( var )) != kOkRC )
rc1 = cwLogError(rc,"The proc instance '%s:%i' reported an invalid valid on variable:%s chIdx:%i.", var->inst->label, var->inst->label_sfx_id, var->label, var->chIdx );
}
return rc1;
}
rc_t _var_channelize( instance_t* inst, const char* preset_label, const char* type_src_label, const char* value_label, const object_t* value )
rc_t _var_channelize( instance_t* inst, const char* preset_label, const char* type_src_label, const char* var_label, const object_t* value )
{
rc_t rc = kOkRC;
variable_t* dummy = nullptr;
variable_t* dummy = nullptr;
var_desc_t* vd = nullptr;
// verify that a valid value exists
if( value == nullptr )
{
rc = cwLogError(kSyntaxErrorRC,"Unexpected missig value on %s preset '%s' instance '%s' variable '%s'.", type_src_label, preset_label, inst->label, cwStringNullGuard(value_label) );
rc = cwLogError(kSyntaxErrorRC,"Unexpected missig value on %s preset '%s' instance '%s' variable '%s'.", type_src_label, preset_label, inst->label, cwStringNullGuard(var_label) );
goto errLabel;
}
// if a list of values was given
if( value->is_list() )
else
{
for(unsigned chIdx=0; chIdx<value->child_count(); ++chIdx)
if((rc = var_channelize( inst, value_label, kBaseSfxId, chIdx, value->child_ele(chIdx), kInvalidId, dummy )) != kOkRC )
goto errLabel;
}
else // otherwise a single value was given
{
if((rc = var_channelize( inst, value_label, kBaseSfxId, kAnyChIdx, value, kInvalidId, dummy )) != kOkRC )
goto errLabel;
}
bool is_var_cfg_type_fl = (vd = var_desc_find( inst->class_desc, var_label ))!=nullptr && cwIsFlag(vd->type,kCfgTFl);
bool is_list_fl = value->is_list();
bool is_list_of_list_fl = is_list_fl && value->child_count() > 0 && value->child_ele(0)->is_list();
bool parse_list_fl = (is_list_fl && !is_var_cfg_type_fl) || (is_list_of_list_fl && is_var_cfg_type_fl);
// if a list of values was given and the var type is not a 'cfg' type or if a list of lists was given
if( parse_list_fl )
{
// then each value in the list is assigned to the associated channel
for(unsigned chIdx=0; chIdx<value->child_count(); ++chIdx)
if((rc = var_channelize( inst, var_label, kBaseSfxId, chIdx, value->child_ele(chIdx), kInvalidId, dummy )) != kOkRC )
goto errLabel;
}
else // otherwise a single value was given
{
if((rc = var_channelize( inst, var_label, kBaseSfxId, kAnyChIdx, value, kInvalidId, dummy )) != kOkRC )
goto errLabel;
}
}
errLabel:
return rc;
}
@ -236,12 +282,12 @@ namespace cw
// for each preset variable
for(unsigned i=0; i<preset_cfg->child_count(); ++i)
{
const object_t* value = preset_cfg->child_ele(i)->pair_value();
const char* value_label = preset_cfg->child_ele(i)->pair_label();
const object_t* value = preset_cfg->child_ele(i)->pair_value();
const char* var_label = preset_cfg->child_ele(i)->pair_label();
//cwLogInfo("variable:%s",value_label);
if((rc = _var_channelize( inst, preset_label, type_src_label, value_label, value )) != kOkRC )
if((rc = _var_channelize( inst, preset_label, type_src_label, var_label, value )) != kOkRC )
goto errLabel;
@ -707,6 +753,7 @@ namespace cw
const char* arg_label; //
const object_t* preset_labels; //
const object_t* arg_cfg; //
const object_t* log_labels; //
const object_t* in_dict; // cfg. node to the in-list
in_stmt_t* in_array; // in_array[ in_arrayN ] in-stmt array
unsigned in_arrayN; // count of in-stmt's in the in-list.
@ -1253,9 +1300,16 @@ namespace cw
{
in_stmt_t& in_stmt = pstate.in_array[i];
const object_t* in_pair = pstate.in_dict->child_ele(i); // in:src pair
const char* in_var_str = in_pair->pair_label(); // 'in' var string
const char* in_var_str = nullptr;
const char* src_proc_var_str = nullptr;
// validate the basic syntax
if( in_pair == nullptr || (in_var_str = in_pair->pair_label()) == nullptr || in_pair->pair_value()==nullptr )
{
cwLogError(rc,"Malformed dictionary encountered in 'in' statement.");
goto errLabel;
}
// get the src net/proc/var string
if((rc = in_pair->pair_value()->value(src_proc_var_str)) != kOkRC )
{
@ -1282,6 +1336,7 @@ namespace cw
kInvalidId,
kAnyChIdx,
in_stmt.in_var_desc->val_cfg,
kInvalidTFl,
dum )) != kOkRC )
{
rc = cwLogError(rc,"in-stmt var create failed on '%s:%s'.",cwStringNullGuard(in_var_str),cwStringNullGuard(src_proc_var_str));
@ -1432,9 +1487,10 @@ namespace cw
// parse the optional args
if((rc = proc_inst_cfg->pair_value()->getv_opt("args", arg_dict,
"in", pstate.in_dict,
"argLabel", pstate.arg_label,
"preset", pstate.preset_labels)) != kOkRC )
"in", pstate.in_dict,
"argLabel", pstate.arg_label,
"preset", pstate.preset_labels,
"log", pstate.log_labels )) != kOkRC )
{
rc = cwLogError(kSyntaxErrorRC,"The instance cfg. '%s' missing: 'type'.",pstate.inst_label);
goto errLabel;
@ -1550,16 +1606,16 @@ namespace cw
// Instantiate all the variables in the class description - that were not already created in _parse_in_list()
for(var_desc_t* vd=class_desc->varDescL; vd!=nullptr; vd=vd->link)
if( !_is_var_inst_already_created( vd->label, pstate ) )
if( !_is_var_inst_already_created( vd->label, pstate ) && cwIsNotFlag(vd->type,kRuntimeTFl) )
{
variable_t* var = nullptr;
if((rc = var_create( inst, vd->label, kBaseSfxId, kInvalidId, kAnyChIdx, vd->val_cfg, var )) != kOkRC )
if((rc = var_create( inst, vd->label, kBaseSfxId, kInvalidId, kAnyChIdx, vd->val_cfg, kInvalidTFl, var )) != kOkRC )
goto errLabel;
}
// All the variables that can be used by this instance have now been created
// and the chIdx of each variable is set to 'any'.
// If a 'preset' field was included in the class cfg then apply the specified class preset
if( pstate.preset_labels != nullptr )
if((rc = _class_apply_presets(inst, pstate.preset_labels )) != kOkRC )
@ -1584,36 +1640,52 @@ namespace cw
// Connect the in-list variables to their sources.
if((rc = _connect_in_vars(net, inst, pstate)) != kOkRC )
{
rc = cwLogError(rc,"Creation of the proc instance '%s:%i' failed during input connection processing.",cwStringNullGuard(inst->label),inst->label_sfx_id);
rc = cwLogError(rc,"Input connection processing failed.");
goto errLabel;
}
// Complete the instantiation of the proc instance by calling the custom instance creation function.
// Call the custom instance create() function.
if((rc = class_desc->members->create( inst )) != kOkRC )
{
rc = cwLogError(kInvalidArgRC,"Instantiation failed on instance '%s:%i'.", inst->label,inst->label_sfx_id );
rc = cwLogError(kInvalidArgRC,"Custom instantiation failed." );
goto errLabel;
}
// Create the instance->varMap[] lookup array
if((rc =_create_instance_var_map( inst )) != kOkRC )
{
rc = cwLogError(rc,"Variable map creation failed.");
goto errLabel;
}
// the custom creation function may have added channels to in-list vars fix up those connections here.
_complete_input_connections(inst);
// set the log flags again so that vars created by the instance can be included in the log output
if((rc = _set_log_flags(inst,pstate.log_labels)) != kOkRC )
goto errLabel;
// call the 'value()' function to inform the instance of the current value of all of it's variables.
if((rc = _call_value_func_on_all_variables( inst )) != kOkRC )
goto errLabel;
if((rc = instance_validate(inst)) != kOkRC )
{
rc = cwLogError(rc,"Proc instance validation failed.");
goto errLabel;
}
inst_ref = inst;
errLabel:
if( rc != kOkRC )
{
rc = cwLogError(rc,"Proc instantiation failed on '%s:%i'.",cwStringNullGuard(pstate.inst_label),sfx_id);
_destroy_inst(inst);
}
_destroy_pstate(pstate);
return rc;

File diff suppressed because it is too large Load Diff

View File

@ -7,8 +7,8 @@ namespace cw
namespace midi_out { extern class_members_t members; }
namespace audio_in { extern class_members_t members; }
namespace audio_out { extern class_members_t members; }
namespace audioFileIn { extern class_members_t members; }
namespace audioFileOut { extern class_members_t members; }
namespace audio_file_in { extern class_members_t members; }
namespace audio_file_out { extern class_members_t members; }
namespace audio_gain { extern class_members_t members; }
namespace audio_split { extern class_members_t members; }
namespace audio_merge { extern class_members_t members; }
@ -31,6 +31,9 @@ namespace cw
namespace number { extern class_members_t members; }
namespace timer { extern class_members_t members; }
namespace counter { extern class_members_t members; }
namespace list { extern class_members_t members; }
namespace add { extern class_members_t members; }
namespace preset { extern class_members_t members; }
}
}

File diff suppressed because it is too large Load Diff

View File

@ -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_sample_t** magV; // magV[ chN ][ binN ]
fd_sample_t** phsV; // phsV[ chN ][ binN ]
fd_sample_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_sample_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
@ -78,6 +78,8 @@ namespace cw
kTypeMask = 0x0000ffff,
kRuntimeTFl = 0x80000000
};
typedef struct mtx_str
@ -92,7 +94,8 @@ namespace cw
typedef struct value_str
{
unsigned flags;
unsigned tflag;
union {
bool b;
uint_t u;
@ -108,6 +111,7 @@ namespace cw
char* s;
const object_t* cfg;
void* p;
} u;
@ -116,8 +120,9 @@ namespace cw
} value_t;
inline bool is_numeric( const value_t* v ) { return cwIsFlag(v->flags,kBoolTFl|kUIntTFl|kIntTFl|kFloatTFl|kDoubleTFl); }
inline bool is_matrix( const value_t* v ) { return cwIsFlag(v->flags,kBoolMtxTFl|kUIntMtxTFl|kIntMtxTFl|kFloatMtxTFl|kDoubleMtxTFl); }
inline void set_null( value_t& v, unsigned tflag ) { v.tflag=tflag; v.u.p=nullptr; }
inline bool is_numeric( const value_t* v ) { return cwIsFlag(v->tflag,kBoolTFl|kUIntTFl|kIntTFl|kFloatTFl|kDoubleTFl); }
inline bool is_matrix( const value_t* v ) { return cwIsFlag(v->tflag,kBoolMtxTFl|kUIntMtxTFl|kIntMtxTFl|kFloatMtxTFl|kDoubleMtxTFl); }
struct instance_str;
struct variable_str;
@ -170,24 +175,40 @@ namespace cw
unsigned polyLimitN; // max. poly copies of this class per network_t or 0 if no limit
} class_desc_t;
enum {
kInvalidVarFl = 0x00,
kLogVarFl = 0x01
};
// Note: The concatenation of 'vid' and 'chIdx' should form a unique identifier among all variables
// on a given 'instance'.
typedef struct variable_str
{
struct instance_str* inst; // pointer to this variables instance
char* label; // this variables label
unsigned label_sfx_id; // the label suffix id of this variable or kInvalidIdx if this has no suffix
unsigned vid; // this variables numeric id ( cat(vid,chIdx) forms a unique variable identifier on this 'inst'
var_desc_t* varDesc; // the variable description for this variable
value_t local_value[ kLocalValueN ]; // the local value instance (actual value if this is not a 'src' variable)
unsigned local_value_idx; // local_value[] is double buffered to allow the cur value of the buf[] to be held while the next value is validated (see _var_set_template())
value_t* value; // pointer to the value associated with this variable
unsigned label_sfx_id; // the label suffix id of this variable or kInvalidIdx if this has no suffix
unsigned vid; // this variables numeric id ( cat(vid,chIdx) forms a unique variable identifier on this 'inst'
unsigned chIdx; // channel index
struct variable_str* src_var; // pointer to this input variables source link (or null if it uses the local_value)
struct variable_str* var_link; // instance.varL link list
struct variable_str* connect_link; // list of outgoing connections
unsigned flags; // kLogVarFl
unsigned type; // This is the value type as established when the var is initialized - it never changes for the life of the var.
var_desc_t* classVarDesc; // pointer to this variables class var desc
var_desc_t* localVarDesc; // pointer to this variables local var desc - if it doesn't match classVarDesc.
var_desc_t* varDesc; // the effective variable description for this variable (set to classVarDesc or localVarDesc)
value_t local_value[ kLocalValueN ]; // the local value instance (actual value if this is not a 'src' variable)
unsigned local_value_idx; // local_value[] is double buffered to allow the cur value of the buf[] to be held while the next value is validated (see _var_set_template())
struct variable_str* src_var; // pointer to this input variables source link (or null if it uses the local_value)
value_t* value; // pointer to the value associated with this variable
struct variable_str* var_link; // instance.varL list link
struct variable_str* ch_link; // list of channels that share this variable (rooted on 'any' channel - in order by channel number)
struct variable_str* dst_head; // Pointer to list of out-going connections (null on var's that do not have out-going connections)
struct variable_str* dst_tail; //
struct variable_str* dst_link; // Link used by dst_head list.
} variable_t;
@ -277,11 +298,13 @@ namespace cw
void mbuf_destroy( mbuf_t*& buf );
mbuf_t* mbuf_duplicate( const mbuf_t* src );
inline bool value_is_abuf( const value_t* v ) { return v->flags & kABufTFl; }
inline bool value_is_fbuf( const value_t* v ) { return v->flags & kFBufTFl; }
inline bool value_is_abuf( const value_t* v ) { return v->tflag & kABufTFl; }
inline bool value_is_fbuf( const value_t* v ) { return v->tflag & kFBufTFl; }
unsigned value_type_label_to_flag( const char* type_desc );
const char* value_type_flag_to_label( unsigned flag );
//------------------------------------------------------------------------------------------------------------------------
//
// Class and Variable Description
@ -305,6 +328,8 @@ namespace cw
//
// Instance
//
rc_t instance_validate( instance_t* inst );
instance_t* instance_find( network_t& net, const char* inst_label, unsigned sfx_id );
rc_t instance_find( network_t& net, const char* inst_label, unsigned sfx_id, instance_t*& instPtrRef );
@ -313,6 +338,9 @@ namespace cw
void instance_print( instance_t* inst );
// Count of all var instances on this proc. This is a count of the length of inst->varL.
unsigned instance_var_count( instance_t* inst );
//------------------------------------------------------------------------------------------------------------------------
@ -321,13 +349,26 @@ namespace cw
//
// Create a variable but do not assign it a value. Return a pointer to the new variable.
// Note: `value_cfg` is optional. Set it to NULL to ignore
rc_t var_create( instance_t* inst, const char* var_label, unsigned sfx_id, unsigned vid, unsigned chIdx, const object_t* value_cfg, variable_t*& varRef );
// Notes:
// 1) `value_cfg` is optional. Set it to NULL to ignore
// 2) If `altTypeFl` is not set to kInvalidTFl then the var is assigned this type.
rc_t var_create( instance_t* inst, const char* var_label, unsigned sfx_id, unsigned vid, unsigned chIdx, const object_t* value_cfg, unsigned altTypeFlag, variable_t*& varRef );
// Channelizing creates a new var record with an explicit channel index to replace the
// automatically generated variable whose channel index is set to 'all'.
rc_t var_channelize( instance_t* inst, const char* var_label, unsigned sfx_id, unsigned chIdx, const object_t* value_cfg, unsigned vid, variable_t*& varRef );
// Set the var. type at runtime.
//rc_t var_set_type( instance_t* inst, unsigned chIdx, const char* var_label, unsigned sfx_id, unsigned type_flags );
// Wrapper around call to var->inst->members->value()
rc_t var_call_custom_value_func( variable_t* var );
// Sets and get the var->flags field
unsigned var_flags( instance_t* inst, unsigned chIdx, const char* var_label, unsigned sfx_id, unsigned& flags_ref );
rc_t var_set_flags( instance_t* inst, unsigned chIdx, const char* var_label, unsigned sfx_id, unsigned flags );
rc_t var_clr_flags( instance_t* inst, unsigned chIdx, const char* var_label, unsigned sfx_id, unsigned flags );
// `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 );
@ -336,8 +377,9 @@ namespace cw
// Return true if this var is acting as a source for another var.
bool is_a_source_var( const variable_t* var );
rc_t var_mult_sfx_id_array( instance_t* inst, const char* var_label, unsigned* idA, unsigned idAllocN, unsigned& idN_ref );
//-----------------
//
// var_register
@ -461,18 +503,19 @@ namespace cw
rc_t var_channel_count( const variable_t* var, unsigned& chCntRef );
rc_t var_get( const variable_t* var, bool& valRef );
rc_t var_get( const variable_t* var, uint_t& valRef );
rc_t var_get( const variable_t* var, int_t& valRef );
rc_t var_get( const variable_t* var, float& valRef );
rc_t var_get( const variable_t* var, double& valRef );
rc_t var_get( const variable_t* var, const char*& valRef );
rc_t var_get( const variable_t* var, const abuf_t*& valRef );
rc_t var_get( variable_t* var, abuf_t*& valRef );
rc_t var_get( const variable_t* var, const fbuf_t*& valRef );
rc_t var_get( variable_t* var, fbuf_t*& valRef );
rc_t var_get( const variable_t* var, const mbuf_t*& valRef );
rc_t var_get( variable_t* var, mbuf_t*& valRef );
rc_t var_get( const variable_t* var, bool& valRef );
rc_t var_get( const variable_t* var, uint_t& valRef );
rc_t var_get( const variable_t* var, int_t& valRef );
rc_t var_get( const variable_t* var, float& valRef );
rc_t var_get( const variable_t* var, double& valRef );
rc_t var_get( const variable_t* var, const char*& valRef );
rc_t var_get( const variable_t* var, const abuf_t*& valRef );
rc_t var_get( variable_t* var, abuf_t*& valRef );
rc_t var_get( const variable_t* var, const fbuf_t*& valRef );
rc_t var_get( variable_t* var, fbuf_t*& valRef );
rc_t var_get( const variable_t* var, const mbuf_t*& valRef );
rc_t var_get( variable_t* var, mbuf_t*& valRef );
rc_t var_get( const variable_t* var, const object_t*& valRef );
template< typename T>
rc_t var_get( instance_t* inst, unsigned vid, unsigned chIdx, T& valRef)
@ -494,14 +537,28 @@ namespace cw
return value;
}
rc_t var_set( instance_t* inst, unsigned vid, unsigned chIdx, bool val );
rc_t var_set( instance_t* inst, unsigned vid, unsigned chIdx, uint_t val );
rc_t var_set( instance_t* inst, unsigned vid, unsigned chIdx, int_t val );
rc_t var_set( instance_t* inst, unsigned vid, unsigned chIdx, float val );
rc_t var_set( instance_t* inst, unsigned vid, unsigned chIdx, double val );
rc_t var_set( instance_t* inst, unsigned vid, unsigned chIdx, const char* val );
rc_t var_set( instance_t* inst, unsigned vid, unsigned chIdx, abuf_t* val );
rc_t var_set( instance_t* inst, unsigned vid, unsigned chIdx, fbuf_t* val );
rc_t var_set( variable_t* var, const value_t* val );
rc_t var_set( variable_t* var, bool val );
rc_t var_set( variable_t* var, uint_t val );
rc_t var_set( variable_t* var, int_t val );
rc_t var_set( variable_t* var, float val );
rc_t var_set( variable_t* var, double val );
rc_t var_set( variable_t* var, const char* val );
rc_t var_set( variable_t* var, abuf_t* val );
rc_t var_set( variable_t* var, fbuf_t* val );
rc_t var_set( variable_t* var, mbuf_t* val );
rc_t var_set( variable_t* var, const object_t* val );
rc_t var_set( instance_t* inst, unsigned vid, unsigned chIdx, const value_t* val );
rc_t var_set( instance_t* inst, unsigned vid, unsigned chIdx, bool val );
rc_t var_set( instance_t* inst, unsigned vid, unsigned chIdx, uint_t val );
rc_t var_set( instance_t* inst, unsigned vid, unsigned chIdx, int_t val );
rc_t var_set( instance_t* inst, unsigned vid, unsigned chIdx, float val );
rc_t var_set( instance_t* inst, unsigned vid, unsigned chIdx, double val );
rc_t var_set( instance_t* inst, unsigned vid, unsigned chIdx, const char* val );
rc_t var_set( instance_t* inst, unsigned vid, unsigned chIdx, abuf_t* val );
rc_t var_set( instance_t* inst, unsigned vid, unsigned chIdx, fbuf_t* val );
rc_t var_set( instance_t* inst, unsigned vid, unsigned chIdx, const object_t* val );
const preset_t* class_preset_find( class_desc_t* cd, const char* preset_label );

View File

@ -23,7 +23,32 @@ and audio processing networks and the application of network state data.
### Polyphonic Network.
3. Network with sub-nets.
### Network with sub-nets.
## Proc Instance Syntax:
```
<label> : { 'class':<class>, "in":{<in_stmt>*}, "preset":<class_preset_label>, "log":<log_dict> "argLabel":<arg_preset_label>, "args":<args_dict> }
```
__args__ : This is a dictionary of named variable value records.
__preset__ : This string references a class preset to use for initializing this proc instance.
__argLabel__ : This string references an `args` dictionary parameter set to be applied after the __preset__ class preset.
If this argument is not given then it is automatically assigned the value "default". (What if there is not __arg__ record named default?
What if the are no __arg__ records at all?)
__log__ : This is a dictionary of `<var_label>:<sfx_id>` pairs whose value should be printed to the console when they change at runtime.
Notes:
1. All fields except 'class' are optional.
2. The class preset named by __preset__ is always applied before the __arg__ values referenced by __argLabel__.
- When a preset is given as a list of values each entry in the list is taken as the value for
the associated channel. When a list value is given to a var that is of type 'cfg' the list is passed
as a single value.
## Processing Unit Class
@ -40,6 +65,7 @@ srate | (float) Sample rate type
sample | (float) Audio sample type
coeff | (float) Value that will be directly applied to a sample value (e.g added or multiplied)
ftime | (double) Fractional seconds
runtime| The type is left up to the processors custom 'create' function. These vars are not automatically created.
See list in cwFlowTypes.cpp : typeLabelFlagsA[]
@ -166,6 +192,11 @@ uint | `uint32_t`
real | `double`
audio | multi-channel audio
spectrum | multi-channel spectrum
cfg |
srate | platform defined sample rate type
sample | platform defined audio sample type
coeff | platform defined signal processing coefficient type
### Variable Flags:
@ -180,7 +211,10 @@ Flag | Description
Notes:
1. Unless the `no_src` attribute is set any variable may be connected to a source variable
in the proc instantation 'in' statement.
in the proc instantation 'in' statement. `no_src` variables are output variables whose
value is calculated by the proc and therefore don't make sense to be fed from
some other entity.
2. By default all variables are created prior to the proc `create()` function being called.
Variable with the `no_dflt_create` attribute will not be created. This is useful in cases