From: Jeff W. <jww...@ya...> - 2004-08-24 01:29:38
|
Hiroo, Greetings!! I'm not sure I understand your message. I don't think the problem is in the SysexSender but rather in the SysexWidget.sendSysex method. To restate my original message, first SysexWidget.sendSysex calls my generate method. When the call returns, SysexWidget.sendSysex calls setMessage(sysex, sysex.length). Because setMessage expects a valid sysex string and not a CC messages, it throws away the CC message and just returns the 0xF0 and 0xF7 sysex delimiters. Are you suggesting adding something like the code snippet you sent to the SysexWidget.sendSysex method? I suppose you could do something like check the first byte of the data and if it's equal to 0xF0, call setMessage, else have it continue through a case construct and test for the various other types of MIDI data. Is this what you're suggesting? Jeff --- Hiroo Hayashi <hir...@co...> wrote: > From: Hiroo Hayashi <hir...@co...> > To: JSynthLib Development > <jsy...@li...> > Subject: Fw: Re: [Jsynthlib-devel] Sending CC > Messages and Disabled Edit Menu > Date: Sun, 22 Aug 2004 21:56:45 -0500 > > I forgot to send mailing list. > > Jeff, could you try the patch at the bottom of this > mail? I borrowed > the code for LinuxMidiProvier which I made with > Torsten. Of course you > need to change SysexSender also. > > Forwarded by Hiroo Hayashi > <hir...@co...> > ----------------------- Original Message > ----------------------- > From: Hiroo Hayashi <hir...@co...> > To: Jeff Weber <jww...@ya...> > Date: Sun, 22 Aug 2004 20:04:24 -0500 > Subject: Re: [Jsynthlib-devel] Sending CC Messages > and Disabled Edit Menu > ---- > > Hi, > > Jeff> Looking at other drivers that use subclasses > of > Jeff> SysexSender, I noticed that a lot of them send > sysex > Jeff> for this purpose. But this really isn't > practical for > Jeff> the Pods (the only other option is to send > complete > Jeff> sysex records and the Pods tend to choke if > you send > Jeff> too much data to quickly). If anyone's > planning to > Jeff> address this issue, I hope this helps. > > This is known issue, but I thought it was not high > priority. I made > this change in April and there was only one report > for this issue. (At > that time I recommended to change driver to use > SysexSend only for sysex > message.) I misunderstand most of driver did not > send Short message by > using SysexSender. > It was my laziness not to check all drivers. I > checked some drivers but > I did not hit drivers who use SysexSend for Short > Message. > > I'll raise the priority for this. > > Jeff> Also, I mentioned a couple of weeks ago a > problem I > Jeff> was having with version 0.19 where the Edit... > command > Jeff> was disabled when I select a patch in the > library > Jeff> window. I received a reply from Torsten saying > he had > Jeff> fixed the problem and that I should try the > lastest > Jeff> version. I've tried several new versions since > then > Jeff> and I'm still having the same problem. For the > time > Jeff> being I've had to temporarily wire the Play > command to > Jeff> bring up my editor (the Pods can't "Play" > patches > Jeff> anyway). So far I haven't been able to track > down the > Jeff> cause of the problem. I still have a couple of > ideas I > Jeff> haven't tried yet but if anyone has any > insight into > Jeff> this, I sure would appreciate hearing from > you. > > I cannot reproduce this. Have you implemented > editPatch as I replied > you? > -- > Hiroo Hayashi > > --------------------- Original Message Ends > -------------------- > Index: MidiUtil.java > =================================================================== > RCS file: > /cvsroot/jsynthlib/JSynthLib/core/MidiUtil.java,v > retrieving revision 1.17 > diff -u -r1.17 MidiUtil.java > --- MidiUtil.java 22 Aug 2004 00:09:14 -0000 1.17 > +++ MidiUtil.java 23 Aug 2004 03:50:41 -0000 > @@ -23,6 +23,7 @@ > > import java.io.File; > import javax.sound.midi.*; > + > import java.util.*; > > /** > @@ -954,4 +955,138 @@ > > sequencer.start(); > } > + > + // create a separate class when jsynthlib.midi > package is created. > + public static class ByteToMidiMessage { > + private static int runningStatus; > + private static boolean thirdByte; > + private static byte[] buf; > + private static int size; // only for Sysex > + private static ArrayList list; > + > + public static MidiMessage[] valueOf(byte[] sysex) > { > + runningStatus = 0; > + thirdByte = false; > + buf = new byte[sysex.length]; > + list = new ArrayList(); > + try { > + for (int i = 0; i < sysex.length; > i++) { > + addToList((int) (sysex[i] & > 0xFF)); > + } > + } catch (InvalidMidiDataException e) { > + ErrorMsg.reportStatus(e); > + } > + return (MidiMessage[]) list.toArray(new > MidiMessage[0]); > + } > + > + private static void transmit(MidiMessage msg) { > + list.add(msg); > + } > + > + /** > + * convert a MIDI byte stream into MidiMessage > objects > + * and add them to input list, <code>list</code>. > + * > + * @author Hiroo Hayashi > + * @see "MIDI 1.0 Detailed Specification, Page > A-3" > + * @See javax.sound.midi.SystemMessage > + */ > + private static void addToList(int c) throws > InvalidMidiDataException { > + MidiMessage msg; > + if ((c & ~0xff) != 0) > + throw new InvalidMidiDataException(); > + if ((c & 0x80) == 0x80) { > + // status byte > + if ((c & 0xf8) == 0xf8) { // System Real Time > Message > + // 0 byte message > + msg = (MidiMessage) new ShortMessage(); > + ((ShortMessage) msg).setMessage(c); > + transmit(msg); > + } else { > + thirdByte = false; > + switch (c) { > + case ShortMessage.END_OF_EXCLUSIVE: > + if (runningStatus == > SysexMessage.SYSTEM_EXCLUSIVE) { > + byte[] d = new byte[size + 1]; > + System.arraycopy(buf, 0, d, 0, size); > + d[size++] = (byte) c; > + msg = (MidiMessage) new SysexMessage(); > + ((SysexMessage) msg).setMessage(d, size); > + transmit(msg); > + } > + break; > + case ShortMessage.TUNE_REQUEST: // 0xf6 > + // 0 byte message > + msg = (MidiMessage) new ShortMessage(); > + ((ShortMessage) msg).setMessage(c); > + transmit(msg); > + break; > + case SysexMessage.SYSTEM_EXCLUSIVE: > + size = 1; > + // FALLTHROUGH > + default: > + buf[0] = (byte) c; > + } > + runningStatus = c; > + } > + } else { > + // data byte > + if (thirdByte) { > + thirdByte = false; > + msg = (MidiMessage) new ShortMessage(); > + ((ShortMessage) msg).setMessage((int) (buf[0] > & 0xff), > + (int) (buf[1] & 0xff), c); > + transmit(msg); > + } else { > + switch (runningStatus < 0xf0 ? runningStatus > & 0xf0 : runningStatus) { > + case ShortMessage.SONG_POSITION_POINTER: // > 0xf2 > + // 2 byte message > + runningStatus = 0; > + // FALLTHROUGH > + case ShortMessage.NOTE_OFF: // 0x8n > + case ShortMessage.NOTE_ON: // 0x9n > + case ShortMessage.POLY_PRESSURE: // 0xAn > + case ShortMessage.CONTROL_CHANGE: // 0xBn > + case ShortMessage.PITCH_BEND: // 0xEn > + // 2 byte message > + thirdByte = true; > + buf[1] = (byte) c; > + break; > + > + case ShortMessage.MIDI_TIME_CODE: // 0xf1 > + case ShortMessage.SONG_SELECT: // 0xf3 > + // 1 byte message > + runningStatus = 0; > + // FALLTHROUGH > + case ShortMessage.PROGRAM_CHANGE: // 0xCn > + case ShortMessage.CHANNEL_PRESSURE: // 0xDn > + // 1 byte message > + msg = (MidiMessage) new ShortMessage(); > + ((ShortMessage) msg).setMessage((int) (buf[0] & > 0xff), c, 0); > + transmit(msg); > + break; > + > + case SysexMessage.SYSTEM_EXCLUSIVE: // 0xf0 > + buf[size++] = (byte) c; > + if (size == buf.length) { > + // Sysex data buffer is full > + byte[] d = new byte[size]; > + System.arraycopy(buf, 0, d, 0, size); > + msg = (MidiMessage) new SysexMessage(); > + ((SysexMessage) msg).setMessage(d, size); > + transmit(msg); > + // See SysexMessage document. > + buf[0] = (byte) > SysexMessage.SPECIAL_SYSTEM_EXCLUSIVE; > + size = 1; > + } > + break; > + > + default: // 0, 0xf4 (undef), 0xf5 (undef), > 0xf6 (Tune Request), 0xf7 (EOX) > + runningStatus = 0; > + // ignore data > + } > + } > + } > + } > + } > } // MidiUtil > > > > ------------------------------------------------------- > SF.Net email is sponsored by Shop4tech.com-Lowest > price on Blank Media > 100pk Sonic DVD-R 4x for only $29 -100pk Sonic DVD+R > for only $33 > Save 50% off Retail on Ink & Toner - Free Shipping > and Free Gift. > http://www.shop4tech.com/z/Inkjet_Cartridges/9_108_r285 > _______________________________________________ > Jsynthlib-devel mailing list > Jsy...@li... > https://lists.sourceforge.net/lists/listinfo/jsynthlib-devel > __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com |