Skip to content

Commit

Permalink
Text to MIDI
Browse files Browse the repository at this point in the history
  • Loading branch information
jazz-soft committed Sep 16, 2021
1 parent 103de55 commit 1cfde03
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 9 deletions.
8 changes: 5 additions & 3 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.4.0"></script> // any particular version
<script src="https://cdn.jsdelivr.net/npm/jzz@1.4.1"></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.4.0"></script> // any particular version
<script src="https://unpkg.com/jzz@1.4.1"></script> // any particular version
//...
```

Expand Down Expand Up @@ -195,9 +195,11 @@ navigator.requestMIDIAccess = JZZ.requestMIDIAccess;
JZZ.MIDI.freq('A5'); // => 440
JZZ.MIDI.freq(69); // => 440
JZZ.MIDI.freq(69.5); // => 452.8929841231365

// from the frequency:
JZZ.MIDI.midi(440); // => 69
JZZ.MIDI.midi(450); // => 69.38905773230853
// or from the name:
JZZ.MIDI.midi('A5'); // => 69
```

## Additional modules
Expand Down
7 changes: 5 additions & 2 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.4.0';
var _version = '1.4.1';
var i, j, k, m, n;

/* istanbul ignore next */
Expand Down Expand Up @@ -1555,7 +1555,10 @@
_float(f0);
return Math.log2(f / f0) * 12;
};
MIDI.midi = function(f, f0) { return MIDI.shift(f, f0) + 69; };
MIDI.midi = function(f, f0) {
if (f != parseFloat(f)) return _7bn(f);
return MIDI.shift(f, f0) + 69;
};
MIDI.to14b = function(x) {
_float(x);
return x <= 0 ? 0 : x >= 1 ? 0x3fff : Math.floor(x * 0x4000);
Expand Down
2 changes: 1 addition & 1 deletion minified/JZZ.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "jzz",
"version": "1.4.0",
"version": "1.4.1",
"description": "MIDI library for Node.js and web-browsers",
"main": "javascript/JZZ.js",
"scripts": {
Expand All @@ -26,7 +26,7 @@
"grunt-contrib-jshint": "^3.0.0",
"grunt-contrib-uglify": "^5.0.1",
"midi-test": "^1.1.8",
"mocha": "^9.1.0",
"mocha": "^9.1.1",
"nyc": "^15.1.0",
"web-midi-test": "^1.1.8"
},
Expand Down
2 changes: 2 additions & 0 deletions test/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -647,7 +647,9 @@ describe('MIDI messages', function() {
});
it('midi', function() {
assert.equal(JZZ.MIDI.midi(50) - JZZ.MIDI.shift(50), 69);
assert.equal(JZZ.MIDI.midi('C#5'), 61);
assert.throws(function() { JZZ.MIDI.midi(50, 'dummy'); });
assert.throws(function() { JZZ.MIDI.midi('dummy'); });
});
it('to14b', function() {
assert.equal(JZZ.MIDI.to14b(-.01), 0);
Expand Down
2 changes: 1 addition & 1 deletion web-midi-api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"web-midi-api"
],
"dependencies": {
"jzz": "^1.4.0"
"jzz": "^1.4.1"
},
"contributors": [
{
Expand Down

0 comments on commit 1cfde03

Please sign in to comment.