|
From: Hiroo H. <hir...@co...> - 2004-08-23 03:56:44
|
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
|