• 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: Calling MIDIPacketListAdd from NSTimer
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Calling MIDIPacketListAdd from NSTimer


  • Subject: Re: Calling MIDIPacketListAdd from NSTimer
  • From: Doug Wyatt <email@hidden>
  • Date: Tue, 11 Oct 2011 14:33:07 -0700

Think of MIDIPacketListAdd as a helper for dynamically building up a MIDIPacketList. Without it you write code something like this:

MIDIPacketList pktlist;
pktlist.numberPackets = 1;
pktlist.packet[0].timeStamp = 0;
pktlist.packet[0].length = 1;
pktlist.packet[0].data[0] = 0xf8;
MIDISend(myOutputPort, someDestination, &pktlist);

But that gets difficult when you want to put a second packet in the list, since packets are variable-length. The idiom for using MIDIPacketListAdd is:

Byte space[256];
MIDIPacketList *pktlist = (MIDIPacketList *)space;

MIDIPacket *pkt = MIDIPacketListInit(pktlist);
pkt = MIDIPacketListAdd(pktlist, sizeof(space), pkt, when, nData, data);
// if pkt == NULL, we ran out of space
...
MIDISend(myOutputPort, someDestination, pktlist);

i.e. Init, Add (Add...), Send. After Send you need to call Init again.

Doug

On Oct 5, 2011, at 16:48 , Tom Jeffries wrote:

Doug,

Let me make sure I understand- you are saying I need to call MIDIsend every time I add a packet?  I tried that and each packet gets sent several times- one note on turns into three note ons.  Any thoughts on why that would happen?

Thanks, Tom

On Wed, Oct 5, 2011 at 4:31 PM, Doug Wyatt <email@hidden> wrote:
MIDIPacketListAdd is just a handy helper for appending a message to a packet list. The packet list doesn't get sent until you call MIDISend. You can't modify the packet list once it's been sent.

On Oct 5, 2011, at 12:51 , Tom Jeffries wrote:
> I'm sending a string of MIDI packets using MIDIPacketListAdd. I want to change the packets dynamically during playback, so I'm using a NSTimer to add each packet before the scheduled time the packet should go out.
>
> The code works perfectly, the address of the current packet is updated correctly, I have verified that all the data is correct.  However, no MIDI data is being sent when MIDIPacketListAdd is called from the timer.  I add the first two packets before starting the timer to make sure that the packets are sent to MIDIPacketListAdd before they need to be played.
>
> I'm very puzzled.  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

  • Follow-Ups:
    • Re: Calling MIDIPacketListAdd from NSTimer
      • From: Tom Jeffries <email@hidden>
References: 
 >Calling MIDIPacketListAdd from NSTimer (From: Tom Jeffries <email@hidden>)
 >Re: Calling MIDIPacketListAdd from NSTimer (From: Doug Wyatt <email@hidden>)
 >Re: Calling MIDIPacketListAdd from NSTimer (From: Tom Jeffries <email@hidden>)

  • Prev by Date: AU notify host that state is dirty
  • Next by Date: Re: Calling MIDIPacketListAdd from NSTimer
  • Previous by thread: Re: Calling MIDIPacketListAdd from NSTimer
  • Next by thread: Re: Calling MIDIPacketListAdd from NSTimer
  • Index(es):
    • Date
    • Thread