123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323 |
- #pragma once
- #include "openmpt/all/BuildSettings.hpp"
- #include "../soundlib/ModInstrument.h"
- #include "../soundlib/ModSample.h"
- #include "../soundlib/SampleIO.h"
- OPENMPT_NAMESPACE_BEGIN
- struct ITFileHeader
- {
-
- enum ITHeaderFlags
- {
- useStereoPlayback = 0x01,
- vol0Optimisations = 0x02,
- instrumentMode = 0x04,
- linearSlides = 0x08,
- itOldEffects = 0x10,
- itCompatGxx = 0x20,
- useMIDIPitchController = 0x40,
- reqEmbeddedMIDIConfig = 0x80,
- extendedFilterRange = 0x1000,
- };
-
- enum ITHeaderSpecialFlags
- {
- embedSongMessage = 0x01,
- embedEditHistory = 0x02,
- embedPatternHighlights = 0x04,
- embedMIDIConfiguration = 0x08,
- };
- char id[4];
- char songname[26];
- uint8le highlight_minor;
- uint8le highlight_major;
- uint16le ordnum;
- uint16le insnum;
- uint16le smpnum;
- uint16le patnum;
- uint16le cwtv;
- uint16le cmwt;
- uint16le flags;
- uint16le special;
- uint8le globalvol;
- uint8le mv;
- uint8le speed;
- uint8le tempo;
- uint8le sep;
- uint8le pwd;
- uint16le msglength;
- uint32le msgoffset;
- uint32le reserved;
- uint8le chnpan[64];
- uint8le chnvol[64];
- };
- MPT_BINARY_STRUCT(ITFileHeader, 192)
- struct ITEnvelope
- {
-
- enum ITEnvelopeFlags
- {
- envEnabled = 0x01,
- envLoop = 0x02,
- envSustain = 0x04,
- envCarry = 0x08,
- envFilter = 0x80,
- };
- struct Node
- {
- int8le value;
- uint16le tick;
- };
- uint8 flags;
- uint8 num;
- uint8 lpb;
- uint8 lpe;
- uint8 slb;
- uint8 sle;
- Node data[25];
- uint8 reserved;
-
- void ConvertToIT(const InstrumentEnvelope &mptEnv, uint8 envOffset, uint8 envDefault);
-
- void ConvertToMPT(InstrumentEnvelope &mptEnv, uint8 envOffset, uint8 maxNodes) const;
- };
- MPT_BINARY_STRUCT(ITEnvelope::Node, 3)
- MPT_BINARY_STRUCT(ITEnvelope, 82)
- struct ITOldInstrument
- {
- enum ITOldInstrFlags
- {
- envEnabled = 0x01,
- envLoop = 0x02,
- envSustain = 0x04,
- };
- char id[4];
- char filename[13];
- uint8le flags;
- uint8le vls;
- uint8le vle;
- uint8le sls;
- uint8le sle;
- char reserved1[2];
- uint16le fadeout;
- uint8le nna;
- uint8le dnc;
- uint16le trkvers;
- uint8le nos;
- char reserved2;
- char name[26];
- char reserved3[6];
- uint8le keyboard[240];
- uint8le volenv[200];
- uint8le nodes[25 * 2];
-
- void ConvertToMPT(ModInstrument &mptIns) const;
- };
- MPT_BINARY_STRUCT(ITOldInstrument, 554)
- struct ITInstrument
- {
- enum ITInstrumentFlags
- {
- ignorePanning = 0x80,
- enableCutoff = 0x80,
- enableResonance = 0x80,
- };
- char id[4];
- char filename[13];
- uint8le nna;
- uint8le dct;
- uint8le dca;
- uint16le fadeout;
- int8le pps;
- uint8le ppc;
- uint8le gbv;
- uint8le dfp;
- uint8le rv;
- uint8le rp;
- uint16le trkvers;
- uint8le nos;
- char reserved1;
- char name[26];
- uint8le ifc;
- uint8le ifr;
- uint8le mch;
- uint8le mpr;
- uint8le mbank[2];
- uint8le keyboard[240];
- ITEnvelope volenv;
- ITEnvelope panenv;
- ITEnvelope pitchenv;
- char dummy[4];
-
- uint32 ConvertToIT(const ModInstrument &mptIns, bool compatExport, const CSoundFile &sndFile);
-
- uint32 ConvertToMPT(ModInstrument &mptIns, MODTYPE fromType) const;
- };
- MPT_BINARY_STRUCT(ITInstrument, 554)
- struct ITInstrumentEx
- {
- ITInstrument iti;
- uint8 keyboardhi[120];
-
-
- uint32 ConvertToIT(const ModInstrument &mptIns, bool compatExport, const CSoundFile &sndFile);
-
- uint32 ConvertToMPT(ModInstrument &mptIns, MODTYPE fromType) const;
- };
- MPT_BINARY_STRUCT(ITInstrumentEx, sizeof(ITInstrument) + 120)
- struct ITSample
- {
-
- enum Magic
- {
- magic = 0x53504D49,
- };
- enum ITSampleFlags
- {
- sampleDataPresent = 0x01,
- sample16Bit = 0x02,
- sampleStereo = 0x04,
- sampleCompressed = 0x08,
- sampleLoop = 0x10,
- sampleSustain = 0x20,
- sampleBidiLoop = 0x40,
- sampleBidiSustain = 0x80,
- enablePanning = 0x80,
- cvtSignedSample = 0x01,
- cvtOPLInstrument = 0x40,
- cvtExternalSample = 0x80,
- cvtADPCMSample = 0xFF,
-
- cvtBigEndian = 0x02,
- cvtDelta = 0x04,
- cvtPTM8to16 = 0x08,
- };
- char id[4];
- char filename[13];
- uint8le gvl;
- uint8le flags;
- uint8le vol;
- char name[26];
- uint8le cvt;
- uint8le dfp;
- uint32le length;
- uint32le loopbegin;
- uint32le loopend;
- uint32le C5Speed;
- uint32le susloopbegin;
- uint32le susloopend;
- uint32le samplepointer;
- uint8le vis;
- uint8le vid;
- uint8le vir;
- uint8le vit;
-
- void ConvertToIT(const ModSample &mptSmp, MODTYPE fromType, bool compress, bool compressIT215, bool allowExternal);
-
- uint32 ConvertToMPT(ModSample &mptSmp) const;
-
- SampleIO GetSampleFormat(uint16 cwtv = 0x214) const;
- };
- MPT_BINARY_STRUCT(ITSample, 80)
- struct FileHistory;
- struct ITHistoryStruct
- {
- uint16le fatdate;
- uint16le fattime;
- uint32le runtime;
-
- void ConvertToMPT(FileHistory &mptHistory) const;
-
- void ConvertToIT(const FileHistory &mptHistory);
- };
- MPT_BINARY_STRUCT(ITHistoryStruct, 8)
- enum IT_ReaderBitMasks
- {
-
-
-
- IT_bitmask_patternChanField_c = 0x7f,
- IT_bitmask_patternChanMask_c = 0x3f,
- IT_bitmask_patternChanEnabled_c = 0x80,
- IT_bitmask_patternChanUsed_c = 0x0f
- };
- template<int32 y, int32 m, int32 d>
- struct SchismVersionFromDate
- {
- private:
- static constexpr int32 mm = (m + 9) % 12;
- static constexpr int32 yy = y - mm / 10;
- public:
- static constexpr int32 date = yy * 365 + yy / 4 - yy / 100 + yy / 400 + (mm * 306 + 5) / 10 + (d - 1);
- };
- inline constexpr int32 SchismTrackerEpoch = SchismVersionFromDate<2009, 10, 31>::date;
- uint32 DecodeITEditTimer(uint16 cwtv, uint32 editTime);
- OPENMPT_NAMESPACE_END
|