cwFlow,cwFlowDecl,cwIoPresetSelApp,cwPresetSel,ui.cfg : Added 'Dry Selected' option to cwIoPresetSelApp.

This commit is contained in:
kevin 2024-05-04 18:22:07 -04:00
parent 4ff1ec578e
commit 19e054cd6b
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 secProbFl = cwIsFlag(mps.flags, kSecPresetProbFl );
bool interpFl = cwIsFlag(mps.flags, kInterpPresetFl ); bool interpFl = cwIsFlag(mps.flags, kInterpPresetFl );
bool allFl = cwIsFlag(mps.flags, kAllowAllPresetFl); 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 // verify that the set of candidate presets is not empty
if( mps.presetN == 0 ) if( mps.presetN == 0 )

View File

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

View File

@ -89,6 +89,7 @@ namespace cw
kPresetInterpCheckId, kPresetInterpCheckId,
kPresetAllowAllCheckId, kPresetAllowAllCheckId,
kPresetDryPriorityCheckId, kPresetDryPriorityCheckId,
kPresetDrySelectedCheckId,
kEnaRecordCheckId, kEnaRecordCheckId,
@ -199,6 +200,7 @@ namespace cw
{ kPanelDivId, kPresetInterpCheckId, "presetInterpCheckId" }, { kPanelDivId, kPresetInterpCheckId, "presetInterpCheckId" },
{ kPanelDivId, kPresetAllowAllCheckId, "presetAllowAllCheckId" }, { kPanelDivId, kPresetAllowAllCheckId, "presetAllowAllCheckId" },
{ kPanelDivId, kPresetDryPriorityCheckId, "presetDryPriorityCheckId" }, { kPanelDivId, kPresetDryPriorityCheckId, "presetDryPriorityCheckId" },
{ kPanelDivId, kPresetDrySelectedCheckId, "presetDrySelectedCheckId" },
@ -935,14 +937,16 @@ namespace cw
{ {
unsigned multiPresetN = 0; unsigned multiPresetN = 0;
// allow-any-fl = pri-prob-fl && allow-any-flag // 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 allowAnyFl = cwIsFlag(app->multiPresetFlags,flow::kAllowAllPresetFl) && cwIsFlag(app->multiPresetFlags,flow::kPriPresetProbFl);
bool dryPriorityFl = cwIsFlag(app->multiPresetFlags,flow::kDryPriorityPresetFl) && 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; unsigned activePresetFlags = 0;
activePresetFlags = cwEnaFlag(activePresetFlags, preset_sel::kAllActiveFl, allowAnyFl); activePresetFlags = cwEnaFlag(activePresetFlags, preset_sel::kAllActiveFl, allowAnyFl);
activePresetFlags = cwEnaFlag(activePresetFlags, preset_sel::kDryPriorityFl, dryPriorityFl); activePresetFlags = cwEnaFlag(activePresetFlags, preset_sel::kDryPriorityFl, dryPriorityFl);
activePresetFlags = cwEnaFlag(activePresetFlags, preset_sel::kDrySelectedFl, drySelectedFl);
flow::multi_preset_selector_t mp_sel = flow::multi_preset_selector_t mp_sel =
{ .flags = app->multiPresetFlags, { .flags = app->multiPresetFlags,
@ -3028,6 +3032,12 @@ rc_t _on_ui_play_loc(app_t* app, unsigned appId, unsigned loc);
if((rc = _fragment_load_data(app)) != kOkRC ) if((rc = _fragment_load_data(app)) != kOkRC )
rc = cwLogError(rc,"Preset data restore failed."); 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); _on_live_midi_checkbox(app,app->useLiveMidiFl);
return rc; return rc;
@ -3097,10 +3107,17 @@ rc_t _on_ui_play_loc(app_t* app, unsigned appId, unsigned loc);
case kPriPresetProbCheckId: case kPriPresetProbCheckId:
app->multiPresetFlags = cwEnaFlag(app->multiPresetFlags,flow::kPriPresetProbFl,m.value->u.b); 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; break;
case kSecPresetProbCheckId: case kSecPresetProbCheckId:
app->multiPresetFlags = cwEnaFlag(app->multiPresetFlags,flow::kSecPresetProbFl,m.value->u.b); 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; break;
case kPresetInterpCheckId: case kPresetInterpCheckId:
@ -3109,12 +3126,16 @@ rc_t _on_ui_play_loc(app_t* app, unsigned appId, unsigned loc);
case kPresetAllowAllCheckId: case kPresetAllowAllCheckId:
app->multiPresetFlags = cwEnaFlag(app->multiPresetFlags,flow::kAllowAllPresetFl,m.value->u.b); 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; break;
case kPresetDryPriorityCheckId: case kPresetDryPriorityCheckId:
app->multiPresetFlags = cwEnaFlag(app->multiPresetFlags,flow::kDryPriorityPresetFl,m.value->u.b); app->multiPresetFlags = cwEnaFlag(app->multiPresetFlags,flow::kDryPriorityPresetFl,m.value->u.b);
break; break;
case kPresetDrySelectedCheckId:
app->multiPresetFlags = cwEnaFlag(app->multiPresetFlags,flow::kDrySelectedPresetFl,m.value->u.b);
break;
case kMidiThruCheckId: case kMidiThruCheckId:
cwLogInfo("MIDI thru:%i",m.value->u.b); cwLogInfo("MIDI thru:%i",m.value->u.b);
@ -3376,6 +3397,10 @@ rc_t _on_ui_play_loc(app_t* app, unsigned appId, unsigned loc);
io::uiSendValue( app->ioH, m.uuId, preset_cfg_flags(app->ioFlowH) & flow::kDryPriorityPresetFl ); io::uiSendValue( app->ioH, m.uuId, preset_cfg_flags(app->ioFlowH) & flow::kDryPriorityPresetFl );
break; break;
case kPresetDrySelectedCheckId:
io::uiSendValue( app->ioH, m.uuId, preset_cfg_flags(app->ioFlowH) & flow::kDrySelectedPresetFl );
break;
case kWetInGainId: case kWetInGainId:
_on_echo_master_value( app, preset_sel::kMasterWetInGainVarId, m.uuId ); _on_echo_master_value( app, preset_sel::kMasterWetInGainVarId, m.uuId );
break; break;

View File

@ -41,6 +41,7 @@ namespace cw
flow::preset_order_t* presetOrderA; // presetOrderA[ presetLabelN ] flow::preset_order_t* presetOrderA; // presetOrderA[ presetLabelN ]
flow::preset_order_t* multiPresetA; // activePresetA[ presetLabelN ] flow::preset_order_t* multiPresetA; // activePresetA[ presetLabelN ]
flow::preset_order_t* dryPresetOrder; // pointer to the dry preset in presetOrderA[]
alt_label_t* altLabelA; alt_label_t* altLabelA;
unsigned altLabelN; 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->presetLabelA[i].label = mem::duplStr(label);
p->presetOrderA[i].preset_label = p->presetLabelA[i].label; p->presetOrderA[i].preset_label = p->presetLabelA[i].label;
p->presetOrderA[i].order = 1; 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 ) if( p->defaultPresetIdx == kInvalidIdx )
cwLogError(kInvalidStateRC,"No default preset was set."); cwLogError(kInvalidStateRC,"No default preset was set.");
if( p->dryPresetOrder == nullptr )
rc = cwLogError(kInvalidStateRC,"The 'dry' preset was not found.");
hRef.set(p); hRef.set(p);
@ -1523,14 +1529,29 @@ const cw::flow::preset_order_t* cw::preset_sel::fragment_active_presets( handle
count_ref = 0; count_ref = 0;
// if this is a dry-only fragment and dryOnlFy is set or if all active flag is not set // Note that kAllActiveFl,kDryPriorityFl,kDrySelectedFl will only be set
if( (cwIsFlag(flags,kDryPriorityFl) && f->dryOnlyFl) || cwIsNotFlag(flags,kAllActiveFl) ) // when the preset is being selected probabilistically
preset_order = _load_active_multi_preset_array(p,f,flags,count_ref);
// 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 else
{
// if all active is set then return all presets ...
if( cwIsFlag(flags,kAllActiveFl) )
{ {
preset_order = p->presetOrderA; preset_order = p->presetOrderA;
count_ref = p->presetLabelN; 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; return preset_order;
} }
@ -1749,8 +1770,14 @@ cw::rc_t cw::preset_sel::read( handle_t h, const char* fn )
_set_alt_str( p, f, i, alt_str ); _set_alt_str( p, f, i, alt_str );
if( playFl ) if( playFl )
{
f->altPresetIdxA[0] = preset_idx; 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 // if only one preset is active and the dry preset is active
@ -1782,7 +1809,7 @@ cw::rc_t cw::preset_sel::report( handle_t h )
unsigned elapsedMs = time::elapsedMs(t0,f->endTimestamp); unsigned elapsedMs = time::elapsedMs(t0,f->endTimestamp);
double mins = elapsedMs / 60000.0; 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; return rc;
@ -1797,8 +1824,9 @@ cw::rc_t cw::preset_sel::report_presets( handle_t h )
for(; f!=nullptr; f=f->link) for(; f!=nullptr; f=f->link)
{ {
const char* dry_label = f->dryOnlyFl ? "dry" : ""; const char* dry_only_label = f->dryOnlyFl ? "only" : "";
cwLogPrint("%5i %5i %3s ",beg_loc,f->endLoc,dry_label); 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) for(unsigned i=0; i<f->presetN; ++i)
if( f->presetA[i].playFl || f->presetA[i].order!=0 ) 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); 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; unsigned endPlayLoc;
char* note; 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 preset_t* presetA; // presetA[ presetN ] - status of each preset
unsigned presetN; unsigned presetN;
@ -140,7 +142,8 @@ namespace cw
enum { enum {
kAllActiveFl = 0x01, kAllActiveFl = 0x01,
kDryPriorityFl = 0x02 kDryPriorityFl = 0x02,
kDrySelectedFl = 0x04
}; };
const flow::preset_order_t* fragment_active_presets( handle_t h, const frag_t* f, unsigned flags, unsigned& count_ref ); 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: presetInterpCheckId, title: "Interp:"},
check: { name: presetAllowAllCheckId, title: "Allow All:" }, check: { name: presetAllowAllCheckId, title: "Allow All:" },
check: { name: presetDryPriorityCheckId,title: "Dry Priority:" }, check: { name: presetDryPriorityCheckId,title: "Dry Priority:" },
check: { name: presetDrySelectedCheckId,title: "Dry Selected:" },
}, },
row: { row: {