Skip to content

Commit

Permalink
Merge pull request #35 from orchetect/dev
Browse files Browse the repository at this point in the history
Fixed `MIDIPacketNext`/`MIDIEventPacketNext` being called one too many times
  • Loading branch information
orchetect authored Aug 27, 2021
2 parents 9fdaea3 + 3393a01 commit 9f324fd
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions Sources/MIDIKitC/CoreMIDI.m
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,13 @@ void CMIDIPacketListIterate(const MIDIPacketList *midiPacketList,

const MIDIPacket *midiPacket = &midiPacketList->packet[0];

for (UInt32 idx = 0; idx < midiPacketList->numPackets; idx++) {
closure(midiPacket);
// call closure for first packet
closure(midiPacket);

// call closure for subsequent packets, if they exist
for (UInt32 idx = 1; idx < midiPacketList->numPackets; idx++) {
midiPacket = MIDIPacketNext(midiPacket);
closure(midiPacket);
}

}
Expand All @@ -36,9 +40,13 @@ void CMIDIEventListIterate(const MIDIEventList *midiEventList,

const MIDIEventPacket *midiEventPacket = &midiEventList->packet[0];

for (UInt32 idx = 0; idx < midiEventList->numPackets; idx++) {
closure(midiEventPacket);
// call closure for first packet
closure(midiEventPacket);

// call closure for subsequent packets, if they exist
for (UInt32 idx = 1; idx < midiEventList->numPackets; idx++) {
midiEventPacket = MIDIEventPacketNext(midiEventPacket);
closure(midiEventPacket);
}

}
Expand Down

0 comments on commit 9f324fd

Please sign in to comment.