Open rektide opened 6 years ago
I pulled some power consumption numbers from powertop and dstat, going from a fresh startup, to plugging in the Korg NanoKontrol2 I use, to running midisnoop listening via alsa while i tap ~2 buttons/s, to turning that off & starting web-midi-api-shim, running requetMIDIAccess() & nothing else, & again tapping ~2 buttons/s.
Stage | Power (W) | User cpu | sys cpu | Wakeups | Context Switches |
---|---|---|---|---|---|
Idle | 3.55 | 0% | 0% | 40 | 28 |
Device attached | 4.31 | 0% | 0% | 55 | 50 |
midisnoop | 4.55 | 5% | 0% | 415 | 340 |
web-midi-api-shim | 10.4 | 21% | 7% | 560 | 36,000 |
I haven't tried using it in any real capacity what-so-ever, but https://github.com/abudaan/WebMIDIAPIShim/tree/upgrade-2018 branch shows very tame cpu usage. I'll see about reproducing above conditions to test how much better, but it looks really close to midisnoop. But I haven't done any real work with that branch yet!
@abudaan - can you report in on the status of that branch? what are the major work areas remaining? anything I can assist with?
Is that issue from WebMIDIAPIShim or from the underlying https://www.npmjs.com/package/jazz-midi ?
@jazz-soft I'm not super sure how to test. I imported jazz-midi in a repl, and ran midi.MidiOutOpen(0)
and midi.MidiInOpen(0)
and my cpu consumption & power is fine. There doesn't appear to be any kind of event-based api in jazz-midi to, for example, see button presses. That implies I'd have to write some kind of loop to sample the device?
You can set the callback function in jazz-midi: http://jazz-soft.net/doc/Jazz-Plugin/MidiInOpen.html But it may be more convenient to use via the JZZ library: https://github.com/jazz-soft/JZZ
@jazz-soft In @abudaan's update-2018
branch, he's started switching WebMIDIAPIShim to use jzz. :) I'm just starting to test whether the basic functionality I need works on that branch.
I believe that was an experimental branch.
@jazz-soft @rektide Yes, Sema is right, update-2018
is still wip; currently it is a quick-and-dirty implementation of the latest Jazz plugin but it has all functionality so you can use it.
I will start working on this branch again early April and it will be backwards compatible so you should be able to update the WebMIDIAPIShim by then without breaking your project's code.
@abudaan FYI: I'm planning to make JZZ expose Web MIDI API in the next release. If you are interested, we can discuss it by email.
@rektide & @abudaan, please have a look at https://github.com/jazz-soft/JZZ - it now enables Web MIDI API
Great work! I have replaced the WebMIDIAPIShim in both heartbeatjs and qambi and it works like a charm! I think we can now deprecate the WebMIDIAPIShim?
Hello. If I
require('web-midi-api-shim'); navigator.requestMIDIAccess()
from Node.js (say a repl, or small script) my Node process starts using two CPUs at >90%. Context-switches go from ~500/s to 36k/s.This makes the library unsuitable for use on a laptop or battery powered system, and I am unsure but somewhat under the impression that it degrades my other web browsing activity on this computer.