Skip to content

Commit

Permalink
Bug fix
Browse files Browse the repository at this point in the history
  • Loading branch information
jazz-soft committed May 3, 2021
1 parent 4fd6d69 commit 388aaa8
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 12 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,15 +68,15 @@ by running `npm remove midi-test --save-dev`.

```html
<script src="https://cdn.jsdelivr.net/npm/jzz"></script> // the latest version, or
<script src="https://cdn.jsdelivr.net/npm/jzz@1.2.9"></script> // any particular version
<script src="https://cdn.jsdelivr.net/npm/jzz@1.3.0"></script> // any particular version
//...
```

##### CDN (unpkg)

```html
<script src="https://unpkg.com/jzz"></script> // the latest version, or
<script src="https://unpkg.com/jzz@1.2.9"></script> // any particular version
<script src="https://unpkg.com/jzz@1.3.0"></script> // any particular version
//...
```

Expand Down
32 changes: 27 additions & 5 deletions javascript/JZZ.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
})(this, function() {

var _scope = typeof window === 'undefined' ? global : window;
var _version = '1.2.9';
var _version = '1.3.0';
var i, j, k, m, n;

var _time = Date.now || function () { return new Date().getTime(); };
Expand Down Expand Up @@ -595,7 +595,7 @@
// Web MIDI API
var _navigator;
var _requestMIDIAccess;
function _tryWebMIDI(sx) {
function _findMidiAccess() {
if (typeof navigator !== 'undefined' && navigator.requestMIDIAccess) {
_navigator = navigator;
_requestMIDIAccess = navigator.requestMIDIAccess;
Expand All @@ -604,22 +604,44 @@
}
catch (err) {}
}
}
function _tryWebMIDI() {
_findMidiAccess();
if (_requestMIDIAccess) {
var self = this;
var onGood = function(midi) {
_initWebMIDI(midi, sx);
_initWebMIDI(midi);
self._resume();
};
var onBad = function(msg) {
self._crash(msg);
};
_requestMIDIAccess.call(_navigator, { sysex: !!sx }).then(onGood, onBad);
var opt = {};
_requestMIDIAccess.call(_navigator, opt).then(onGood, onBad);
this._pause();
return;
}
this._break();
}
function _tryWebMIDIsysex() { _tryWebMIDI(true); }
function _tryWebMIDIsysex() {
_findMidiAccess();
if (_requestMIDIAccess) {
var self = this;
var onGood = function(midi) {
_initWebMIDI(midi, true);
self._resume();
};
var onBad = function(msg) {
self._crash(msg);
};
var opt = { sysex:true };
_requestMIDIAccess.call(_navigator, opt).then(onGood, onBad);
this._pause();
return;
}
this._break();
}

// Web-extension
function _tryCRX() {
var self = this;
Expand Down
2 changes: 1 addition & 1 deletion minified/JZZ.js

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "jzz",
"version": "1.2.9",
"version": "1.3.0",
"description": "MIDI library for Node.js and web-browsers",
"main": "javascript/JZZ.js",
"scripts": {
Expand All @@ -21,14 +21,14 @@
"jazz-midi": "^1.7.4"
},
"devDependencies": {
"eslint": "^7.24.0",
"grunt": "^1.3.0",
"eslint": "^7.25.0",
"grunt": "^1.4.0",
"grunt-contrib-jshint": "^3.0.0",
"grunt-contrib-uglify": "^5.0.1",
"midi-test": "^1.1.5",
"mocha": "^8.3.2",
"nyc": "^15.1.0",
"web-midi-test": "^1.1.3"
"web-midi-test": "^1.1.4"
},
"runkitExampleFilename": "runkit.js",
"repository": {
Expand Down

0 comments on commit 388aaa8

Please sign in to comment.