class_inputeventmidi.rst 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217
  1. :github_url: hide
  2. .. DO NOT EDIT THIS FILE!!!
  3. .. Generated automatically from Godot engine sources.
  4. .. Generator: https://github.com/godotengine/godot/tree/3.6/doc/tools/make_rst.py.
  5. .. XML source: https://github.com/godotengine/godot/tree/3.6/doc/classes/InputEventMIDI.xml.
  6. .. _class_InputEventMIDI:
  7. InputEventMIDI
  8. ==============
  9. **Inherits:** :ref:`InputEvent<class_InputEvent>` **<** :ref:`Resource<class_Resource>` **<** :ref:`Reference<class_Reference>` **<** :ref:`Object<class_Object>`
  10. Input event for MIDI inputs.
  11. .. rst-class:: classref-introduction-group
  12. Description
  13. -----------
  14. InputEventMIDI allows receiving input events from MIDI devices such as a piano. MIDI stands for Musical Instrument Digital Interface.
  15. MIDI signals can be sent over a 5-pin MIDI connector or over USB, if your device supports both be sure to check the settings in the device to see which output it's using.
  16. To receive input events from MIDI devices, you need to call :ref:`OS.open_midi_inputs<class_OS_method_open_midi_inputs>`. You can check which devices are detected using :ref:`OS.get_connected_midi_inputs<class_OS_method_get_connected_midi_inputs>`.
  17. Note that Godot does not currently support MIDI output, so there is no way to emit MIDI signals from Godot. Only MIDI input works.
  18. .. rst-class:: classref-introduction-group
  19. Tutorials
  20. ---------
  21. - `MIDI Message Status Byte List <https://www.midi.org/specifications-old/item/table-2-expanded-messages-list-status-bytes>`__
  22. - `Wikipedia General MIDI Instrument List <https://en.wikipedia.org/wiki/General_MIDI#Program_change_events>`__
  23. - `Wikipedia Piano Key Frequencies List <https://en.wikipedia.org/wiki/Piano_key_frequencies#List>`__
  24. .. rst-class:: classref-reftable-group
  25. Properties
  26. ----------
  27. .. table::
  28. :widths: auto
  29. +-----------------------+---------------------------------------------------------------------------+-------+
  30. | :ref:`int<class_int>` | :ref:`channel<class_InputEventMIDI_property_channel>` | ``0`` |
  31. +-----------------------+---------------------------------------------------------------------------+-------+
  32. | :ref:`int<class_int>` | :ref:`controller_number<class_InputEventMIDI_property_controller_number>` | ``0`` |
  33. +-----------------------+---------------------------------------------------------------------------+-------+
  34. | :ref:`int<class_int>` | :ref:`controller_value<class_InputEventMIDI_property_controller_value>` | ``0`` |
  35. +-----------------------+---------------------------------------------------------------------------+-------+
  36. | :ref:`int<class_int>` | :ref:`instrument<class_InputEventMIDI_property_instrument>` | ``0`` |
  37. +-----------------------+---------------------------------------------------------------------------+-------+
  38. | :ref:`int<class_int>` | :ref:`message<class_InputEventMIDI_property_message>` | ``0`` |
  39. +-----------------------+---------------------------------------------------------------------------+-------+
  40. | :ref:`int<class_int>` | :ref:`pitch<class_InputEventMIDI_property_pitch>` | ``0`` |
  41. +-----------------------+---------------------------------------------------------------------------+-------+
  42. | :ref:`int<class_int>` | :ref:`pressure<class_InputEventMIDI_property_pressure>` | ``0`` |
  43. +-----------------------+---------------------------------------------------------------------------+-------+
  44. | :ref:`int<class_int>` | :ref:`velocity<class_InputEventMIDI_property_velocity>` | ``0`` |
  45. +-----------------------+---------------------------------------------------------------------------+-------+
  46. .. rst-class:: classref-section-separator
  47. ----
  48. .. rst-class:: classref-descriptions-group
  49. Property Descriptions
  50. ---------------------
  51. .. _class_InputEventMIDI_property_channel:
  52. .. rst-class:: classref-property
  53. :ref:`int<class_int>` **channel** = ``0``
  54. .. rst-class:: classref-property-setget
  55. - void **set_channel** **(** :ref:`int<class_int>` value **)**
  56. - :ref:`int<class_int>` **get_channel** **(** **)**
  57. The MIDI channel of this input event. There are 16 channels, so this value ranges from 0 to 15. MIDI channel 9 is reserved for the use with percussion instruments, the rest of the channels are for non-percussion instruments.
  58. .. rst-class:: classref-item-separator
  59. ----
  60. .. _class_InputEventMIDI_property_controller_number:
  61. .. rst-class:: classref-property
  62. :ref:`int<class_int>` **controller_number** = ``0``
  63. .. rst-class:: classref-property-setget
  64. - void **set_controller_number** **(** :ref:`int<class_int>` value **)**
  65. - :ref:`int<class_int>` **get_controller_number** **(** **)**
  66. If the message is ``MIDI_MESSAGE_CONTROL_CHANGE``, this indicates the controller number, otherwise this is zero. Controllers include devices such as pedals and levers.
  67. .. rst-class:: classref-item-separator
  68. ----
  69. .. _class_InputEventMIDI_property_controller_value:
  70. .. rst-class:: classref-property
  71. :ref:`int<class_int>` **controller_value** = ``0``
  72. .. rst-class:: classref-property-setget
  73. - void **set_controller_value** **(** :ref:`int<class_int>` value **)**
  74. - :ref:`int<class_int>` **get_controller_value** **(** **)**
  75. If the message is ``MIDI_MESSAGE_CONTROL_CHANGE``, this indicates the controller value, otherwise this is zero. Controllers include devices such as pedals and levers.
  76. .. rst-class:: classref-item-separator
  77. ----
  78. .. _class_InputEventMIDI_property_instrument:
  79. .. rst-class:: classref-property
  80. :ref:`int<class_int>` **instrument** = ``0``
  81. .. rst-class:: classref-property-setget
  82. - void **set_instrument** **(** :ref:`int<class_int>` value **)**
  83. - :ref:`int<class_int>` **get_instrument** **(** **)**
  84. The instrument of this input event. This value ranges from 0 to 127. Refer to the instrument list on the General MIDI wikipedia article to see a list of instruments, except that this value is 0-index, so subtract one from every number on that chart. A standard piano will have an instrument number of 0.
  85. .. rst-class:: classref-item-separator
  86. ----
  87. .. _class_InputEventMIDI_property_message:
  88. .. rst-class:: classref-property
  89. :ref:`int<class_int>` **message** = ``0``
  90. .. rst-class:: classref-property-setget
  91. - void **set_message** **(** :ref:`int<class_int>` value **)**
  92. - :ref:`int<class_int>` **get_message** **(** **)**
  93. Returns a value indicating the type of message for this MIDI signal. This is a member of the :ref:`MidiMessageList<enum_@GlobalScope_MidiMessageList>` enum.
  94. For MIDI messages between 0x80 and 0xEF, only the left half of the bits are returned as this value, as the other part is the channel (ex: 0x94 becomes 0x9). For MIDI messages from 0xF0 to 0xFF, the value is returned as-is.
  95. Notes will return ``MIDI_MESSAGE_NOTE_ON`` when activated, but they might not always return ``MIDI_MESSAGE_NOTE_OFF`` when deactivated, therefore your code should treat the input as stopped if some period of time has passed.
  96. For more information, see the MIDI message status byte list chart linked above.
  97. .. rst-class:: classref-item-separator
  98. ----
  99. .. _class_InputEventMIDI_property_pitch:
  100. .. rst-class:: classref-property
  101. :ref:`int<class_int>` **pitch** = ``0``
  102. .. rst-class:: classref-property-setget
  103. - void **set_pitch** **(** :ref:`int<class_int>` value **)**
  104. - :ref:`int<class_int>` **get_pitch** **(** **)**
  105. The pitch index number of this MIDI signal. This value ranges from 0 to 127. On a piano, middle C is 60, and A440 is 69, see the "MIDI note" column of the piano key frequency chart on Wikipedia for more information.
  106. .. rst-class:: classref-item-separator
  107. ----
  108. .. _class_InputEventMIDI_property_pressure:
  109. .. rst-class:: classref-property
  110. :ref:`int<class_int>` **pressure** = ``0``
  111. .. rst-class:: classref-property-setget
  112. - void **set_pressure** **(** :ref:`int<class_int>` value **)**
  113. - :ref:`int<class_int>` **get_pressure** **(** **)**
  114. The pressure of the MIDI signal. This value ranges from 0 to 127. For many devices, this value is always zero.
  115. .. rst-class:: classref-item-separator
  116. ----
  117. .. _class_InputEventMIDI_property_velocity:
  118. .. rst-class:: classref-property
  119. :ref:`int<class_int>` **velocity** = ``0``
  120. .. rst-class:: classref-property-setget
  121. - void **set_velocity** **(** :ref:`int<class_int>` value **)**
  122. - :ref:`int<class_int>` **get_velocity** **(** **)**
  123. The velocity of the MIDI signal. This value ranges from 0 to 127. For a piano, this corresponds to how quickly the key was pressed, and is rarely above about 110 in practice. Note that some MIDI devices may send a :ref:`@GlobalScope.MIDI_MESSAGE_NOTE_ON<class_@GlobalScope_constant_MIDI_MESSAGE_NOTE_ON>` message with zero velocity and expect this to be treated the same as a :ref:`@GlobalScope.MIDI_MESSAGE_NOTE_OFF<class_@GlobalScope_constant_MIDI_MESSAGE_NOTE_OFF>` message, but device implementations vary so Godot reports event data exactly as received.
  124. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  125. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  126. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
  127. .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`