From c4d518db47d0a4d51f97deead98e5ae180356bb3 Mon Sep 17 00:00:00 2001 From: kevin Date: Sat, 6 Apr 2024 16:06:17 -0400 Subject: [PATCH] cwIo.h,cpp : Updates to include cwMidiDevice input device buffer. Added hardwareReport(). Updates to account for change to midi::cbFunc_t. --- cwIo.cpp | 37 +++++++++++++++++++++++++++++++++---- cwIo.h | 7 +++++++ 2 files changed, 40 insertions(+), 4 deletions(-) diff --git a/cwIo.cpp b/cwIo.cpp index 5a0ebc5..fa2d66e 100644 --- a/cwIo.cpp +++ b/cwIo.cpp @@ -611,7 +611,7 @@ namespace cw // // MIDI // - void _midiCallback( const midi::packet_t* pktArray, unsigned pktCnt ) + void _midiCallback( void* cbArg, const midi::packet_t* pktArray, unsigned pktCnt ) { unsigned i; for(i=0; i(pkt->cbArg); + io_t* p = reinterpret_cast(cbArg); rc_t rc = kOkRC; @@ -2114,10 +2114,12 @@ namespace cw rc = cwLogError(rc,"Audio device configuration failed."); goto errLabel; } - - audio::device::report( p->audioH ); errLabel: + + if( rc != kOkRC && p->audioH.isValid() ) + audio::device::report( p->audioH ); + return rc; } @@ -2495,6 +2497,15 @@ void cw::io::report( handle_t h ) 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 ) { 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 ); } +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 ) { return midi::device::openMidiFile( _handleToPtr(h)->midiH, devIdx, portIdx, fname ); diff --git a/cwIo.h b/cwIo.h index ec4a8e1..9251dac 100644 --- a/cwIo.h +++ b/cwIo.h @@ -172,7 +172,9 @@ namespace cw bool isShuttingDown( handle_t h ); void report( handle_t h ); + void hardwareReport( handle_t h ); void realTimeReport( handle_t h ); + //---------------------------------------------------------------------------------------------------------- // @@ -229,6 +231,11 @@ namespace cw const char* midiDevicePortName( handle_t h, unsigned devIdx, bool inputFl, unsigned portIdx ); 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 ); + + 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 midiLoadMsgPacket( handle_t h, const midi::packet_t& pkt ); // Note: Set devIdx/portIdx via pkt.devIdx/pkt.portIdx