cwFlowTypes.h,cwFlowProc.cpp,proc_dict.cfg : Add 'parallel' param to 'poly' proc.

This commit is contained in:
kevin 2024-09-16 08:19:09 -04:00
parent e1ebbeac6c
commit 3f9458afb2
3 changed files with 46 additions and 25 deletions

View File

@ -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<inst_t>();
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,10 +308,17 @@ namespace cw
inst_t* p = (inst_t*)proc->userPtr;
rc_t rc = kOkRC;
if( p->parallel_fl )
{
}
else
{
if((rc = exec_cycle(p->net)) != kOkRC )
{
rc = cwLogError(rc,"poly internal network exec failed.");
}
}
return rc;
}

View File

@ -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;

View File

@ -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." }
}
}