Skip to content

Commit

Permalink
Add comments with links to Windows MIDI API
Browse files Browse the repository at this point in the history
  • Loading branch information
softins committed Dec 2, 2024
1 parent 09d7397 commit be04d89
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/sound/asio/sound.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1236,7 +1236,11 @@ int64_t CSound::Flip64Bits ( const int64_t iIn )
return iOut;
}

//---------------------------------------------------------------------------------------
// Windows Native MIDI support
//
// For API, see https://learn.microsoft.com/en-gb/windows/win32/multimedia/midi-reference

void CSound::MidiStart()
{
/* Get the number of MIDI In devices in this computer */
Expand Down Expand Up @@ -1285,6 +1289,8 @@ void CSound::MidiStop()
}
}

// See https://learn.microsoft.com/en-us/previous-versions//dd798460(v=vs.85)
// for the definition of the MIDI input callback function.
void CALLBACK CSound::MidiCallback ( HMIDIIN hMidiIn, UINT wMsg, DWORD_PTR dwInstance, DWORD_PTR dwParam1, DWORD_PTR dwParam2 )
{
Q_UNUSED ( hMidiIn );
Expand All @@ -1293,6 +1299,8 @@ void CALLBACK CSound::MidiCallback ( HMIDIIN hMidiIn, UINT wMsg, DWORD_PTR dwIns

if ( wMsg == MIM_DATA )
{
// See https://learn.microsoft.com/en-gb/windows/win32/multimedia/mim-data
// The three bytes of a MIDI message are encoded into the 32-bit dwParam1 parameter.
BYTE status = dwParam1 & 0xFF;
BYTE data1 = ( dwParam1 >> 8 ) & 0xFF;
BYTE data2 = ( dwParam1 >> 16 ) & 0xFF;
Expand Down

0 comments on commit be04d89

Please sign in to comment.