Added flow::get_variable_value()
This commit is contained in:
parent
b9e01aa288
commit
9782c1b3c9
69
cwFlow.cpp
69
cwFlow.cpp
@ -41,6 +41,7 @@ namespace cw
|
|||||||
{ "audio_delay", &audio_delay::members },
|
{ "audio_delay", &audio_delay::members },
|
||||||
{ "dc_filter", &dc_filter::members },
|
{ "dc_filter", &dc_filter::members },
|
||||||
{ "balance", &balance::members },
|
{ "balance", &balance::members },
|
||||||
|
{ "audio_meter", &audio_meter::members },
|
||||||
{ nullptr, nullptr }
|
{ nullptr, nullptr }
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -759,19 +760,23 @@ namespace cw
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// complete the instantiation
|
// Complete the instantiation
|
||||||
|
|
||||||
|
// Call the custom instance create() function.
|
||||||
if((rc = class_desc->members->create( inst )) != kOkRC )
|
if((rc = class_desc->members->create( inst )) != kOkRC )
|
||||||
{
|
{
|
||||||
rc = cwLogError(kInvalidArgRC,"Instantiation failed on instance '%s'.", inst->label );
|
rc = cwLogError(kInvalidArgRC,"Instantiation failed on instance '%s'.", inst->label );
|
||||||
goto errLabel;
|
goto errLabel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Create the instance->varMap[] lookup array
|
||||||
if((rc =_create_instance_var_map( inst )) != kOkRC )
|
if((rc =_create_instance_var_map( inst )) != kOkRC )
|
||||||
goto errLabel;
|
goto errLabel;
|
||||||
|
|
||||||
|
//
|
||||||
_complete_input_connections(inst);
|
_complete_input_connections(inst);
|
||||||
|
|
||||||
|
// 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 )
|
if((rc = _call_value_func_on_all_variables( inst )) != kOkRC )
|
||||||
goto errLabel;
|
goto errLabel;
|
||||||
|
|
||||||
@ -873,13 +878,15 @@ namespace cw
|
|||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
template< typename T >
|
rc_t _get_variable( flow_t* p, const char* inst_label, const char* var_label, unsigned chIdx, instance_t*& instPtrRef, variable_t*& varPtrRef )
|
||||||
rc_t _set_variable_value( flow_t* p, const char* inst_label, const char* var_label, unsigned chIdx, T value )
|
|
||||||
{
|
{
|
||||||
rc_t rc = kOkRC;
|
rc_t rc = kOkRC;
|
||||||
instance_t* inst = nullptr;
|
instance_t* inst = nullptr;
|
||||||
variable_t* var = nullptr;
|
variable_t* var = nullptr;
|
||||||
|
|
||||||
|
varPtrRef = nullptr;
|
||||||
|
instPtrRef = nullptr;
|
||||||
|
|
||||||
// locate the proc instance
|
// locate the proc instance
|
||||||
if((inst = instance_find(p,inst_label)) == nullptr )
|
if((inst = instance_find(p,inst_label)) == nullptr )
|
||||||
{
|
{
|
||||||
@ -894,6 +901,24 @@ namespace cw
|
|||||||
goto errLabel;
|
goto errLabel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
instPtrRef = inst;
|
||||||
|
varPtrRef = var;
|
||||||
|
|
||||||
|
errLabel:
|
||||||
|
return rc;
|
||||||
|
}
|
||||||
|
|
||||||
|
template< typename T >
|
||||||
|
rc_t _set_variable_value( flow_t* p, const char* inst_label, const char* var_label, unsigned chIdx, T value )
|
||||||
|
{
|
||||||
|
rc_t rc = kOkRC;
|
||||||
|
instance_t* inst = nullptr;
|
||||||
|
variable_t* var = nullptr;
|
||||||
|
|
||||||
|
// get the variable
|
||||||
|
if((rc = _get_variable(p,inst_label,var_label,chIdx,inst,var)) != kOkRC )
|
||||||
|
goto errLabel;
|
||||||
|
|
||||||
// set the variable value
|
// set the variable value
|
||||||
if((rc = var_set( inst, var->vid, chIdx, value )) != kOkRC )
|
if((rc = var_set( inst, var->vid, chIdx, value )) != kOkRC )
|
||||||
{
|
{
|
||||||
@ -905,6 +930,28 @@ namespace cw
|
|||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template< typename T >
|
||||||
|
rc_t _get_variable_value( flow_t* p, const char* inst_label, const char* var_label, unsigned chIdx, T& valueRef )
|
||||||
|
{
|
||||||
|
rc_t rc = kOkRC;
|
||||||
|
instance_t* inst = nullptr;
|
||||||
|
variable_t* var = nullptr;
|
||||||
|
|
||||||
|
// get the variable
|
||||||
|
if((rc = _get_variable(p,inst_label,var_label,chIdx,inst,var)) != kOkRC )
|
||||||
|
goto errLabel;
|
||||||
|
|
||||||
|
// get the variable value
|
||||||
|
if((rc = var_get( inst, var->vid, chIdx, valueRef )) != kOkRC )
|
||||||
|
{
|
||||||
|
rc = cwLogError(kOpFailRC,"The variable get failed on instance:'%s' variable:'%s'.",cwStringNullGuard(inst_label),cwStringNullGuard(var_label));
|
||||||
|
goto errLabel;
|
||||||
|
}
|
||||||
|
|
||||||
|
errLabel:
|
||||||
|
return rc;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -1128,6 +1175,22 @@ cw::rc_t cw::flow::set_variable_value( handle_t h, const char* inst_label, const
|
|||||||
cw::rc_t cw::flow::set_variable_value( handle_t h, const char* inst_label, const char* var_label, unsigned chIdx, double value )
|
cw::rc_t cw::flow::set_variable_value( handle_t h, const char* inst_label, const char* var_label, unsigned chIdx, double value )
|
||||||
{ return _set_variable_value( _handleToPtr(h), inst_label, var_label, chIdx, value ); }
|
{ return _set_variable_value( _handleToPtr(h), inst_label, var_label, chIdx, value ); }
|
||||||
|
|
||||||
|
cw::rc_t cw::flow::get_variable_value( handle_t h, const char* inst_label, const char* var_label, unsigned chIdx, bool& valueRef )
|
||||||
|
{ return _get_variable_value( _handleToPtr(h), inst_label, var_label, chIdx, valueRef ); }
|
||||||
|
|
||||||
|
cw::rc_t cw::flow::get_variable_value( handle_t h, const char* inst_label, const char* var_label, unsigned chIdx, int& valueRef )
|
||||||
|
{ return _get_variable_value( _handleToPtr(h), inst_label, var_label, chIdx, valueRef ); }
|
||||||
|
|
||||||
|
cw::rc_t cw::flow::get_variable_value( handle_t h, const char* inst_label, const char* var_label, unsigned chIdx, unsigned& valueRef )
|
||||||
|
{ return _get_variable_value( _handleToPtr(h), inst_label, var_label, chIdx, valueRef ); }
|
||||||
|
|
||||||
|
cw::rc_t cw::flow::get_variable_value( handle_t h, const char* inst_label, const char* var_label, unsigned chIdx, float& valueRef )
|
||||||
|
{ return _get_variable_value( _handleToPtr(h), inst_label, var_label, chIdx, valueRef ); }
|
||||||
|
|
||||||
|
cw::rc_t cw::flow::get_variable_value( handle_t h, const char* inst_label, const char* var_label, unsigned chIdx, double& valueRef )
|
||||||
|
{ return _get_variable_value( _handleToPtr(h), inst_label, var_label, chIdx, valueRef ); }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void cw::flow::print_class_list( handle_t h )
|
void cw::flow::print_class_list( handle_t h )
|
||||||
{
|
{
|
||||||
|
6
cwFlow.h
6
cwFlow.h
@ -73,6 +73,12 @@ namespace cw
|
|||||||
rc_t set_variable_value( handle_t h, const char* inst_label, const char* var_label, unsigned chIdx, float value );
|
rc_t set_variable_value( handle_t h, const char* inst_label, const char* var_label, unsigned chIdx, float value );
|
||||||
rc_t set_variable_value( handle_t h, const char* inst_label, const char* var_label, unsigned chIdx, double value );
|
rc_t set_variable_value( handle_t h, const char* inst_label, const char* var_label, unsigned chIdx, double value );
|
||||||
|
|
||||||
|
rc_t get_variable_value( handle_t h, const char* inst_label, const char* var_label, unsigned chIdx, bool& valueRef );
|
||||||
|
rc_t get_variable_value( handle_t h, const char* inst_label, const char* var_label, unsigned chIdx, int& valueRef );
|
||||||
|
rc_t get_variable_value( handle_t h, const char* inst_label, const char* var_label, unsigned chIdx, unsigned& valueRef );
|
||||||
|
rc_t get_variable_value( handle_t h, const char* inst_label, const char* var_label, unsigned chIdx, float& valueRef );
|
||||||
|
rc_t get_variable_value( handle_t h, const char* inst_label, const char* var_label, unsigned chIdx, double& valueRef );
|
||||||
|
|
||||||
void print_class_list( handle_t h );
|
void print_class_list( handle_t h );
|
||||||
void print_network( handle_t h );
|
void print_network( handle_t h );
|
||||||
|
|
||||||
|
@ -271,6 +271,25 @@ namespace cw
|
|||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template< typename T >
|
||||||
|
rc_t _get_variable_value( handle_t h, destId_t destId, const char* inst_label, const char* var_label, unsigned chIdx, T& valueRef )
|
||||||
|
{
|
||||||
|
rc_t rc = kOkRC;
|
||||||
|
flow_cross_t* p = _handleToPtr(h);
|
||||||
|
unsigned flow_idx = destId == kAllDestId ? 0 : _get_flow_index(p, destId );
|
||||||
|
unsigned flow_cnt = destId == kAllDestId ? p->netN : flow_idx + 1;
|
||||||
|
|
||||||
|
for(; flow_idx < flow_cnt; ++flow_idx )
|
||||||
|
if((rc = get_variable_value( p->netA[ flow_idx ].flowH, inst_label, var_label, chIdx, valueRef )) != kOkRC )
|
||||||
|
{
|
||||||
|
cwLogError(rc,"Get variable value failed on cross-network index: %i.",flow_idx);
|
||||||
|
goto errLabel;
|
||||||
|
}
|
||||||
|
|
||||||
|
errLabel:
|
||||||
|
return rc;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -421,6 +440,22 @@ cw::rc_t cw::flow_cross::set_variable_value( handle_t h, destId_t destId, const
|
|||||||
cw::rc_t cw::flow_cross::set_variable_value( handle_t h, destId_t destId, const char* inst_label, const char* var_label, unsigned chIdx, double value )
|
cw::rc_t cw::flow_cross::set_variable_value( handle_t h, destId_t destId, const char* inst_label, const char* var_label, unsigned chIdx, double value )
|
||||||
{ return _set_variable_value(h,destId,inst_label,var_label,chIdx,value); }
|
{ return _set_variable_value(h,destId,inst_label,var_label,chIdx,value); }
|
||||||
|
|
||||||
|
|
||||||
|
cw::rc_t cw::flow_cross::get_variable_value( handle_t h, destId_t destId, const char* inst_label, const char* var_label, unsigned chIdx, bool& valueRef )
|
||||||
|
{ return _get_variable_value(h,destId,inst_label,var_label,chIdx,valueRef); }
|
||||||
|
|
||||||
|
cw::rc_t cw::flow_cross::get_variable_value( handle_t h, destId_t destId, const char* inst_label, const char* var_label, unsigned chIdx, int& valueRef )
|
||||||
|
{ return _get_variable_value(h,destId,inst_label,var_label,chIdx,valueRef); }
|
||||||
|
|
||||||
|
cw::rc_t cw::flow_cross::get_variable_value( handle_t h, destId_t destId, const char* inst_label, const char* var_label, unsigned chIdx, unsigned& valueRef )
|
||||||
|
{ return _get_variable_value(h,destId,inst_label,var_label,chIdx,valueRef); }
|
||||||
|
|
||||||
|
cw::rc_t cw::flow_cross::get_variable_value( handle_t h, destId_t destId, const char* inst_label, const char* var_label, unsigned chIdx, float& valueRef )
|
||||||
|
{ return _get_variable_value(h,destId,inst_label,var_label,chIdx,valueRef); }
|
||||||
|
|
||||||
|
cw::rc_t cw::flow_cross::get_variable_value( handle_t h, destId_t destId, const char* inst_label, const char* var_label, unsigned chIdx, double& valueRef )
|
||||||
|
{ return _get_variable_value(h,destId,inst_label,var_label,chIdx,valueRef); }
|
||||||
|
|
||||||
cw::rc_t cw::flow_cross::begin_cross_fade( handle_t h, unsigned crossFadeMs )
|
cw::rc_t cw::flow_cross::begin_cross_fade( handle_t h, unsigned crossFadeMs )
|
||||||
{
|
{
|
||||||
rc_t rc = kOkRC;
|
rc_t rc = kOkRC;
|
||||||
@ -471,3 +506,16 @@ void cw::flow_cross::print_network( handle_t h, destId_t destId )
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void cw::flow_cross::report( handle_t h )
|
||||||
|
{
|
||||||
|
flow_cross_t* p = _handleToPtr(h);
|
||||||
|
unsigned cur_flow_idx = _get_flow_index( p, kCurDestId );
|
||||||
|
unsigned next_flow_idx = _get_flow_index( p, kNextDestId );
|
||||||
|
|
||||||
|
for(unsigned i=0; i<p->netN; ++i)
|
||||||
|
{
|
||||||
|
const char* label = i==cur_flow_idx ? "Current" : (i==next_flow_idx ? "Next" : "");
|
||||||
|
printf("%s %f : ",label,p->netA[i].fadeGain );
|
||||||
|
}
|
||||||
|
printf("\n");
|
||||||
|
}
|
||||||
|
@ -36,10 +36,17 @@ namespace cw
|
|||||||
rc_t set_variable_value( handle_t h, destId_t destId, const char* inst_label, const char* var_label, unsigned chIdx, float value );
|
rc_t set_variable_value( handle_t h, destId_t destId, const char* inst_label, const char* var_label, unsigned chIdx, float value );
|
||||||
rc_t set_variable_value( handle_t h, destId_t destId, const char* inst_label, const char* var_label, unsigned chIdx, double value );
|
rc_t set_variable_value( handle_t h, destId_t destId, const char* inst_label, const char* var_label, unsigned chIdx, double value );
|
||||||
|
|
||||||
|
rc_t get_variable_value( handle_t h, destId_t destId, const char* inst_label, const char* var_label, unsigned chIdx, bool& valueRef );
|
||||||
|
rc_t get_variable_value( handle_t h, destId_t destId, const char* inst_label, const char* var_label, unsigned chIdx, int& valueRef );
|
||||||
|
rc_t get_variable_value( handle_t h, destId_t destId, const char* inst_label, const char* var_label, unsigned chIdx, unsigned& valueRef );
|
||||||
|
rc_t get_variable_value( handle_t h, destId_t destId, const char* inst_label, const char* var_label, unsigned chIdx, float& valueRef );
|
||||||
|
rc_t get_variable_value( handle_t h, destId_t destId, const char* inst_label, const char* var_label, unsigned chIdx, double& valueRef );
|
||||||
|
|
||||||
rc_t begin_cross_fade( handle_t h, unsigned crossFadeMs );
|
rc_t begin_cross_fade( handle_t h, unsigned crossFadeMs );
|
||||||
|
|
||||||
void print( handle_t h );
|
void print( handle_t h );
|
||||||
void print_network( handle_t h, flow_cross::destId_t destId );
|
void print_network( handle_t h, flow_cross::destId_t destId );
|
||||||
|
void report( handle_t h );
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
20
cwIoFlow.cpp
20
cwIoFlow.cpp
@ -437,8 +437,28 @@ cw::rc_t cw::io_flow::set_variable_value( handle_t h, flow_cross::destId_t destI
|
|||||||
cw::rc_t cw::io_flow::begin_cross_fade( handle_t h, unsigned crossFadeMs )
|
cw::rc_t cw::io_flow::begin_cross_fade( handle_t h, unsigned crossFadeMs )
|
||||||
{ return flow_cross::begin_cross_fade( _handleToPtr(h)->crossFlowH, crossFadeMs ); }
|
{ return flow_cross::begin_cross_fade( _handleToPtr(h)->crossFlowH, crossFadeMs ); }
|
||||||
|
|
||||||
|
|
||||||
|
cw::rc_t cw::io_flow::get_variable_value( handle_t h, flow_cross::destId_t destId, const char* inst_label, const char* var_label, unsigned chIdx, bool& valueRef )
|
||||||
|
{ return flow_cross::get_variable_value( _handleToPtr(h)->crossFlowH, destId, inst_label, var_label, chIdx, valueRef ); }
|
||||||
|
|
||||||
|
cw::rc_t cw::io_flow::get_variable_value( handle_t h, flow_cross::destId_t destId, const char* inst_label, const char* var_label, unsigned chIdx, int& valueRef )
|
||||||
|
{ return flow_cross::get_variable_value( _handleToPtr(h)->crossFlowH, destId, inst_label, var_label, chIdx, valueRef ); }
|
||||||
|
|
||||||
|
cw::rc_t cw::io_flow::get_variable_value( handle_t h, flow_cross::destId_t destId, const char* inst_label, const char* var_label, unsigned chIdx, unsigned& valueRef )
|
||||||
|
{ return flow_cross::get_variable_value( _handleToPtr(h)->crossFlowH, destId, inst_label, var_label, chIdx, valueRef ); }
|
||||||
|
|
||||||
|
cw::rc_t cw::io_flow::get_variable_value( handle_t h, flow_cross::destId_t destId, const char* inst_label, const char* var_label, unsigned chIdx, float& valueRef )
|
||||||
|
{ return flow_cross::get_variable_value( _handleToPtr(h)->crossFlowH, destId, inst_label, var_label, chIdx, valueRef ); }
|
||||||
|
|
||||||
|
cw::rc_t cw::io_flow::get_variable_value( handle_t h, flow_cross::destId_t destId, const char* inst_label, const char* var_label, unsigned chIdx, double& valueRef )
|
||||||
|
{ return flow_cross::get_variable_value( _handleToPtr(h)->crossFlowH, destId, inst_label, var_label, chIdx, valueRef ); }
|
||||||
|
|
||||||
|
|
||||||
void cw::io_flow::print( handle_t h )
|
void cw::io_flow::print( handle_t h )
|
||||||
{ return flow_cross::print( _handleToPtr(h)->crossFlowH ); }
|
{ return flow_cross::print( _handleToPtr(h)->crossFlowH ); }
|
||||||
|
|
||||||
void cw::io_flow::print_network( handle_t h, flow_cross::destId_t destId )
|
void cw::io_flow::print_network( handle_t h, flow_cross::destId_t destId )
|
||||||
{ return flow_cross::print_network( _handleToPtr(h)->crossFlowH, destId ); }
|
{ return flow_cross::print_network( _handleToPtr(h)->crossFlowH, destId ); }
|
||||||
|
|
||||||
|
void cw::io_flow::report( handle_t h )
|
||||||
|
{ flow_cross::report( _handleToPtr(h)->crossFlowH ); }
|
||||||
|
@ -29,9 +29,16 @@ namespace cw
|
|||||||
|
|
||||||
rc_t begin_cross_fade( handle_t h, unsigned crossFadeMs );
|
rc_t begin_cross_fade( handle_t h, unsigned crossFadeMs );
|
||||||
|
|
||||||
|
rc_t get_variable_value( handle_t h, flow_cross::destId_t destId, const char* inst_label, const char* var_label, unsigned chIdx, bool& valueRef );
|
||||||
|
rc_t get_variable_value( handle_t h, flow_cross::destId_t destId, const char* inst_label, const char* var_label, unsigned chIdx, int& valueRef );
|
||||||
|
rc_t get_variable_value( handle_t h, flow_cross::destId_t destId, const char* inst_label, const char* var_label, unsigned chIdx, unsigned& valueRef );
|
||||||
|
rc_t get_variable_value( handle_t h, flow_cross::destId_t destId, const char* inst_label, const char* var_label, unsigned chIdx, float& valueRef );
|
||||||
|
rc_t get_variable_value( handle_t h, flow_cross::destId_t destId, const char* inst_label, const char* var_label, unsigned chIdx, double& valueRef );
|
||||||
|
|
||||||
|
|
||||||
void print( handle_t h );
|
void print( handle_t h );
|
||||||
void print_network( handle_t h, flow_cross::destId_t destId );
|
void print_network( handle_t h, flow_cross::destId_t destId );
|
||||||
|
void report( handle_t h );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user