From: Hiroo H. <hir...@co...> - 2004-08-29 19:22:59
|
I'd like to propose two inner interfaces for SysexWidget. 1. IParamModel public interface IParamModel { void set(int value); int get(); } The current ParamModel class depends on Patch class which is an implementation of IPatch. It cannot be used for other implementation of IPatch. By introducing this interface, SysexWidget and its subclasses can support any implementation of IPatch. 2. ISender public interface ISender { void send(IPatchDriver driver, int value); } Now SysexSender.generate() returns a byte array and SysexWidget.sendSysex() converts the byte array into a SysexMessage and send it to MIDI port. After my proposal SysexWidget.sendSysex() will just call ISender.send() method and send() method does all of the job. The main job of SysexSender class becomes sending Sysex Message. Easy to understand, isn't it? More importantly a sender has more flexibility. It can send any message, short message, multiple message, and mix of sysex and short message. For example WaldorfPulseSingleEditor.WaldorfPulseSender (the only sender which sends short message, I could find.) becomes as follows; class WaldorfPulseSender implements SysexWidget.ISender { private int param; private int mult; public WaldorfPulseSender(int param) { this(param, 1); } public WaldorfPulseSender(int param, int multiplier) { this.param = param; this.mult = multiplier; } public void send(IPatchDriver driver, int value) { ShortMessage msg = new ShortMessage(); try { msg.setMessage(ShortMessage.CONTROL_CHANGE, driver.getChannel() - 1, param, value * mult); driver.send(msg); } catch (InvalidMidiDataException e) { ErrorMsg.reportStatus(e); } } } This proposal requires little changes of SysexWidget, its subclasses in core, SysexSender, and ParamModel. No change for synthdrivers. I'm ready to commit them. Rib, are you changing these files for your XML driver? If so, I'll check-in my fix after your check-in. -- Hiroo Hayashi |