From: Hiroo H. <hir...@co...> - 2005-03-07 00:34:45
|
Hi Jeff, Now you can specify MIDI output buffer size and MIDI output delay time by MIDI preference dialog. These have been on my TODO list and I've finally implemented them. Enjoy. Jeff> Just a note Mac OSX signal errors. I tried Plumstone Jeff> but was unable to get it working. However I did some Jeff> experimentation with CAProvider yesterday and Jeff> discovered a couple of modifications to the Jeff> core.MidiUtil.java class that will at least cut down Jeff> on the frequency of signal errors. First of all, I was Jeff> having a lot of problems with the Behringer FCB1010. Jeff> This device only has one type of patch with a length Jeff> of 2352. Since it's a fairly large patch and since I Jeff> wasn't getting as many signal errors as with the other Jeff> devices, I suspected that the problem might be some Jeff> kind of a timing issue. Jeff> Jeff> First, I changed the value of BUFSIZE from 0 to 256 Jeff> which causes the MIDI data to be sent in multiple Jeff> blocks of 256 bytes. Then I added a 100 millisecond Jeff> delay at the end of the send(Receiver rcv, MidiMessage Jeff> msg) method. The whole thing looks like this: Jeff> /** Jeff> * MIDI Output buffer size. If set to '0', Whole Jeff> Sysex data is Jeff> * sent in one packet. Set '0' unless you have Jeff> problem. Jeff> */ Jeff> private static final int BUFSIZE = 256; Jeff> Jeff> /** Jeff> * Send a <code>MidiMessage</code>. If BUFSIZE is Jeff> non-zero, data Jeff> * size will be limited to the size. Jeff> */ Jeff> public static void send(Receiver rcv, MidiMessage Jeff> msg) Jeff> throws MidiUnavailableException, Jeff> InvalidMidiDataException { Jeff> int size = msg.getLength(); Jeff> Jeff> if (BUFSIZE == 0 || size <= BUFSIZE) { Jeff> rcv.send(msg, -1); Jeff> log("XMIT: ", msg); Jeff> } else { Jeff> // divide large System Exclusive Jeff> Message into multiple Jeff> // small messages. Jeff> byte[] sysex = msg.getMessage(); Jeff> byte[] tmpArray = new byte[BUFSIZE + Jeff> 1]; Jeff> for (int i = 0; size > 0; i += Jeff> BUFSIZE, size -= BUFSIZE) { Jeff> int s = Math.min(size, BUFSIZE); Jeff> Jeff> if (i == 0) { Jeff> System.arraycopy(sysex, i, Jeff> tmpArray, 0, s); Jeff> ((SysexMessage) Jeff> msg).setMessage(tmpArray, s); Jeff> } else { Jeff> tmpArray[0] = (byte) Jeff> SysexMessage.SPECIAL_SYSTEM_EXCLUSIVE; Jeff> System.arraycopy(sysex, i, Jeff> tmpArray, 1, s); Jeff> ((SysexMessage) Jeff> msg).setMessage(tmpArray, ++s); Jeff> } Jeff> rcv.send(msg, -1); Jeff> log("XMIT: ", msg); Jeff> try { Jeff> Thread.sleep (100); Jeff> } catch (Exception e) {} Jeff> } Jeff> } Jeff> } Jeff> Jeff> I realize this is only a temporary workaround. While Jeff> it doesn't totally eliminate signal errors I'm getting Jeff> way fewer of them than I was getting. Jeff> Jeff> I have only made these changes to my local copy and I Jeff> don't plan on committing the changes, since they would Jeff> only apply to Mac users and would only be a temporary Jeff> workaround at best. But for any of you who are Mac Jeff> users and don't want to use Plumstone, this might be Jeff> another alternative. -- Hiroo Hayashi |