cwFlowType.h/cpp : Convert fbuf_t binN and hopSmpN_V to vectors.

This commit is contained in:
kevin 2022-11-11 13:51:06 -05:00
parent c1a0e7708b
commit df3a948608
2 changed files with 33 additions and 18 deletions

View File

@ -175,7 +175,11 @@ namespace cw
if( v->u.fbuf == nullptr ) if( v->u.fbuf == nullptr )
printf("fbuf: <null>"); printf("fbuf: <null>");
else 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; i<v->u.fbuf->chN; ++i)
printf("(binN:%i hopSmpN:%i) ", v->u.fbuf->binN_V[i], v->u.fbuf->hopSmpN_V[i] );
}
break; break;
case kBoolMtxTFl: case kBoolMtxTFl:
@ -907,17 +911,23 @@ cw::flow::fbuf_t* cw::flow::fbuf_create( srate_t srate, unsigned chN, unsigned
f->srate = srate; f->srate = srate;
f->chN = chN; f->chN = chN;
f->binN = binN; f->binN_V = mem::allocZ<unsigned>(chN);;
f->hopSmpN = hopSmpN; f->hopSmpN_V = mem::allocZ<unsigned>(chN);
f->magV = mem::allocZ<sample_t*>(chN); f->magV = mem::allocZ<sample_t*>(chN);
f->phsV = mem::allocZ<sample_t*>(chN); f->phsV = mem::allocZ<sample_t*>(chN);
f->hzV = mem::allocZ<sample_t*>(chN); f->hzV = mem::allocZ<sample_t*>(chN);
f->readyFlV= mem::allocZ<bool>(chN); f->readyFlV= mem::allocZ<bool>(chN);
for(unsigned chIdx=0; chIdx<chN; ++chIdx)
{
f->binN_V[chIdx] = binN;
f->hohpSmpN_V[chIdx] = hopSmpN;
}
if( magV != nullptr || phsV != nullptr || hzV != nullptr ) if( magV != nullptr || phsV != nullptr || hzV != nullptr )
{ {
for(unsigned chIdx=0; chIdx<chN; ++chIdx) for(unsigned chIdx=0; chIdx<chN; ++chIdx)
{ {
f->magV[ chIdx ] = (sample_t*)magV[chIdx]; f->magV[ chIdx ] = (sample_t*)magV[chIdx];
f->phsV[ chIdx ] = (sample_t*)phsV[chIdx]; f->phsV[ chIdx ] = (sample_t*)phsV[chIdx];
f->hzV[ chIdx ] = (sample_t*)hzV[chIdx]; f->hzV[ chIdx ] = (sample_t*)hzV[chIdx];
@ -945,7 +955,9 @@ void cw::flow::fbuf_destroy( fbuf_t*& fbuf )
{ {
if( fbuf == nullptr ) if( fbuf == nullptr )
return; return;
mem::release( fbuf->binN_V );
mem::release( fbuf->hopSmpN_V);
mem::release( fbuf->magV); mem::release( fbuf->magV);
mem::release( fbuf->phsV); mem::release( fbuf->phsV);
mem::release( fbuf->hzV); 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 ); fbuf_t* fbuf = fbuf_create( src->srate, src->chN, src->binN, src->hopSmpN );
for(unsigned i=0; i<fbuf->chN; ++i) for(unsigned i=0; i<fbuf->chN; ++i)
{ {
vop::copy( fbuf->magV[i], src->magV[i], fbuf->binN ); fbuf->binN_V[i] = src->binN_V[i];
vop::copy( fbuf->phsV[i], src->phsV[i], fbuf->binN ); fbuf->hopSmpN_V[i] = src->hopSmpN_V[i];
vop::copy( fbuf->hzV[i], src->hzV[i], fbuf->binN );
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; return fbuf;
} }

View File

@ -32,16 +32,16 @@ namespace cw
typedef struct fbuf_str typedef struct fbuf_str
{ {
struct value_str* base; struct value_str* base;
srate_t srate; // signal sample rate srate_t srate; // signal sample rate
unsigned flags; // See kXXXFbufFl unsigned flags; // See kXXXFbufFl
unsigned chN; // count of channels unsigned chN; // count of channels
unsigned binN; // count of sample frames per channel unsigned* binN_V; // binN_V[ chN ] count of sample frames per channel
unsigned hopSmpN; // hop sample count unsigned* hopSmpN_V; // hopSmpN_V[ chN ] hop sample count
sample_t** magV; // magV[ chN ][ binN ] sample_t** magV; // magV[ chN ][ binN ]
sample_t** phsV; // phsV[ chN ][ binN ] sample_t** phsV; // phsV[ chN ][ binN ]
sample_t** hzV; // hzV[ 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) 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) sample_t* buf; // memory used by this buffer (or NULL if magV,phsV,hzV point are proxied to another buffer)
} fbuf_t; } fbuf_t;
enum enum