From 8af87f8d6de953f3d56698283cf98ae58fc652e4 Mon Sep 17 00:00:00 2001 From: kevin Date: Fri, 20 Dec 2024 14:24:15 -0500 Subject: [PATCH] cwFlow.h/cpp : Added send_ui_updates(). Added poly_xform_ctl,score_player,preset_select,score_follower. Added global var. release handling. --- cwFlow.cpp | 87 +++++++++++++++++++++++++++++++++++++++++++++++++++++- cwFlow.h | 8 ++++- 2 files changed, 93 insertions(+), 2 deletions(-) diff --git a/cwFlow.cpp b/cwFlow.cpp index 09086ff..ed8b5b0 100644 --- a/cwFlow.cpp +++ b/cwFlow.cpp @@ -17,10 +17,11 @@ #include "cwMidiDecls.h" #include "cwFlowDecl.h" #include "cwFlow.h" +#include "cwFlowValue.h" #include "cwFlowTypes.h" #include "cwFlowNet.h" #include "cwFlowProc.h" - +#include "cwFlowPerf.h" namespace cw { namespace flow @@ -75,6 +76,10 @@ namespace cw { "midi_split", &midi_split::members }, { "midi_file", &midi_file::members }, { "midi_merge", &midi_merge::members }, + { "poly_xform_ctl", &poly_xform_ctl::members }, + { "score_player", &score_player::members }, + { "preset_select", &preset_select::members }, + { "score_follower", &score_follower::members }, { nullptr, nullptr } }; @@ -231,6 +236,7 @@ namespace cw if((rc = vd->cfg->getv_opt("flags", var_flags_obj, "type", var_value_type_str, "value", vd->val_cfg, + "fmt", vd->fmt_cfg, "proxy", proxy_string )) != kOkRC ) { rc = cwLogError(rc,"Parsing optional fields failed."); @@ -239,11 +245,23 @@ namespace cw // convert the type string to a numeric type flag if( var_value_type_str != nullptr ) + { if( (vd->type = value_type_label_to_flag( var_value_type_str )) == kInvalidTId ) { rc = cwLogError(kSyntaxErrorRC,"Invalid variable description type flag: '%s' was encountered.", var_value_type_str ); goto errLabel; } + } + + // if this is a 'record' type with a 'fmt' specifier + if( vd->type & kRBufTFl && vd->fmt_cfg != nullptr ) + { + if((rc = recd_format_create( vd->fmt.recd_fmt, vd->fmt_cfg )) != kOkRC ) + { + rc = cwLogError(rc,"The record type associated with the 'fmt' field could not be created."); + goto errLabel; + } + } // parse the proxy string into it's two parts: . if( proxy_string != nullptr ) @@ -290,6 +308,43 @@ namespace cw return kOkRC; } + + rc_t _create_preset_list( class_preset_t*& presetL, const object_t* presetD ) + { + rc_t rc = kOkRC; + + // parse the preset dictionary + if( presetD != nullptr ) + { + if( !presetD->is_dict() ) + { + rc = cwLogError(rc,"The preset dictionary is not a dictionary." ); + goto errLabel; + } + + // for each preset in the class desc. + for(unsigned j=0; jchild_count(); ++j) + { + const object_t* pair = presetD->child_ele(j); + + if( !pair->pair_value()->is_dict() ) + { + rc = cwLogError(kSyntaxErrorRC,"The preset '%s' is not a dictionary.", cwStringNullGuard(pair->pair_label())); + goto errLabel; + } + + class_preset_t* preset = mem::allocZ< class_preset_t >(); + + preset->label = pair->pair_label(); + preset->cfg = pair->pair_value(); + preset->link = presetL; + presetL = preset; + } + } + + errLabel: + return rc; + } rc_t _parse_class_cfg(flow_t* p, const object_t* classCfg) { @@ -321,6 +376,7 @@ namespace cw goto errLabel; } + /* // parse the preset dictionary if( presetD != nullptr ) { @@ -350,6 +406,13 @@ namespace cw cd->presetL = preset; } } + */ + if((rc = _create_preset_list( cd->presetL, presetD )) != kOkRC ) + { + rc = cwLogError(rc,"The presets for the class desc: '%s' could not be parsed.",cwStringNullGuard(cd->label)); + goto errLabel; + } + // create the class descripiton if((rc = _create_class_ui_desc(cd)) != kOkRC ) @@ -743,6 +806,18 @@ namespace cw return rc; network_destroy(p->net); + + global_var_t* gv=p->globalVarL; + while( gv != nullptr ) + { + global_var_t* gv0 = gv->link; + mem::release(gv->var_label); + mem::release(gv->blob); + mem::release(gv); + gv = gv0; + } + + _release_class_desc_array(p->classDescA,p->classDescN); _release_class_desc_array(p->udpDescA,p->udpDescN); @@ -1100,6 +1175,16 @@ cw::rc_t cw::flow::exec( handle_t h ) return rc; } +cw::rc_t cw::flow::send_ui_updates( handle_t h ) +{ + rc_t rc = kOkRC; + flow_t* p = _handleToPtr(h); + + _make_flow_to_ui_callback(p); + + return rc; +} + cw::rc_t cw::flow::apply_preset( handle_t h, const char* presetLabel ) { diff --git a/cwFlow.h b/cwFlow.h index a12bce7..4c309b5 100644 --- a/cwFlow.h +++ b/cwFlow.h @@ -51,7 +51,13 @@ namespace cw rc_t exec_cycle( handle_t h ); // Run a non-real-time program to completion. - rc_t exec( handle_t h ); + rc_t exec( handle_t h ); + + // Send any pending updates to the UI. + // This happens automatically if exec() exec_cycle() is called. + // Calling this function is only necessary when the state of the + // network is changed outside of runtime. + rc_t send_ui_updates( handle_t h ); rc_t apply_preset( handle_t h, const char* presetLabel ); rc_t apply_dual_preset( handle_t h, const char* presetLabel_0, const char* presetLabel_1, double coeff );