A.V.R. PRO SERIES 16m Appendix III Sample Data Formats ------------------- Here is a brief description of the AVR Sample format The first 128 Byte on an AVR sound file on diac contain a sound file header. The first BYTE or WORD immediately following the header is the first BYTE or WORD of the sound sample itself. The contents of the header are as follows OFFSET SIZE DESCRITPTION (BYTES) --------- ------- ---------------------------------------------------- 0 - 3 4 4 BYTE ASCII CHARACTER I.D. CONTAINS '2BIT' 4 - 11 8 8 BYTE ASCII CHARACTER SAMPLE NAME UNUSED BYTES PADDED WITH NULL ($00). 12 - 13 2 WORD = 0 FOR MONO $FFFF FOR STEREO SAMPLE 14 - 15 2 WORD = SAMPLE RESOLUTION $0008 (8 BIT) $0010 (16 BIT) 16 - 17 2 WORD = $0000 UNSIGNED SAMPLE WORD = $FFFF SIGNED SAMPLE 18 - 19 2 WORD = $0000 NON-LOOPING SAMPLE WORD = $FFFF LOOPING SAMPLE 20 - 21 2 WORD = ASSIGNED MIDI NOTE / SPLIT $FFFF = NO ASSIGNMENT (DEFAULT) $FFxx = SINGLE KEY NOTE ASSIGNMENT $LLHH = KEY SPLIT, TWO BYTES, NOTE LOW/NOTE HI 22 - 25 4 LONG = SAMPLE SPEED SPLIT INTO 1 BYTE & 3 BYTES BYTE 22 = 0 TO 7 OR $FF BYTE 23 - 25 = 3 BYTE SAMPLE FREQUENCY IN HERTZ 26 - 29 4 LONG LENGTH OF SAMPLE IN DATA BYTES OR WORDS 30 - 33 4 LONG FIRST LOOP POINT (OFFSET IN DATA WORDS) FORCE $0000 IF UNUSED 34 - 37 4 LONG END LOOP POINT (OFFSET IN DATA WORDS) FORCE TO SAMPLE LENGTH IF UNUSED 38 - 39 2 - DO NOT USE - RESERVED AREA - MIDI KEYBOARD SPLIT 40 - 41 2 - DO NOT USE - RESERVED AREA - SAMPLE COMPRESSION 42 - 43 2 - DO NOT USE - RESERVED AREA - FILL WITH $00 44 - 63 20 FILENAME EXTENSION. FILLED WITH $00 IF UNUSED 64 - 127 64 FREE AREA FOR DEFINITION BY USER. MAY HAVE ASCII MESSAGE OR OTHER USER DEFINED DATA 128 - EOF -SAMPLE- Held in format described by header. Appendix - Page 13 This format represents a useful header which can be used to describe not only 16 Bit samples, but has the flexibility built into it to cater for MONO/STEREO and 8, 12, 14, and 16 BIT data sizes. 2-BIT SYSTEMS recommend, that users DO NOT occupy the reserved space in the first 64 BYTES of the header, the last 64 BYTES have been provided for micellanous use and abuse. If the user is developing software which uses the AVR format, please note the following :- When reading samples -------------------- i) Always check for the first 4 BYTES of the sample file for '2BIT' before attempting to load in any sample from disc. If this header is found, then it can be assumed, that the smple is in AVR format, no matter what the file extension is. It is useful, though not important, to save AVR files out as XXXX.AVR. ii) After having established that the sample is indeed an AVR file, load the 128 BYTE header into a seperate area of memory. Interpret this header before attempting to load the rest of the file. This is important for a number of reasons, the least of which is, that if a Stereo or 16 BIT sample were just about to be loaded, the load address for the sampl block should be made on a WORD boundary. iii) Do not take anything for grated about the sample. Ensure, that all of the important parameters have been read and interpreted. E.G. SIGN status. If your program can only use BYTE EXCESS samples then ensure that the samples is not signed (and un-sign it if it is). iv) When reading the FREQUENCY long word, mask off the top 8 BITS. These bits were used in ST REPLAY, PEPLAY PROFESSIONAL and the first version of the PRO-SERIES editors. This byte took the form of a value from 0 to 7 which was used to denote a fixed SYSTEM frequency (0 = 5 kHz, 7 = 48 kHz etc.). If this value is read as $FF, then the editor assumes that the sample frequency is not immediately compatible with the choice which the cartridge and EDITOR support. When writing a file ------------------- i) ALWAYS wipe the eintrire header area with zero's when constructing a new header. ii) ALWAYS force default values and never leave RUBBISH in areas unused by the program in question, remember, another program may look for DATA which is nonsense otherwise. iii) If looping is not used within an sample, ALWAYS force the start loop to be zero and end loop to match the sample length. iv) When writing the sample record frequency long word into the header, ensure that the default of $FF is placed into the top 8 BITS. SIZES and POINTER OFFSETS ------------------------- Please note the use of the phrase 'WORD size' when expressing the size of a sample or the offset of the loop pointers from the start of the sample. It is assumed that if the sample is an 8 BIT sample (or less), then the WORD size is BYTE. If the sample is greater that 8 BITS then the size is assumed to be a 16 BIT data WORD. Hence a 16 BIT file size of 10000 words would actually be 20000 BYTES in length. The value stored in the header should be 10000. Appendix - Page 14