ShortMessage msgMSB = new ShortMessage(); ShortMessage msgTrigNumLSB = new ShortMessage(); ShortMessage msgTrigNumDataEntry = new ShortMessage();
if (trigNum != lastTrigNum) { ShortMessage msgMSB = new ShortMessage(); ShortMessage msgTrigNumLSB = new ShortMessage(); ShortMessage msgTrigNumDataEntry = new ShortMessage(); try { msgMSB.setMessage(ShortMessage.CONTROL_CHANGE, driver.getDevice().getChannel() - 1, 99, 0);  msgTrigNumLSB.setMessage(ShortMessage.CONTROL_CHANGE, driver.getDevice().getChannel() - 1, 98, 0);  msgTrigNumDataEntry.setMessage(ShortMessage.CONTROL_CHANGE, driver.getDevice().getChannel() - 1, 6, trigNum * 127 / maxTrigNum);  driver.send(msgMSB); driver.send(msgTrigNumLSB); driver.send(msgTrigNumDataEntry); } catch  (InvalidMidiDataException e) { ErrorMsg.reportStatus(e); } lastTrigNum = trigNum;  try { Thread.sleep (50); } catch (Exception e) {} }
    public void send(IPatchDriver driver, int value) {        ShortMessage msgMSB = new ShortMessage();        ShortMessage msgTrigNumLSB = new ShortMessage();        ShortMessage msgTrigNumDataEntry = new ShortMessage();        ShortMessage msgParamLSB = new ShortMessage();        ShortMessage msgValueDataEntry = new ShortMessage();        try {            msgMSB.setMessage(ShortMessage.CONTROL_CHANGE,                           driver.getDevice().getChannel() - 1, 99, 0);                        msgTrigNumLSB.setMessage(ShortMessage.CONTROL_CHANGE,                                     driver.getDevice().getChannel() - 1, 98, 0);                        msgTrigNumDataEntry.setMessage(ShortMessage.CONTROL_CHANGE,                                           driver.getDevice().getChannel() - 1, 6, trigNum);                        msgParamLSB.setMessage(ShortMessage.CONTROL_CHANGE,                           driver.getDevice().getChannel() - 1, 98, param);                        msgValueDataEntry.setMessage(ShortMessage.CONTROL_CHANGE,                           driver.getDevice().getChannel() - 1, 6, value * 127 / max);            driver.send(msgMSB);            driver.send(msgTrigNumLSB);            driver.send(msgTrigNumDataEntry);            driver.send(msgParamLSB);            driver.send(msgValueDataEntry);        } catch (InvalidMidiDataException e) {            ErrorMsg.reportStatus(e);        }    }