Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'csound6' of github.com:csound/csound into csound6
- Loading branch information
Showing
16 changed files
with
130 additions
and
76 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,28 @@ | ||
import { logMidiRequest as log } from "../logger"; | ||
|
||
const connectedMidiDevices = new Set(); | ||
|
||
export async function requestMidi({ onMidiMessage /** function(number,number,number):void */ }) { | ||
log("requesting for web-midi connection"); | ||
log("requesting for web-midi connection")(); | ||
|
||
if (navigator && navigator.requestMIDIAccess) { | ||
try { | ||
const midiDevices = await navigator.requestMIDIAccess(); | ||
|
||
if (midiDevices.inputs) { | ||
/** @type {Iterator} | ||
* @supress {JSC_WRONG_ARGUMENT_COUNT} | ||
*/ | ||
const midiInputs = midiDevices.inputs.values(); | ||
for (let input = midiInputs.next(); input && !input.done; input = midiInputs.next()) { | ||
log(`Connecting midi-input: ${input.value.name || "unkown"}`); | ||
if (!connectedMidiDevices.has(input.value.name || "unkown")) { | ||
input.value.onmidimessage = onMidiMessage; | ||
connectedMidiDevices.add(input.value.name || "unkown"); | ||
} | ||
log(`Connecting midi-input: ${input.value.name || "unkown"}`)(); | ||
input.value.onmidimessage = onMidiMessage; | ||
} | ||
} else { | ||
log("no midi-device detected"); | ||
log("no midi-device detected")(); | ||
} | ||
} catch (error) { | ||
log("error while connecting web-midi: " + error); | ||
log("error while connecting web-midi: " + error)(); | ||
} | ||
} else { | ||
log("no web-midi support found, midi-input will not work!"); | ||
log("no web-midi support found, midi-input will not work!")(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.