MIDIPacketListAdd questions
MIDIPacketListAdd questions
- Subject: MIDIPacketListAdd questions
- From: Tom Jeffries <email@hidden>
- Date: Mon, 10 Oct 2011 10:45:23 -0700
I'm still having problems getting MIDIPacketListAdd to function correctly. Doug Wyatt's suggestion that I need to call MIDISend after every MIDIPacketListAdd both helped and caused other problems. I'm using MIDI Monitor to watch the output, and each note that my code is sending gets sent many times rather than just once. I have used both step debugging and NSLog to verify that my code is sending each note on just once. However, it shows up many times in the output. Either I misunderstand the way MIDIPackets are handled or there is a problem in CoreMIDI.
The program has 12 tracks and splits the time into steps. AddPacket is called the first time by the main loop after a call to MIDIPacketListInit. After that it is called by the timer loop. I simplified this a bit, the actual code has a more accurate way of setting the time, but I've also tried it this way with no difference in result.
- (void) AddPacket
{
Byte stepData[256];
int bytesInStep = 0;
MIDITimeStamp nextNoteTime = 0;
for(int track = 0; track < MAX_TRACKS; track++)
{
bytesInStep = [self GetNoteOnData : track : currStep : stepData]; // check for a note on
if(bytesInStep > 0)
{
currTrackPacket = MIDIPacketListAdd(trackPacketPointer, 4096, currTrackPacket, nextNoteTime, bytesInStep, stepData);
[self PlayPacket];
}
}
currStep++;
if(currStep >= totalSteps)
currStep = 0;
}
- (void) PlayPacket
{
OSStatus err = MIDISend(MIDIPort, MIDIGetDestination(0), trackPacketPointer);
if (err != noErr)
NSLog(@"MIDISend err = %d", err);
}
Any suggestions?
Thanks, Tom Jeffries
_______________________________________________
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