cwIoPresetSelApp.cpp,cwPresetSel.h/cpp,ui.cfg,cwFlowDecl.h : Added 'Allow All' for uniform prob. preset selection. Add 'loc location' flag to UI.

This commit is contained in:
kevin 2024-03-09 15:12:56 -05:00
parent 63faf6a6d2
commit 2d0c59a8fa
5 changed files with 110 additions and 30 deletions

View File

@ -8,7 +8,8 @@ namespace cw
enum { enum {
kPriPresetProbFl = 0x01, kPriPresetProbFl = 0x01,
kSecPresetProbFl = 0x02, kSecPresetProbFl = 0x02,
kInterpPresetFl = 0x04 kInterpPresetFl = 0x04,
kAllowAllPresetFl = 0x08
}; };
typedef struct preset_order_str typedef struct preset_order_str

View File

@ -54,6 +54,9 @@ namespace cw
kStartBtnId, kStartBtnId,
kStopBtnId, kStopBtnId,
kBegPlayLocNumbId,
kEndPlayLocNumbId,
kLockLoctnCheckId,
kLiveCheckId, kLiveCheckId,
kTrackMidiCheckId, kTrackMidiCheckId,
@ -81,6 +84,7 @@ namespace cw
kPriPresetProbCheckId, kPriPresetProbCheckId,
kSecPresetProbCheckId, kSecPresetProbCheckId,
kPresetInterpCheckId, kPresetInterpCheckId,
kPresetAllowAllCheckId,
kEnaRecordCheckId, kEnaRecordCheckId,
@ -90,8 +94,6 @@ namespace cw
kSfResetBtnId, kSfResetBtnId,
kSfResetLocNumbId, kSfResetLocNumbId,
kBegPlayLocNumbId,
kEndPlayLocNumbId,
kInsertLocId, kInsertLocId,
kInsertBtnId, kInsertBtnId,
@ -159,6 +161,9 @@ namespace cw
{ kPanelDivId, kStartBtnId, "startBtnId" }, { kPanelDivId, kStartBtnId, "startBtnId" },
{ kPanelDivId, kStopBtnId, "stopBtnId" }, { kPanelDivId, kStopBtnId, "stopBtnId" },
{ kPanelDivId, kBegPlayLocNumbId, "begLocNumbId" },
{ kPanelDivId, kEndPlayLocNumbId, "endLocNumbId" },
{ kPanelDivId, kLockLoctnCheckId, "locLoctnCheckId" },
{ kPanelDivId, kLiveCheckId, "liveCheckId" }, { kPanelDivId, kLiveCheckId, "liveCheckId" },
{ kPanelDivId, kTrackMidiCheckId, "trackMidiCheckId" }, { kPanelDivId, kTrackMidiCheckId, "trackMidiCheckId" },
@ -182,9 +187,11 @@ namespace cw
{ kPanelDivId, kLoadBtnId, "loadBtnId" }, { kPanelDivId, kLoadBtnId, "loadBtnId" },
{ kPanelDivId, kPerfSelId, "perfSelId" }, { kPanelDivId, kPerfSelId, "perfSelId" },
{ kPanelDivId, kAltSelId, "altSelId" }, { kPanelDivId, kAltSelId, "altSelId" },
{ kPanelDivId, kPriPresetProbCheckId, "presetProbPriCheckId" }, { kPanelDivId, kPriPresetProbCheckId, "presetProbPriCheckId" },
{ kPanelDivId, kSecPresetProbCheckId, "presetProbSecCheckId" }, { kPanelDivId, kSecPresetProbCheckId, "presetProbSecCheckId" },
{ kPanelDivId, kPresetInterpCheckId, "presetInterpCheckId" }, { kPanelDivId, kPresetInterpCheckId, "presetInterpCheckId" },
{ kPanelDivId, kPresetAllowAllCheckId, "presetAllowAllCheckId" },
{ kPanelDivId, kEnaRecordCheckId, "enaRecordCheckId" }, { kPanelDivId, kEnaRecordCheckId, "enaRecordCheckId" },
{ kPanelDivId, kMidiSaveBtnId, "midiSaveBtnId" }, { kPanelDivId, kMidiSaveBtnId, "midiSaveBtnId" },
@ -193,8 +200,6 @@ namespace cw
{ kPanelDivId, kSfResetBtnId, "sfResetBtnId" }, { kPanelDivId, kSfResetBtnId, "sfResetBtnId" },
{ kPanelDivId, kSfResetLocNumbId, "sfResetLocNumbId" }, { kPanelDivId, kSfResetLocNumbId, "sfResetLocNumbId" },
{ kPanelDivId, kBegPlayLocNumbId, "begLocNumbId" },
{ kPanelDivId, kEndPlayLocNumbId, "endLocNumbId" },
{ kPanelDivId, kInsertLocId, "insertLocId" }, { kPanelDivId, kInsertLocId, "insertLocId" },
{ kPanelDivId, kInsertBtnId, "insertBtnId" }, { kPanelDivId, kInsertBtnId, "insertBtnId" },
@ -318,6 +323,7 @@ namespace cw
unsigned beg_play_loc; // beg/end play loc's from the UI unsigned beg_play_loc; // beg/end play loc's from the UI
unsigned end_play_loc; unsigned end_play_loc;
bool lockLoctnFl;
preset_sel::handle_t psH; preset_sel::handle_t psH;
const preset_sel::frag_t* psNextFrag; const preset_sel::frag_t* psNextFrag;
@ -363,6 +369,10 @@ namespace cw
perf_recording_t* perfRecordingBeg; perf_recording_t* perfRecordingBeg;
perf_recording_t* perfRecordingEnd; perf_recording_t* perfRecordingEnd;
const char* dflt_perf_label;
unsigned dflt_perf_app_id;
} app_t; } app_t;
@ -435,6 +445,7 @@ namespace cw
"crossFadeCount", app->crossFadeCnt, "crossFadeCount", app->crossFadeCnt,
"beg_play_loc", app->beg_play_loc, "beg_play_loc", app->beg_play_loc,
"end_play_loc", app->end_play_loc, "end_play_loc", app->end_play_loc,
"dflt_perf_label", app->dflt_perf_label,
"live_mode_fl", app->useLiveMidiFl, "live_mode_fl", app->useLiveMidiFl,
"enable_recording_fl", app->enableRecordFl, "enable_recording_fl", app->enableRecordFl,
"midi_record_dir", midi_record_dir, "midi_record_dir", midi_record_dir,
@ -612,6 +623,13 @@ namespace cw
goto errLabel; goto errLabel;
} }
if( app->dflt_perf_label )
if( textIsEqual(prp->label,app->dflt_perf_label) )
{
app->dflt_perf_app_id = kPerfOptionBaseId+id;
cwLogInfo("The default performance '%s' was found.",prp->label);
}
prp->id = id; prp->id = id;
id += 1; id += 1;
} }
@ -915,14 +933,14 @@ namespace cw
.coeffMinV = score_evt->featMinV, .coeffMinV = score_evt->featMinV,
.coeffMaxV = score_evt->featMaxV, .coeffMaxV = score_evt->featMaxV,
.coeffN = perf_meas::kValCnt, .coeffN = perf_meas::kValCnt,
.presetA = frag->multiPresetA, .presetA = cwIsFlag(app->multiPresetFlags,flow::kAllowAllPresetFl) ? preset_order_array(app->psH) : frag->multiPresetA,
.presetN = frag->multiPresetN .presetN = cwIsFlag(app->multiPresetFlags,flow::kAllowAllPresetFl) ? preset_count(app->psH) : frag->multiPresetN
}; };
if( app->ioFlowH.isValid() ) if( app->ioFlowH.isValid() )
apply_rc = io_flow::apply_preset( app->ioFlowH, flow_cross::kNextDestId, mp_sel ); apply_rc = io_flow::apply_preset( app->ioFlowH, flow_cross::kNextDestId, mp_sel );
preset_label = mp_sel.presetN>0 && mp_sel.presetA[0].preset_label!=nullptr ? mp_sel.presetA[0].preset_label : nullptr; preset_label = "(multi)"; //mp_sel.presetN>0 && mp_sel.presetA[0].preset_label!=nullptr ? mp_sel.presetA[0].preset_label : nullptr;
preset_type_label = "multi"; preset_type_label = "multi";
@ -945,10 +963,10 @@ namespace cw
// don't display preset updates unless the score is actually loaded // don't display preset updates unless the score is actually loaded
printf("Apply %s preset: '%s' : loc:%i status:%i\n", preset_type_label, preset_label==nullptr ? "<invalid>" : preset_label, loc, apply_rc ); printf("Apply %s preset: '%s' : loc:%i status:%i\n", preset_type_label, preset_label==nullptr ? "<invalid>" : preset_label, loc, apply_rc );
_set_status(app,"Apply %s preset: '%s'.", preset_type_label, preset_label==nullptr ? "<invalid>" : preset_label);
} }
_set_status(app,"Apply %s preset: '%s'.", preset_type_label, preset_label==nullptr ? "<invalid>" : preset_label);
// apply the fragment defined gain settings // apply the fragment defined gain settings
if( app->ioFlowH.isValid() ) if( app->ioFlowH.isValid() )
@ -1900,6 +1918,10 @@ namespace cw
return rc; return rc;
} }
rc_t _on_perf_select(app_t* app, unsigned optionAppId );
rc_t _on_ui_play_loc(app_t* app, unsigned appId, unsigned loc);
rc_t _fragment_restore_ui( app_t* app ) rc_t _fragment_restore_ui( app_t* app )
{ {
@ -1937,6 +1959,24 @@ namespace cw
cwLogInfo("Fragment restore complete: elapsed secs:%f",time::elapsedSecs(app->psLoadT0)); cwLogInfo("Fragment restore complete: elapsed secs:%f",time::elapsedSecs(app->psLoadT0));
io::uiRealTimeReport(app->ioH); io::uiRealTimeReport(app->ioH);
/*
if( app->dflt_perf_app_id != kInvalidId )
{
uiSendValue( app->ioH, io::uiFindElementUuId(app->ioH, kPerfSelId), app->dflt_perf_app_id );
_on_perf_select(app, app->dflt_perf_app_id );
uiSendValue( app->ioH, io::uiFindElementUuId(app->ioH, kBegPlayLocNumbId), 2538 );
uiSendValue( app->ioH, io::uiFindElementUuId(app->ioH, kEndPlayLocNumbId), 3517 );
_on_ui_play_loc(app, kBegPlayLocNumbId, 2538);
_on_ui_play_loc(app, kBegPlayLocNumbId, 3517);
}
*/
} }
} }
@ -2178,8 +2218,11 @@ namespace cw
rc_t _do_load_perf_score( app_t* app, const char* perf_fn, const vel_tbl_t* vtA=nullptr, unsigned vtN=0 ) rc_t _do_load_perf_score( app_t* app, const char* perf_fn, const vel_tbl_t* vtA=nullptr, unsigned vtN=0 )
{ {
rc_t rc = kOkRC; rc_t rc = kOkRC;
unsigned midiEventN = 0; unsigned midiEventN = 0;
// only lock the current beg/end location settings if a valid perf. score is already loaded
bool lockLoctnFl = app->perfScoreH.isValid() && app->lockLoctnFl;
cwLogInfo("Loading"); cwLogInfo("Loading");
_set_status(app,"Loading..."); _set_status(app,"Loading...");
@ -2208,6 +2251,7 @@ namespace cw
// A performance is loaded so enable the UI // A performance is loaded so enable the UI
io::uiSetEnable( app->ioH, io::uiFindElementUuId( app->ioH, kStartBtnId ), true ); io::uiSetEnable( app->ioH, io::uiFindElementUuId( app->ioH, kStartBtnId ), true );
io::uiSetEnable( app->ioH, io::uiFindElementUuId( app->ioH, kStopBtnId ), true ); io::uiSetEnable( app->ioH, io::uiFindElementUuId( app->ioH, kStopBtnId ), true );
io::uiSetEnable( app->ioH, io::uiFindElementUuId( app->ioH, kLockLoctnCheckId ), true );
io::uiSetEnable( app->ioH, io::uiFindElementUuId( app->ioH, kLiveCheckId ), true ); io::uiSetEnable( app->ioH, io::uiFindElementUuId( app->ioH, kLiveCheckId ), true );
io::uiSetEnable( app->ioH, io::uiFindElementUuId( app->ioH, kEnaRecordCheckId ), true ); io::uiSetEnable( app->ioH, io::uiFindElementUuId( app->ioH, kEnaRecordCheckId ), true );
io::uiSetEnable( app->ioH, io::uiFindElementUuId( app->ioH, kTrackMidiCheckId ), true ); io::uiSetEnable( app->ioH, io::uiFindElementUuId( app->ioH, kTrackMidiCheckId ), true );
@ -2215,9 +2259,12 @@ namespace cw
io::uiSetEnable( app->ioH, io::uiFindElementUuId( app->ioH, kInsertLocId ), true ); io::uiSetEnable( app->ioH, io::uiFindElementUuId( app->ioH, kInsertLocId ), true );
// set the UI begin/end play to the locations of the newly loaded performance // set the UI begin/end play to the locations of the newly loaded performance
app->end_play_loc = app->maxPerfLoc; if( !lockLoctnFl )
app->beg_play_loc = app->minPerfLoc; {
app->end_play_loc = app->maxPerfLoc;
app->beg_play_loc = app->minPerfLoc;
}
// Update the master range of the play beg/end number widgets // Update the master range of the play beg/end number widgets
io::uiSetNumbRange( app->ioH, io::uiFindElementUuId(app->ioH, kBegPlayLocNumbId), app->minPerfLoc, app->maxPerfLoc, 1, 0, app->beg_play_loc ); io::uiSetNumbRange( app->ioH, io::uiFindElementUuId(app->ioH, kBegPlayLocNumbId), app->minPerfLoc, app->maxPerfLoc, 1, 0, app->beg_play_loc );
io::uiSetNumbRange( app->ioH, io::uiFindElementUuId(app->ioH, kEndPlayLocNumbId), app->minPerfLoc, app->maxPerfLoc, 1, 0, app->end_play_loc ); io::uiSetNumbRange( app->ioH, io::uiFindElementUuId(app->ioH, kEndPlayLocNumbId), app->minPerfLoc, app->maxPerfLoc, 1, 0, app->end_play_loc );
@ -3024,7 +3071,12 @@ namespace cw
case kPresetInterpCheckId: case kPresetInterpCheckId:
app->multiPresetFlags = cwEnaFlag(app->multiPresetFlags,flow::kInterpPresetFl,m.value->u.b); app->multiPresetFlags = cwEnaFlag(app->multiPresetFlags,flow::kInterpPresetFl,m.value->u.b);
break; break;
case kPresetAllowAllCheckId:
app->multiPresetFlags = cwEnaFlag(app->multiPresetFlags,flow::kAllowAllPresetFl,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);
_set_midi_thru_state(app, m.value->u.b); _set_midi_thru_state(app, m.value->u.b);
@ -3037,6 +3089,18 @@ namespace cw
case kStopBtnId: case kStopBtnId:
_do_stop_play(app); _do_stop_play(app);
break; break;
case kBegPlayLocNumbId:
_on_ui_play_loc(app, m.appId, m.value->u.i);
break;
case kEndPlayLocNumbId:
_on_ui_play_loc(app, m.appId, m.value->u.i);
break;
case kLockLoctnCheckId:
app->lockLoctnFl = m.value->u.b;
break;
case kLiveCheckId: case kLiveCheckId:
_on_live_midi_checkbox(app, m.value->u.b ); _on_live_midi_checkbox(app, m.value->u.b );
@ -3074,14 +3138,6 @@ namespace cw
_on_master_value( app, "sync_delay","delayMs",preset_sel::kMasterSyncDelayMsVarId, (double)m.value->u.i ); _on_master_value( app, "sync_delay","delayMs",preset_sel::kMasterSyncDelayMsVarId, (double)m.value->u.i );
break; break;
case kBegPlayLocNumbId:
_on_ui_play_loc(app, m.appId, m.value->u.i);
break;
case kEndPlayLocNumbId:
_on_ui_play_loc(app, m.appId, m.value->u.i);
break;
case kInsertLocId: case kInsertLocId:
_on_ui_insert_loc(app, m.value->u.u ); _on_ui_insert_loc(app, m.value->u.u );
break; break;
@ -3272,6 +3328,10 @@ namespace cw
case kPresetInterpCheckId: case kPresetInterpCheckId:
io::uiSendValue( app->ioH, m.uuId, preset_cfg_flags(app->ioFlowH) & flow::kInterpPresetFl ); io::uiSendValue( app->ioH, m.uuId, preset_cfg_flags(app->ioFlowH) & flow::kInterpPresetFl );
break; break;
case kPresetAllowAllCheckId:
io::uiSendValue( app->ioH, m.uuId, preset_cfg_flags(app->ioFlowH) & flow::kAllowAllPresetFl );
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 );
@ -3300,7 +3360,7 @@ namespace cw
case kLiveCheckId: case kLiveCheckId:
io::uiSendValue( app->ioH, m.uuId, app->useLiveMidiFl ); io::uiSendValue( app->ioH, m.uuId, app->useLiveMidiFl );
break; break;
case kTrackMidiCheckId: case kTrackMidiCheckId:
io::uiSendValue( app->ioH, m.uuId, app->trackMidiFl ); io::uiSendValue( app->ioH, m.uuId, app->trackMidiFl );
break; break;
@ -3514,7 +3574,8 @@ cw::rc_t cw::preset_sel_app::main( const object_t* cfg, int argc, const char* ar
.sdUpr = -1.1, .sdUpr = -1.1,
.sdLwr = 2.0, .sdLwr = 2.0,
.sdMix = 0.0, .sdMix = 0.0,
.cmpBypassFl = false .cmpBypassFl = false,
.dflt_perf_app_id = kInvalidId
}; };
const object_t* params_cfg = nullptr; const object_t* params_cfg = nullptr;

View File

@ -38,6 +38,8 @@ namespace cw
{ {
preset_label_t* presetLabelA; preset_label_t* presetLabelA;
unsigned presetLabelN; unsigned presetLabelN;
flow::preset_order_t* presetOrderA; // presetOrderA[ presetLabelN ]
alt_label_t* altLabelA; alt_label_t* altLabelA;
unsigned altLabelN; unsigned altLabelN;
@ -60,6 +62,7 @@ namespace cw
unsigned sel_frag_id; // fragment id assoc'd with last selected frag. ui element unsigned sel_frag_id; // fragment id assoc'd with last selected frag. ui element
unsigned cur_alt_idx; unsigned cur_alt_idx;
} preset_sel_t; } preset_sel_t;
@ -144,7 +147,8 @@ namespace cw
for(unsigned i=0; i<p->presetLabelN; ++i) for(unsigned i=0; i<p->presetLabelN; ++i)
mem::release( p->presetLabelA[i].label ); mem::release( p->presetLabelA[i].label );
mem::release( p->presetLabelA ); mem::release( p->presetLabelA );
mem::release( p->presetOrderA );
for(unsigned i=0; i<p->altLabelN; ++i) for(unsigned i=0; i<p->altLabelN; ++i)
mem::release( p->altLabelA[i].label ); mem::release( p->altLabelA[i].label );
mem::release( p->altLabelA ); mem::release( p->altLabelA );
@ -857,6 +861,7 @@ cw::rc_t cw::preset_sel::create( handle_t& hRef, const object_t* cfg )
// allocate the label array // allocate the label array
p->presetLabelN = preset_labelL->child_count(); p->presetLabelN = preset_labelL->child_count();
p->presetLabelA = mem::allocZ<preset_label_t>(p->presetLabelN); p->presetLabelA = mem::allocZ<preset_label_t>(p->presetLabelN);
p->presetOrderA = mem::allocZ<flow::preset_order_t>(p->presetLabelN);
// get the preset labels // get the preset labels
for(unsigned i=0; i<p->presetLabelN; ++i) for(unsigned i=0; i<p->presetLabelN; ++i)
@ -874,6 +879,8 @@ 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].order = 1;
} }
@ -946,6 +953,12 @@ const char* cw::preset_sel::preset_label( handle_t h, unsigned preset_idx )
return _preset_label(p,preset_idx); return _preset_label(p,preset_idx);
} }
const cw::flow::preset_order_t* cw::preset_sel::preset_order_array( handle_t h )
{
preset_sel_t* p = _handleToPtr(h);
return p->presetOrderA;
}
unsigned cw::preset_sel::alt_count( handle_t h ) unsigned cw::preset_sel::alt_count( handle_t h )
{ {
preset_sel_t* p = _handleToPtr(h); preset_sel_t* p = _handleToPtr(h);

View File

@ -80,6 +80,9 @@ namespace cw
unsigned preset_count( handle_t h ); unsigned preset_count( handle_t h );
const char* preset_label( handle_t h, unsigned preset_idx ); const char* preset_label( handle_t h, unsigned preset_idx );
// Return preset_order[ preset_count() ] w/ all order's = 1
const flow::preset_order_t* preset_order_array( handle_t h );
// Count/label of alternatives (alt_idx==0 is 'no alternative selected) // Count/label of alternatives (alt_idx==0 is 'no alternative selected)
unsigned alt_count( handle_t h ); unsigned alt_count( handle_t h );
const char* alt_label( handle_t h, unsigned alt_idx ); const char* alt_label( handle_t h, unsigned alt_idx );

View File

@ -24,6 +24,7 @@
check: { name: presetProbPriCheckId, title: "Pri Prob::" }, check: { name: presetProbPriCheckId, title: "Pri Prob::" },
check: { name: presetProbSecCheckId, title: "Sec Prob:" }, check: { name: presetProbSecCheckId, title: "Sec Prob:" },
check: { name: presetInterpCheckId, title: "Interp:"} check: { name: presetInterpCheckId, title: "Interp:"}
check: { name: presetAllowAllCheckId,title: "Allow All:" },
}, },
row: { row: {
@ -44,6 +45,7 @@
button:{ name: stopBtnId, title:"Stop", enable: false }, button:{ name: stopBtnId, title:"Stop", enable: false },
number:{ name: begLocNumbId, title:"Loc:", min:0, max:100000, step:1, decpl:0, enable: false }, number:{ name: begLocNumbId, title:"Loc:", min:0, max:100000, step:1, decpl:0, enable: false },
number:{ name: endLocNumbId, title:"End:", min:0, max:100000, step:1, decpl:0, enable: false }, number:{ name: endLocNumbId, title:"End:", min:0, max:100000, step:1, decpl:0, enable: false },
check: { name: locLoctnCheckId, title:"Lock loc:", enable: false },
check: { name: liveCheckId, title:"Live", enable: false }, check: { name: liveCheckId, title:"Live", enable: false },
check: { name: trackMidiCheckId, title:"Track MIDI", enable: false }, check: { name: trackMidiCheckId, title:"Track MIDI", enable: false },
}, },