Looping chunks for 8SVX form SEQN and FADE Chunks Multiple Loop Sequencing in the "8SVX" IFF 8-bit Sample Voice --------------------------------------------------- Registered by Peter Norman, RamScan Software Pty Ltd. Sound samples are notorious for demanding huge amounts of memory. While earlier uses of digital sound on the Amiga were mainly in the form of short looping waveforms for use as musical instruments, many people today wish to record several seconds (even minutes) of sound. This of course eats memory. Assuming that quite often the content of these recordings is music, and that quite often music contains several passages which repeat at given times, "verse1 .. chorus .. verse2 .. chorus .." etc, a useful extention has been added to the 8SVX list of optional data chunks. It's purpose is to conserve memory by having the computer repeat sections rather than having several instances of a similar sound or musical passage taking up valuable sample space. The "SEQN" chunk has been created to define "Multiple" loops or sections within a single octave 8SVX MONO or STEREO waveform. It is intended that a sampled sound player program which supports this chunk will play sections of the waveform sequentially in an order that the SEQN chunk specifies. This means for example, if an identical chorus repeats throughout a recording, rather than have this chorus stored several times along the waveform, it is only necessary to have one copy of the chorus stored in the waveform. A "SEQeNce" of definitions can then be set up to have the computer loop back and repeat the chorus at the required time. The remaining choruses stored in the waveform will no longer be necessary and can be removed. eg. If we had a recording of the following example, we would find that there are several parts which simply repeat. Substantial savings can be made by having the computer repeat sections rather than have them stored in memory. EXAMPLE "Haaaallelujah....Haaaallelujah...Hallelujah..Hallelujah..Halleeeelujaaaah." Applying a sequence to the above recording would look as follows. Haaaallelujah....Haaaallelujah...Hallelujah..Hallelujah..Halleeeelujaaaah. [ Loop1 ] [ Loop2 ] [ Loop3 ] [ Loop4 ] [ Loop5 ] [ Dead Space ] [ Dead Space ] The DEAD SPACE can be removed. With careful editing of the multiple loop positions, the passage can be made to sound exactly the same as the original with far less memory required. Chunk Definitions... Optional Data Chunk SEQN ________________________ The optional data chunk SEQN gives the information necessary to play a sample in a sequence of defined blocks. To have a segment repeat twice, the definition occurs twice in the list. This list consists of pairs of ULONG "loop start" and "end" definitions which are offsets from the start of the waveform. The locations or values must be LONGWORD aligned (divisable by 4). To determine how many loop definitions in a given file, simply divide the SEQN chunk size by 8. eg if chunk size == 40 ... number of loops = (40 / 8) .. equals 5 loops. The raw data in a file might look like this... 'S-E-Q-N' [ size ] [ Loop 1 ] [ Loop 2 ] [ Loop 3 ] 5345514E 00000028 00000000 00000C00 00000000 00000C00 00000C08 00002000 ^ ^ 'Haaaallelujah..' 'Haaaallelujah..' 'Hallelujah..' ^ ^ 40 bytes decimal / 8 = 5 loop or segments [ Loop 4 ] [ Loop 5 ]'B-O-D-Y' Size Data 00000C08 00002000 00002008 00003000 424F4459 000BE974 010101010101010 'Hallelujah..' 'Halleeeelujah..' In a waveform containing SEQN chunks, the oneShotHiSamples should be set to 0 and the repeatHiSamples should equal the BODY length (divided by 2 if STEREO). Remember the locations of the start and end of each segment or loop should be LONGWORD aligned. If the waveform is Stereo, treat the values and locations in exactly the same way. In other words, if a loop starts at location 400 within a Stereo waveform, you start the sound at the 400th byte position in the left data and the 400th byte position in the right data simultaneously. #define ID_SEQN MakeID('S','E','Q','N') Optional Data Chunk FADE _______________________ The FADE chunk defines at what loop number the sound should begin to fade away to silence. It is possible to finish a sample of music in much the same way as commercial music does today. A FADE chunk consists of one ULONG value which has a number in it. This number corresponds to the loop number at which the fade should begin. eg. You may have a waveform containing 50 loops. A FADE definition of 45 will specify that once loop 45 is reached, fading to zero volume should begin. The rate at which this fade takes place is determined by the length of time left to play. The playing software should do a calculation based on the following... Length of all remaining sequences including current sequence (in bytes) divided by the current playback rate in samples per second = time remaining. Begin stepping the volume down at a rate which will hit zero volume just as the waveform finishes. The raw data in a file may look like this. 'F-A-D-E' [ Size ] Loop No. 'B-O-D-Y' Size Data.. 46414445 00000004 0000002D 424F4459 000BE974 01010101 01010101 etc etc ^ Start fading when loop number 45 is reached. #define ID_FADE MakeID('F','A','D','E') Although order shouldn't make much difference, it is a general rule of thumb that SEQN should come before FADE and FADE should be last before the BODY. Stereo waveforms would have CHAN,SEQN,FADE,BODY in that order.