diff --git a/explainer.md b/explainer.md index 48abf97..8fba1de 100644 --- a/explainer.md +++ b/explainer.md @@ -62,6 +62,30 @@ function listInputsAndOutputs( midiAccess ) { } ``` +### Adding inputs and outputs to select boxes + +```js +// to tell how many entries there are: +let numberOfMIDIInputs = inputs.size; + +// add each of the ports to a
- This type is used to represent all the currently available MIDI input - ports. This enables: + This type is used to represent all the currently available [=MIDI input + ports=].
- // to tell how many entries there are:
- let numberOfMIDIInputs = inputs.size;
-
- // add each of the ports to a <select> box
- inputs.forEach( function( port, key ) {
- let opt = document.createElement("option");
- opt.text = port.name;
- document.getElementById("inputportselector").add(opt);
- });
-
- // or you could express in ECMAScript 6 as:
- for (let input of inputs.values()) {
- let opt = document.createElement("option");
- opt.text = input.name;
- document.getElementById("inputportselector").add(opt);
- }
This type is used to represent all the currently available [=MIDI - output ports=]. This enables: + output ports=].
- // to tell how many entries there are:
- let numberOfMIDIOutputs = outputs.size;
-
- // add each of the ports to a <select> box
- outputs.forEach( function( port, key ) {
- let opt = document.createElement("option");
- opt.text = port.name;
- document.getElementById("outputportselector").add(opt);
- });
-
- // or you could express in ECMAScript 6 as:
- for (let output of outputs.values()) {
- let opt = document.createElement("option");
- opt.text = output.name;
- document.getElementById("outputportselector").add(opt);
- }