The patterns hold the notes. Each is a grid of 64 rows by 4 channels, and each cell says which sample to play, at what pitch and with what effect. The patterns are stored straight after the header, from offset 1084, and the order table says in which order they are played.
Patterns
Every pattern is 1,024 bytes: 64 rows of 16 bytes. They are stored in number order, pattern 0 first, with nothing between them, and there is no count: the number stored is one more than the highest number in the order table. Pattern p starts at 1084 + p × 1,024, and the cell for row r and channel c (counting channels from 1) is at
1084 + p × 1024 + r × 16 + (c − 1) × 4
A pattern always has 64 rows. A song can leave one early with a pattern break (Dxy) or a position jump (Bxx); see Effects. A pattern that no position names is still stored if a higher number is named, and is never played.
Rows
A row is 16 bytes: one 4-byte cell for each of the 4 channels, channel 1 first. All four cells of a row are played at the same moment, and the rows follow each other every few ticks, as the speed says (see timing).
+0 01 40 30 00 00 00 00 00 10 D6 20 00 00 00 0C 20
F-2 03 ... | --- .. ... | C-3 18 ... | --- .. C20Channel 1 plays sample 3 at F-2; channel 2 does nothing; channel 3 plays sample 18 at
C-3; channel 4 plays no note but sets its volume to 32 (C20).
Cells
A cell is 4 bytes, a b c d. The sample number is split across the first and third bytes, because it grew from 4 bits to 5 when modules went from 15 samples to 31:
a: ssss pppp s = high 4 bits of the sample number, p = period bits 11–8
b: pppp pppp period bits 7–0
c: ssss eeee s = low 4 bits of the sample number, e = effect (0–F)
d: xxxx yyyy effect parameter
| Value | From the bytes | Meaning |
|---|---|---|
| sample | (a & 0xF0) | (c >> 4) | 1 to 31; 0 means no sample is given, and the channel keeps the one it has. |
| period | ((a & 0x0F) << 8) | b | The pitch, as a 12-bit Amiga period; 0 means no note. |
| effect | c & 0x0F | The effect number, 0 to F. |
| parameter | d | The effect’s parameter, often read as two nibbles x and y. |
An effect of 0 with a parameter of 0 is no effect. Since the sample number is at most
31 (1F), only the lowest of its top four bits can be set, so the byte
a is below 20 hexadecimal in a correct file.
| Cell | Sample | Period | Effect | Shown as |
|---|---|---|---|---|
01 40 30 00 | 3 | 140 = 320 | none | F-2 03 ... |
10 D6 20 00 | 10 | 2 = 18 | 0D6 = 214 | none | C-3 18 ... |
00 00 0C 20 | none | none | C, parameter 32 | --- .. C20 |
The first two cells are from files examined for this site.
Periods
The pitch is stored as an Amiga period: the number of cycles of the Amiga’s colour clock that each sample byte is held for. The clock runs at 3,546,895 Hz on a PAL Amiga and 3,579,545 Hz on an NTSC one, so a note plays its sample at
rate = 3,546,895 / period bytes a second (PAL)
C-2, period 428, plays at about 8,287 bytes a second; each octave up halves the period. ProTracker names three octaves, C-1 to B-3, periods 856 down to 113. These are the periods with finetune 0, the ones written in the cells:
| C | C# | D | D# | E | F | F# | G | G# | A | A# | B | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Octave 1 | 856 | 808 | 762 | 720 | 678 | 640 | 604 | 570 | 538 | 508 | 480 | 453 |
| Octave 2 | 428 | 404 | 381 | 360 | 339 | 320 | 302 | 285 | 269 | 254 | 240 | 226 |
| Octave 3 | 214 | 202 | 190 | 180 | 170 | 160 | 151 | 143 | 135 | 127 | 120 | 113 |
ProTracker keeps one such row of 36 periods for each finetune, each followed by a 0 in memory, in the order of the finetune nibble: 0, +1 to +7, then −8 to −1. From C-1 to B-3:
0: 856 808 762 720 678 640 604 570 538 508 480 453 428 404 381 360 339 320 302 285 269 254 240 226 214 202 190 180 170 160 151 143 135 127 120 113
+1: 850 802 757 715 674 637 601 567 535 505 477 450 425 401 379 357 337 318 300 284 268 253 239 225 213 201 189 179 169 159 150 142 134 126 119 113
+2: 844 796 752 709 670 632 597 563 532 502 474 447 422 398 376 355 335 316 298 282 266 251 237 224 211 199 188 177 167 158 149 141 133 125 118 112
+3: 838 791 746 704 665 628 592 559 528 498 470 444 419 395 373 352 332 314 296 280 264 249 235 222 209 198 187 176 166 157 148 140 132 125 118 111
+4: 832 785 741 699 660 623 588 555 524 495 467 441 416 392 370 350 330 312 294 278 262 247 233 220 208 196 185 175 165 156 147 139 131 124 117 110
+5: 826 779 736 694 655 619 584 551 520 491 463 437 413 390 368 347 328 309 292 276 260 245 232 219 206 195 184 174 164 155 146 138 130 123 116 109
+6: 820 774 730 689 651 614 580 547 516 487 460 434 410 387 365 345 325 307 290 274 258 244 230 217 205 193 183 172 163 154 145 137 129 122 115 109
+7: 814 768 725 684 646 610 575 543 513 484 457 431 407 384 363 342 323 305 288 272 256 242 228 216 204 192 181 171 161 152 144 136 128 121 114 108
-8: 907 856 808 762 720 678 640 604 570 538 508 480 453 428 404 381 360 339 320 302 285 269 254 240 226 214 202 190 180 170 160 151 143 135 127 120
-7: 900 850 802 757 715 675 636 601 567 535 505 477 450 425 401 379 357 337 318 300 284 268 253 238 225 212 200 189 179 169 159 150 142 134 126 119
-6: 894 844 796 752 709 670 632 597 563 532 502 474 447 422 398 376 355 335 316 298 282 266 251 237 223 211 199 188 177 167 158 149 141 133 125 118
-5: 887 838 791 746 704 665 628 592 559 528 498 470 444 419 395 373 352 332 314 296 280 264 249 235 222 209 198 187 176 166 157 148 140 132 125 118
-4: 881 832 785 741 699 660 623 588 555 524 494 467 441 416 392 370 350 330 312 294 278 262 247 233 220 208 196 185 175 165 156 147 139 131 123 117
-3: 875 826 779 736 694 655 619 584 551 520 491 463 437 413 390 368 347 328 309 292 276 260 245 232 219 206 195 184 174 164 155 146 138 130 123 116
-2: 868 820 774 730 689 651 614 580 547 516 487 460 434 410 387 365 345 325 307 290 274 258 244 230 217 205 193 183 172 163 154 145 137 129 122 115
-1: 862 814 768 725 684 646 610 575 543 513 484 457 431 407 384 363 342 323 305 288 272 256 242 228 216 203 192 181 171 161 152 144 136 128 121 114
A few values are not what a formula would give: finetune −7 has 675 for E-1, −4 has 494 for A#-1 and −1 has 203 for C#-3. They are ProTracker’s own, and a player that wants to sound like ProTracker uses them as they are.
A cell’s period is always written with the finetune 0 values. To play a note, ProTracker goes through the finetune 0 row and finds the first entry the cell’s period is not below, then takes the entry at the same place in the row of the sample’s finetune. A sample with finetune +3 asked to play C-2 (428) plays 419.
Some PC trackers also write periods outside ProTracker’s range, for an octave 0 (1712 to 907) and an octave 4 (107 to 57). ProTracker has no entries for them; a period above 856 is played as C-1 of the sample’s finetune row, so 1712 plays as 856. The explorer plays this format as ProTracker does.