Re: MIDISend output from with my program...
Re: MIDISend output from with my program...
- Subject: Re: MIDISend output from with my program...
- From: Brian Kennedy <email@hidden>
- Date: Thu, 31 Mar 2005 18:12:54 -0700
Thanks Paul,
That works for me now. Apparently I was setting up gPortOut
correctly afterall...
Thanks again,
-Brian
On Thu, 31 Mar 2005 16:41:16 -0800, Paul Swearingen <email@hidden> wrote:
>
> Brian,
>
> After searching the mail list for MIDISend I found Chris Reed's code Jan 21,
> 2003
> and from that I created this, since I still couldn't seem to place data into
> the MIDIPacketList,
> correctly. This works fine for me. gOutPort appears to get initialized
> correctly as long as
> I call the midi init routine somewhere upon program initialization.
>
> MIDIOutputPortCreate is in the midi init routine and appears to correctly
> create the output port for me.
>
> inline void MidiOut3(int byte0, int byte1, int byte2)
> {
> Byte midi[] = { byte0, byte1, byte2 };
>
> MIDIPacketList packetList;
> MIDIPacket *packetPtr = MIDIPacketListInit(&packetList);
>
> packetPtr = MIDIPacketListAdd(&packetList, sizeof packetList,
> packetPtr, 0, 3, (const Byte *) &midi);
>
> MIDISend(gOutPort, gDest, &packetList);
> }
>
>
>
>
> ----- Original Message -----
> From: "Brian Kennedy" <email@hidden>
> To: "Doug Wyatt" <email@hidden>
> Cc: "CoreAudio API" <email@hidden>
> Sent: Thursday, March 31, 2005 4:19 PM
> Subject: Re: MIDISend output from with my program...
>
> >I am also new to MIDI programming on the Mac and seem to be running
> > into a similar problem with the code I am working on. My packets seem
> > to be correct according to what I see in the debugger but
> > unfortunately my data is not making its way out to the device I am
> > testing with. I fear I may have set up the gOutPort incorrectly in my
> > code. Following the echo example code, I am able to see all of the
> > available devices, but I can't seem to find any examples of how to
> > find out what gOutPort should be set to for those devices. Is there
> > something I am missing or am I going about this in completely the
> > wrong way? Thanks,
> >
> > -Brian
> >
> >
> > On Thu, 31 Mar 2005 09:03:12 -0800, Doug Wyatt <email@hidden> wrote:
> >> 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
> >>
> > _______________________________________________
> > 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