SAMPLE DUMP STANDARD A standard has been developed for sampler data dumps. It has been designed to work as an open or closed loop system. The closed loop system implements handshaking to improve speed and error recovery. This also accomodates machines that may need more time to process incoming data. The open loop system may be desired by those wishing to implement a simplified version with no handshaking. The basic messages are Dump Request, ACK, NAK, Wait, Cancel, Dump Header, and Data Packets. These messages are described in detail below. The data formats are given in hexidecimal. Dump Request F0 7E cc 03 ss ss F7 cc = channel number ss ss = requested sample, LSB first Upon receiving this message, the sampler should check to see if the requested sample number falls in a legal range. If it is, the sample is dumped to the requesting master following the procedure outlined below. If it is not within a legal range, the message should be ignored. ACK F0 7E cc 7F pp F7 cc = channel number pp = packet number This is the first handshaking flag. It means "Last data packet was received correctly. Start sending the next one." The packet number represents the packet being acknowledged as correct. NAK F0 7E cc 7E pp F7 cc = channel number pp = packet number This is the second handshaking flag. It means "Last data packet was received incorrectly. Please resend." The packet number represents the packet being rejected. Cancel F0 7E cc 7D pp F7 cc = channel number pp = packet number This is the third handshaking flag. It means "Abort dump." The packet number represents the packet on which the abort takes place. Wait F0 7E cc 7C pp F7 cc = channel number pp = packet number This is the fourth handshaking flag. It means "Do not send any more packets until told to do otherwise." This is important for systems in which the receiver (such as a computer) may need to perform other operations (such as disk access) before receiving the remainder of the dump. An ACK will continue the dump while a Cancel will abort the dump. Dump Header F0 7E cc 01 ss ss ee ff ff ff gg gg gg hh hh hh ii ii ii jj F7 cc = channel number ss ss = sample number (LSB first) ee = sample format (# of significant bits from 8-28) ff ff ff = sample period (1/sample rate) in nanoseconds (LSB first) gg gg gg = sample length in words (LSB first) hh hh hh = sustain loop start point word number (LSB first) ii ii ii = sustain loop end point word number (LSB first) jj = loop type (00 = forward only, 01 = backward/forward) Data Packet F0 7E cc 02 kk <120 bytes> ll F7 cc = channel number kk = running packet count (0-127) ll = checksum (XOR of 7E cc 02 kk <120 bytes>) The total size of a data packet is 127 bytes. This is to prevent MIDI input buffer overflow in machines that may want to receive an entire message before processing it. 128 bytes, or 1/2 page of memory, is considered the smallest reasonable buffer for modern MIDI instruments. Once a dump has been requested either from the front panel or over MIDI, the dump header is sent. After sending the header, the master must time out for at least two seconds, allowing the receiver to decide if it will accept the dump (enough memory, etc.). If the master receives a Cancel, it should abort the dump immediately. If it receives an ACK, it will start sending data packets. If it receives a Wait, it will pause indefinitely until another message is received. If nothing is received within the timeout, the master will assume an open loop and begin sending packets. A data packet consists of it's own header, a packet number, 120 data bytes, a checksum, and an End Of Exclusive (EOX). The packet number starts at 00 and increments with each new packet, resetting to 00 after it reaches 7FH. This is used by the receiver to distinguish between a new data packet and one being resent. This number is followed by 120 bytes of data which form 30, 40, or 60 words (MSB first) depending on the sample format. Each data byte consists of 7 bits. If the sample format is 8-14 bit, two bytes form a word. Sample formats of 15-21 bits require three bytes/word (yielding 40 words/packet). Sample formats of 22-28 bits require four bytes/word (yielding 30 words/packet). Information is left-justified within the 7-bit bytes and unused bits are filled in with zeros. For example, the sample word FFFH would be sent as 01111111B 01111100B. The word FFFH happens to represent a full positive value (000H represents full negative). The checksum is the XOR of 7E 02 <120 bytes>. When a sampler is receiving a data dump, it should keep a running checksum during reception. If the checksums match, it sends an ACK and wait for the next packet. If the checksums do not match, it sends a NAK and waits for the next packet. If the next packet number does not match the previous one and the sampler has no facility for receiving packets out of sequence, it should ignore the error and continue as if the checksum had matched. When a sampler is sending a data dump, it should send a packet and watch its MIDI In port. If an ACK is received, it sends the next packet. If a NAK is received and the packet number matches that of the previous packet, it resends that packet. If the packet numbers do not match and the sampler has no facility to send packets out of sequence, it should ignore the NAK. If a Wait is received, the sampler should watch its MIDI IN port indefinitely for another message and process it like a normal ACK, NAK, Cancel, or illegal message (which would usually abort the dump). If nothing is received within 20 milliseconds, the sampler can assume an open loop and send the next packet. The packet numbers are included in the handshaking flags (ACK, NAK, Cancel, Wait) in order to accomodate future machines that might have the intelligence to retransmit specific packets after the entire dump is completed or if synchronization is lost. This process continues until there are less than 121 bytes to send. The final data packet will still consist of 120 data bytes regardless of how many significant bytes actually remain. The unused bytes will be filled out with zeros. The receiver should receive and handshake on the last packet. If the receiver's memory becomes full, it should send a Cancel to the master. Sample Dump Standard 1