Merge branch 'master' of gitea.larke.org:kevin/libcw

This commit is contained in:
kevin 2024-05-11 12:12:04 -04:00
commit 32ed80183b
6 changed files with 76 additions and 17 deletions

View File

@ -1871,9 +1871,10 @@ cw::rc_t cw::flow::apply_preset( handle_t h, const multi_preset_selector_t& mps
bool secProbFl = cwIsFlag(mps.flags, kSecPresetProbFl );
bool interpFl = cwIsFlag(mps.flags, kInterpPresetFl );
bool allFl = cwIsFlag(mps.flags, kAllowAllPresetFl);
bool dryFl = cwIsFlag(mps.flags, kDryPriorityPresetFl);
bool dryPrioFl = cwIsFlag(mps.flags, kDryPriorityPresetFl);
bool drySelFl = cwIsFlag(mps.flags, kDrySelectedPresetFl);
printf("preset flags: pri:%i sec:%i interp:%i all:%i dry:%i\n",priProbFl,secProbFl,interpFl,allFl,dryFl);
printf("preset flags: pri:%i sec:%i interp:%i all:%i dry-(prio:%i sel:%i) n:%i\n",priProbFl,secProbFl,interpFl,allFl,dryPrioFl,drySelFl,mps.presetN);
// verify that the set of candidate presets is not empty
if( mps.presetN == 0 )

View File

@ -10,7 +10,8 @@ namespace cw
kSecPresetProbFl = 0x02,
kInterpPresetFl = 0x04,
kAllowAllPresetFl = 0x08,
kDryPriorityPresetFl = 0x10
kDryPriorityPresetFl = 0x10,
kDrySelectedPresetFl = 0x20,
};
typedef struct preset_order_str

View File

@ -90,6 +90,7 @@ namespace cw
kPresetInterpCheckId,
kPresetAllowAllCheckId,
kPresetDryPriorityCheckId,
kPresetDrySelectedCheckId,
kEnaRecordCheckId,
@ -202,6 +203,7 @@ namespace cw
{ kPanelDivId, kPresetInterpCheckId, "presetInterpCheckId" },
{ kPanelDivId, kPresetAllowAllCheckId, "presetAllowAllCheckId" },
{ kPanelDivId, kPresetDryPriorityCheckId, "presetDryPriorityCheckId" },
{ kPanelDivId, kPresetDrySelectedCheckId, "presetDrySelectedCheckId" },
@ -938,14 +940,16 @@ namespace cw
{
unsigned multiPresetN = 0;
// allow-any-fl = pri-prob-fl && allow-any-flag
bool allowAnyFl = cwIsFlag(app->multiPresetFlags,flow::kAllowAllPresetFl) && cwIsFlag(app->multiPresetFlags,flow::kPriPresetProbFl);
// allow-any,dry-priority,dry-selected may only be set when pri-prob is set
bool allowAnyFl = cwIsFlag(app->multiPresetFlags,flow::kAllowAllPresetFl) && cwIsFlag(app->multiPresetFlags,flow::kPriPresetProbFl);
bool dryPriorityFl = cwIsFlag(app->multiPresetFlags,flow::kDryPriorityPresetFl) && cwIsFlag(app->multiPresetFlags,flow::kPriPresetProbFl);
bool drySelectedFl = cwIsFlag(app->multiPresetFlags,flow::kDrySelectedPresetFl) && cwIsFlag(app->multiPresetFlags,flow::kPriPresetProbFl);
unsigned activePresetFlags = 0;
activePresetFlags = cwEnaFlag(activePresetFlags, preset_sel::kAllActiveFl, allowAnyFl);
activePresetFlags = cwEnaFlag(activePresetFlags, preset_sel::kDryPriorityFl, dryPriorityFl);
activePresetFlags = cwEnaFlag(activePresetFlags, preset_sel::kDrySelectedFl, drySelectedFl);
flow::multi_preset_selector_t mp_sel =
{ .flags = app->multiPresetFlags,
@ -3053,6 +3057,12 @@ rc_t _on_ui_play_loc(app_t* app, unsigned appId, unsigned loc);
if((rc = _fragment_load_data(app)) != kOkRC )
rc = cwLogError(rc,"Preset data restore failed.");
io::uiSetEnable( app->ioH, io::uiFindElementUuId( app->ioH, kPresetInterpCheckId ), false );
io::uiSetEnable( app->ioH, io::uiFindElementUuId( app->ioH, kPresetAllowAllCheckId ), false );
io::uiSetEnable( app->ioH, io::uiFindElementUuId( app->ioH, kPresetDryPriorityCheckId ), false );
io::uiSetEnable( app->ioH, io::uiFindElementUuId( app->ioH, kPresetDrySelectedCheckId ), false );
_on_live_midi_checkbox(app,app->useLiveMidiFl);
return rc;
@ -3122,10 +3132,17 @@ rc_t _on_ui_play_loc(app_t* app, unsigned appId, unsigned loc);
case kPriPresetProbCheckId:
app->multiPresetFlags = cwEnaFlag(app->multiPresetFlags,flow::kPriPresetProbFl,m.value->u.b);
io::uiSetEnable( app->ioH, io::uiFindElementUuId( app->ioH, kPresetAllowAllCheckId ), m.value->u.b );
io::uiSetEnable( app->ioH, io::uiFindElementUuId( app->ioH, kPresetDrySelectedCheckId ), m.value->u.b );
break;
case kSecPresetProbCheckId:
app->multiPresetFlags = cwEnaFlag(app->multiPresetFlags,flow::kSecPresetProbFl,m.value->u.b);
io::uiSetEnable( app->ioH, io::uiFindElementUuId( app->ioH, kPresetInterpCheckId ), m.value->u.b );
break;
case kPresetInterpCheckId:
@ -3134,12 +3151,16 @@ rc_t _on_ui_play_loc(app_t* app, unsigned appId, unsigned loc);
case kPresetAllowAllCheckId:
app->multiPresetFlags = cwEnaFlag(app->multiPresetFlags,flow::kAllowAllPresetFl,m.value->u.b);
io::uiSetEnable( app->ioH, io::uiFindElementUuId( app->ioH, kPresetDryPriorityCheckId ), m.value->u.b );
break;
case kPresetDryPriorityCheckId:
app->multiPresetFlags = cwEnaFlag(app->multiPresetFlags,flow::kDryPriorityPresetFl,m.value->u.b);
break;
case kPresetDrySelectedCheckId:
app->multiPresetFlags = cwEnaFlag(app->multiPresetFlags,flow::kDrySelectedPresetFl,m.value->u.b);
break;
case kMidiThruCheckId:
cwLogInfo("MIDI thru:%i",m.value->u.b);
@ -3404,6 +3425,10 @@ rc_t _on_ui_play_loc(app_t* app, unsigned appId, unsigned loc);
case kPresetDryPriorityCheckId:
io::uiSendValue( app->ioH, m.uuId, preset_cfg_flags(app->ioFlowH) & flow::kDryPriorityPresetFl );
break;
case kPresetDrySelectedCheckId:
io::uiSendValue( app->ioH, m.uuId, preset_cfg_flags(app->ioFlowH) & flow::kDrySelectedPresetFl );
break;
case kWetInGainId:
_on_echo_master_value( app, preset_sel::kMasterWetInGainVarId, m.uuId );

View File

@ -41,6 +41,7 @@ namespace cw
flow::preset_order_t* presetOrderA; // presetOrderA[ presetLabelN ]
flow::preset_order_t* multiPresetA; // activePresetA[ presetLabelN ]
flow::preset_order_t* dryPresetOrder; // pointer to the dry preset in presetOrderA[]
alt_label_t* altLabelA;
unsigned altLabelN;
@ -928,6 +929,9 @@ cw::rc_t cw::preset_sel::create( handle_t& hRef, const object_t* cfg )
p->presetLabelA[i].label = mem::duplStr(label);
p->presetOrderA[i].preset_label = p->presetLabelA[i].label;
p->presetOrderA[i].order = 1;
if( textIsEqual(p->presetOrderA[i].preset_label,"dry") )
p->dryPresetOrder = p->presetOrderA + i;
}
@ -964,6 +968,8 @@ cw::rc_t cw::preset_sel::create( handle_t& hRef, const object_t* cfg )
if( p->defaultPresetIdx == kInvalidIdx )
cwLogError(kInvalidStateRC,"No default preset was set.");
if( p->dryPresetOrder == nullptr )
rc = cwLogError(kInvalidStateRC,"The 'dry' preset was not found.");
hRef.set(p);
@ -1536,13 +1542,28 @@ const cw::flow::preset_order_t* cw::preset_sel::fragment_active_presets( handle
count_ref = 0;
// if this is a dry-only fragment and dryOnlFy is set or if all active flag is not set
if( (cwIsFlag(flags,kDryPriorityFl) && f->dryOnlyFl) || cwIsNotFlag(flags,kAllActiveFl) )
preset_order = _load_active_multi_preset_array(p,f,flags,count_ref);
// Note that kAllActiveFl,kDryPriorityFl,kDrySelectedFl will only be set
// when the preset is being selected probabilistically
// if this fragment is dry-selected or dry-only and the associated flags are set
// then select then return the 'dry' preset
if( (cwIsFlag(flags,kDrySelectedFl) && f->drySelectedFl) || (cwIsFlag(flags,kDryPriorityFl) && f->dryOnlyFl) )
{
preset_order = p->dryPresetOrder;
count_ref = 1;
}
else
{
preset_order = p->presetOrderA;
count_ref = p->presetLabelN;
// if all active is set then return all presets ...
if( cwIsFlag(flags,kAllActiveFl) )
{
preset_order = p->presetOrderA;
count_ref = p->presetLabelN;
}
else // ... otherwise return the active presets only
{
preset_order = _load_active_multi_preset_array(p,f,flags,count_ref);
}
}
return preset_order;
@ -1762,12 +1783,18 @@ cw::rc_t cw::preset_sel::read( handle_t h, const char* fn )
_set_alt_str( p, f, i, alt_str );
if( playFl )
{
f->altPresetIdxA[0] = preset_idx;
// if the dry preset is selected
if( preset_idx == dryPresetIdx )
f->drySelectedFl = true;
}
}
// if only one preset is active and the dry preset is active
f->dryOnlyFl = activePresetN==1 && (f->presetA[dryPresetIdx].order>0 || f->presetA[dryPresetIdx].playFl);
f->dryOnlyFl = activePresetN==1 && (f->presetA[dryPresetIdx].order>0 || f->presetA[dryPresetIdx].playFl);
}
@ -1795,7 +1822,7 @@ cw::rc_t cw::preset_sel::report( handle_t h )
unsigned elapsedMs = time::elapsedMs(t0,f->endTimestamp);
double mins = elapsedMs / 60000.0;
cwLogInfo("%3i id:%3i end loc:%3i end min:%f dry-only:%i",i,f->fragId,f->endLoc, mins, f->dryOnlyFl);
cwLogInfo("%3i id:%3i end loc:%3i end min:%f dry-only:%i dry-sel:%i",i,f->fragId,f->endLoc, mins, f->dryOnlyFl, f->drySelectedFl);
}
return rc;
@ -1810,8 +1837,9 @@ cw::rc_t cw::preset_sel::report_presets( handle_t h )
for(; f!=nullptr; f=f->link)
{
const char* dry_label = f->dryOnlyFl ? "dry" : "";
cwLogPrint("%5i %5i %3s ",beg_loc,f->endLoc,dry_label);
const char* dry_only_label = f->dryOnlyFl ? "only" : "";
const char* dry_sel_label = f->drySelectedFl ? "sel" : "";
cwLogPrint("%5i %5i dry-(%4s %3s)",beg_loc,f->endLoc,dry_only_label,dry_sel_label);
for(unsigned i=0; i<f->presetN; ++i)
if( f->presetA[i].playFl || f->presetA[i].order!=0 )
cwLogPrint("(%s-%i) ", p->presetLabelA[ f->presetA[i].preset_idx ].label, f->presetA[i].order);

View File

@ -32,7 +32,9 @@ namespace cw
unsigned endPlayLoc;
char* note;
bool dryOnlyFl;
bool dryOnlyFl; // there is one active preset and it is dry
bool drySelectedFl; // the dry preset was selected ('playFl' is set)
preset_t* presetA; // presetA[ presetN ] - status of each preset
unsigned presetN;
@ -140,8 +142,9 @@ namespace cw
unsigned fragment_seq_count( handle_t h, unsigned fragId );
enum {
kAllActiveFl = 0x01,
kDryPriorityFl = 0x02
kAllActiveFl = 0x01,
kDryPriorityFl = 0x02,
kDrySelectedFl = 0x04
};
const flow::preset_order_t* fragment_active_presets( handle_t h, const frag_t* f, unsigned flags, unsigned& count_ref );

View File

@ -29,6 +29,7 @@
check: { name: presetInterpCheckId, title: "Interp:"},
check: { name: presetAllowAllCheckId, title: "Allow All:" },
check: { name: presetDryPriorityCheckId,title: "Dry Priority:" },
check: { name: presetDrySelectedCheckId,title: "Dry Selected:" },
},
row: {