djipco / webmidi

Tame the Web MIDI API. Send and receive MIDI messages with ease. Control instruments with user-friendly functions (playNote, sendPitchBend, etc.). React to MIDI input with simple event listeners (noteon, pitchbend, controlchange, etc.).
Apache License 2.0
1.52k stars 115 forks source link

allnotesoff not working #22

Closed cfry closed 6 years ago

cfry commented 6 years ago

http://cotejp.github.io/webmidi/latest/classes/Output.html and its crucial content says: sendChannelMode (command, value, [channel=all], [options={}]) Output chainable

Defined in src/webmidi.js:3793

Sends a MIDI channel mode message to the specified channel(s).

The channel mode message to send can be specified numerically or by using one of the following common names:

allsoundoff (#120) resetallcontrollers (#121) localcontrol (#122) allnotesoff (#123) omnimodeoff (#124) omnimodeon (#125) monomodeon (#126) polymodeon (#127)

First attempt: WebMidi.outputs[0].sendChannelMode("allnotesoff") yields error: RangeError: Value must be integers between 0 and 127. Hmm, why does allnotesoff need a value and what would iit be? Can't it default?

In any case, attempt 2: WebMidi.outputs[0].sendChannelMode("allnotesoff", 0) doesn't error but doesn't shut off ongoing notes either. I've tried the variation of using WebMidi.outputs[0].sendChannelMode("allsoundoff", 0) as well as using the command numbers instead of strings, and passing the value of 127. Didn't turn off ongoing notes playing on GarageBand on Mac. It's possible that GarageBand doesn't respond to allnotesoff.

djipco commented 6 years ago

Per the MIDI spec, the allnotesoff message does require a value of 0. However, since most channel mode messages require a value of 0, I decided to make it the default.

This means that, starting with version 2.0.0-rc.8, you can omit the value parameter altogether:

WebMidi.outputs[0].sendChannelMode('allnotesoff');

Regarding GarageBand, it is very possible that it does not support MIDI channel mode commands. As a matter of fact, it seems you're not the only one with this issue.

cfry commented 6 years ago

Thanks so much for the speedy reply. I'm just about to make a release of my development environment. This is the LAST thing that got in. Too bad it doesn't work in GarageBand but KNOWING that is worth a lot. WebMidi.js rocks!

On Wed, Sep 20, 2017 at 10:08 PM, Jean-Philippe Côté < notifications@github.com> wrote:

Closed #22 https://github.com/cotejp/webmidi/issues/22.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/cotejp/webmidi/issues/22#event-1258568314, or mute the thread https://github.com/notifications/unsubscribe-auth/ABITfZjkZb9RC_NqHeRulZSDsyPFwgRBks5skcUBgaJpZM4PeczV .