Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

onmidimessage event change #13664

Merged
merged 11 commits into from
Mar 10, 2022
1 change: 1 addition & 0 deletions files/en-us/_redirects.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8356,6 +8356,7 @@
/en-US/docs/Web/API/LockedFile.truncate /en-US/docs/Web/API/LockedFile/truncate
/en-US/docs/Web/API/LockedFile.write /en-US/docs/Web/API/LockedFile/write
/en-US/docs/Web/API/LongRange /en-US/docs/Web/API/MediaTrackConstraints
/en-US/docs/Web/API/MIDIInput/onmidimessage /en-US/docs/Web/API/MIDIInput/midimessage_event
/en-US/docs/Web/API/MSContentZoom /en-US/docs/Web/API/Element/msContentZoom_event
/en-US/docs/Web/API/MSLaunchUri /en-US/docs/Web/API/Navigator/msLaunchUri
/en-US/docs/Web/API/MSManipulationStateChanged /en-US/docs/Web/API/Element/MSManipulationStateChanged_event
Expand Down
10 changes: 5 additions & 5 deletions files/en-us/web/api/midiinput/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,23 +21,23 @@ The **`MIDIInput`** interface of the [Web MIDI API](/en-US/docs/Web/API/Web_MIDI

_This interface doesn't implement any specific properties, but inherits properties from {{domxref("MIDIPort")}}._

### Event handlers
### Events
Rumyra marked this conversation as resolved.
Show resolved Hide resolved

- {{domxref("MIDIInput.onmidimessage")}}
- : When the current port receives a MIDI message it triggers a call to this event handler.
- {{domxref("MIDIInput.midimessage_event")}}
Rumyra marked this conversation as resolved.
Show resolved Hide resolved
- : When the current port receives a MIDI message it triggers a `midimessage` event.
Rumyra marked this conversation as resolved.
Show resolved Hide resolved

## Methods

_This interface doesn't implement any specific methods, but inherits methods from {{domxref("MIDIPort")}}._

## Examples

In the following example the name of each `MIDIInput` is printed to the console. Then, `onmidimessage` events are listened for on all input ports. When a message is received the {{domxref("MIDIMessageEvent.data")}} property is printed to the console.
In the following example the name of each `MIDIInput` is printed to the console. Then, `midimessage` events are listened for on all input ports. When a message is received the {{domxref("MIDIMessageEvent.data")}} property is printed to the console.

```js
inputs.forEach((input) => {
console.log(input.name); /* inherited property from MIDIPort */
input.onmidimessage = function(message) {
input.onmidimessage = (message) => {
Rumyra marked this conversation as resolved.
Show resolved Hide resolved
console.log(message.data);
}
})
Expand Down
54 changes: 54 additions & 0 deletions files/en-us/web/api/midiinput/midimessage_event/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
---
title: 'MIDIInput: midimessage event'
slug: Web/API/MIDIInput/midimessage_event
tags:
- midimessage
- API
- Event
- Reference
- MIDIInput
browser-compat: api.MIDIInput.midimessage_event
---
{{APIRef("Web MIDI API")}}{{securecontext_header}}

The `midimessage` event of the Web MIDI API is fired when the MIDI port corresponding to this {{domxref("MIDIInput")}} finishes receiving one or more MIDI messages. An instance of {{domxref("MIDIMessageEvent")}} containing the message that was received is passed to the event handler.
Rumyra marked this conversation as resolved.
Show resolved Hide resolved

## Syntax

Use the event name in methods like {{domxref("EventTarget.addEventListener", "addEventListener()")}}, or set an event handler property.

```js
addEventListener('midimessage', event => { });

onmidimessage = event => { };
```

## Event type

An {{domxref("MIDIMessageEvent")}}. Inherits from {{domxref("Event")}}.

{{InheritanceDiagram("MIDIMessageEvent")}}

## Event properties

{{page("/en-US/docs/Web/API/MIDIMessageEvent", "Properties")}}
Rumyra marked this conversation as resolved.
Show resolved Hide resolved

## Examples

In the following example `midimessage` events are listened for on all input ports. When a message is received the {{domxref("MIDIMessageEvent.data")}} property is printed to the console.

```js
inputs.forEach((input) => {
Rumyra marked this conversation as resolved.
Show resolved Hide resolved
input.onmidimessage = (message) => {
Rumyra marked this conversation as resolved.
Show resolved Hide resolved
console.log(message.data);
}
})
```

## Specifications

{{Specifications}}

## Browser compatibility

{{Compat}}
43 changes: 0 additions & 43 deletions files/en-us/web/api/midiinput/onmidimessage/index.md

This file was deleted.

4 changes: 2 additions & 2 deletions files/en-us/web/api/midimessageevent/data/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ A {{jsxref("Uint8Array")}}.

## Examples

In the following example {{domxref("MIDIInput.onmidimessage")}} events are listened for on all input ports. When a message is received the value of `data` is printed to the console.
In the following example {{domxref("MIDIInput.midimessage_event","midimessage events")}} are listened for on all input ports. When a message is received the value of `data` is printed to the console.
Rumyra marked this conversation as resolved.
Show resolved Hide resolved

```js
inputs.forEach((input) => {
input.onmidimessage = function(message) {
input.onmidimessage = (message) => {
Rumyra marked this conversation as resolved.
Show resolved Hide resolved
console.log(message.data);
}
})
Expand Down
2 changes: 1 addition & 1 deletion files/en-us/web/api/midimessageevent/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ browser-compat: api.MIDIMessageEvent
---
{{securecontext_header}}{{APIRef("Web MIDI API")}}

The **`MIDIMessageEvent`** interface of the [Web MIDI API](/en-US/docs/Web/API/Web_MIDI_API) represents the event passed to the {{domxref("MIDIInput.onmidimessage","onmidimessage")}} event handler of the {{domxref("MIDIInput")}} interface. A `midimessage` event is fired every time a MIDI message is sent from a device represented by a {{domxref("MIDIInput")}}, for example when a MIDI keyboard key is pressed, a knob is tweaked, or a slider is moved.
The **`MIDIMessageEvent`** interface of the [Web MIDI API](/en-US/docs/Web/API/Web_MIDI_API) represents the event passed to the {{domxref("MIDIInput.midimessage_event","midimessage")}} event of the {{domxref("MIDIInput")}} interface. A `midimessage` event is fired every time a MIDI message is sent from a device represented by a {{domxref("MIDIInput")}}, for example when a MIDI keyboard key is pressed, a knob is tweaked, or a slider is moved.

{{InheritanceDiagram}}

Expand Down
2 changes: 1 addition & 1 deletion files/en-us/web/api/web_midi_api/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ The interfaces deal with the practical aspects of sending and receiving MIDI mes
- {{domxref("MIDIOutput")}}
- : Queues messages to the linked MIDI port. Messages can be sent immediately or after a specified delay.
- {{domxref("MIDIMessageEvent")}}
- : The event passed to {{domxref("MIDIInput.onmidimessage")}}.
- : The event passed to {{domxref("MIDIInput.midimessage_event")}}.
- {{domxref("MIDIConnectionEvent")}}
- : The event passed to the {{domxref("MIDIAccess.onstatechange")}} and {{domxref("MIDIPort.onstatechange")}} event handlers, when a port becomes available or unavailable.

Expand Down