diff options
-rw-r--r-- | core/os/midi_driver.cpp | 48 | ||||
-rw-r--r-- | core/os/midi_driver.h | 1 | ||||
-rw-r--r-- | doc/classes/Camera.xml | 17 | ||||
-rw-r--r-- | doc/classes/Listener.xml | 8 | ||||
-rw-r--r-- | modules/gdscript/doc_classes/@GDScript.xml | 5 |
5 files changed, 55 insertions, 24 deletions
diff --git a/core/os/midi_driver.cpp b/core/os/midi_driver.cpp index 7cb7ae130f..81871d6c4f 100644 --- a/core/os/midi_driver.cpp +++ b/core/os/midi_driver.cpp @@ -33,6 +33,7 @@ #include "core/os/os.h" #include "main/input_default.h" +uint8_t MIDIDriver::last_received_message = 0x00; MIDIDriver *MIDIDriver::singleton = NULL; MIDIDriver *MIDIDriver::get_singleton() { @@ -48,33 +49,42 @@ void MIDIDriver::receive_input_packet(uint64_t timestamp, uint8_t *data, uint32_ Ref<InputEventMIDI> event; event.instance(); + uint32_t param_position = 1; if (length >= 1) { - event->set_channel(data[0] & 0xF); - event->set_message(data[0] >> 4); + if ((data[0] & 0x80) == 0x00) { + // running status + event->set_channel(last_received_message & 0xF); + event->set_message(last_received_message >> 4); + param_position = 0; + } else { + event->set_channel(data[0] & 0xF); + event->set_message(data[0] >> 4); + param_position = 1; + last_received_message = data[0]; + } } switch (event->get_message()) { case MIDI_MESSAGE_AFTERTOUCH: - if (length >= 3) { - event->set_pitch(data[1]); - event->set_pressure(data[2]); + if (length >= 2 + param_position) { + event->set_pitch(data[param_position]); + event->set_pressure(data[param_position + 1]); } break; case MIDI_MESSAGE_CONTROL_CHANGE: - if (length >= 3) { - event->set_controller_number(data[1]); - event->set_controller_value(data[2]); + if (length >= 2 + param_position) { + event->set_controller_number(data[param_position]); + event->set_controller_value(data[param_position + 1]); } break; case MIDI_MESSAGE_NOTE_ON: case MIDI_MESSAGE_NOTE_OFF: - case MIDI_MESSAGE_PITCH_BEND: - if (length >= 3) { - event->set_pitch(data[1]); - event->set_velocity(data[2]); + if (length >= 2 + param_position) { + event->set_pitch(data[param_position]); + event->set_velocity(data[param_position + 1]); if (event->get_message() == MIDI_MESSAGE_NOTE_ON && event->get_velocity() == 0) { // https://www.midi.org/forum/228-writing-midi-software-send-note-off,-or-zero-velocity-note-on @@ -83,15 +93,21 @@ void MIDIDriver::receive_input_packet(uint64_t timestamp, uint8_t *data, uint32_ } break; + case MIDI_MESSAGE_PITCH_BEND: + if (length >= 2 + param_position) { + event->set_pitch((data[param_position + 1] << 7) | data[param_position]); + } + break; + case MIDI_MESSAGE_PROGRAM_CHANGE: - if (length >= 2) { - event->set_instrument(data[1]); + if (length >= 1 + param_position) { + event->set_instrument(data[param_position]); } break; case MIDI_MESSAGE_CHANNEL_PRESSURE: - if (length >= 2) { - event->set_pressure(data[1]); + if (length >= 1 + param_position) { + event->set_pressure(data[param_position]); } break; } diff --git a/core/os/midi_driver.h b/core/os/midi_driver.h index e0e5e2be67..33f49d19f5 100644 --- a/core/os/midi_driver.h +++ b/core/os/midi_driver.h @@ -41,6 +41,7 @@ class MIDIDriver { static MIDIDriver *singleton; + static uint8_t last_received_message; public: static MIDIDriver *get_singleton(); diff --git a/doc/classes/Camera.xml b/doc/classes/Camera.xml index 3b4313b204..aca53d4ed0 100644 --- a/doc/classes/Camera.xml +++ b/doc/classes/Camera.xml @@ -38,12 +38,14 @@ <argument index="0" name="layer" type="int"> </argument> <description> + Returns [code]true[/code] if the given [code]layer[/code] in the [member cull_mask] is enabled, [code]false[/code] otherwise. </description> </method> <method name="get_frustum" qualifiers="const"> <return type="Array"> </return> <description> + Returns the camera's frustum planes in world-space units as an array of [Plane]s in the following order: near, far, left, top, right, bottom. Not to be confused with [member frustum_offset]. </description> </method> <method name="is_position_behind" qualifiers="const"> @@ -109,6 +111,7 @@ <argument index="1" name="enable" type="bool"> </argument> <description> + Enables or disables the given [code]layer[/code] in the [member cull_mask]. </description> </method> <method name="set_frustum"> @@ -123,6 +126,7 @@ <argument index="3" name="z_far" type="float"> </argument> <description> + Sets the camera projection to frustum mode (see [constant PROJECTION_FRUSTUM]), by specifying a [code]size[/code], an [code]offset[/code], and the [code]z_near[/code] and [code]z_far[/code] clip planes in world-space units. </description> </method> <method name="set_orthogonal"> @@ -135,7 +139,7 @@ <argument index="2" name="z_far" type="float"> </argument> <description> - Sets the camera projection to orthogonal mode, by specifying a width and the [code]near[/code] and [code]far[/code] clip planes in worldspace units. (As a hint, 2D games often use this projection, with values specified in pixels) + Sets the camera projection to orthogonal mode (see [constant PROJECTION_ORTHOGONAL]), by specifying a [code]size[/code], and the [code]z_near[/code] and [code]z_far[/code] clip planes in world-space units. (As a hint, 2D games often use this projection, with values specified in pixels.) </description> </method> <method name="set_perspective"> @@ -148,7 +152,7 @@ <argument index="2" name="z_far" type="float"> </argument> <description> - Sets the camera projection to perspective mode, by specifying a [code]fov[/code] angle in degrees (FOV means Field of View), and the [code]near[/code] and [code]far[/code] clip planes in world-space units. + Sets the camera projection to perspective mode (see [constant PROJECTION_PERSPECTIVE]), by specifying a [code]fov[/code] (field of view) angle in degrees, and the [code]z_near[/code] and [code]z_far[/code] clip planes in world-space units. </description> </method> <method name="unproject_position" qualifiers="const"> @@ -169,7 +173,7 @@ If [code]true[/code], the ancestor [Viewport] is currently using this camera. </member> <member name="doppler_tracking" type="int" setter="set_doppler_tracking" getter="get_doppler_tracking" enum="Camera.DopplerTracking" default="0"> - If not [constant DOPPLER_TRACKING_DISABLED], this camera will simulate the Doppler effect for objects changed in particular [code]_process[/code] methods. See [enum DopplerTracking] for possible values. + If not [constant DOPPLER_TRACKING_DISABLED], this camera will simulate the [url=https://en.wikipedia.org/wiki/Doppler_effect]Doppler effect[/url] for objects changed in particular [code]_process[/code] methods. See [enum DopplerTracking] for possible values. </member> <member name="environment" type="Environment" setter="set_environment" getter="get_environment"> The [Environment] to use for this camera. @@ -181,6 +185,7 @@ The camera's field of view angle (in degrees). Only applicable in perspective mode. Since [member keep_aspect] locks one axis, [code]fov[/code] sets the other axis' field of view angle. </member> <member name="frustum_offset" type="Vector2" setter="set_frustum_offset" getter="get_frustum_offset" default="Vector2( 0, 0 )"> + The camera's frustum offset. This can be changed from the default to create "tilted frustum" effects such as [url=https://zdoom.org/wiki/Y-shearing]Y-shearing[/url]. </member> <member name="h_offset" type="float" setter="set_h_offset" getter="get_h_offset" default="0.0"> The horizontal (X) offset of the camera viewport. @@ -218,13 +223,13 @@ Preserves the vertical aspect ratio; also known as Hor+ scaling. This is usually the best option for projects running in landscape mode, as wider aspect ratios will automatically benefit from a wider horizontal FOV. </constant> <constant name="DOPPLER_TRACKING_DISABLED" value="0" enum="DopplerTracking"> - Disables Doppler effect simulation (default). + Disables [url=https://en.wikipedia.org/wiki/Doppler_effect]Doppler effect[/url] simulation (default). </constant> <constant name="DOPPLER_TRACKING_IDLE_STEP" value="1" enum="DopplerTracking"> - Simulate Doppler effect by tracking positions of objects that are changed in [code]_process[/code]. Changes in the relative velocity of this camera compared to those objects affect how Audio is perceived (changing the Audio's [code]pitch shift[/code]). + Simulate [url=https://en.wikipedia.org/wiki/Doppler_effect]Doppler effect[/url] by tracking positions of objects that are changed in [code]_process[/code]. Changes in the relative velocity of this camera compared to those objects affect how Audio is perceived (changing the Audio's [code]pitch shift[/code]). </constant> <constant name="DOPPLER_TRACKING_PHYSICS_STEP" value="2" enum="DopplerTracking"> - Simulate Doppler effect by tracking positions of objects that are changed in [code]_physics_process[/code]. Changes in the relative velocity of this camera compared to those objects affect how Audio is perceived (changing the Audio's [code]pitch shift[/code]). + Simulate [url=https://en.wikipedia.org/wiki/Doppler_effect]Doppler effect[/url] by tracking positions of objects that are changed in [code]_physics_process[/code]. Changes in the relative velocity of this camera compared to those objects affect how Audio is perceived (changing the Audio's [code]pitch shift[/code]). </constant> </constants> </class> diff --git a/doc/classes/Listener.xml b/doc/classes/Listener.xml index 130263a069..cd47c758b4 100644 --- a/doc/classes/Listener.xml +++ b/doc/classes/Listener.xml @@ -1,8 +1,11 @@ <?xml version="1.0" encoding="UTF-8" ?> <class name="Listener" inherits="Spatial" category="Core" version="3.2"> <brief_description> + Overrides the location sounds are heard from. </brief_description> <description> + Once added to the scene tree and enabled using [method make_current], this node will override the location sounds are heard from. This can be used to listen from a location different from the [member Camera]. + [b]Note:[/b] There is no 2D equivalent for this node yet. </description> <tutorials> </tutorials> @@ -11,24 +14,29 @@ <return type="void"> </return> <description> + Disables the listener to use the current camera's listener instead. </description> </method> <method name="get_listener_transform" qualifiers="const"> <return type="Transform"> </return> <description> + Returns the listener's global orthonormalized [Transform]. </description> </method> <method name="is_current" qualifiers="const"> <return type="bool"> </return> <description> + Returns [code]true[/code] if the listener was made current using [method]make_current[/method), [code]false[/code] otherwise. + [b]Note:[/b] There may be more than one Listener marked as "current" in the scene tree, but only the one that was made current last will be used. </description> </method> <method name="make_current"> <return type="void"> </return> <description> + Enables the listener. This will override the current camera's listener. </description> </method> </methods> diff --git a/modules/gdscript/doc_classes/@GDScript.xml b/modules/gdscript/doc_classes/@GDScript.xml index 949663c5ea..2a8453116e 100644 --- a/modules/gdscript/doc_classes/@GDScript.xml +++ b/modules/gdscript/doc_classes/@GDScript.xml @@ -336,11 +336,12 @@ <description> Rounds [code]s[/code] to the closest smaller integer and returns it. [codeblock] - # a is 2 + # a is 2.0 a = floor(2.99) - # a is -3 + # a is -3.0 a = floor(-2.99) [/codeblock] + [b]Note:[/b] This method returns a float. If you need an integer, you can use [code]int(s)[/code] directly. </description> </method> <method name="fmod"> |