
                             Impulse Header Layout

        0   1   2   3   4   5   6   7   8   9   A   B   C   D   E   F
      Ŀ
0000: 'I''M''P''M' Song Name, max 26 characters, includes NULL   
      Ĵ
0010: ....................................................... x  x 
      Ĵ
0020: OrdNum InsNum SmpNum PatNum  Cwt/v  Cmwt   Flags  x  x 
      Ĵ
0030: GV MV IS IT Sep(0) x  x  x  x  x  x  x  x  x  x 
      Ĵ
0040:  Chnl Pan (64 bytes)...........................................
      Ĵ

      Ĵ
0080:  Chnl Vol (64 bytes)...........................................
      Ĵ

      Ĵ
00C0:  Orders, Length = OrdNum                                       
      Ĵ
xxxx:  'Long' Offset of instruments, Length = InsNum*4 (1)           
      Ĵ
xxxx:  'Long' Offset of samples headers, Length = SmpNum*4 (2)       
      Ĵ
xxxx:  'Long' Offset of patterns, Length = PatNum*4 (3)              
      

      (1) Offset = 00C0h+OrdNum
      (2) Offset = 00C0h+OrdNum+InsNum*4
      (3) Offset = 00C0h+OrdNum+InsNum*4+SmpNum*4

      Cwt:      Created with tracker.
                 Impulse Tracker 1.0 = 0100h (256 dec)
      Cmwt:     Compatible with tracker with version greater than value.
      OrdNum:   Number of orders in song.
      InsNum:   Number of instruments in song
      SmpNum:   Number of samples in song
      PatNum:   Number of patterns in song
      Flags:    Bit 0: On = Stereo, Off = Mono
                Bit 1: Vol0MixOptimizations - If on, no mixing occurs if
                       the volume at mixing time is 0
                Bit 2: On = Use instruments, Off = Use samples.
                Bit 3: On = Linear slides, Off = Amiga slides.
      GV:       Global volume. (0->128) All volumes are adjusted by this
      MV:       Mix volume (0->128) During mixing, this value controls
                the magnitude of the wave being mixed.
      IS:       Initial Speed of song.
      IT:       Initial Tempo of song
      Sep:      Panning separation between channels (0->128, 128 is max sep.)
      Chnl Vol: Volume for each channel. Ranges from 0->64
      Chnl Pan: Each byte contains a panning value for a channel. Ranges from
                 0 (absolute left) to 64 (absolute right). 32 = central pan,
                 100 = Surround sound.
                 +128 = disabled channel (notes will not be played)
      Orders:   This is the order in which the patterns are played.
                 Valid values are from 0->199.
                 255 = "---", End of song marker
                 254 = "+++", Skip to next order


                           Impulse Instrument Format

        0   1   2   3   4   5   6   7   8   9   A   B   C   D   E   F
      Ŀ
0000: 'I''M''P''I' DOS FileName (12345678.123)                   
      Ĵ
0010: 00hFlgVLSVLESLSSLE x  x FdO x NNADNC x  x  x  x 
      Ĵ
0020:  Instrument Name, max 26 bytes, includes NUL...................
      Ĵ
0030: ....................................... x  x  x  x  x  x 
      Ĵ
0040:  Note-Sample/Keyboard Table, Length = 240 bytes................
      Ĵ

      Ĵ
0130:  Volume envelope (200 bytes)...................................
      Ĵ

                                      Ĵ
01F8:                                  Node points (25x2 bytes)......
                                      

      Flg:      Bit 0. On = Use volume envelope
                Bit 1. On = Use volume loop
                Bit 2. On = Use sustain volume loop
      VLS:      Volume loop start
      VLE:      Volume loop end
      SLS:      Sustain loop start
      SLE:      Sustain loop end
      FdO:      FadeOut
                Fade applied when:
                1) Note fade NNA is selected and triggered (by another note)
                2) Note off NNA is selected with no volume envelope
                   or volume envelope loop
                3) Volume envelope end is reached

      DNC:      Duplicate note check
      NNA:      New note action:
                        0 = Note cut
                        1 = Note off
                        2 = Note continue (only for non looped samples,
                                           a looped sample will be faded)
                        3 = Note fade

      Note-Sample/Keyboard Table.
       Each note of the instrument is first converted to a sample number
       and a note (C-0 -> B-9). These are stored as sample/note byte pairs

       Volume envelope: Values from 0->64, 0FFh indicating end of envelope.
       (after which note fade applies)

      Node data: Tick THEN magnitude



                             Impulse Sample Format

        0   1   2   3   4   5   6   7   8   9   A   B   C   D   E   F
      Ŀ
0000: 'I''M''P''S' DOS Filename (12345678.123)                   
      Ĵ
0010: 00hGvLFlgVol Sample Name, max 26 bytes, includes NUL.......
      Ĵ
0020: ....................................................... x  x 
      Ĵ
0030:  Length         Loop Begin     Loop End       C5Speed       
      Ĵ
0040:  SusLoop Begin  SusLoop End    SamplePointer ViSViDViRViT
      

The cache file has the following pieces of information added on:

        0   1   2   3   4   5   6   7   8   9   A   B   C   D   E   F
      Ŀ
0050:  File Size      Date   Time  Fmt...........................
      

        Fmt. 0 = unchecked. 1 = directory, 2 = it sample, 3 = st sample


      GvL:      Global volume for instrument, ranges from 0->64
      Flg:      Bit 0. On = sample associated with header.
                Bit 1-3. Reserved
                Bit 4. On = Use loop
                Bit 5. On = Use sustain loop
                Bit 6. On = Ping Pong loop, Off = Forwards loop
                Bit 7. On = Ping Pong Sustain loop, Off = Forwards Sustain loop
      Vol:      Default volume for instrument

      Length:   Length of sample                  }
      LoopBeg:  Start of loop                     } Only the lower 2 bytes of
      Loop End: Byte AFTER end of loop            } these values are used
      C5Speed:  Number of bytes a second for C-5  } IT 1.0
      SusLBeg:  Start of sustain loop             }
      SusLEnd:  Byte AFTER end of sustain loop    }

      SmpPoint: 'Long' Offset of sample in file.

      ViS:      Vibrato Speed, ranges from 0->64
      ViD:      Vibrato Depth, ranges from 0->64
      ViT:      Vibrato waveform type.
                        0=Sine wave
                        1=Ramp down
                        2=Square wave
                        3=Random (speed is irrelevant)
      ViR:      Vibrato Rate, rate at which vibrato is applied (0->64)



                             Impulse Pattern Format

        0   1   2   3   4   5   6   7   8   9   A   B   C   D   E   F
      Ŀ
0000: Length  Rows   x  x  x  x  Packed data................   
      Ĵ

      Length:   Length of packed pattern, not including the 8 byte header
      Rows:     Number of rows in this pattern (Ranges from 32->200)

      Patterns are unpacked by the following pseudocode...

      GetNextChannelMarker:
        Read byte into channelvariable.
        if(channelvariable = 0) then end of row
        Channel = (channelvariable-1) & 63
        if(channelvariable & 128) then read byte into maskvariable
          else maskvariable = previousmaskvariable for current channel
        if(maskvariable & 1), then read note. (byte value)
                // Note ranges from 0->119 (C-0 -> B-9)
                // 255 = note off, 254 = notecut
        if(maskvariable & 2), then read instrument (byte value)
                // Instrument ranges from 1->99
        if(maskvariable & 4), then read volume (byte value)
                // Volume ranges from 0->64
        if(maskvariable & 8), then read command (byte value) and commandvalue
                // Valid ranges from 0->31 (A=1, B=2, C=3, etc.)
        if(maskvariable & 16), then note = lastnote for channel
        if(maskvariable & 32), then instrument = lastinstrument for channel
        if(maskvariable & 64), then volume = lastvolume for channel
        if(maskvariable & 128), then {
                command = lastcommand for channel and
                commandvalue = lastcommandvalue for channel
        }
        Goto GetNextChannelMarker
