cwMidiDevice,cwMidiFileDev : Added midi::file_dev.msg_count() and midi::device.loadMsgPacket().

This commit is contained in:
kevin 2024-02-21 07:49:28 -05:00
parent 11350402d4
commit e3ff4828b0
4 changed files with 51 additions and 1 deletions

View File

@ -511,13 +511,46 @@ cw::rc_t cw::midi::device::openMidiFile( handle_t h, unsigned devIdx, unsigned p
errLabel: errLabel:
return rc; return rc;
}
cw::rc_t cw::midi::device::loadMsgPacket( handle_t h, const packet_t& pkt )
{
rc_t rc = kOkRC;
device_t* p = _handleToPtr(h);
if( _devIdxToFileDevIdx(p,pkt.devIdx) == kInvalidIdx )
{
cwLogError(kInvalidArgRC,"The device index %i does not identify a valid file device.",pkt.devIdx);
goto errLabel;
}
if((rc = load_messages( p->fileDevH, pkt.portIdx, pkt.msgArray, pkt.msgCnt)) != kOkRC )
goto errLabel;
errLabel:
return rc;
}
unsigned cw::midi::device::msgCount( handle_t h, unsigned devIdx, unsigned portIdx )
{
device_t* p = _handleToPtr(h);
if(_devIdxToFileDevIdx(p,devIdx) == kInvalidIdx )
{
cwLogError(kInvalidArgRC,"The device index %i does not identify a valid file device.",devIdx);
goto errLabel;
}
return msg_count( p->fileDevH, portIdx);
errLabel:
return 0;
} }
cw::rc_t cw::midi::device::seekToMsg( handle_t h, unsigned devIdx, unsigned portIdx, unsigned msgIdx ) cw::rc_t cw::midi::device::seekToMsg( handle_t h, unsigned devIdx, unsigned portIdx, unsigned msgIdx )
{ {
rc_t rc = kOkRC; rc_t rc = kOkRC;
device_t* p = _handleToPtr(h); device_t* p = _handleToPtr(h);
if(_devIdxToFileDevIdx(p,devIdx) == kInvalidIdx ) if(_devIdxToFileDevIdx(p,devIdx) == kInvalidIdx )
{ {

View File

@ -52,6 +52,8 @@ namespace cw
rc_t sendData( handle_t h, unsigned devIdx, unsigned portIdx, const uint8_t* dataPtr, unsigned byteCnt ); rc_t sendData( handle_t h, unsigned devIdx, unsigned portIdx, const uint8_t* dataPtr, unsigned byteCnt );
rc_t openMidiFile( handle_t h, unsigned devIdx, unsigned portIdx, const char* fname ); rc_t openMidiFile( handle_t h, unsigned devIdx, unsigned portIdx, const char* fname );
rc_t loadMsgPacket(handle_t h, const packet_t& pkt ); // Note: Set devIdx/portIdx via pkt.devIdx/pkt.portIdx
unsigned msgCount( handle_t h, unsigned devIdx, unsigned portIdx );
rc_t seekToMsg( handle_t h, unsigned devIdx, unsigned portIdx, unsigned msgIdx ); rc_t seekToMsg( handle_t h, unsigned devIdx, unsigned portIdx, unsigned msgIdx );
rc_t setEndMsg( handle_t h, unsigned devIdx, unsigned portidx, unsigned msgIdx ); rc_t setEndMsg( handle_t h, unsigned devIdx, unsigned portidx, unsigned msgIdx );

View File

@ -716,6 +716,19 @@ errLabel:
return rc; return rc;
} }
unsigned cw::midi::device::file_dev::msg_count( handle_t h, unsigned file_idx )
{
file_dev_t* p = _handleToPtr(h);
rc_t rc;
if((rc = _validate_file_existence(p,file_idx)) != kOkRC )
goto errLabel;
return p->msgN;
errLabel:
return 0;
}
cw::rc_t cw::midi::device::file_dev::seek_to_msg_index( handle_t h, unsigned file_idx, unsigned msg_idx ) cw::rc_t cw::midi::device::file_dev::seek_to_msg_index( handle_t h, unsigned file_idx, unsigned msg_idx )
{ {

View File

@ -66,6 +66,8 @@ namespace cw
} exec_result_t; } exec_result_t;
unsigned msg_count( handle_t h, unsigned file_idx );
// Set the next msg to be returned. // Set the next msg to be returned.
rc_t seek_to_msg_index( handle_t h, unsigned file_idx, unsigned msg_idx ); rc_t seek_to_msg_index( handle_t h, unsigned file_idx, unsigned msg_idx );
rc_t set_end_msg_index( handle_t h, unsigned file_idx, unsigned msg_idx ); rc_t set_end_msg_index( handle_t h, unsigned file_idx, unsigned msg_idx );