Merge branch 'master' of gitea.larke.org:kevin/libcw
This commit is contained in:
commit
d7e15df5c7
@ -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<double,double> dobj_t;
|
||||
|
||||
template< typename T0, typename T1 >
|
||||
rc_t create( struct obj_str<T0,T1>*& 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<T0,T1>*& 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<T0,T1> >();
|
||||
|
||||
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<T0,T1>* p, double* X1m, unsigned binCnt, double thresh, double upr, double lwr )
|
||||
void _cmSpecDist2BasicMode_Original( struct obj_str<T0,T1>* p, double* X1m, unsigned binCnt, double thresh, double upr, double lwr )
|
||||
{
|
||||
|
||||
unsigned i=0;
|
||||
@ -842,6 +845,42 @@ namespace cw
|
||||
|
||||
}
|
||||
|
||||
template< typename T0, typename T1 >
|
||||
void _cmSpecDist2BasicMode( struct obj_str<T0,T1>* 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<binCnt; ++i)
|
||||
{
|
||||
double a = fabs(X1m[i]);
|
||||
double d = a - thresh;
|
||||
double curve_thresh = 3;
|
||||
|
||||
X1m[i] = -thresh;
|
||||
|
||||
if( d > 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<T0,T1>* 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;
|
||||
|
@ -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;
|
||||
|
@ -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 )
|
||||
|
@ -647,6 +647,7 @@ cw::rc_t cw::preset_sel::create_fragment( handle_t h, unsigned end_loc, time::sp
|
||||
fragIdRef = f->fragId;
|
||||
|
||||
|
||||
// intiialize the preset array elements
|
||||
for(unsigned i=0; i<p->presetLabelN; ++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);
|
||||
|
@ -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 );
|
||||
|
@ -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 },
|
||||
},
|
||||
|
||||
/*
|
||||
|
Loading…
Reference in New Issue
Block a user