diff --git a/cwFlowProc.cpp b/cwFlowProc.cpp index 9921484..c937d68 100644 --- a/cwFlowProc.cpp +++ b/cwFlowProc.cpp @@ -31,6 +31,8 @@ #include "cwWaveTableBank.h" +#include "cwThread.h" +#include "cwThreadMach.h" namespace cw { @@ -214,31 +216,37 @@ namespace cw { enum { + kParallelFlPId, kCountPId, - kOrderPId, }; - + typedef struct { unsigned count; network_t net; - network_order_id_t orderId; + bool parallel_fl; + thread_mach::handle_t threadMachH; } inst_t; + bool _thread_func( void* arg ) + { + + return true; + } + rc_t create( proc_t* proc ) { rc_t rc = kOkRC; inst_t* inst = mem::allocZ(); const object_t* networkCfg = nullptr; - const char* order_label = nullptr; variable_t* proxyVarL = nullptr; proc->userPtr = inst; if((rc = var_register_and_get( proc, kAnyChIdx, - kCountPId, "count", kBaseSfxId, inst->count, - kOrderPId, "order", kBaseSfxId, order_label )) != kOkRC ) + kParallelFlPId, "parallel_fl", kBaseSfxId, inst->parallel_fl, + kCountPId, "count", kBaseSfxId, inst->count )) != kOkRC ) goto errLabel; if( inst->count == 0 ) @@ -253,19 +261,6 @@ namespace cw goto errLabel; } - // get the network exec. order type - if( textIsEqual(order_label,"net") ) - inst->orderId = kNetFirstPolyOrderId; - else - { - if( textIsEqual(order_label,"proc") ) - inst->orderId = kProcFirstPolyOrderId; - else - { - rc = cwLogError(kInvalidArgRC,"'%s' is not one of the valid order types (i.e. 'net','proc').",order_label); - goto errLabel; - } - } if((rc = network_create(proc->ctx,networkCfg,inst->net,proxyVarL,inst->count)) != kOkRC ) { @@ -273,6 +268,16 @@ namespace cw goto errLabel; } + if( inst->parallel_fl ) + { + if((rc = thread_mach::create( inst->threadMachH, _thread_func, proc->net->poly_voiceA, sizeof(poly_voice_t), inst->count )) != kOkRC ) + { + rc = cwLogError(rc,"Thread machine create failed."); + goto errLabel; + } + + } + // Set the internal net pointer in the base proc instance // so that network based utilities can scan it @@ -287,8 +292,9 @@ namespace cw inst_t* p = (inst_t*)proc->userPtr; network_destroy(p->net); - + thread_mach::destroy(p->threadMachH); mem::release( proc->userPtr ); + return kOkRC; } @@ -302,9 +308,16 @@ namespace cw inst_t* p = (inst_t*)proc->userPtr; rc_t rc = kOkRC; - if((rc = exec_cycle(p->net)) != kOkRC ) + if( p->parallel_fl ) { - rc = cwLogError(rc,"poly internal network exec failed."); + + } + else + { + if((rc = exec_cycle(p->net)) != kOkRC ) + { + rc = cwLogError(rc,"poly internal network exec failed."); + } } return rc; diff --git a/cwFlowTypes.h b/cwFlowTypes.h index 657ed66..7c86e1b 100644 --- a/cwFlowTypes.h +++ b/cwFlowTypes.h @@ -317,12 +317,20 @@ namespace cw } net_global_var_t; + typedef struct poly_voice_str + { + struct network_str* net; // Network containing the proc's referened by proc_idx, proc_cnt + unsigned proc_idx; // Index into network_t.proc_array[] of first proc in voice + unsigned proc_cnt; // Count of proc's in the voice + rc_t rc; // Result code from last call to exec_cycle() + } poly_voice_t; + typedef struct network_str { const object_t* procsCfg; // network proc list const object_t* presetsCfg; // presets designed for this network - unsigned* poly_proc_idxA; // poly_proc_idxA[ poly_cnt ]. Index into proc_array[] of first proc in each network + poly_voice_t* poly_voiceA; // poly_voiceA[ poly_cnt ]. unsigned poly_cnt; // count of duplicated networks in the list struct proc_str** proc_array; diff --git a/flow/proc_dict.cfg b/flow/proc_dict.cfg index 368cfcf..8ea04d8 100644 --- a/flow/proc_dict.cfg +++ b/flow/proc_dict.cfg @@ -565,8 +565,8 @@ poly: { vars: { - count: { type:uint, doc:"Count of network duplicates." }, - order: { type:string, value:"net", doc:"Execution order 'net'=net first 'proc'=proc first" } + count: { type:uint, flags:['init'], value:1, doc:"Count of network duplicates." }, + parallel_fl: { type:bool, flags:['init'], value:false, doc:"True to run voices concurrently." } } }