From: <tt_...@gm...> - 2004-10-02 08:16:32
|
Hi Hiroo, Hiroo Hayashi wrote: > Hi, > > I'd like to propose another core change of checksum handling. > > One of my questions when I made my synth driver was when I had to call > calculateChecksum method. Some of core methods calculate checksum. And > a synth driver also calculate checksum. It seems that calculateChecksum > is called many times unnecessarily. I guess this situation occurred > because it was not clear who has to calculate checksum and some method > calculated it for safe. > > Now we define the boundary between core and synthdrivers by defining > interfaces (IDriver, etc.). Now a patch goes to outside of synthdriver > via the following methods. > case 1. void IPatchDriver.send(IPatch, int, int) > case 2. void ISingleDriver.send(IPatch) > case 3. byte[] IPatch.getByteArray() > case 4. void Driver.send(byte[]) > > Here is my proposal > Proposal a) call calculateChecksum(Patch) in Driver.send(IPatch, int, > int) and Driver.send(IPatch). > > This cover the case 1 and 2. This does not require any synthdriver > change. > > Proposal b) Define IPatch.export(IPatch) which returns a byte array as > getByteArray() after it calculate checksum. This does not require any > synthdriver change, either. > > This cover the case 3. case 3 is for exporting Patch. > > For case 4, before Driver.send(byte[]) is called, calculateChecksum() is > always called already. > > By the simple proposal a) and b), both core and synth drivers do not > have to call calculateChecksum() method any more. We can get rid of > IPatchDriver.calculateCheckSum(IPatch) interface method instead of > adding IPatchDriver.export(). > > Driver class taking care of all of its subclass. A Synth driver > extending Driver class does not have to call calculateChecksum method. > And core does not have to call calculateChecksum method, either. > > This sounds good, doesn't it? > > I made fix locally. If there is no objection, I'll check it in a few > days later. > > Any feedback is welcome. I have no objections, but I think calculateChecksum is needed in some defined cases. 1. If we import a patch or request a patch from a synth to check the integrity of the received patch. 2. if we change a patch; for example if we edit a single patch or if we change the content of a bank patch. But I don't think that we need to call calculateChecksum if we only send or store a patch from library to the synth, because all patches which are stored resp. hold in the library should have the right Checksum. If not, we made a mistake while importing, loading, requesting a patch resp. editing or changing the content of a bank patch. Because of this scenario I don't think we need to call calculateChecksum for every send or store action. Of course we need to call calculateChecksum if we are working in the editor and send/play a patch for test purpose. I also think this is the right time to decide, if it's not better to put all the calculateChecksum stuff in an own core class and remove it from the drivers. Of course the drivers must contain the necessary information (in the constucto?) of the kind of checksum (2's complement, ...), the start and end of data which are concerned by the checksum, the place of the checksum itself in the patch, ... To be honour I have no idea how to implement this and it remains the point of changing core classes if a new kind of checksum is needed by a new driver. I have also no idea how to implement this if a driver separate a patch in several sysex messages because of it's large size. And shurely I missed some items. Bye Torsten |