cwIoPresetSelApp.cpp: Expand 'scoreFn' and 'record_dir' args.

Prevent first fragment from being played when MIDI player stops.
This commit is contained in:
kevin 2022-05-14 10:19:18 -04:00
parent 67078663be
commit 09517f2653

View File

@ -236,9 +236,6 @@ namespace cw
unsigned hpVel; unsigned hpVel;
unsigned hpDurMs; unsigned hpDurMs;
unsigned hpDnDelayMs; unsigned hpDnDelayMs;
} app_t; } app_t;
rc_t _parseCfg(app_t* app, const object_t* cfg, const object_t*& params_cfgRef ) rc_t _parseCfg(app_t* app, const object_t* cfg, const object_t*& params_cfgRef )
@ -265,6 +262,18 @@ namespace cw
rc = cwLogError(kSyntaxErrorRC,"Preset Select App configuration parse failed."); rc = cwLogError(kSyntaxErrorRC,"Preset Select App configuration parse failed.");
} }
if((app->scoreFn = filesys::expandPath( app->scoreFn )) == nullptr )
{
rc = cwLogError(kInvalidArgRC,"The score file name is invalid.");
goto errLabel;
}
if((app->record_dir = filesys::expandPath(app->record_dir)) == nullptr )
{
rc = cwLogError(kInvalidArgRC,"The record directory path is invalid.");
goto errLabel;
}
// verify that the output directory exists // verify that the output directory exists
if((rc = filesys::isDir(app->record_dir)) != kOkRC ) if((rc = filesys::isDir(app->record_dir)) != kOkRC )
if((rc = filesys::makeDir(app->record_dir)) != kOkRC ) if((rc = filesys::makeDir(app->record_dir)) != kOkRC )
@ -312,6 +321,8 @@ namespace cw
rc_t _free( app_t& app ) rc_t _free( app_t& app )
{ {
mem::release((char*&)app.record_dir);
mem::release((char*&)app.scoreFn);
preset_sel::destroy(app.psH); preset_sel::destroy(app.psH);
io_flow::destroy(app.ioFlowH); io_flow::destroy(app.ioFlowH);
midi_record_play::destroy(app.mrpH); midi_record_play::destroy(app.mrpH);
@ -404,6 +415,8 @@ namespace cw
printf("%s\n",buf); printf("%s\n",buf);
} }
if( midi_record_play::is_started(app->mrpH) )
{
const preset_sel::frag_t* f = nullptr; const preset_sel::frag_t* f = nullptr;
if( preset_sel::track_timestamp( app->psH, timestamp, f ) ) if( preset_sel::track_timestamp( app->psH, timestamp, f ) )
{ {
@ -414,6 +427,7 @@ namespace cw
_do_select_frag( app, f->guiUuId ); _do_select_frag( app, f->guiUuId );
} }
} }
}
// Find the closest locMap equal to or after 'loc' // Find the closest locMap equal to or after 'loc'
loc_map_t* _find_loc( app_t* app, unsigned loc ) loc_map_t* _find_loc( app_t* app, unsigned loc )
@ -1453,11 +1467,11 @@ 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");
break; break;
case kSaveBtnId: case kSaveBtnId: