# Difference between revisions of "Impulse Tracker"

GreaseMonkey (talk | contribs) (→IT214 sample compression: the explanation might be a bit crap, sorry, but there's something here.) |
GreaseMonkey (talk | contribs) (→Resonant filters: adding some info) |
||

Line 31: | Line 31: | ||

===Resonant filters=== | ===Resonant filters=== | ||

− | ''TODO'' | + | |

+ | The resonant filter (added in 2.14p3) uses the following formula: | ||

+ | |||

+ | *K[n] = a * S[n] + b * K[n-1] + c * K[n-2] | ||

+ | |||

+ | where: | ||

+ | |||

+ | *K[n] is the outputted value at time n | ||

+ | *S[n] is the input value at time n | ||

+ | *a = 1/(1+d+e) | ||

+ | *b = (d+2e) / (1+d+e) | ||

+ | *c = -e / (1+d+e) | ||

+ | |||

+ | where: | ||

+ | |||

+ | *d = 2pr+2p-1 | ||

+ | *e = r^2 | ||

+ | |||

+ | where: | ||

+ | |||

+ | *r = 2^((cutoff/24.0)/(2.0*PI*110.0*(2.0^0.25))) (probably divided by the playback frequency) | ||

+ | *p = 10^((-resonance*24.0)/(128.0f*20.0f)) | ||

+ | |||

+ | ''TODO: The information is from [http://schismtracker.org/wiki/Resonant%20Filters here] and needs to be confirmed for accuracy (as in, where does the playback frequency come in?).'' | ||

===Effects=== | ===Effects=== |

## Revision as of 03:06, 22 January 2012

- Extension: it

## File Format

*TODO*

*it would be interesting to find out how the MIDI/timestamp stuff after the pointer list works... the other TODOs I (GM) know about*

## IT214 sample compression

If bit 3 (0x08 compressed samples) is set, the sample is compressed.

- Compression is split into blocks, where the
**uncompressed size**is 0x8000**bytes**(0x4000 samples for 16-bit, and 0x8000 otherwise). - Once a block is decompressed (or at least fails to decompress), the data is then delta decoded.
- The sample conversion flags are applied
**per-block**rather than for the whole sample. These are probably applied after delta decoding. - IT215 samples are IT214-compressed samples with the "Delta" flag (not the "Byte Delta" flag) set in the conversion flags.
- Each compressed block starts with a 16-bit length field, and then the bitstream is encoded in little-endian binary (LSB up).
- There is a "bit width" initially set to 9 for 8-bit samples, and 17 for 16-bit samples.
- The "bit width" is changed by special values inside their respective types. If such a special value is not triggered, the values are read as signed values, and unpacked
- There are three types of blocks, which we will call A, B, and C.
- Type A: Bit widths 1 through 6. Special value is 1 in the top bit and 0s for the rest. If such a value is triggered, it then reads 3 (8-bit) or 4 (16-bit) bits for calculating the new bit width (see below).
- Type B: Bit widths 7 through n, where n is 8 for 8-bit samples and 16 for 16-bit. Special values are 0...0100 through 1...1011 for 8-bit and 0...01000 through 1...10111 for 16-bit. If such a value is triggered, subtract 0...0100 (8-bit) or 0...01000 (16-bit) and use that to calculate the new bit width (see below).
- Type C: Bit width n+1. If the top bit is set, the lower 8 bits plus 1 are the new bit width.

- Barring type C, the new width selected is (v+1), except where v+1 >= the previous bit width, in which case the new width is v+1.
- If an invalid bit width is selected (only possible in type C), the decompressor
**terminates and leaves all the remaining values as 0 before delta decoding.** - The defacto standard for compressed stereo samples (as set by XMPlay) is to decompress the left channel
**entirely separately**from the right channel (where the data follows immediately afterwards), rather than decompress them together and separate afterwards.

*if this is a bit too messy, feel free to tidy it up*

## Playback notes

*TODO*

### Resonant filters

The resonant filter (added in 2.14p3) uses the following formula:

- K[n] = a * S[n] + b * K[n-1] + c * K[n-2]

where:

- K[n] is the outputted value at time n
- S[n] is the input value at time n
- a = 1/(1+d+e)
- b = (d+2e) / (1+d+e)
- c = -e / (1+d+e)

where:

- d = 2pr+2p-1
- e = r^2

where:

- r = 2^((cutoff/24.0)/(2.0*PI*110.0*(2.0^0.25))) (probably divided by the playback frequency)
- p = 10^((-resonance*24.0)/(128.0f*20.0f))

*TODO: The information is from here and needs to be confirmed for accuracy (as in, where does the playback frequency come in?).*

### Effects

#### Axx

Set song speed.

#### Bxx

Jump to Order.

- If this comes after an SBx loop command,
**the effect is done as-is**.

#### Cxx

Break to row.

- If this comes after an SBx loop command,
**the effect is ignored**.*TODO: look into how this information is relayed*

#### Dxx

Volume slide.

#### Exx

Pitch slide down.

#### Fxx

Pitch slide up.

#### Gxx

Slide to note.

#### Hxy

Vibrato with speed x, depth y.

#### Ixy

Tremor with ontime x and offtime y.

#### Jxy

Arpeggio.

#### Kxx

Dual command: H00 & Dxx

#### Lxx

Dual command: G00 & Dxx

#### Mxx

Set channel volume.

- If xx is > 0x40,
**the effect is ignored.**

#### Nxx

Channel volume slide.

#### Oxx

Set sample offset.

#### Pxy

Panning slide.

#### Qxy

Retrig.

#### Rxy

Tremolo with speed x, depth y.

#### Sxy - Miscellaneous effects

##### S0x

Set filter. Not implemented in Impulse Tracker.

**S00 - repeats the last nonzero Sxx effect for the channel.**

##### S1x

Set glissando control. Not implemented in Impulse Tracker.

##### S2x

Set finetune. Not Implemented in Impulse Tracker.

##### S3x

Set vibrato waveform.

Values for x:

- 0: Sine wave
- 1: Ramp down
- 2: Square wave
- 3: Random wave

**If x > 3, the effect is ignored.**

##### S4x

Set tremolo waveform.

Uses the same waveform table as S3x. **If x > 3, the effect is ignored.**

##### S5x

Set panbrello waveform.

Uses the same waveform table as S3x.

**If x > 3, the effect is ignored.**- This effect
**retriggers the panbrello waveform position**.

##### S6x

Pattern delay for x ticks.

##### S70

Past note cut.

##### S71

Past note off.

##### S72

Past note fade.

##### S73

Set NNA to note cut.

##### S74

Set NNA to continue.

##### S75

Set NNA to note off.

##### S76

Set NNA to note fade.

##### S77

Turn off volume envelope.

##### S78

Turn on volume envelope.

##### S79

Turn off panning envelope.

##### S7A

Turn on panning envelope.

##### S7B

Turn off pitch envelope.

##### S7C

Turn on pitch envelope.

##### S8x

Set panning position.

##### S91

Set surround sound.

##### SAy

Set high value of sample offset yxx00h

##### SBx

Pattern loop.

##### SCx

Note cut after x ticks.

##### SDx

Note delay for x ticks.

##### SEx

Pattern delay for x rows

##### SFx

Set parameterised MIDI macro.

#### Txx

Set Tempo.

#### Uxy

Fine vibrato with speed x, depth y.

#### Vxx

Set global volume.

- If xx is > 0x80,
**the effect is ignored.**

#### Wxy

Global volume slide.

#### Xxx

Set panning position. Sets panning to **(xx + 2) div 4**

#### Yxy

Panbrello with speed x, depth y.

**If the panbrello waveform is set to 'Random', then the speed is interpreted as a delay**.

#### Zxx

MIDI Macros