web-midi | Web MIDI API for browsers | Audio Utils library
kandi X-RAY | web-midi Summary
kandi X-RAY | web-midi Summary
Web MIDI API for browsers
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of web-midi
web-midi Key Features
web-midi Examples and Code Snippets
Community Discussions
Trending Discussions on web-midi
QUESTION
Folks,
I am trying work on a simple Web MIDI app.
I already looked up and found out that Google Chrome is the only browser that supports this. So, I installed this but I still get this.
WebMidi could not be enabled Error: The Web MIDI API is not supported by your browser. at WebMidi.enable (webmidi.min.js:30) at script.js:430 (anonymous) @ script.js:432 WebMidi.enable @ webmidi.min.js:30 (anonymous) @ script.js:430 Promise.then (async) (anonymous) @ script.js:154
Mac - 10.15.2 Chrome - 79.0.3945.117
According to this link - https://www.midi.org/17-the-mma/99-web-midi , Chrome definitely has the support.
Important Note - If I were run the code directly on codepen, it works just fine. So the browser is working. But when I try to run locally, I get the error.
...ANSWER
Answered 2020-Jan-12 at 02:41I've used web-midi with Chromium and Opera on 10.12.6, so I wouldn't say that Chrome is the only browser that has web-midi.
With Opera I think I had to enable experimental features:
QUESTION
I am developing a JavaScript library (https://github.com/yvesgurcan/web-midi-player) to enable MIDI playback in a web application. The library relies on the Web Audio API to create a way to play these MIDI files (https://github.com/yvesgurcan/web-midi-player/blob/test/src/MidiPlayer.js#L50). However, I am having trouble creating meaningful unit tests with Jest (https://github.com/yvesgurcan/web-midi-player/blob/test/tests/midiPlayer.js) because these tests don't have access to the window
object and more particularly to window.AudioContext
. As a consequence, running my application code which relies on AudioContext
throws errors related to the fact that this object does not exist and I can't actually test very much things in the library.
I've tried the following packages to solve my problem: jsdom
, jsdom-global
, and also web-audio-test-api
but none of these seem to inject AudioContext
in the environment.
I am thinking that the solution here would be to stub/mock AudioContext
but that does not sound like a good solution for solid unit tests.
What do you folks suggest to test the Web Audio API? Is stubbing the only viable solution here?
...ANSWER
Answered 2019-Dec-14 at 18:49I think it depends a bit on what you want to test. Since you're using Jest I imagine you're just interested in testing the correctness of your own code. In that case I would recommend to fully mock the Web Audio API. It's not part of your responsibility and you can assume it works the way it should. The only thing you have to test is if your code is making the expected calls.
Mocking globally available variables like the AudioContext constructor is always a bit tricky but you could allow an AudioContext to be passed into your MidiPlayer
class as an optional argument. It would make testing a little easier and it would also allow users of your library to bring their own AudioContext.
I think of something like this:
QUESTION
How can I specify which channel to send a midi message on, with the MIDI Web API?
This example from the official docs shows how to send a message on channel 1. But in the code snippet, I don't find any reference to that.
...ANSWER
Answered 2018-Dec-17 at 15:57The midi protocol uses hexadecimal representation for its "messages".
First half is dedicated to the command while the second part is used to specify the channel. They are 16 possible channels (MIDI channels are 0-indexed, as specified in documentation).
Example:
0x90 means Note on (0x90) on Chan 1 (0x90)
So, if you want to send the same message en channel 2, you have to change it like this:
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install web-midi
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page