Source code for jdxi_editor.midi.message.identity_request.message

"""
MIDI Identity Request Message Module

This module defines the `IdentityRequestMessage` class, which represents a MIDI Identity Request message.
MIDI Identity Request messages are used to query a device for its identity_request, typically to retrieve information such as its model or manufacturer.

Classes:
    - IdentityRequestMessage: Represents a MIDI Identity Request message used to query a device's identity_request.

Features:
    - Inherits from the base `Message` class, utilizing SysEx message structure.
    - Includes device identification information, such as device ID and fixed SysEx parameters.
    - Provides a method for converting the message into a list of bytes for sending via MIDI.

Constants Used:
    - START_OF_SYSEX: The start byte for a SysEx message.
    - ID_NUMBER, DEVICE, SUB_ID_1, SUB_ID_2: Fixed SysEx identifiers for the identity_request request.
    - END_OF_SYSEX: The end byte for a SysEx message.

Usage Example:
    >>> identity_msg = IdentityRequestMessage()
    >>> identity_msg.to_message_list()
    [0xF0, 0x7E, 0x00, 0x01, 0x02, 0xF7]

"""

from dataclasses import dataclass
from typing import List

from jdxi_editor.midi.message.midi import MidiMessage
from picomidi.constant import Midi


@dataclass
[docs] class IdentityRequestMessage(MidiMessage): """MIDI Identity Request message"""
[docs] device_id: int = 0x10 # Default device ID
[docs] def to_message_list(self) -> List[int]: """ Convert to list of bytes for sending :return: list """ from jdxi_editor.core.jdxi import JDXi return [ Midi.sysex.START, JDXi.Midi.SYSEX.IDENTITY.CONST.NUMBER, JDXi.Midi.SYSEX.IDENTITY.CONST.DEVICE, JDXi.Midi.SYSEX.IDENTITY.CONST.SUB1_GENERAL_INFORMATION, JDXi.Midi.SYSEX.IDENTITY.CONST.SUB2_IDENTITY_REQUEST, Midi.sysex.END, ]