MANUFACTURER_ID = [0x41]  # Roland
GT1000_FAMILY = [0x4F, 0x03]
# this is the broadcast address, it gets replaced if we receive a valid device_id
DEVICE_ID_BCAST = 0x7F
MODEL_ID = [0x00, 0x00, 0x00, 0x4F]
RQ1_COMMAND_ID = [0x11]
DT1_COMMAND_ID = [0x12]
DT1_SYSEX_HEADER = MANUFACTURER_ID + [DEVICE_ID_BCAST] + MODEL_ID + DT1_COMMAND_ID
RQ1_SYSEX_HEADER = MANUFACTURER_ID + [DEVICE_ID_BCAST] + MODEL_ID + RQ1_COMMAND_ID

SYSEX_START = [0xF0]
SYSEX_END = [0xF7]

NON_RT_MSG = [0x7E]
BCAST_DEV_ID = [0x7F]
GEN_INFO = [0x06]
IDENTITY_REQUEST = [0x01]
IDENTITY_REPLY = [0x02]

ONE_BYTE = [0x0, 0x0, 0x0, 0x1]

# [0xf0, 0x7e, 0x7f, 0x6, 0x1, 0xf7]
IDENTITY_REQUEST_MSG = (
    SYSEX_START + NON_RT_MSG + BCAST_DEV_ID + GEN_INFO + IDENTITY_REQUEST + SYSEX_END
)

# Asking to read 1 byte from 0x7f, 0x0, 0x0, 0x0 ?
# 0xf0, 0x41, 0x10, 0x0, 0x0, 0x0, 0x4f, 0x11, 0x7f, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1, 0x0, 0xf7
EDITOR_MODE_ADDRESS_FETCH1 = [0x7F, 0x0, 0x0, 0x0]
EDITOR_MODE_ADDRESS_LEN1 = ONE_BYTE

# Read 0x8 at 0x7f, 0x0, 0x0, 0x0
# 0xf0, 0x41, 0x10, 0x0, 0x0, 0x0, 0x4f, 0x12, 0x7f, 0x0, 0x0, 0x0, 0x8, 0x79, 0xf7
EDITOR_REPLY1 = [0x8]

# Set 1 at 0x7f, 0x0, 0x0, 0x1 ?
# 0xf0, 0x41, 0x10, 0x0, 0x0, 0x0, 0x4f, 0x12, 0x7f, 0x0, 0x0, 0x1, 0x1, 0x7f, 0xf7
EDITOR_MODE_ADDRESS_SET2 = [0x7F, 0x0, 0x0, 0x1]
EDITOR_MODE_ADDESS_VALUE2 = [0x1]
EDITOR_REPLY2 = EDITOR_MODE_ADDESS_VALUE2
# the reply to command2 is the same as the request

# Asking to read 1 byte from 0x7f, 0x0, 0x0, 0x3
# 0xf0, 0x41, 0x10, 0x0, 0x0, 0x0, 0x4f, 0x11, 0x7f, 0x0, 0x0, 0x3, 0x0, 0x0, 0x0, 0x1, 0x7d, 0xf7
EDITOR_MODE_ADDRESS_FETCH3 = [0x7F, 0x0, 0x0, 0x3]
EDITOR_MODE_ADDRESS_LEN3 = ONE_BYTE

# Read 0 at 0x7f, 0x0, 0x0, 0x3
# 0xf0, 0x41, 0x10, 0x0, 0x0, 0x0, 0x4f, 0x12, 0x7f, 0x0, 0x0, 0x3, 0x0, 0x7e, 0xf7
EDITOR_REPLY3 = [0x0]

# 0xf0, 0x41, 0x10, 0x0, 0x0, 0x0, 0x4f, 0x11, 0x52, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1, 0x0, 0x2d, 0xf7
EDITOR_MODE_COMMAND4 = [0x52, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1, 0x0]
# the reply to command4 is the same as the request

PATCH_NAMES_BEGIN_OFFSET = [0x52, 0x0, 0x0, 0x0]
PATCH_NAMES_LEN = [0x0, 0x0, 0x1, 0x0]

PATCH_NAMES_REPLY = (
    SYSEX_START + DT1_SYSEX_HEADER + PATCH_NAMES_BEGIN_OFFSET
)  # and then it's 16 bytes of ASCII per patch, 8 patches, then checksum and SYSEX_END

# then we get the same for addresses:
# [0x52, 0x0, 0x1, 0x0]
# [0x52, 0x0, 0x2, 0x0]
# [...]
# [0x52, 0x0, 0x3e, 0x0]

FX_TO_TABLE_SUFFIX = {
    "AC GUITAR SIM": "AGSim",
    "AC RESONANCE": "AcReso",
    "AUTO WAH": "AWah",
    "CHORUS": "Chorus",
    "CLASSIC-VIBE": "CVibe",
    "COMPRESSOR": "Comp",
    "DEFRETTER": "Defretter",
    "FEEDBACKER": "Feedbacker",
    "FLANGER": "Flanger",
    "HARMONIST": "Harmonist",
    "HUMANIZER": "Humanizer",
    "OCTAVE": "Octave",
    "OVERTONE": "Overtone",
    "PAN": "Pan",
    "PHASER": "Phaser",
    "PITCH SHIFTER": "PitchShift",
    "RING MOD": "RingMod",
    "ROTARY": "Rotary",
    "SITAR SIM": "SitarSim",
    "SLICER": "Slicer",
    "SLOW GEAR": "SlowGear",
    "SOUND HOLD": "SoundHold",
    "S-BEND": "SBend",
    "TOUCH WAH": "TWah",
    "TREMOLO": "Tremolo",
    "VIBRATO": "Vibrato",
    "CHORUS BASS": "ChorusBass",
    "FLANGER BASS": "FlangerBass",
    "DISTORTION": "Dist",
    "MASTERING FX": "MasterFx",
    # These 4 don't have an entry in the "patch[2,3]" tables ?
    "DEFRETTER BASS": "PatchFxDefretterBass",
    "OCTAVE BASS": "PatchFxOctaveBass",
    "SLOW GEAR BASS": "PatchFxSlowGearBass",
    "TOUCH WAH BASS": "PatchFxTWahBass",
}
