cwIoPresetSelApp.cpp,ui.cfg: various fixes to correctly handle beg/endPlayLoc interface.

Fragment UI template is now read from html/preset_sel/ui.cfg.
This commit is contained in:
kevin 2022-12-13 20:58:06 -05:00
parent 13bc47389b
commit 644c57458d
2 changed files with 148 additions and 105 deletions

View File

@ -236,8 +236,6 @@ namespace cw
preset_sel::handle_t psH; preset_sel::handle_t psH;
io_flow::handle_t ioFlowH; io_flow::handle_t ioFlowH;
unsigned tmp;
double crossFadeSrate; double crossFadeSrate;
unsigned crossFadeCnt; unsigned crossFadeCnt;
@ -1017,7 +1015,7 @@ namespace cw
unsigned fragBegLoc = 0; unsigned fragBegLoc = 0;
// create the UI object // create the UI object
if((rc = io::uiCreateFromObject( app->ioH, app->frag_panel_cfg, fragListUuId, fragChanId )) != kOkRC ) if((rc = io::uiCreateFromRsrc( app->ioH, "frag_panel", fragListUuId, fragChanId )) != kOkRC )
{ {
rc = cwLogError(rc,"The fragments UI object creation failed."); rc = cwLogError(rc,"The fragments UI object creation failed.");
goto errLabel; goto errLabel;
@ -1243,12 +1241,6 @@ namespace cw
rc_t rc = kOkRC; rc_t rc = kOkRC;
unsigned midiEventN = 0; unsigned midiEventN = 0;
bool firstLoadFl = !app->scoreH.isValid(); bool firstLoadFl = !app->scoreH.isValid();
//unsigned minLoc = firstLoadFl ? 0 : app->minLoc;
//unsigned maxLoc = firstLoadFl ? 0 : app->maxLoc;
// if the score is already loaded
//if( app->scoreH.isValid() )
// return rc;
cwLogInfo("Loading"); cwLogInfo("Loading");
_set_status(app,"Loading..."); _set_status(app,"Loading...");
@ -1258,13 +1250,6 @@ namespace cw
if((rc = _load_piano_score(app,midiEventN)) != kOkRC ) if((rc = _load_piano_score(app,midiEventN)) != kOkRC )
goto errLabel; goto errLabel;
/*
if( !firstLoadFl)
{
minLoc = std::max(minLoc,app->minLoc);
maxLoc = std::min(maxLoc,app->maxLoc);
}
*/
// reset the timestamp tracker // reset the timestamp tracker
track_loc_reset( app->psH ); track_loc_reset( app->psH );
@ -1275,22 +1260,21 @@ namespace cw
unsigned begPlayLocUuId = io::uiFindElementUuId(app->ioH, kBegPlayLocNumbId); unsigned begPlayLocUuId = io::uiFindElementUuId(app->ioH, kBegPlayLocNumbId);
unsigned endPlayLocUuId = io::uiFindElementUuId(app->ioH, kEndPlayLocNumbId); unsigned endPlayLocUuId = io::uiFindElementUuId(app->ioH, kEndPlayLocNumbId);
unsigned end_play_loc = app->end_play_loc==0 ? app->maxLoc : app->end_play_loc; if( app->end_play_loc == 0 )
unsigned beg_play_loc = app->minLoc <= app->beg_play_loc && app->beg_play_loc <= app->maxLoc ? app->beg_play_loc : app->minLoc; app->end_play_loc = app->maxLoc;
io::uiSetNumbRange( app->ioH, begPlayLocUuId, app->minLoc, app->maxLoc, 1, 0, app->minLoc ); if( !(app->minLoc <= app->beg_play_loc && app->beg_play_loc <= app->maxLoc) )
io::uiSetNumbRange( app->ioH, endPlayLocUuId, app->minLoc, app->maxLoc, 1, 0, app->maxLoc ); app->beg_play_loc = app->minLoc;
//io::uiSendValue( app->ioH, begPlayLocUuId, app->minLoc); io::uiSetNumbRange( app->ioH, begPlayLocUuId, app->minLoc, app->maxLoc, 1, 0, app->beg_play_loc );
//io::uiSendValue( app->ioH, endPlayLocUuId, app->maxLoc); io::uiSetNumbRange( app->ioH, endPlayLocUuId, app->minLoc, app->maxLoc, 1, 0, app->end_play_loc );
io::uiSendValue( app->ioH, begPlayLocUuId, beg_play_loc);
io::uiSendValue( app->ioH, endPlayLocUuId, end_play_loc);
io::uiSendValue( app->ioH, begPlayLocUuId, app->beg_play_loc);
io::uiSendValue( app->ioH, endPlayLocUuId, app->end_play_loc);
// enable the insert '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 ); io::uiSetEnable( app->ioH, io::uiFindElementUuId( app->ioH, kInsertLocId ), true );
} }
// update the current event and event count // update the current event and event count
@ -1324,6 +1308,8 @@ namespace cw
else else
_set_status(app,"%i MIDI events loaded.",midiEventN); _set_status(app,"%i MIDI events loaded.",midiEventN);
io::uiSetEnable( app->ioH, io::uiFindElementUuId( app->ioH, kLoadBtnId ), false );
return rc; return rc;
} }
@ -1673,11 +1659,12 @@ namespace cw
break; break;
case kReportBtnId: case kReportBtnId:
preset_sel::report( app->psH ); //preset_sel::report( app->psH );
//io_flow::apply_preset( app->ioFlowH, 2000.0, app->tmp==0 ? "a" : "b"); //io_flow::apply_preset( app->ioFlowH, 2000.0, app->tmp==0 ? "a" : "b");
//app->tmp = !app->tmp; //app->tmp = !app->tmp;
//io_flow::print(app->ioFlowH); //io_flow::print(app->ioFlowH);
//midi_record_play::save_csv(app->mrpH,"/home/kevin/temp/mrp_1.csv"); //midi_record_play::save_csv(app->mrpH,"/home/kevin/temp/mrp_1.csv");
printf("%i %i\n",app->beg_play_loc,app->end_play_loc);
break; break;
case kSaveBtnId: case kSaveBtnId:
@ -1773,7 +1760,6 @@ namespace cw
break; break;
case kFragWetDryGainId: case kFragWetDryGainId:
//printf("UI wet/dry:%f\n",m.value->u.d);
_on_ui_frag_value( app, m.uuId, m.value->u.d ); _on_ui_frag_value( app, m.uuId, m.value->u.d );
break; break;
@ -1902,6 +1888,14 @@ namespace cw
_on_echo_master_value( app, preset_sel::kMasterSyncDelayMsVarId, m.uuId ); _on_echo_master_value( app, preset_sel::kMasterSyncDelayMsVarId, m.uuId );
break; break;
case kBegPlayLocNumbId:
io::uiSendValue( app->ioH, m.uuId, app->beg_play_loc );
break;
case kEndPlayLocNumbId:
io::uiSendValue( app->ioH, m.uuId, app->end_play_loc );
break;
/* /*
case kHalfPedalPedalVel: case kHalfPedalPedalVel:
case kHalfPedalDelayMs: case kHalfPedalDelayMs:
@ -2025,6 +2019,9 @@ namespace cw
rc = _ui_callback(app,m->u.ui); rc = _ui_callback(app,m->u.ui);
break; break;
case io::kExecTId:
break;
default: default:
assert(0); assert(0);

View File

@ -1,5 +1,5 @@
{ {
main: {
parent: "uiDivId" parent: "uiDivId"
panel: { panel: {
@ -76,7 +76,53 @@
log: { name: logId, title:"Log" } log: { name: logId, title:"Log" }
} }
}
},
frag_panel: {
panel: {
name: fragPanelId
addClassName: fragPanel
row: {
name: fragPanelRowId
addClassName: fragPanelRow
col: {
numb_disp: { name: fragBegLocId, title:"Beg Loc", value: 0 },
numb_disp: { name: fragEndLocId, title:"End Loc", value: 0 },
number: { name: fragInGainId, title:"In Gain", min:0.0, max:100.0, step:0.1, decpl:1 },
number: { name: fragOutGainId, title:"Out Gain", min:0.0, max:100.0, step:0.1, decpl:1 },
},
col: {
row: {
name: fragPresetRowId,
addClassName: fragPresetRow,
},
row: {
string: { name: fragNoteId, addClassName: fragNote, title:"Note" },
}
},
col: {
number:{ name: fragWetDryGainId, title:"Wet/Dry", min:0.0, max:1.0, step:0.1, decpl:2 },
number:{ name: fragFadeOutMsId, title:"Fade Ms", min:0.0, max:5000, step:1, decpl:0 },
row: {
button:{ name: fragPlaySeqBtnId, title:"Play Seq" },
button:{ name: fragPlayAllBtnId, title:"Play All" },
}
},
col: {
number: { name: fragBegPlayLocId, title:"Begin", min:0, max:1000000, step:1, decpl:0 },
number: { name: fragEndPlayLocId, title:"End", min:0, max:1000000, step:1, decpl:0 },
button: { name: fragPlayBtnId, title:"Play" }
}
}
}
}
} }