cwIo.h,cpp : Updates to include cwMidiDevice input device buffer.

Added hardwareReport().
Updates to account for change to midi::cbFunc_t.
This commit is contained in:
kevin 2024-04-06 16:06:17 -04:00
parent 374d3ad8a8
commit c4d518db47
2 changed files with 40 additions and 4 deletions

View File

@ -611,7 +611,7 @@ namespace cw
// //
// MIDI // MIDI
// //
void _midiCallback( const midi::packet_t* pktArray, unsigned pktCnt ) void _midiCallback( void* cbArg, const midi::packet_t* pktArray, unsigned pktCnt )
{ {
unsigned i; unsigned i;
for(i=0; i<pktCnt; ++i) for(i=0; i<pktCnt; ++i)
@ -619,7 +619,7 @@ namespace cw
msg_t m; msg_t m;
midi_msg_t mm; midi_msg_t mm;
const midi::packet_t* pkt = pktArray + i; const midi::packet_t* pkt = pktArray + i;
io_t* p = reinterpret_cast<io_t*>(pkt->cbArg); io_t* p = reinterpret_cast<io_t*>(cbArg);
rc_t rc = kOkRC; rc_t rc = kOkRC;
@ -2115,9 +2115,11 @@ namespace cw
goto errLabel; goto errLabel;
} }
audio::device::report( p->audioH );
errLabel: errLabel:
if( rc != kOkRC && p->audioH.isValid() )
audio::device::report( p->audioH );
return rc; return rc;
} }
@ -2495,6 +2497,15 @@ void cw::io::report( handle_t h )
printf("audio: %s\n", cwStringNullGuard(audioDeviceName(h,i))); printf("audio: %s\n", cwStringNullGuard(audioDeviceName(h,i)));
} }
void cw::io::hardwareReport( handle_t h )
{
io_t* p = _handleToPtr(h);
audio::device::report( p->audioH );
midi::device::report(p->midiH);
}
void cw::io::realTimeReport( handle_t h ) void cw::io::realTimeReport( handle_t h )
{ {
io_t* p = _handleToPtr(h); io_t* p = _handleToPtr(h);
@ -2749,6 +2760,24 @@ cw::rc_t cw::io::midiDeviceSend( handle_t h, unsigned devIdx, unsigned portIdx,
return midi::device::send( p->midiH, devIdx, portIdx, status, d0, d1 ); return midi::device::send( p->midiH, devIdx, portIdx, status, d0, d1 );
} }
unsigned cw::io::midiDeviceMaxBufferMsgCount( handle_t h )
{
io_t* p = _handleToPtr(h);
return midi::device::maxBufferMsgCount(p->midiH );
}
const cw::midi::ch_msg_t* cw::io::midiDeviceBuffer( handle_t h, unsigned& msgCntRef )
{
io_t* p = _handleToPtr(h);
return midi::device::getBuffer(p->midiH, msgCntRef );
}
cw::rc_t cw::io::midiDeviceClearBuffer( handle_t h, unsigned msgCnt )
{
io_t* p = _handleToPtr(h);
return midi::device::clearBuffer(p->midiH, msgCnt );
}
cw::rc_t cw::io::midiOpenMidiFile( handle_t h, unsigned devIdx, unsigned portIdx, const char* fname ) cw::rc_t cw::io::midiOpenMidiFile( handle_t h, unsigned devIdx, unsigned portIdx, const char* fname )
{ {
return midi::device::openMidiFile( _handleToPtr(h)->midiH, devIdx, portIdx, fname ); return midi::device::openMidiFile( _handleToPtr(h)->midiH, devIdx, portIdx, fname );

7
cwIo.h
View File

@ -172,8 +172,10 @@ namespace cw
bool isShuttingDown( handle_t h ); bool isShuttingDown( handle_t h );
void report( handle_t h ); void report( handle_t h );
void hardwareReport( handle_t h );
void realTimeReport( handle_t h ); void realTimeReport( handle_t h );
//---------------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------------
// //
// Thread // Thread
@ -230,6 +232,11 @@ namespace cw
unsigned midiDevicePortIndex( handle_t h, unsigned devIdx, bool inputFl, const char* portName ); unsigned midiDevicePortIndex( handle_t h, unsigned devIdx, bool inputFl, const char* portName );
rc_t midiDeviceSend( handle_t h, unsigned devIdx, unsigned portIdx, uint8_t status, uint8_t d0, uint8_t d1 ); rc_t midiDeviceSend( handle_t h, unsigned devIdx, unsigned portIdx, uint8_t status, uint8_t d0, uint8_t d1 );
unsigned midiDeviceMaxBufferMsgCount( handle_t h );
const midi::ch_msg_t* midiDeviceBuffer( handle_t h, unsigned& msgCntRef );
rc_t midiDeviceClearBuffer( handle_t h, unsigned msgCnt );
rc_t midiOpenMidiFile( handle_t h, unsigned devIdx, unsigned portIdx, const char* fname ); rc_t midiOpenMidiFile( handle_t h, unsigned devIdx, unsigned portIdx, const char* fname );
rc_t midiLoadMsgPacket( handle_t h, const midi::packet_t& pkt ); // Note: Set devIdx/portIdx via pkt.devIdx/pkt.portIdx rc_t midiLoadMsgPacket( handle_t h, const midi::packet_t& pkt ); // Note: Set devIdx/portIdx via pkt.devIdx/pkt.portIdx
unsigned midiMsgCount( handle_t h, unsigned devIdx, unsigned portIdx ); unsigned midiMsgCount( handle_t h, unsigned devIdx, unsigned portIdx );