cwIoAudioMidiApp.cpp,cwIoMidiRecordPlay.h/cpp : Upgrades to cwIoAudioMidiApp.
This commit is contained in:
parent
3c79433145
commit
4b65621c68
@ -46,7 +46,8 @@ namespace cw
|
||||
kTestFailRC, // 27
|
||||
kInvalidStateRC, // 28
|
||||
kTypeMismatchRC, // 29
|
||||
kBaseAppRC // 30
|
||||
kNotImplementedRC, // 30
|
||||
kBaseAppRC // 31
|
||||
} cwRC_t;
|
||||
|
||||
typedef unsigned rc_t;
|
||||
|
@ -90,6 +90,9 @@ namespace cw
|
||||
|
||||
midi_record_play::handle_t mrpH;
|
||||
audio_record_play::handle_t arpH;
|
||||
|
||||
const object_t* midi_play_record_cfg;
|
||||
|
||||
} app_t;
|
||||
|
||||
rc_t _parseCfg(app_t* app, const object_t* cfg )
|
||||
@ -99,7 +102,8 @@ namespace cw
|
||||
if((rc = cfg->getv(
|
||||
"record_dir", app->record_dir,
|
||||
"record_folder", app->record_folder,
|
||||
"record_fn_ext", app->record_fn_ext)) != kOkRC )
|
||||
"record_fn_ext", app->record_fn_ext,
|
||||
"midi_play_record", app->midi_play_record_cfg)) != kOkRC )
|
||||
{
|
||||
rc = cwLogError(kSyntaxErrorRC,"Audio MIDI app configuration parse failed.");
|
||||
}
|
||||
@ -173,6 +177,15 @@ namespace cw
|
||||
mem::release(fn);
|
||||
}
|
||||
|
||||
if((fn = filesys::makeFn(dir,"midi","csv",nullptr)) != nullptr )
|
||||
{
|
||||
if((rc0 = midi_record_play::save_csv( app->mrpH, fn )) != kOkRC )
|
||||
rc0 = cwLogError(rc0,"MIDI CSV file '%s' save failed.",fn);
|
||||
|
||||
mem::release(fn);
|
||||
}
|
||||
|
||||
|
||||
if((fn = filesys::makeFn(dir,"audio","wav",nullptr)) != nullptr )
|
||||
{
|
||||
if((rc1 = audio_record_play::save( app->arpH, fn )) != kOkRC )
|
||||
@ -355,6 +368,7 @@ namespace cw
|
||||
break;
|
||||
|
||||
case kReportBtnId:
|
||||
report( app->mrpH );
|
||||
break;
|
||||
|
||||
case kSaveBtnId:
|
||||
@ -518,7 +532,7 @@ cw::rc_t cw::audio_midi_app::main( const object_t* cfg )
|
||||
return rc;
|
||||
|
||||
// create the MIDI record-play object
|
||||
if((rc = midi_record_play::create(app.mrpH,app.ioH,*cfg)) != kOkRC )
|
||||
if((rc = midi_record_play::create(app.mrpH,app.ioH,*app.midi_play_record_cfg)) != kOkRC )
|
||||
{
|
||||
rc = cwLogError(rc,"MIDI record-play object create failed.");
|
||||
goto errLabel;
|
||||
|
@ -208,7 +208,7 @@ namespace cw
|
||||
goto errLabel;
|
||||
}
|
||||
|
||||
printf("FORCE PEDAL:%i %i %i\n",
|
||||
printf("Force Pedal: enabled%i thresh:%i veloc:%i\n",
|
||||
p->midiDevA[i].force_damper_down_fl,
|
||||
p->midiDevA[i].force_damper_down_threshold,
|
||||
p->midiDevA[i].force_damper_down_velocity);
|
||||
@ -271,6 +271,9 @@ namespace cw
|
||||
{
|
||||
am_midi_msg_t* am = nullptr;
|
||||
|
||||
//if( !midi::isPedal(status,d0) )
|
||||
// printf("MIDI store: %i : ch:%i st:%i d0:%i d1:%i\n",p->iMsgArrayInIdx,ch,status,d0,d1);
|
||||
|
||||
// verify that space exists in the record buffer
|
||||
if( p->iMsgArrayInIdx < p->iMsgArrayN )
|
||||
{
|
||||
@ -527,7 +530,7 @@ namespace cw
|
||||
unsigned fileByteN = 0; // count of bytes in the file
|
||||
int version = 0; // version id (always a negative number)
|
||||
bool alloc_fl = false;
|
||||
bool print_fl = false;
|
||||
bool print_fl = true;
|
||||
file::handle_t fH;
|
||||
|
||||
if((rc = file::open(fH,fn,file::kReadFl)) != kOkRC )
|
||||
@ -834,11 +837,21 @@ namespace cw
|
||||
|
||||
void _report_midi( midi_record_play_t* p )
|
||||
{
|
||||
printf("omsg cnt:%i\n",p->msgArrayInIdx);
|
||||
for(unsigned i=0; i<p->msgArrayInIdx; ++i)
|
||||
{
|
||||
am_midi_msg_t* mm = p->msgArray + i;
|
||||
_print_midi_msg(mm);
|
||||
}
|
||||
|
||||
|
||||
printf("imsg cnt:%i\n",p->iMsgArrayInIdx);
|
||||
for(unsigned i=0; i<p->iMsgArrayInIdx; ++i)
|
||||
{
|
||||
am_midi_msg_t* mm = p->iMsgArray + i;
|
||||
_print_midi_msg(mm);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
rc_t _write_vel_histogram( midi_record_play_t* p )
|
||||
@ -871,6 +884,20 @@ namespace cw
|
||||
return rc;
|
||||
}
|
||||
|
||||
// Fill the play buffer (msgArray) from the record buffer (iMsgArray)
|
||||
void _iMsgArray_to_msgArray(midi_record_play_t* p)
|
||||
{
|
||||
if( p->msgArrayN < p->iMsgArrayN)
|
||||
{
|
||||
mem::resize(p->msgArray,p->iMsgArrayN,mem::kZeroAllFl);
|
||||
p->msgArrayN = p->iMsgArrayN;
|
||||
}
|
||||
p->msgArrayOutIdx = 0;
|
||||
p->msgArrayInIdx = p->iMsgArrayInIdx;
|
||||
memcpy(p->msgArray,p->iMsgArray,p->iMsgArrayInIdx*sizeof(am_midi_msg_t));
|
||||
}
|
||||
|
||||
|
||||
rc_t _stop( midi_record_play_t* p )
|
||||
{
|
||||
rc_t rc = kOkRC;
|
||||
@ -889,9 +916,12 @@ namespace cw
|
||||
// set the 'microsec' value for each MIDI msg as an offset from the first message[]
|
||||
for(unsigned i=0; i<p->iMsgArrayInIdx; ++i)
|
||||
{
|
||||
p->msgArray[i].microsec = time::elapsedMicros(p->iMsgArray[0].timestamp,p->iMsgArray[i].timestamp);
|
||||
p->iMsgArray[i].microsec = time::elapsedMicros(p->iMsgArray[0].timestamp,p->iMsgArray[i].timestamp);
|
||||
}
|
||||
|
||||
// copy the recorded messages from the input buffer to the output buffer
|
||||
_iMsgArray_to_msgArray(p);
|
||||
|
||||
cwLogInfo("MIDI messages recorded: %i",p->msgArrayInIdx );
|
||||
|
||||
}
|
||||
@ -926,12 +956,13 @@ namespace cw
|
||||
// if this is a sys-ex msg
|
||||
if( pkt->msgArray == NULL )
|
||||
{
|
||||
cwLogError(kNotImplementedRC,"Sys-ex recording not implemented.");
|
||||
}
|
||||
else // this is a triple
|
||||
{
|
||||
|
||||
//if( !midi::isPedal(pkt->msgArray[j].status,pkt->msgArray[j].d0) )
|
||||
//printf("IN: 0x%x 0x%x 0x%x\n", pkt->msgArray[j].status, pkt->msgArray[j].d0, pkt->msgArray[j].d1 );
|
||||
// printf("IN: 0x%x 0x%x 0x%x\n", pkt->msgArray[j].status, pkt->msgArray[j].d0, pkt->msgArray[j].d1 );
|
||||
|
||||
if( (p->recordFl || p->logInFl) && p->startedFl )
|
||||
{
|
||||
@ -1478,3 +1509,9 @@ cw::rc_t cw::midi_record_play::am_to_midi_file( const object_t* cfg )
|
||||
return rc;
|
||||
|
||||
}
|
||||
|
||||
void cw::midi_record_play::report( handle_t h )
|
||||
{
|
||||
midi_record_play_t* p = _handleToPtr(h);
|
||||
_report_midi(p);
|
||||
}
|
||||
|
@ -71,6 +71,8 @@ namespace cw
|
||||
rc_t am_to_midi_dir( const char* inDir );
|
||||
rc_t am_to_midi_file( const object_t* cfg );
|
||||
|
||||
void report( handle_t h );
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user