複数の MIDI デバイスを使用しているときに、MIDI パケットのソースを返す方法を理解する必要があります。
次のループを使用して、すべてのソースを接続しています。
ItemCount sourceCount = MIDIGetNumberOfSources();
for (ItemCount i = 0 ; i < sourceCount ; ++i) {
MIDIEndpointRef source = MIDIGetSource(i);
MIDISourceConnectPort( inPort, source, &i);
}
MIDISourceConnectPort() の最後のパラメーターは、MIDIReadProc コールバックに送信されるソースを識別するためのコンテキストであることを理解しています。そこで、ソースのインデックスを MIDIReadProc に送信しようとしています。
void MIDIReadProc (const MIDIPacketList *pktlist,
void *readProcRefCon,
void *srcConnRefCon)
{
\\ How do I access the source index passed in the conRef by using *srcConnRefSource?
}
これを知る必要がある理由は、LED フィードバックをデバイスに送信しようとしていて、どのデバイスがパケットを送信したかを知る必要があるためです。これにより、フィードバックを正しいデバイスに送信できます。