|
| 1 | +# Dn-FamiTracker Instrument format |
| 2 | + |
| 3 | +- Document updated 2025-01-06 |
| 4 | +- Version 2.4 |
| 5 | + |
| 6 | +--- |
| 7 | + |
| 8 | +## File header |
| 9 | + |
| 10 | +| _Data type_ | _Unit size (bytes)_ | _Repeat_ | _Object/relevant variable in code_ | _Description_ | _Valid values_ | _Notes_ | |
| 11 | +| ------------ | ---------------------- | -------- | ---------------------------------------------------------------- | ---------------------- | ---------------------------------- | ---------------------- | |
| 12 | +| char[4] | 4 | | `INST_HEADER` | Identifier string | `FTI` | Null-terminated string | |
| 13 | +| unsigned int | 4 | | `INST_VERSION` | Module version | `2.4` | Null-terminated string | |
| 14 | +| char | 1 | | `m_pInstrumentManager->GetInstrument()->m_iType` | Instrument type | `enum inst_type_t` | See table. | |
| 15 | +| int | 4 | | `strlen()` of `m_pInstrumentManager->GetInstrument()->GetName()` | Instrument name length | 0 to `CInstrument::INST_NAME_MAX`. | | |
| 16 | +| char[] | Instrument name length | | `m_pInstrumentManager->GetInstrument()->GetName()` | Instrument name | | | |
| 17 | + |
| 18 | +## Instrument type value |
| 19 | + |
| 20 | +| *Chip* | *Index* | |
| 21 | +| ---- | ----- | |
| 22 | +| 2A03 | 0x01 | |
| 23 | +| VRC6 | 0x02 | |
| 24 | +| VRC7 | 0x03 | |
| 25 | +| FDS | 0x04 | |
| 26 | +| N163 | 0x05 | |
| 27 | +| S5B | 0x06 | |
| 28 | + |
| 29 | +## Base instrument format |
| 30 | + |
| 31 | +| _Data type_ | _Unit size (bytes)_ | _Repeat_ | _Object/relevant variable in code_ | _Description_ | _Valid range_ | _Notes_ | _Present in block version_ | |
| 32 | +| ----------- | ------------------- | ------------------ | ---------------------------------- | ------------------------------------------------- | ----------------- | ------------------------------------------------------------------------------------ | -------------------------- | |
| 33 | +| int | 4 | | `SEQ_COUNT` | Sequence count | `enum sequence_t` | Number of defined sequence types. <br>Volume, Arpeggio, Pitch, Hi-Pitch, Duty cycle | 1+ | |
| 34 | +| char | 1 | Per sequence count | `CSeqInstrument::m_iSeqEnable[]` | 0 = sequence is disabled, 1 = sequence is enabled | `enum sequence_t` | | 1+ | |
| 35 | +| char | 1 | ^ | `CSeqInstrument::m_iSeqIndex[]` | Sequence index | `enum sequence_t` | | 1+ | |
| 36 | + |
| 37 | +### 2A03 instruments |
| 38 | + |
| 39 | +Instrument type value: `0x01` |
| 40 | + |
| 41 | +| _Data type_ | _Unit size (bytes)_ | _Repeat_ | _Object/relevant variable in code_ | _Description_ | _Valid range_ | _Notes_ | _Present in block version_ | |
| 42 | +| ----------- | ------------------- | ---------------------------- | ----------------------------------------------- | ------------------------------------------------- | --------------------- | ------------------------------------------------------------ | -------------------------- | |
| 43 | +| int | 4 | | `SEQ_COUNT` | Sequence count | `enum sequence_t` | Volume, Arpeggio, Pitch, Hi-Pitch, Duty / Noise | 1+ | |
| 44 | +| char | 1 | Per sequence count | `CSeqInstrument::m_iSeqEnable[]` | 0 = sequence is disabled, 1 = sequence is enabled | `enum sequence_t` | | 1+ | |
| 45 | +| char | 1 | ^ | `CSeqInstrument::m_iSeqIndex[]` | Sequence index | `enum sequence_t` | | 1+ | |
| 46 | +| int | 4 | | `CInstrument2A03::GetSampleCount()` | DPCM sample assignment count | 0 to `MAX_DSAMPLES` | | 7+ | |
| 47 | +| char | 1 | DPCM sample assignment count | `Note` | DPCM sample assignment note index | 0 to `NOTE_COUNT - 1` | Written only when a sample exists at that note. | 7+ | |
| 48 | +| char | 1 | ^ | `CInstrument2A03::m_cSamples[Octave][Note]` | DPCM sample assignment index | 0 to `MAX_DSAMPLES` | Written only when a sample exists at that note in FT 050b1+. | 1+ | |
| 49 | +| char | 1 | ^ | `CInstrument2A03::m_cSamplePitch[Octave][Note]` | DPCM sample pitch | 0x0 to 0xF | Written only when a sample exists at that note in FT 050b1+. | 1+ | |
| 50 | +| char | 1 | ^ | `CInstrument2A03::m_cSampleDelta[Octave][Note]` | DPCM delta offset of a given note | | Written only when a sample exists at that note in FT 050b1+. | 6+ | |
| 51 | +#### Notes |
| 52 | + |
| 53 | +- Information is based on `CInstrument2A03::Store()` |
| 54 | +- Only 72 notes are defined in version 1. Version 2+ has all 96 notes defined. |
| 55 | +- In FamiTracker 0.5.0 beta, the DPCM format has been changed to only count notes with DPCM assignments. |
| 56 | + |
| 57 | +### VRC6 instruments |
| 58 | + |
| 59 | +- Same format as base instrument sequences format. |
| 60 | +- Fifth sequence type is named `Pulse Width`. |
| 61 | + |
| 62 | +#### Notes |
| 63 | + |
| 64 | +- Information is based on `CSeqInstrument::Store()` |
| 65 | +- Similar to 2A03 instruments but with no special considerations for DPCM |
| 66 | + |
| 67 | +### VRC7 instruments |
| 68 | + |
| 69 | +| _Data type_ | _Unit size (bytes)_ | _Repeat_ | _Object/relevant variable in code_ | _Description_ | _Valid range_ | _Notes_ | _Present in block version_ | |
| 70 | +| ----------- | ------------------- | -------- | ---------------------------------- | --------------------- | ------------- | ---------------------------------------- | -------------------------- | |
| 71 | +| int | 4 | | `CInstrumentVRC7::m_iPatch` | VRC7 patch number | | Hardware patch number of the instrument. | 2+ | |
| 72 | +| char[8] | 8 | | `CInstrumentVRC7::m_iRegs[]` | Custom patch settings | | Patch settings of hardware patch 0. | 2+ | |
| 73 | + |
| 74 | +#### Notes |
| 75 | + |
| 76 | +- Information is based on `CInstrumentVRC7::Store()` |
| 77 | + |
| 78 | +### FDS instruments |
| 79 | + |
| 80 | +| _Data type_ | _Unit size (bytes)_ | _Repeat_ | _Object/relevant variable in code_ | _Description_ | _Valid range_ | _Notes_ | _Present in block version_ | |
| 81 | +| ----------- | ------------------- | -------------------------------- | ------------------------------------ | --------------------------- | ------------------- | ------- | -------------------------- | |
| 82 | +| char[64] | 64 | | `CInstrumentFDS::m_iSamples[]` | Wave data | | | 3+ | |
| 83 | +| char[32] | 32 | | `CInstrumentFDS::m_iModulation[]` | Modulation table | | | 3+ | |
| 84 | +| int | 4 | | `CInstrumentFDS::m_iModulationSpeed` | Instrument modulation rate | | | 3+ | |
| 85 | +| int | 4 | | `CInstrumentFDS::m_iModulationDepth` | Instrument modulation depth | | | 3+ | |
| 86 | +| int | 4 | | `CInstrumentFDS::m_iModulationDelay` | Instrument modulation delay | | | 3+ | |
| 87 | +| char | 1 | `CInstrumentFDS::SEQUENCE_COUNT` | `CSequence::m_iItemCount` | Sequence item count | 0 to 255 | | 3+ | |
| 88 | +| int | 4 | ^ | `CSequence::m_iLoopPoint` | Sequence loop point | -1 to`SeqCount - 1` | | 3+ | |
| 89 | +| int | 4 | ^ | `CSequence::m_iReleasePoint` | Sequence release point | -1 to`SeqCount - 1` | | 4+ | |
| 90 | +| int | 4 | ^ | `CSequence::m_iSetting` | Sequence setting type | `seq_setting_t` | | 4+ | |
| 91 | +| char[] | Sequence item count | ^ | `CSequence::m_cValues[Index]` | Sequence data | | | 3+ | |
| 92 | + |
| 93 | +#### Notes |
| 94 | + |
| 95 | +- Information is based on `CInstrumentFDS::Store()` |
| 96 | +- FDS instruments stores its own sequences via `CInstrumentFDS::StoreSequence()`, separate from `CSeqInstrument::Store()` |
| 97 | + - These sequences only store 3 types, Volume, Arpeggio, and Pitch. |
| 98 | +- In version 3, volume range was 0-15. Later versions have volume ranges from 0-31. |
| 99 | +- In version 2, FDS sequences were stored incorrectly. |
| 100 | + |
| 101 | +### N163 instruments |
| 102 | + |
| 103 | +| _Data type_ | _Unit size (bytes)_ | _Repeat_ | _Object/relevant variable in code_ | _Description_ | _Valid range_ | _Notes_ | _Present in block version_ | |
| 104 | +| ----------- | ------------------- | ------------------ | ------------------------------------------- | ------------------------------------------------- | ------------------------ | ------------------------------------------------------------------------------------ | -------------------------- | |
| 105 | +| int | 4 | | `SEQ_COUNT` | Sequence count | `enum sequence_t` | Number of defined sequence types. <br>Volume, Arpeggio, Pitch, Hi-Pitch, Duty cycle | 1+ | |
| 106 | +| char | 1 | Per sequence count | `CSeqInstrument::m_iSeqEnable[]` | 0 = sequence is disabled, 1 = sequence is enabled | `enum sequence_t` | | 1+ | |
| 107 | +| char | 1 | ^ | `CSeqInstrument::m_iSeqIndex[]` | Sequence index | `enum sequence_t` | | 1+ | |
| 108 | +| int | 4 | | `AutoPosition` | Automatic wave data RAM allocation | 0, nonzero | | 8+ | |
| 109 | +| int | 4 | | `m_iWaveSize` | N163 wave size | 4 to `MAX_WAVE_SIZE` | In FT 0.5.0 beta, `m_iWaveSize` is determined by `m_iWaveCount / remaining_bytes` | 2-6 | |
| 110 | +| int | 4 | | `m_iWavePos` | N163 wave position | 0 to `MAX_WAVE_SIZE - 1` | Ignored if automatic wave data ram allocation is enabled | 2-6 | |
| 111 | +| int | 4 | | `m_iWaveCount` | N163 wave count | 1 to `MAX_WAVE_COUNT` | | 2+ | |
| 112 | +| char[] | Wave data size | Per wave count | `m_iSamples[MAX_WAVE_COUNT][MAX_WAVE_SIZE]` | N163 wave sample | 0 to 15 | | 2+ | |
| 113 | + |
| 114 | +#### Notes |
| 115 | + |
| 116 | +- Information is based on `CInstrumentN163::Store()` and instrument file binary analysis |
| 117 | +- Automatic wave data RAM allocation feature is from FT 0.5.0 beta. |
| 118 | + |
| 119 | +### S5B instruments |
| 120 | + |
| 121 | +- Same format as base instrument sequences format. |
| 122 | +- Fifth sequence type is named `Noise / Mode`. |
| 123 | + |
| 124 | +#### Notes |
| 125 | + |
| 126 | +- Information is based on `CSeqInstrument::Store()` |
| 127 | +- Similar to 2A03 instruments but with no special considerations for DPCM |
0 commit comments