123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235 |
- #pragma once
- #include "openmpt/all/BuildSettings.hpp"
- #include "Snd_defs.h"
- #include "../common/misc_util.h"
- OPENMPT_NAMESPACE_BEGIN
- class CSoundFile;
- enum : uint8
- {
- NOTE_NONE = 0,
- NOTE_MIN = 1,
- NOTE_MAX = 120,
- NOTE_MIDDLEC = (5 * 12 + NOTE_MIN),
- NOTE_KEYOFF = 0xFF,
- NOTE_NOTECUT = 0xFE,
- NOTE_FADE = 0xFD,
- NOTE_PC = 0xFC,
- NOTE_PCS = 0xFB,
- NOTE_MIN_SPECIAL = NOTE_PCS,
- NOTE_MAX_SPECIAL = NOTE_KEYOFF,
- };
- enum VolumeCommand : uint8
- {
- VOLCMD_NONE = 0,
- VOLCMD_VOLUME = 1,
- VOLCMD_PANNING = 2,
- VOLCMD_VOLSLIDEUP = 3,
- VOLCMD_VOLSLIDEDOWN = 4,
- VOLCMD_FINEVOLUP = 5,
- VOLCMD_FINEVOLDOWN = 6,
- VOLCMD_VIBRATOSPEED = 7,
- VOLCMD_VIBRATODEPTH = 8,
- VOLCMD_PANSLIDELEFT = 9,
- VOLCMD_PANSLIDERIGHT = 10,
- VOLCMD_TONEPORTAMENTO = 11,
- VOLCMD_PORTAUP = 12,
- VOLCMD_PORTADOWN = 13,
- VOLCMD_PLAYCONTROL = 14,
- VOLCMD_OFFSET = 15,
- MAX_VOLCMDS
- };
- enum EffectCommand : uint8
- {
- CMD_NONE = 0,
- CMD_ARPEGGIO = 1,
- CMD_PORTAMENTOUP = 2,
- CMD_PORTAMENTODOWN = 3,
- CMD_TONEPORTAMENTO = 4,
- CMD_VIBRATO = 5,
- CMD_TONEPORTAVOL = 6,
- CMD_VIBRATOVOL = 7,
- CMD_TREMOLO = 8,
- CMD_PANNING8 = 9,
- CMD_OFFSET = 10,
- CMD_VOLUMESLIDE = 11,
- CMD_POSITIONJUMP = 12,
- CMD_VOLUME = 13,
- CMD_PATTERNBREAK = 14,
- CMD_RETRIG = 15,
- CMD_SPEED = 16,
- CMD_TEMPO = 17,
- CMD_TREMOR = 18,
- CMD_MODCMDEX = 19,
- CMD_S3MCMDEX = 20,
- CMD_CHANNELVOLUME = 21,
- CMD_CHANNELVOLSLIDE = 22,
- CMD_GLOBALVOLUME = 23,
- CMD_GLOBALVOLSLIDE = 24,
- CMD_KEYOFF = 25,
- CMD_FINEVIBRATO = 26,
- CMD_PANBRELLO = 27,
- CMD_XFINEPORTAUPDOWN = 28,
- CMD_PANNINGSLIDE = 29,
- CMD_SETENVPOSITION = 30,
- CMD_MIDI = 31,
- CMD_SMOOTHMIDI = 32,
- CMD_DELAYCUT = 33,
- CMD_XPARAM = 34,
- CMD_FINETUNE = 35,
- CMD_FINETUNE_SMOOTH = 36,
- CMD_DUMMY = 37,
- CMD_NOTESLIDEUP = 38,
- CMD_NOTESLIDEDOWN = 39,
- CMD_NOTESLIDEUPRETRIG = 40,
- CMD_NOTESLIDEDOWNRETRIG = 41,
- CMD_REVERSEOFFSET = 42,
- CMD_DBMECHO = 43,
- CMD_OFFSETPERCENTAGE = 44,
- CMD_DIGIREVERSESAMPLE = 45,
- MAX_EFFECTS
- };
- enum EffectType : uint8
- {
- EFFECT_TYPE_NORMAL = 0,
- EFFECT_TYPE_GLOBAL = 1,
- EFFECT_TYPE_VOLUME = 2,
- EFFECT_TYPE_PANNING = 3,
- EFFECT_TYPE_PITCH = 4,
- MAX_EFFECT_TYPE = 5
- };
- class ModCommand
- {
- public:
- using NOTE = uint8;
- using INSTR = uint8;
- using VOL = uint8;
- using VOLCMD = uint8;
- using COMMAND = uint8;
- using PARAM = uint8;
-
-
- static constexpr int maxColumnValue = 999;
-
- static ModCommand Empty() { return ModCommand(); }
- bool operator==(const ModCommand &mc) const
- {
- return (note == mc.note)
- && (instr == mc.instr)
- && (volcmd == mc.volcmd)
- && (command == mc.command)
- && ((volcmd == VOLCMD_NONE && !IsPcNote()) || vol == mc.vol)
- && ((command == CMD_NONE && !IsPcNote()) || param == mc.param);
- }
- bool operator!=(const ModCommand& mc) const { return !(*this == mc); }
- void Set(NOTE n, INSTR ins, uint16 volcol, uint16 effectcol) { note = n; instr = ins; SetValueVolCol(volcol); SetValueEffectCol(effectcol); }
- uint16 GetValueVolCol() const { return GetValueVolCol(volcmd, vol); }
- static uint16 GetValueVolCol(uint8 volcmd, uint8 vol) { return (volcmd << 8) + vol; }
- void SetValueVolCol(const uint16 val) { volcmd = static_cast<VOLCMD>(val >> 8); vol = static_cast<uint8>(val & 0xFF); }
- uint16 GetValueEffectCol() const { return GetValueEffectCol(command, param); }
- static uint16 GetValueEffectCol(uint8 command, uint8 param) { return (command << 8) + param; }
- void SetValueEffectCol(const uint16 val) { command = static_cast<COMMAND>(val >> 8); param = static_cast<uint8>(val & 0xFF); }
-
- void Clear() { memset(this, 0, sizeof(ModCommand)); }
-
- bool IsEmpty() const
- {
- return (note == NOTE_NONE && instr == 0 && volcmd == VOLCMD_NONE && command == CMD_NONE);
- }
-
- bool IsInstrPlug() const { return IsPcNote(); }
-
- bool IsPcNote() const { return IsPcNote(note); }
- static bool IsPcNote(NOTE note) { return note == NOTE_PC || note == NOTE_PCS; }
-
- bool IsNote() const { return mpt::is_in_range(note, NOTE_MIN, NOTE_MAX); }
- static bool IsNote(NOTE note) { return mpt::is_in_range(note, NOTE_MIN, NOTE_MAX); }
-
- bool IsSpecialNote() const { return mpt::is_in_range(note, NOTE_MIN_SPECIAL, NOTE_MAX_SPECIAL); }
- static bool IsSpecialNote(NOTE note) { return mpt::is_in_range(note, NOTE_MIN_SPECIAL, NOTE_MAX_SPECIAL); }
-
- bool IsNoteOrEmpty() const { return note == NOTE_NONE || IsNote(); }
- static bool IsNoteOrEmpty(NOTE note) { return note == NOTE_NONE || IsNote(note); }
-
- bool IsPortamento() const { return command == CMD_TONEPORTAMENTO || command == CMD_TONEPORTAVOL || volcmd == VOLCMD_TONEPORTAMENTO; }
-
- bool IsContinousCommand(const CSoundFile &sndFile) const;
- bool IsContinousVolColCommand() const;
-
- bool IsSlideUpDownCommand() const;
-
- bool IsGlobalCommand() const { return IsGlobalCommand(command, param); }
- static bool IsGlobalCommand(COMMAND command, PARAM param);
-
- bool IsAmigaNote() const { return IsAmigaNote(note); }
- static bool IsAmigaNote(NOTE note) { return !IsNote(note) || (note >= NOTE_MIDDLEC - 12 && note < NOTE_MIDDLEC + 24); }
- static EffectType GetEffectType(COMMAND cmd);
- EffectType GetEffectType() const { return GetEffectType(command); }
- static EffectType GetVolumeEffectType(VOLCMD volcmd);
- EffectType GetVolumeEffectType() const { return GetVolumeEffectType(volcmd); }
-
- void Convert(MODTYPE fromType, MODTYPE toType, const CSoundFile &sndFile);
-
- void ExtendedMODtoS3MEffect();
-
- void ExtendedS3MtoMODEffect();
-
-
- static size_t GetEffectWeight(COMMAND cmd);
-
- static bool ConvertVolEffect(uint8 &effect, uint8 ¶m, bool force);
-
- static std::pair<EffectCommand, PARAM> TwoRegularCommandsToMPT(uint8 &effect1, uint8 ¶m1, uint8 &effect2, uint8 ¶m2);
-
- static bool CombineEffects(uint8 &eff1, uint8 ¶m1, uint8 &eff2, uint8 ¶m2);
- public:
- uint8 note = NOTE_NONE;
- uint8 instr = 0;
- uint8 volcmd = VOLCMD_NONE;
- uint8 command = CMD_NONE;
- uint8 vol = 0;
- uint8 param = 0;
- };
- OPENMPT_NAMESPACE_END
|