Re: optimizing midi packet processing
Re: optimizing midi packet processing
- Subject: Re: optimizing midi packet processing
- From: Nonnus™ <email@hidden>
- Date: Tue, 4 Nov 2008 04:34:09 +0000
after some further investigation
i came to the conclusion that indeed i dont need to parse the midi
data itself at this stage
just send each MIDIPacket to handleMidimessage:
so i reduced the processMIDIPacketList: to:
- (void)processMIDIPacketList:(const MIDIPacketList*)packetList
{
//NSLog(@"processMIDIPacketList:");
NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
const MIDIPacket* packet = packetList->packet; // Step through
each packet
for (int i = 0; i < packetList->numPackets; i++)
{
[owner handleMIDIMessage:(uint8_t*)packet->data ofSize:packet-
>length];
packet = MIDIPacketNext(packet);
}
[pool release];
}
this seems as optimized as possible
(especially as there is not that much going on :)
can somebody confirm this ?
i would also take the change to ask if there is the need for the
NSAutoreleasePool
i have been reading the docs but cant seem to understand if in this
case it even does anything
(i am sorry as i suppose this is not the best place to ask about pool,
but at least i ask about it in this midi implemntation;)
abraços
nonnus
On Nov 1, 2008, at 8:43 PM, Peter Rebholz wrote:
I think more details might help us answer your question better. The
way you process the commands depends on how you are using them. It
also would help to know what you mean by the handling not being
accurate.
What isn't accurate? The messages that are being passed to
handleMIDIMessage:ofSize:? The timing?
Without any details on how this is being used I made the following
observations:
1) You aren't paying any attention to the timeStamp property of
MIDIPacket. Are you expecting all MIDIPackets to be received in
realtime?
2) A MIDIPacket packet is a collection of simultaneous MIDI events.
Given that, doesn't it make sense to send the whole MIDIPacket to
handleMIDIMessage:ofSize:? I think you're creating extra work for
your self by copying out each individual command and passing it on.
Additionally, sending a message to an object does have some overhead
so depending on how frequently you are calling that method you may
be hurting your performance a bit.
Hope that helps,
Peter
On Nov 1, 2008, at 12:41 PM, Nonnus™ wrote:
hello
currently i am using this code to parse incoming midi data:
- (void)processMIDIPacketList:(const MIDIPacketList*)packetList
{
NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
int i,j;
const MIDIPacket* packet;
uint8_t message[kBufferSize];
int messageSize = 0;
packet = packetList->packet;
for (i = 0; i < packetList->numPackets; i++)
{
for (j = 0; j < packet->length; j++)
{
if (packet->data[j] >= 0xF8) continue;
if ((packet->data[j] & 0x80) != 0 && messageSize > 0)
{
[owner handleMIDIMessage:message ofSize:messageSize];
messageSize = 0;
}
message[messageSize++] = packet->data[j];
}
packet = MIDIPacketNext(packet);
}
if (messageSize > 0)
[owner handleMIDIMessage:message ofSize:messageSize];
[pool release];
}
however i feel the midi handling is not as accurate as desired
can anyone please provide a better implementation
thank you for your support
abraços
nonnus
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Coreaudio-api mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Coreaudio-api mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden