From df3a948608c3178c78ea97f44a7efc26253a51cd Mon Sep 17 00:00:00 2001 From: kevin Date: Fri, 11 Nov 2022 13:51:06 -0500 Subject: [PATCH] cwFlowType.h/cpp : Convert fbuf_t binN and hopSmpN_V to vectors. --- cwFlowTypes.cpp | 31 +++++++++++++++++++++++-------- cwFlowTypes.h | 20 ++++++++++---------- 2 files changed, 33 insertions(+), 18 deletions(-) diff --git a/cwFlowTypes.cpp b/cwFlowTypes.cpp index 75a6615..ace8ea1 100644 --- a/cwFlowTypes.cpp +++ b/cwFlowTypes.cpp @@ -175,7 +175,11 @@ namespace cw if( v->u.fbuf == nullptr ) printf("fbuf: "); else - printf("fbuf: chN:%i binN:%i hopSmpN:%i srate:%8.1f", v->u.fbuf->chN, v->u.fbuf->binN, v->u.fbuf->hopSmpN, v->u.fbuf->srate ); + { + printf("fbuf: chN:%i srate:%8.1f ", v->u.fbuf->chN, v->u.fbuf->srate ); + for(unsigned i; iu.fbuf->chN; ++i) + printf("(binN:%i hopSmpN:%i) ", v->u.fbuf->binN_V[i], v->u.fbuf->hopSmpN_V[i] ); + } break; case kBoolMtxTFl: @@ -907,17 +911,23 @@ cw::flow::fbuf_t* cw::flow::fbuf_create( srate_t srate, unsigned chN, unsigned f->srate = srate; f->chN = chN; - f->binN = binN; - f->hopSmpN = hopSmpN; + f->binN_V = mem::allocZ(chN);; + f->hopSmpN_V = mem::allocZ(chN); f->magV = mem::allocZ(chN); f->phsV = mem::allocZ(chN); f->hzV = mem::allocZ(chN); f->readyFlV= mem::allocZ(chN); + for(unsigned chIdx=0; chIdxbinN_V[chIdx] = binN; + f->hohpSmpN_V[chIdx] = hopSmpN; + } + if( magV != nullptr || phsV != nullptr || hzV != nullptr ) { for(unsigned chIdx=0; chIdxmagV[ chIdx ] = (sample_t*)magV[chIdx]; f->phsV[ chIdx ] = (sample_t*)phsV[chIdx]; f->hzV[ chIdx ] = (sample_t*)hzV[chIdx]; @@ -945,7 +955,9 @@ void cw::flow::fbuf_destroy( fbuf_t*& fbuf ) { if( fbuf == nullptr ) return; - + + mem::release( fbuf->binN_V ); + mem::release( fbuf->hopSmpN_V); mem::release( fbuf->magV); mem::release( fbuf->phsV); mem::release( fbuf->hzV); @@ -959,9 +971,12 @@ cw::flow::fbuf_t* cw::flow::fbuf_duplicate( const fbuf_t* src ) fbuf_t* fbuf = fbuf_create( src->srate, src->chN, src->binN, src->hopSmpN ); for(unsigned i=0; ichN; ++i) { - vop::copy( fbuf->magV[i], src->magV[i], fbuf->binN ); - vop::copy( fbuf->phsV[i], src->phsV[i], fbuf->binN ); - vop::copy( fbuf->hzV[i], src->hzV[i], fbuf->binN ); + fbuf->binN_V[i] = src->binN_V[i]; + fbuf->hopSmpN_V[i] = src->hopSmpN_V[i]; + + vop::copy( fbuf->magV[i], src->magV[i], fbuf->binN_V[i] ); + vop::copy( fbuf->phsV[i], src->phsV[i], fbuf->binN_V[i] ); + vop::copy( fbuf->hzV[i], src->hzV[i], fbuf->binN_V[i] ); } return fbuf; } diff --git a/cwFlowTypes.h b/cwFlowTypes.h index 7d524b8..8da2247 100644 --- a/cwFlowTypes.h +++ b/cwFlowTypes.h @@ -32,16 +32,16 @@ namespace cw typedef struct fbuf_str { struct value_str* base; - srate_t srate; // signal sample rate - unsigned flags; // See kXXXFbufFl - unsigned chN; // count of channels - unsigned binN; // count of sample frames per channel - unsigned hopSmpN; // hop sample count - sample_t** magV; // magV[ chN ][ binN ] - sample_t** phsV; // phsV[ chN ][ binN ] - 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) - sample_t* buf; // memory used by this buffer (or NULL if magV,phsV,hzV point are proxied to another buffer) + srate_t srate; // signal sample rate + unsigned flags; // See kXXXFbufFl + unsigned chN; // count of channels + unsigned* binN_V; // binN_V[ chN ] count of sample frames per channel + unsigned* hopSmpN_V; // hopSmpN_V[ chN ] hop sample count + sample_t** magV; // magV[ chN ][ binN ] + sample_t** phsV; // phsV[ chN ][ binN ] + 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) + sample_t* buf; // memory used by this buffer (or NULL if magV,phsV,hzV point are proxied to another buffer) } fbuf_t; enum