From: Hiroo H. <hir...@co...> - 2005-03-12 23:34:47
|
Hi, Well, there were so many mails on this ML this week. It's good news for this project. But it's very difficult for me to read them... Let me reply on this check sum issue first. (Sorry, this mail gets long, too.) There were discussions about this issue since I joined this ML. The current implementation is the best way I could think of. 1. The interfaces between core and synthdrivers expect a patch whose check sum is already calculated, and do not have method to calculate check sum. 2. core interfaces a patch by using IPatch interface. 3. The current synthdrivers extend Driver class which is called via IPatch interface. 4. Driver class has the following *protected* classes. /** * Calculate check sum of a <code>Patch</code>.<p> * * Need to be overridden if a patch is consist from multiple SysEX * messages. * * @param p a <code>Patch</code> value */ protected void calculateChecksum(Patch p) { calculateChecksum(p, checksumStart, checksumEnd, checksumOffset); } The original Driver class had the method above. /** * Calculate check sum of a <code>Patch</code>. * <p> * * This method is called by calculateChecksum(Patch). The checksum * calculation method of this method is used by Roland, YAMAHA, etc. * Override this for different checksum calculation method. =2E.. */ protected void calculateChecksum(Patch patch, int start, int end, int offset) { DriverUtil.calculateChecksum(patch.sysex, start, end, offset); } The method above was introduced to make being reused easier. DriverUtils class has the following *static* method. By using *static* method we can call it without inheriting nor creating object. (For example a bank driver can share check sum method with a single driver easily). /** * Calculate check sum of a byte array <code>sysex</code>. * <p> * * The checksum calculation method of this method is used by Roland, YA= MAHA, * etc.<p> * =2E.. * @see Driver#calculateChecksum(Patch) */ public static void calculateChecksum(byte[] sysex, int start, int end, = int ofs) { int sum =3D 0; for (int i =3D start; i <=3D end; i++) sum +=3D sysex[i]; sysex[ofs] =3D (byte) (-sum & 0x7f); } What we can do is to add variation of this method on this class and let programmers choose one of them. The most difficult work is to name them as someone pointed. It is not difficult for programmers to implement this level of code. And it may be more difficult for them to select one of methods provided:-)=20 And my manual for Roland synth explain check sum as follows; aa + bb + cc + ... + hh =3D sum sum / 128 =3D quotient ... remainder 128 - remainder =3D check sum It might be even more difficult to understand the method above implements this calculation method. Better documentation may help some, but I have little hope. --=20 Hiroo Hayashi |