• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: MIDISend output from with my program...
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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
  • Follow-Ups:
    • Re: MIDISend output from with my program...
      • From: Brian Kennedy <email@hidden>
References: 
 >MIDISend output from with my program... (From: "Paul Swearingen" <email@hidden>)

  • Prev by Date: Rép : Allowing a user-space driver to be the default system
  • Next by Date: simultaneous audio input/ output
  • Previous by thread: MIDISend output from with my program...
  • Next by thread: Re: MIDISend output from with my program...
  • Index(es):
    • Date
    • Thread