Re: MIDIPacketList behaviour problem
Re: MIDIPacketList behaviour problem
- Subject: Re: MIDIPacketList behaviour problem
- From: Michael Harbour <email@hidden>
- Date: Tue, 20 Jan 2004 22:36:30 +0000
Thanks for replying, Thomas, but I'm still a bit flummoxed.
As I understand it, sysex messages can be spread across multiple
packets. This is logical, since a single packet is for a specific time,
and you might not want reception delayed until the complete packet has
been received, especially with a large message.
righto, but
1. how would such multiple MIDIPacket be bundled up inside
MIDIPacketLists (or not and sent from the driver to the app as a bunch
ot MIDIPacketlists
(is this process driver-specific or specified by Apple?)
2. how can we explain the presentation of 127 separate MIDIPacketLists
to my app which originated as a single MIDIPacketList that I squirted
to the unit? The raw bytes i stuck into the MIDIData was signed-Int
versions of some note-on 0x80 or 0x90 (cant remember off the top of my
head) - this doesnt count as a Sysex, i dont think ??
Also note that it is preferable to use 'sysexSend' for sending sysex
messages, as opposed to 'send' (not sure about the java names,
MIDISysexSend and MIDISend respectively in the C world). The later
returns after the complete message has been sent, whereas the former
completes asynchronously with a callback notification
(MIDISysexSendRequest, if my memory serves). This might be important
from the standpoint of timing considerations wrt large sysex packets.
Ahhh. right mate, There's a separate MIDISysexSendRequest java object
which I'll use from now on. But as I mentioned, i'm not sure i'm
constructing Sysex messages. - ought the sending of sysexes through
MIDISend and not MIDISysexSend throw exceptions or be deprecated or
something?
Thanks for the link to the Swiki site. The stuff there all looks
useful. If i can get thess problem nailed i'd like to contribute more
docs to that site.
Mike
TH
On Tue, 2004-01-20 at 11:20, Michael Harbour wrote:
Hi folks. hope you are all well.
I've got Panther, and a MIDISport 2x2 and the M-Audio USB
Support.plugin driver version 3.1
I was writing a librarian app and i was seeing packetlists not
arriving
from a one-way sysex dump from a keyboard. So I tried to write a
program to look at MIDIPacketlist delivery, thinking I needed to learn
something about baud rate or something. I thought I would simulate
lots
of packets coming in, by sending them out from the computer around a
loop. Connecting the MIDISport Out A to the In A ports (this is not a
silly thing to do, right?)., i tried to send out 100 midipacketlists
with various time intervals to see if all 100 return. I actually got
hundreds back - actually 127 for each one i sent out. I have pruned
the
code down to the absolute minimum that replicates this bug with a
single packet squirt. 127 come back. Could somebody please tell me
what
is happening here ?
Not every invocation of the program produces any result, which i also
find odd, and using InA and OutB also produces the same behaviour.
If you have a MIDISport could you please try to replicate this problem
by hooking out A to In A, compiling this code, and telling me what you
see?
Thanks,
Mike Harbour
here's the code:
public class Problem implements com.apple.audio.midi.MIDIReadProc,
com.apple.audio.midi.MIDINotifyProc
{
public static void main(String[] args)
{
Problem p = new Problem();
try{ Thread.sleep(2000);}catch(Exception e){}
p.demonstrate();
try{ Thread.sleep(2000);}catch(Exception e){}
}
protected com.apple.audio.midi.MIDIOutputPort opA = null;
protected com.apple.audio.midi.MIDIClient mc = null;
protected com.apple.audio.midi.MIDIDevice midisport = null;
protected com.apple.audio.midi.MIDIEntity portA = null;
protected com.apple.audio.midi.MIDIEndpoint INA = null;
protected com.apple.audio.midi.MIDIEndpoint OUTA = null;
protected com.apple.audio.midi.MIDIInputPort ipA = null;
public Problem()
{
try
{
mc = new com.apple.audio.midi.MIDIClient(new
com.apple.audio.util.CAFString("duh!"),this);
opA = mc.outputPortCreate(new
com.apple.audio.util.CAFString("out"));
for( int
i=0;i<com.apple.audio.midi.MIDIDevice.getNumberOfDevices();i++)
{
com.apple.audio.midi.MIDIDevice temp =
com.apple.audio.midi.MIDIDevice.getDevice(i);
if (
temp.getStringProperty(com.apple.audio.midi.MIDIConstants.kMIDIPropert
yN
ame).toString().equals("2x2")){ midisport=temp; }
}
for( int i=0;i<midisport.getNumberOfEntities();i++)
{
com.apple.audio.midi.MIDIEntity temp =
midisport.getEntity(i);
if
(temp.getStringProperty(com.apple.audio.midi.MIDIConstants.kMIDIProper
ty
Name).toString().equals("Port A")){ portA = temp;}
}
INA = portA.getSource(0);
OUTA = portA.getDestination(0);
ipA = mc.inputPortCreate(new
com.apple.audio.util.CAFString("whatever"),this);
ipA.connectSource(INA);
}catch(Exception e) { System.out.println(e); }
}
public void demonstrate()
{
try
{
com.apple.audio.midi.MIDIPacketList list = null;
com.apple.audio.util.MIDIData md =
com.apple.audio.util.MIDIData.newMIDIPacketData(256);
md.addRawData( new byte[] { -112, 38, 67 });
list = new com.apple.audio.midi.MIDIPacketList(0, md);
opA.send(OUTA,list);
}
catch(Exception e){e.printStackTrace();}
}
protected int count = 1;
public void execute(com.apple.audio.midi.MIDIInputPort port,
com.apple.audio.midi.MIDIEndpoint srcEndPoint,
com.apple.audio.midi.MIDIPacketList list)
{ System.out.println(String.valueOf(count) + ": " +list);
count++;
}
public void execute(com.apple.audio.midi.MIDIClient mc,
com.apple.audio.midi.MIDINotification mn){}
}
_______________________________________________
coreaudio-api mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/coreaudio-api
Do not post admin requests to the list. They will be ignored.
_______________________________________________
coreaudio-api mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/coreaudio-api
Do not post admin requests to the list. They will be ignored.