Re: MIDISend output from with my program...
Re: MIDISend output from with my program...
- Subject: Re: MIDISend output from with my program...
- From: Doug Wyatt <email@hidden>
- Date: Thu, 31 Mar 2005 09:03:12 -0800
On Mar 30, 2005, at 17:46, Paul Swearingen wrote:
inline void MidiOut3(int byte0, int byte1, int byte2)
{
MIDIPacketList packetList;
MIDIPacket packet = packetList.packet[0]; // I think this
starts out pointing to the first packet
No, you've copied garbage from the uninitialized local variable
packetList into the local variable packet.
packetList.numPackets = 1;
packet.timeStamp = 0;
packet.length = 3;
packet.data[0] = byte0;
packet.data[1] = byte1;
packet.data[2] = byte2;
Now you've filled out packet, but packetList.packet[0] is still garbage.
MIDISend(gOutPort, gDest, &packetList);
}
Either make packet a C++ reference to packetList.packet[0], or a
pointer to it, e.g.:
MIDIPacket *packet = &packetList.packet[0];
packet->timeStamp = 0;
packet->length = 3;
packet->data[0] = byte0;
packet->data[1] = byte1;
packet->data[2] = byte2;
Don't do anything with packetList.packet[1] or beyond; packet[0] is
variable-length. Use MIDIPacketNext to traverse the packets in a
packetlist (on reading)... or MIDIPacketListInit / MIDIPacketListAdd
to build a multiple packet list dynamically.
Doug
_______________________________________________
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