From c13a03abe5a9134c53f9a429dde1df32ee47ef7b Mon Sep 17 00:00:00 2001 From: kevin Date: Mon, 12 Dec 2022 12:24:25 -0500 Subject: [PATCH] cwAudioTransforms.hcwFlowProc.cpp : Added 'bypassFl' and transform curve to specDist. --- cwAudioTransforms.h | 49 ++++++++++++++++++++++++++++++++++++++++++--- cwFlowProc.cpp | 3 +++ 2 files changed, 49 insertions(+), 3 deletions(-) diff --git a/cwAudioTransforms.h b/cwAudioTransforms.h index 7b37e15..b717e3e 100644 --- a/cwAudioTransforms.h +++ b/cwAudioTransforms.h @@ -739,6 +739,8 @@ namespace cw template< typename T0, typename T1 > struct obj_str { + bool bypassFl; + T1 ceiling; T1 expo; T1 mix; @@ -757,12 +759,13 @@ namespace cw typedef struct obj_str dobj_t; template< typename T0, typename T1 > - rc_t create( struct obj_str*& p, unsigned binN, T1 ceiling=30, T1 expo=2, T1 thresh=60, T1 uprSlope=0, T1 lwrSlope=2, T1 mix=0 ) + rc_t create( struct obj_str*& p, unsigned binN, bool bypassFl=false, T1 ceiling=30, T1 expo=2, T1 thresh=60, T1 uprSlope=0, T1 lwrSlope=2, T1 mix=0 ) { rc_t rc = kOkRC; p = mem::allocZ< struct obj_str >(); + p->bypassFl = bypassFl; p->ceiling = ceiling; p->expo = expo; p->thresh = thresh; @@ -819,7 +822,7 @@ namespace cw } template< typename T0, typename T1 > - void _cmSpecDist2BasicMode( struct obj_str* p, double* X1m, unsigned binCnt, double thresh, double upr, double lwr ) + void _cmSpecDist2BasicMode_Original( struct obj_str* p, double* X1m, unsigned binCnt, double thresh, double upr, double lwr ) { unsigned i=0; @@ -841,6 +844,42 @@ namespace cw } } + + template< typename T0, typename T1 > + void _cmSpecDist2BasicMode( struct obj_str* p, double* X1m, unsigned binCnt, double thresh, double upr, double lwr ) + { + + unsigned i=0; + + if( lwr < 0.3 ) + lwr = 0.3; + + for(i=0; i curve_thresh ) + X1m[i] -= (lwr*d); + else + { + if( d < -curve_thresh ) + X1m[i] -= (upr*d); + else + { + double a = (d+curve_thresh)/(curve_thresh*2.0); + double slope = lwr*a + upr*(1.0-a); + X1m[i] -= slope * d; + } + + } + } + + } + template< typename T0, typename T1 > rc_t exec( struct obj_str* p, const T0* magV, const T0* phsV, unsigned binN ) @@ -891,7 +930,11 @@ namespace cw } // apply the output gain - vop::mul( p->outMagV, X1m, std::min((T1)4.0,p->ogain), binN); + if( p->bypassFl ) + vop::copy( p->outMagV, magV, binN ); + else + vop::mul( p->outMagV, X1m, std::min((T1)4.0,p->ogain), binN); + vop::copy( p->outPhsV, phsV, binN); return rc; diff --git a/cwFlowProc.cpp b/cwFlowProc.cpp index e26215e..d5256c2 100644 --- a/cwFlowProc.cpp +++ b/cwFlowProc.cpp @@ -1675,6 +1675,7 @@ namespace cw enum { kInPId, + kBypassPId, kCeilingPId, kExpoPId, kThreshPId, @@ -1736,6 +1737,7 @@ namespace cw spec_dist_t* sd = inst->sdA[i]; if((rc = var_register_and_get( ctx, i, + kBypassPId, "bypass", sd->bypassFl, kCeilingPId, "ceiling", sd->ceiling, kExpoPId, "expo", sd->expo, kThreshPId, "thresh", sd->thresh, @@ -1783,6 +1785,7 @@ namespace cw switch( var->vid ) { + case kBypassPId: rc = var_get( var, val ); sd->bypassFl = val; break; case kCeilingPId: rc = var_get( var, val ); sd->ceiling = val; break; case kExpoPId: rc = var_get( var, val ); sd->expo = val; break; case kThreshPId: rc = var_get( var, val ); sd->thresh = val; break;