cwIoPresetSelApp.cpp : Added use of cwVelTableTuner

This commit is contained in:
kevin 2023-03-20 19:41:58 -04:00
parent 67361c928b
commit 6c97b62d6f

View File

@ -24,6 +24,7 @@
#include "cwFlowCross.h"
#include "cwIoFlow.h"
#include "cwPresetSel.h"
#include "cwVelTableTuner.h"
#define INVALID_LOC (0)
@ -90,15 +91,6 @@ namespace cw
kAMtrOut0Id,
kAMtrOut1Id,
/*
kHalfPedalPedalVel,
kHalfPedalDelayMs,
kHalfPedalPitch,
kHalfPedalVel,
kHalfPedalDurMs,
kHalfPedalDnDelayMs,
*/
kLogId,
kFragListId,
@ -121,14 +113,10 @@ namespace cw
kFragPlayBtnId,
kFragPlaySeqBtnId,
kFragPlayAllBtnId,
kFragNoteId
kFragNoteId,
};
enum
{
kPiano_MRP_DevIdx = 1,
kSampler_MRP_DevIdx = 0
kVelTblMinId = vtbl::kVtMinId,
kVelTblMaxId = vtbl::kVtMaxId
};
enum
@ -177,15 +165,6 @@ namespace cw
{ kPanelDivId, kInsertBtnId, "insertBtnId" },
{ kPanelDivId, kDeleteBtnId, "deleteBtnId" },
/*
{ kPanelDivId, kHalfPedalPedalVel, "halfPedalPedalVelId" },
{ kPanelDivId, kHalfPedalDelayMs, "halfPedalDelayMsId" },
{ kPanelDivId, kHalfPedalPitch, "halfPedalPitchId" },
{ kPanelDivId, kHalfPedalVel, "halfPedalVelId" },
{ kPanelDivId, kHalfPedalDurMs, "halfPedalDurMsId" },
{ kPanelDivId, kHalfPedalDnDelayMs, "halfPedalDnDelayMsId" },
*/
{ kPanelDivId, kPvWndSmpCntId, "pvWndSmpCntId" },
{ kPanelDivId, kSdBypassId, "sdBypassId" },
{ kPanelDivId, kSdInGainId, "sdInGainId" },
@ -205,6 +184,7 @@ namespace cw
{ kPanelDivId, kLogId, "logId" },
{ kPanelDivId, kFragListId, "fragListId" },
{ kFragListId, kFragPanelId, "fragPanelId" },
{ kFragPanelId, kFragMeasId, "fragMeasId" },
@ -222,6 +202,8 @@ namespace cw
{ kFragPanelId, kFragPlayAllBtnId, "fragPlayAllBtnId" },
{ kFragPanelId, kFragNoteId, "fragNoteId" },
};
unsigned mapN = sizeof(mapA)/sizeof(mapA[0]);
@ -248,6 +230,8 @@ namespace cw
const char* record_fn_ext;
const char* record_backup_dir;
const char* scoreFn;
const char* velTableFname;
const char* velTableBackupDir;
const object_t* midi_play_record_cfg;
const object_t* presets_cfg;
object_t* flow_proc_dict;
@ -275,6 +259,7 @@ namespace cw
unsigned end_play_loc;
preset_sel::handle_t psH;
vtbl::handle_t vtH;
io_flow::handle_t ioFlowH;
double crossFadeSrate;
@ -282,13 +267,6 @@ namespace cw
bool printMidiFl;
unsigned hpDelayMs;
unsigned hpPedalVel;
unsigned hpPitch;
unsigned hpVel;
unsigned hpDurMs;
unsigned hpDnDelayMs;
bool seqActiveFl; // true if the sequence is currently active (set by 'Play Seq' btn)
unsigned seqStartedFl; // set by the first seq idle callback
unsigned seqFragId; //
@ -316,25 +294,25 @@ namespace cw
for(int i=0; i<argc ; i+=2)
{
if( strcmp(argv[i],"record_fn")==0 )
if( textCompare(argv[i],"record_fn") == 0 )
{
app->record_fn = argv[i+1];
goto found_fl;
}
if( strcmp(argv[i],"score_fn")==0 )
if( textCompare(argv[i],"score_fn") == 0 )
{
app->scoreFn = argv[i+1];
goto found_fl;
}
if( strcmp(argv[i],"beg_play_loc")==0 )
if( textCompare(argv[i],"beg_play_loc") == 0 )
{
string_to_number( argv[i+1], app->beg_play_loc );
goto found_fl;
}
if( strcmp(argv[i],"end_play_loc")==0 )
if( textCompare(argv[i],"end_play_loc") == 0 )
{
string_to_number( argv[i+1], app->end_play_loc );
goto found_fl;
@ -371,6 +349,8 @@ namespace cw
"score_fn", app->scoreFn,
"flow_proc_dict_fn", flow_proc_dict_fn,
"midi_play_record", app->midi_play_record_cfg,
"vel_table_fname", app->velTableFname,
"vel_table_backup_dir", app->velTableBackupDir,
"presets", app->presets_cfg,
"crossFadeSrate", app->crossFadeSrate,
"crossFadeCount", app->crossFadeCnt,
@ -476,6 +456,7 @@ namespace cw
mem::release((char*&)app.record_backup_dir);
mem::release((char*&)app.record_dir);
mem::release((char*&)app.scoreFn);
vtbl::destroy(app.vtH);
preset_sel::destroy(app.psH);
io_flow::destroy(app.ioFlowH);
midi_record_play::destroy(app.mrpH);
@ -666,7 +647,7 @@ namespace cw
if( midi::isChStatus(mm->status) )
{
if(midi_record_play::send_midi_msg( app->mrpH, kSampler_MRP_DevIdx, mm->status & 0x0f, mm->status & 0xf0, mm->d0, mm->d1 ) == kOkRC )
if(midi_record_play::send_midi_msg( app->mrpH, midi_record_play::kSampler_MRP_DevIdx, mm->status & 0x0f, mm->status & 0xf0, mm->d0, mm->d1 ) == kOkRC )
_midi_play_callback( app, midi_record_play::kMidiEventActionId, id, timestamp, loc, mm->status & 0x0f, mm->status & 0xf0, mm->d0, mm->d1 );
}
@ -757,8 +738,6 @@ namespace cw
goto errLabel;
}
//midi_record_play::half_pedal_params( app->mrpH, app->hpDelayMs, app->hpPitch, app->hpVel, app->hpPedalVel, app->hpDurMs, app->hpDnDelayMs );
if( app->in_audio_dev_idx != kInvalidIdx )
{
unsigned frameIdx = 0;
@ -1880,78 +1859,6 @@ namespace cw
}
/*
rc_t _on_ui_half_pedal_value( app_t* app, unsigned appId, unsigned uuId, unsigned value )
{
switch( appId )
{
case kHalfPedalDelayMs:
app->hpDelayMs = value;
break;
case kHalfPedalPedalVel:
app->hpPedalVel = value;
break;
case kHalfPedalPitch:
app->hpPitch = value;
break;
case kHalfPedalVel:
app->hpVel = value;
break;
case kHalfPedalDurMs:
app->hpDurMs = value;
break;
case kHalfPedalDnDelayMs:
app->hpDnDelayMs = value;
break;
default:
{ assert(0); }
}
return kOkRC;
}
rc_t _on_echo_half_pedal( app_t* app, unsigned appId, unsigned uuId )
{
switch( appId )
{
case kHalfPedalDelayMs:
io::uiSendValue( app->ioH, uuId, app->hpDelayMs );
break;
case kHalfPedalPedalVel:
io::uiSendValue( app->ioH, uuId, app->hpPedalVel );
break;
case kHalfPedalPitch:
io::uiSendValue( app->ioH, uuId, app->hpPitch );
break;
case kHalfPedalVel:
io::uiSendValue( app->ioH, uuId, app->hpVel );
break;
case kHalfPedalDurMs:
io::uiSendValue( app->ioH, uuId, app->hpDurMs );
break;
case kHalfPedalDnDelayMs:
io::uiSendValue( app->ioH, uuId, app->hpDnDelayMs );
break;
default:
{ assert(0); }
}
return kOkRC;
}
*/
rc_t _onUiInit(app_t* app, const io::ui_msg_t& m )
{
rc_t rc = kOkRC;
@ -2000,7 +1907,8 @@ namespace cw
//io_flow::report(app->ioFlowH);
//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);
io::realTimeReport(app->ioH);
//io::realTimeReport(app->ioH);
midi_record_play::report(app->mrpH);
break;
case kSaveBtnId:
@ -2037,11 +1945,11 @@ namespace cw
break;
case kPianoMidiCheckId:
_on_midi_enable( app, m.appId, kPiano_MRP_DevIdx, m.value->u.b );
_on_midi_enable( app, m.appId, midi_record_play::kPiano_MRP_DevIdx, m.value->u.b );
break;
case kSamplerMidiCheckId:
_on_midi_enable( app, m.appId, kSampler_MRP_DevIdx, m.value->u.b );
_on_midi_enable( app, m.appId, midi_record_play::kSampler_MRP_DevIdx, m.value->u.b );
break;
case kWetInGainId:
@ -2093,17 +2001,6 @@ namespace cw
_on_sd_control(app,m);
break;
/*
case kHalfPedalPedalVel:
case kHalfPedalDelayMs:
case kHalfPedalPitch:
case kHalfPedalVel:
case kHalfPedalDurMs:
case kHalfPedalDnDelayMs:
_on_ui_half_pedal_value( app, m.appId, m.uuId, m.value->u.u );
break;
*/
case kFragInGainId:
_on_ui_frag_value( app, m.uuId, m.value->u.d);
break;
@ -2156,6 +2053,9 @@ namespace cw
_on_ui_frag_value( app, m.uuId, m.value->u.b );
break;
default:
if( kVelTblMinId <= m.appId && m.appId < kVelTblMaxId )
vtbl::on_ui_value( app->vtH, m);
}
return rc;
@ -2218,11 +2118,11 @@ namespace cw
break;
case kPianoMidiCheckId:
_on_echo_midi_enable( app, m.uuId, kPiano_MRP_DevIdx );
_on_echo_midi_enable( app, m.uuId, midi_record_play::kPiano_MRP_DevIdx );
break;
case kSamplerMidiCheckId:
_on_echo_midi_enable( app, m.uuId, kSampler_MRP_DevIdx );
_on_echo_midi_enable( app, m.uuId, midi_record_play::kSampler_MRP_DevIdx );
break;
case kWetInGainId:
@ -2297,17 +2197,9 @@ namespace cw
io::uiSendValue( app->ioH, m.uuId, app->cmpBypassFl );
break;
/*
case kHalfPedalPedalVel:
case kHalfPedalDelayMs:
case kHalfPedalPitch:
case kHalfPedalVel:
case kHalfPedalDurMs:
case kHalfPedalDnDelayMs:
_on_echo_half_pedal( app, m.appId, m.uuId );
break;
*/
default:
if( kVelTblMinId <= m.appId && m.appId <= kVelTblMaxId )
vtbl::on_ui_echo( app->vtH, m );
}
return rc;
@ -2423,6 +2315,7 @@ namespace cw
break;
case io::kExecTId:
vtbl::exec(app->vtH);
break;
default:
@ -2442,8 +2335,7 @@ cw::rc_t cw::preset_sel_app::main( const object_t* cfg, int argc, const char* ar
{
rc_t rc;
app_t app = { .hpDelayMs=250, .hpPedalVel=127, .hpPitch=64, .hpVel=64, .hpDurMs=500, .hpDnDelayMs=1000,
.trackMidiFl = true,
app_t app = { .trackMidiFl = true,
.pvWndSmpCnt = 512,
.sdBypassFl = false,
.sdInGain = 1.0,
@ -2453,17 +2345,29 @@ cw::rc_t cw::preset_sel_app::main( const object_t* cfg, int argc, const char* ar
.sdUpr = -1.1,
.sdLwr = 2.0,
.sdMix = 0.0,
.cmpBypassFl = false,
.cmpBypassFl = false
};
const object_t* params_cfg = nullptr;
unsigned vtMapN = vtbl::get_ui_id_map_count();
const ui::appIdMap_t* vtMap = vtbl::get_ui_id_map( kPanelDivId );
unsigned bigMapN = mapN + vtMapN;
ui::appIdMap_t bigMap[ bigMapN ];
for(unsigned i=0; i<mapN; ++i)
bigMap[i] = mapA[i];
for(unsigned i=0; i<vtMapN; ++i)
bigMap[mapN+i] = vtMap[i];
// Parse the configuration
if((rc = _parseCfg(&app,cfg,params_cfg,argc,argv)) != kOkRC )
goto errLabel;
// create the io framework instance
if((rc = io::create(app.ioH,cfg,_io_callback,&app,mapA,mapN)) != kOkRC )
if((rc = io::create(app.ioH,cfg,_io_callback,&app,bigMap,bigMapN)) != kOkRC )
{
rc = cwLogError(kOpFailRC,"IO Framework create failed.");
goto errLabel;
@ -2498,12 +2402,19 @@ cw::rc_t cw::preset_sel_app::main( const object_t* cfg, int argc, const char* ar
}
// create the MIDI record-play object
if((rc = midi_record_play::create(app.mrpH,app.ioH,*app.midi_play_record_cfg,_midi_play_callback,&app)) != kOkRC )
if((rc = midi_record_play::create(app.mrpH,app.ioH,*app.midi_play_record_cfg,app.velTableFname,_midi_play_callback,&app)) != kOkRC )
{
rc = cwLogError(rc,"MIDI record-play object create failed.");
goto errLabel;
}
// create the vel table tuner
if((rc = create( app.vtH, app.ioH, app.mrpH, app.velTableFname, app.velTableBackupDir)) != kOkRC )
{
rc = cwLogError(rc,"velocity table tuner create failed.");
goto errLabel;
}
// create the IO Flow controller
if(app.flow_cfg==nullptr || app.flow_proc_dict==nullptr || (rc = io_flow::create(app.ioFlowH,app.ioH,app.crossFadeSrate,app.crossFadeCnt,*app.flow_proc_dict,*app.flow_cfg)) != kOkRC )
{