cwIo.h/cpp : Added midiDeviceAllNotesOff().

This commit is contained in:
kevin 2024-12-23 15:56:48 -05:00
parent 58e545d58c
commit fac5b2b31a
2 changed files with 25 additions and 0 deletions

View File

@ -2883,6 +2883,30 @@ cw::rc_t cw::io::midiDeviceSend( handle_t h, unsigned devIdx, unsigned portIdx,
return midi::device::send( p->midiH, devIdx, portIdx, status, d0, d1 );
}
cw::rc_t cw::io::midiDeviceAllNotesOff( handle_t h, unsigned devIdx, unsigned portIdx )
{
rc_t rc = kOkRC;
unsigned devN = midiDeviceCount(h);
for(unsigned i=0; i<devN; ++i)
if( devIdx==kInvalidIdx || devIdx==i )
{
unsigned portN = midiDevicePortCount(h,i,false);
for(unsigned j=0; j<portN; ++j)
if( portIdx==kInvalidIdx || portIdx==j )
{
rc_t rc0;
if((rc0 = midiDeviceSend(h,i,j,midi::kCtlMdId,121,0)) != kOkRC) // reset all controllers
rc = cwLogError(rc0,"Send reset all controllers failed on %i:%i.",i,j);
if((rc0 = midiDeviceSend(h,i,j,midi::kCtlMdId,123,0)) != kOkRC) // all notes off
rc = cwLogError(rc0,"Send all-notes-off failed on %i:%i.",i,j);
}
}
return rc;
}
unsigned cw::io::midiDeviceMaxBufferMsgCount( handle_t h )
{
io_t* p = _handleToPtr(h);

1
cwIo.h
View File

@ -235,6 +235,7 @@ 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 );
rc_t midiDeviceAllNotesOff( handle_t h, unsigned devIdx=kInvalidIdx, unsigned portIdx=kInvalidIdx );
unsigned midiDeviceMaxBufferMsgCount( handle_t h );
const midi::ch_msg_t* midiDeviceBuffer( handle_t h, unsigned& msgCntRef );