From c13a03abe5a9134c53f9a429dde1df32ee47ef7b Mon Sep 17 00:00:00 2001 From: kevin Date: Mon, 12 Dec 2022 12:24:25 -0500 Subject: [PATCH 1/4] 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; From fc379df197d3dac9a654d531f89c6e1c44dd8acd Mon Sep 17 00:00:00 2001 From: kevin Date: Mon, 12 Dec 2022 12:26:26 -0500 Subject: [PATCH 2/4] cwPresetSel.h/cpp: Changed name of is_fragment_loc() to is_fragment_end_loc(). Fixed delete_fragment() to update 'end_loc' of previous frag. to 'end_loc' of deleted frag. --- cwPresetSel.cpp | 11 +++++++++-- cwPresetSel.h | 2 +- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/cwPresetSel.cpp b/cwPresetSel.cpp index 7335b9a..7466b39 100644 --- a/cwPresetSel.cpp +++ b/cwPresetSel.cpp @@ -646,7 +646,8 @@ cw::rc_t cw::preset_sel::create_fragment( handle_t h, unsigned end_loc, time::sp // set the return value fragIdRef = f->fragId; - + + // intiialize the preset array elements for(unsigned i=0; ipresetLabelN; ++i) { f->presetA[i].preset_idx = i; @@ -719,7 +720,12 @@ cw::rc_t cw::preset_sel::delete_fragment( handle_t h, unsigned fragId ) if( f->prev == nullptr ) p->fragL = f->link; else + { + // the previous fragment's end-loc become the + // endloc of the deleted fragment + f->prev->endLoc = f->endLoc; f->prev->link = f->link; + } if( f->link != nullptr ) f->link->prev = f->prev; @@ -734,13 +740,14 @@ cw::rc_t cw::preset_sel::delete_fragment( handle_t h, unsigned fragId ) return cwLogError(kInvalidArgRC,"The fragment '%i' could not be found to delete.",fragId); } -bool cw::preset_sel::is_fragment_loc( handle_t h, unsigned loc ) +bool cw::preset_sel::is_fragment_end_loc( handle_t h, unsigned loc ) { preset_sel_t* p = _handleToPtr(h); return _loc_to_frag(p,loc) != nullptr; } + unsigned cw::preset_sel::ui_select_fragment_id( handle_t h ) { preset_sel_t* p = _handleToPtr(h); diff --git a/cwPresetSel.h b/cwPresetSel.h index e16d791..e2ae26a 100644 --- a/cwPresetSel.h +++ b/cwPresetSel.h @@ -88,7 +88,7 @@ namespace cw rc_t create_fragment( handle_t h, unsigned end_loc, time::spec_t endTimestamp, unsigned& fragIdRef ); rc_t delete_fragment( handle_t h, unsigned fragId ); - bool is_fragment_loc( handle_t h, unsigned loc ); + bool is_fragment_end_loc( handle_t h, unsigned loc ); // Return the fragment id of the 'selected' fragment. unsigned ui_select_fragment_id( handle_t h ); From 231e8810fd920b385e2dba012157ca18230a39e0 Mon Sep 17 00:00:00 2001 From: kevin Date: Mon, 12 Dec 2022 12:27:01 -0500 Subject: [PATCH 3/4] html/preset_sel/ui.cfg : Layout and label changes. --- html/preset_sel/ui.cfg | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/html/preset_sel/ui.cfg b/html/preset_sel/ui.cfg index d021305..858d9f1 100644 --- a/html/preset_sel/ui.cfg +++ b/html/preset_sel/ui.cfg @@ -47,7 +47,10 @@ row: { number:{ name: insertLocId, title:"End Loc:", min:0, max:100000, step:1, decpl:0 }, button:{ name: insertBtnId, title:"Insert", enable: false }, - button:{ name: deleteBtnId, title:"Delete", enable: false }, + }, + + row: { + button:{ name: deleteBtnId, title:"Delete Selected", enable: false }, }, /* From 1342248172c9c07add6fd2316be1c60eabedf9f8 Mon Sep 17 00:00:00 2001 From: kevin Date: Mon, 12 Dec 2022 12:28:27 -0500 Subject: [PATCH 4/4] cwIoPresetSelApp.cpp : Removed use of 'end_loc' and UI 'chanId'. Fragment delete now correctly updates UI. --- cwIoPresetSelApp.cpp | 32 ++++++++++++++++++++------------ 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/cwIoPresetSelApp.cpp b/cwIoPresetSelApp.cpp index bd8577b..24b763d 100644 --- a/cwIoPresetSelApp.cpp +++ b/cwIoPresetSelApp.cpp @@ -773,7 +773,7 @@ namespace cw unsigned fragPanelUuId; // The uiChan is the fragment endLoc - unsigned uiChanId = fragEndLoc; + unsigned uiChanId = fragId; //fragEndLoc; // Get the fragPanelUUid get_value( app->psH, fragId, preset_sel::kGuiUuIdVarId, kInvalidId, fragPanelUuId ); @@ -800,7 +800,7 @@ namespace cw rc_t _update_frag_ui(app_t* app, unsigned fragId ) { // Notes: - // uiChanId = endLoc for panel values + // uiChanId = fragId for panel values // or uiChanId = preset_index for preset values rc_t rc = kOkRC; @@ -812,7 +812,7 @@ namespace cw unsigned uValue; double dValue; const char* sValue; - unsigned uiChanId = endLoc; + unsigned uiChanId = fragId; //endLoc; unsigned fragPanelUuId = kInvalidId; get_value( app->psH, fragId, preset_sel::kGuiUuIdVarId, kInvalidId, fragPanelUuId ); @@ -1008,7 +1008,7 @@ namespace cw { rc_t rc = kOkRC; unsigned fragListUuId = io::uiFindElementUuId( app->ioH, kFragListId ); - unsigned fragChanId = endLoc; // use the frag. endLoc as the channel id + unsigned fragChanId = fragId; //endLoc; // use the frag. endLoc as the channel id unsigned fragPanelUuId = kInvalidId; unsigned fragBegLocUuId = kInvalidId; unsigned fragEndLocUuId = kInvalidId; @@ -1289,7 +1289,7 @@ namespace cw io::uiSendValue( app->ioH, endPlayLocUuId, end_play_loc); - // enable the 'End Loc' number box since the score is loaded + // enable the insert 'End Loc' number box since the score is loaded io::uiSetEnable( app->ioH, io::uiFindElementUuId( app->ioH, kInsertLocId ), true ); } @@ -1346,7 +1346,7 @@ namespace cw bool _is_valid_insert_loc( app_t* app, unsigned loc ) { bool fl0 = _find_loc(app,loc) != nullptr; - bool fl1 = preset_sel::is_fragment_loc( app->psH, loc)==false; + bool fl1 = preset_sel::is_fragment_end_loc( app->psH, loc)==false; return fl0 && fl1; } @@ -1407,7 +1407,6 @@ namespace cw return rc; } - rc_t _on_ui_insert_btn( app_t* app ) { rc_t rc = kOkRC; @@ -1430,7 +1429,7 @@ namespace cw } // verify that the end-loc is not already in use - this shouldn't be possible because the 'insert' btn should be disabled if the 'insertLoc' is not valid - if( preset_sel::is_fragment_loc( app->psH, app->insertLoc ) ) + if( preset_sel::is_fragment_end_loc( app->psH, app->insertLoc ) ) { rc = cwLogError(kInvalidIdRC,"The new fragment's 'End Loc' is already in use."); goto errLabel; @@ -1473,9 +1472,10 @@ namespace cw rc_t _on_ui_delete_btn( app_t* app ) { - rc_t rc = kOkRC; - unsigned fragId = kInvalidId; - unsigned uuId = kInvalidId; + rc_t rc = kOkRC; + unsigned fragId = kInvalidId; + unsigned uuId = kInvalidId; + const preset_sel::frag_t* f = nullptr;; // get the fragment id (uuid) of the selected (high-lighted) fragment if((fragId = preset_sel::ui_select_fragment_id(app->psH)) == kInvalidId ) @@ -1491,6 +1491,10 @@ namespace cw goto errLabel; } + // get a pointer to the fragment prior to the one to be deleted + if((f = get_fragment(app->psH,fragId)) != nullptr ) + f = f->prev; + // delete the fragment data record if((rc = preset_sel::delete_fragment(app->psH,fragId)) != kOkRC ) goto errLabel; @@ -1499,6 +1503,10 @@ namespace cw if((rc = io::uiDestroyElement( app->ioH, uuId )) != kOkRC ) goto errLabel; + // update the fragment prior to deleted fragment + if(f != nullptr ) + _update_frag_ui(app, f->fragId ); + errLabel: if( rc != kOkRC ) @@ -1826,7 +1834,7 @@ namespace cw case kInsertLocId: io::uiSetEnable( app->ioH, io::uiFindElementUuId( app->ioH, kInsertBtnId ), false ); break; - + case kFragBegPlayLocId: case kFragEndPlayLocId: _disable_frag_play_btn(app, m.uuId );